DataMCPDataMCP
|Tutorial

Claude Desktop + PostgreSQL: MCP Setup in 60 Seconds

Connect Claude Desktop to your PostgreSQL database through MCP. Two approaches: direct with mcp-remote, or managed through DataMCP. Real configs, real tradeoffs.

Andrei
Founder of DataMCP

Claude Desktop and MCP

Claude Desktop supports MCP natively, but with a catch: it only works with stdio-based servers. It can't connect to HTTP MCP endpoints directly.

This means you need mcp-remote, an npm package that bridges the gap. It wraps an HTTP MCP endpoint into a stdio process that Claude Desktop can talk to.

As of March 2026, MCP in Claude Desktop requires a Claude Pro subscription.

Approach 1: Direct connection with mcp-remote

The fastest way to get PostgreSQL into Claude Desktop is @modelcontextprotocol/server-postgres, the community-maintained fork of Anthropic's original (deprecated) server.

Edit your Claude Desktop config file:

| OS | Path | |---|---| | macOS | ~/Library/Application Support/Claude/claude_desktop_config.json | | Windows | %APPDATA%\Claude\claude_desktop_config.json | | Linux | ~/.config/Claude/claude_desktop_config.json |

{
  "mcpServers": {
    "my-database": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://user:password@host:5432/dbname"
      ]
    }
  }
}

Save the file. Fully restart Claude Desktop (not just close the window, actually quit and reopen). Look for the hammer icon in a new conversation. That's your MCP connection.

What you get: Read-only access. List tables, inspect schemas, run SELECT queries.

What you don't get: Permission control, audit logging, write access, team features, AI-generated schema descriptions. And the connection string sits in a JSON file on your machine in plaintext.

This is fine for exploring a local dev database. Not ideal for anything with real data.

Approach 2: DataMCP with mcp-remote

DataMCP is an HTTP-based MCP gateway. Claude Desktop needs mcp-remote to bridge it:

{
  "mcpServers": {
    "my-database": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-remote@latest",
        "https://api.datamcp.app/api/mcp/YOUR_CONNECTION_ID?token=sk_live_YOUR_API_KEY"
      ]
    }
  }
}

Same restart process. Same hammer icon.

What you get on top of approach 1:

  • Six tools instead of read-only queries. query (with configurable permissions), get_schema (with AI-generated descriptions for every table and column), get_table_details, get_permissions, get_schema_changes, resync_schema.
  • Permission control. The MCP link can be read-only, read-write, full DDL, or custom per-table. Claude can only do what you allow.
  • AI schema descriptions. Every table gets a one-sentence description, every column gets a 6-word summary. Claude understands what trx_ref_id means before writing a query.
  • Audit trail. Every query Claude runs is logged: SQL text, execution time, row count, status.
  • No connection string on your machine. The API key is scoped and revokable. The database credentials stay in DataMCP, encrypted.

What Claude does with database context

Once connected, Claude can reference your schema in any conversation. Some things that work well:

Data analysis. "What's the average order value by month for the last year?" Claude calls get_schema, finds your orders table, sees it has total_amount and created_at columns, and writes the correct GROUP BY query.

Writing migrations. "Add a last_login_at column to the users table" works better when Claude sees the existing columns, types, and constraints before generating the ALTER TABLE.

Debugging queries. Paste a slow query and ask Claude to optimize it. With schema context, it knows which columns are indexed, what the foreign keys are, and can suggest actual improvements instead of generic advice.

Understanding unfamiliar databases. If you're onboarding onto a project with 200 tables and no documentation, Claude with get_schema (especially with DataMCP's AI descriptions) is the fastest way to get oriented.

Claude Code: easier setup

If you use Claude Code (the CLI) instead of Claude Desktop, the setup is simpler because it supports HTTP transport directly:

claude mcp add my-database \
  --transport streamable-http \
  "https://api.datamcp.app/api/mcp/YOUR_CONNECTION_ID" \
  --header "Authorization: Bearer sk_live_YOUR_API_KEY"

No mcp-remote needed.

Claude.ai (web): even easier

Claude.ai supports MCP connectors natively. Go to Settings, Connectors, Add custom connector, and paste the DataMCP URL. You'll go through an OAuth flow to authorize, and then Claude has access to your database schema in every conversation.

Choosing between the approaches

Use direct connection if: you're exploring a local/throwaway database alone and want zero setup overhead.

Use DataMCP if: you're working with a team, care about what Claude does with your data, want AI-enhanced schema descriptions, or need to connect the same database to Cursor and VS Code too (one connection, multiple tools, different permission scopes per tool).

Get started

Sign up at dashboard.datamcp.app. Add your PostgreSQL connection. Create an MCP link. Copy the config into Claude Desktop. The free tier covers 1 connection and 1 MCP link, enough to see if it changes how you work with Claude.

ClaudePostgreSQLMCPAI tools

Ready to connect AI to your database?

Set up DataMCP in 60 seconds. No credit card required.

Get Started Free

Questions? Read the docs or view pricing.