<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Vivek Sah</title>
    <description>The latest articles on DEV Community by Vivek Sah (@viveks32).</description>
    <link>https://dev.to/viveks32</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3948712%2Fb2e12938-dc78-4650-9ae4-c75ba16f8bee.jpg</url>
      <title>DEV Community: Vivek Sah</title>
      <link>https://dev.to/viveks32</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/viveks32"/>
    <language>en</language>
    <item>
      <title>How to connect Postgres to Claude (and make it work for your team)</title>
      <dc:creator>Vivek Sah</dc:creator>
      <pubDate>Tue, 16 Jun 2026 05:42:48 +0000</pubDate>
      <link>https://dev.to/viveks32/how-to-connect-postgres-to-claude-and-make-it-work-for-your-team-apg</link>
      <guid>https://dev.to/viveks32/how-to-connect-postgres-to-claude-and-make-it-work-for-your-team-apg</guid>
      <description>&lt;p&gt;Connecting Postgres to Claude is easy. For one person. But when you want your whole team querying the same database, things fall apart. Here's what I've learned and built to manage this.&lt;/p&gt;

&lt;h2&gt;
  
  
  The quick way: direct MCP
&lt;/h2&gt;

&lt;p&gt;Anthropic published a reference Postgres MCP server. Install it, point it at your database, and Claude can run queries in minutes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;claude_desktop_config.json&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"mcpServers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"postgres"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npx"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"-y"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"@modelcontextprotocol/server-postgres"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"postgresql://read_user:pass@host:5432/mydb"&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once connected, Claude can list tables, inspect schemas, and run SQL. Ask "how many users signed up this week?" and it writes the query, runs it, and returns the answer. Fast, free, and useful for a solo dev exploring a schema they already know.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Tip: add context with Claude Projects&lt;/strong&gt;&lt;br&gt;
You can improve accuracy by creating a &lt;strong&gt;Claude Project&lt;/strong&gt;, adding notes about your schema (table descriptions, metric definitions, business rules), and using that project when querying. This works well for one person, but the context lives in your Claude account and isn't shared with anyone else.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important: use a read replica&lt;/strong&gt;&lt;br&gt;
Never point analytics queries at your production primary. A slow aggregation can lock tables and affect your app. RDS, Supabase, Neon, and most hosted Postgres providers offer read replicas.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Where it starts breaking
&lt;/h2&gt;

&lt;p&gt;The direct connection works for one person. When you try to hand it to a team, two things break: reliability and management.&lt;/p&gt;

&lt;h3&gt;
  
  
  The reliability problem
&lt;/h3&gt;

&lt;p&gt;Production Postgres schemas are messy. They evolve over years, with abbreviated column names, legacy tables, and implicit business logic. Claude sees this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="c1"&gt;-- What Claude sees&lt;/span&gt;
&lt;span class="n"&gt;usr_acct&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;crt_at&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;upd_at&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tier_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ref_src&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;acq_ch&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;ord&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;usr_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amt_gross&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amt_net&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;disc_cd&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;crt_at&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;sub&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;usr_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;plan_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mrr_cents&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;churn_at&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cancel_rsn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Without context, Claude guesses. Is &lt;code&gt;sts&lt;/code&gt; a status code or a string? Does &lt;code&gt;amt_net&lt;/code&gt; include tax? What values of &lt;code&gt;sts&lt;/code&gt; mean "completed"? Two people ask "what's our revenue?" and get two different numbers because Claude interprets it differently each time.&lt;/p&gt;

&lt;h3&gt;
  
  
  The context problem
&lt;/h3&gt;

&lt;p&gt;You can work around the messy schema by adding notes in a Claude Project. But now you're maintaining context manually. When a column gets renamed, a table gets added, or a metric definition changes, someone has to update those notes. And if your teammate has their own project with their own notes, you're back to inconsistent answers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyucm9k6euszey00pj5zb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyucm9k6euszey00pj5zb.png" alt="Diagram showing multiple Claude Projects with diverging manual notes, leading to inconsistent data definitions across team members" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The management problem
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Everyone manages their own config.&lt;/strong&gt; Each person edits a JSON file on their laptop with database credentials. Your head of ops isn't doing that.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Everyone gets the same access.&lt;/strong&gt; There's one connection string. Everyone sees everything. Unless you create separate database users for each person, there's no way to restrict who sees what.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Credentials live on laptops.&lt;/strong&gt; Database passwords in plaintext config files. No way to revoke access without changing the password for everyone.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Switching providers breaks everything.&lt;/strong&gt; If you move from Supabase to Neon, or RDS to Railway, every person on the team needs to update their config.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No visibility.&lt;/strong&gt; No audit log of what queries ran, who asked what, or whether the answers were correct.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The team-ready way: Claude + ContextFlo
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://contextflo.com" rel="noopener noreferrer"&gt;ContextFlo&lt;/a&gt; connects to your Postgres database using read-only credentials. It scans your schema and auto-generates context: what every table and column actually means, how tables relate to each other, and how key metrics should be calculated.&lt;/p&gt;

&lt;p&gt;Your team still asks questions in Claude. The difference is what Claude knows. Here's how it works:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7rc0g55063ftvdrtdl6g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7rc0g55063ftvdrtdl6g.png" alt="Step 1: Claude calls ContextFlo to discover available tables, column descriptions, and metric definitions before writing any SQL" width="800" height="445"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcmdgt5jqwnt5a1fd8hir.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcmdgt5jqwnt5a1fd8hir.png" alt="Step 2: Claude sends SQL through ContextFlo, which enforces ACL rules and runs the query against Postgres" width="800" height="348"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Everyone on the team gets the same definitions. The connection is managed centrally. If you switch Postgres providers, you update one connection, not twenty laptops. Access controls scope which tables each person can query. Every question and every query is logged.&lt;/p&gt;

&lt;p&gt;Works with any hosted Postgres: AWS RDS, Supabase, Neon, PlanetScale, Google Cloud SQL, Azure Postgres, Railway, Render, or self-hosted.&lt;/p&gt;

&lt;h2&gt;
  
  
  The natural path
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Start here&lt;/th&gt;
&lt;th&gt;When you need a team&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Setup&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Edit JSON config per person&lt;/td&gt;
&lt;td&gt;Connect once, invite team&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Schema context&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Raw table/column names&lt;/td&gt;
&lt;td&gt;Auto-generated descriptions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Metric consistency&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Shared definitions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Access control&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Same DB user for everyone&lt;/td&gt;
&lt;td&gt;Per-table, per-user ACL&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Credentials&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;On every laptop&lt;/td&gt;
&lt;td&gt;Centralized, never exposed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Provider change&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Update every config&lt;/td&gt;
&lt;td&gt;Update one connection&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Audit trail&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;td&gt;Full query log&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Start with the direct MCP connection. It's the fastest way to see if Claude + Postgres is useful for your workflow. &lt;strong&gt;When you want to bring your team in, ContextFlo handles the context, governance, and visibility so you don't have to build it yourself.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://contextflo.com/auth/signin?mode=signup&amp;amp;source=postgres" class="crayons-btn crayons-btn--primary" rel="noopener noreferrer"&gt;Get started for free on Contextflo&lt;/a&gt;
&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://contextflo.com/blog/claude-with-postgres" rel="noopener noreferrer"&gt;contextflo.com/blog/claude-with-postgres&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>postgres</category>
      <category>claude</category>
      <category>mcp</category>
      <category>ai</category>
    </item>
  </channel>
</rss>
