Skip to main content
mcpFirst-partyLow risk Safety Privacy
Anthropic logo

Postgresql MCP Server - MCP Servers

Official MCP server providing read-only access to PostgreSQL databases with schema inspection and query capabilities

by Anthropic·added 2025-09-16·
HarnessClaude CodeClaude Desktop

Citation facts

Source-backed facts for citing this resource, derived directly from the registry — also available as plain text for AI assistants.

Source URLs
https://modelcontextprotocol.io/docs/getting-started/intro, https://github.com/JSONbored/awesome-claude/blob/main/content/mcp/postgresql-mcp-server.mdx
Brand
Anthropic
Brand domain
anthropic.com
Brand asset source
brandfetch
Package URL
/downloads/mcp/postgresql-mcp-server.mcpb
Package SHA256
2935644e5353e573faf8b78d11f376a7f99e6662b4687ae8f40d2ad39d1fde83
Safety notes
Use a read-only database user with restricted schemas unless write access is explicitly needed and reviewed.
Privacy notes
Queried schemas, table names, rows, connection details, and application data may be exposed through tool calls.
Author
Anthropic
Claim status
unclaimed
Last verified
2025-09-16

Decision playbook

Ready to evaluate for your workflow

Signals are comparatively strong, but you should still validate source, privacy posture, and package provenance for your environment.

Compare context
Selected

0

Current score

96

Baseline

Delta

No baseline selected

No major trust-signal divergence detected in the current selection.

Source and provenance checks

Complete

Confirm ownership and provenance before trusting install instructions.

  • Source link availableRequired

    Open the canonical repository and verify ownership.

    Done
  • Source provenance statusRequired

    Marked as first-party.

    Done
  • Metadata reviewed

    Registry metadata indicates a reviewed listing.

    Done

Safety and privacy checks

Complete

Validate risk disclosures before installation or API wiring.

  • Safety notes presentRequired

    Review the listed safety guidance before running commands.

    Done
  • Privacy notes presentRequired

    Review data handling notes before connecting accounts or secrets.

    Done
  • Trust level risk gateRequired

    Trust level does not block evaluation.

    Done

Package and install checks

Complete

Check package metadata and artifact integrity signals.

  • Install payload available

    Install or copy payload is available for review.

    Done
  • Package verification flag

    Package marked verified.

    Done
  • Checksum metadata

    SHA-256 hash is present.

    Done

Compare-driven decision checks

Needs review

Use compare context to validate trade-offs before adoption.

  • Compare tray has multiple entries

    Add at least one more entry to compare trust differences.

    Pending
  • Baseline comparison available

    No baseline peer selected yet.

    Pending
  • Diverging trust signals identified

    No major trust-signal divergence found.

    Pending

Setup at a glance

Package install

Copy-ready — paste the snippet to get started.

3 minutes

Install command

Provided

Config snippet

Provided

Copy snippet

Provided

Prerequisites

10 to clear

Platforms

2 listed

Difficulty

1/100

Adoption plan

Balanced adoption plan

Current risk score 0/100. Use staged verification before broader rollout.

Risk 0

Pre-adoption checks

Validate source and review signals before any execution.

  • Confirm source provenanceRequired

    Source URL/provenance metadata is present.

    Done
  • Confirm metadata review state

    Listing has review metadata.

    Done
  • Verify install payload

    Install/config payload exists and can be inspected.

    Done

Security checks

Confirm safety, privacy, and package integrity signals.

  • Review safety notesRequired

    Safety notes are present.

    Done
  • Review privacy notesRequired

    Privacy notes are present.

    Done
  • Verify package integrity metadata

    Package verification/checksum metadata is available.

    Done

Rollout

Adopt in controlled steps based on the selected plan.

  • Run in isolated sandbox firstRequired

    Use a constrained sandbox and observe behavior across multiple tasks.

    Pending
  • Roll out graduallyRequired

    Roll out to a small cohort before wider usage.

    Pending
  • Set monitoring and fallback

    Define rollback path and monitor errors after adoption.

    Pending

Evidence readiness

Evidence readiness matrix · balanced

Required evidence gates are covered (6/6 signals complete).

Risk 0

Source provenance

Present

Source repository/provenance is listed.

Required in this preset

Metadata review

Present

Review metadata is present.

Required in this preset

Safety notes

Present

Safety notes are present.

Required in this preset

Privacy notes

Present

Privacy notes are present.

Optional in this preset

Package integrity

Present

Package integrity metadata is present.

Optional in this preset

Install payload

Present

Install payload is available.

Required in this preset

Required evidence gates are covered for this preset.

Decision timeline

Decision timeline · balanced

6/6 steps complete with no blocking gaps for this preset.

Risk 0

triage

Confirm source provenanceRequired

Source/provenance metadata is available.

Done

triage

Check metadata review statusRequired

Review metadata is available.

Done

verify

Review safety notesRequired

Safety notes are available.

Done

verify

Review privacy notes

Privacy notes are available.

Done

verify

Validate package integrity metadata

Package integrity metadata is available.

Done

rollout

Verify install payload and commandsRequired

Install payload is available.

Done

No required blockers for this timeline preset.

Prerequisite readiness

Prerequisite readiness

10 prerequisites to line up before setup.

0/10 ready
Install & runtime1Configuration3Permissions & scopes1Network & hosting3General23 minutes

Safety & privacy surface

Safety & privacy surface

1 safety and 1 privacy notes across 1 risk area.

1 area
  • SafetyGeneralUse a read-only database user with restricted schemas unless write access is explicitly needed and reviewed.
  • PrivacyGeneralQueried schemas, table names, rows, connection details, and application data may be exposed through tool calls.

Safety notes

  • Use a read-only database user with restricted schemas unless write access is explicitly needed and reviewed.

Privacy notes

  • Queried schemas, table names, rows, connection details, and application data may be exposed through tool calls.

Prerequisites

  • PostgreSQL database (local or remote PostgreSQL server)
  • PostgreSQL connection string (postgresql://user:password@host:port/database format)
  • Node.js and npx (for running @modelcontextprotocol/server-postgres package)
  • Network access (if connecting to remote PostgreSQL server)
  • Database user with SELECT permissions (read-only access required)
  • Understanding of PostgreSQL connection string format (postgresql:// URI scheme)
  • Understanding of PostgreSQL authentication methods (password, certificate, peer)
  • Claude Desktop 0.7.0+ or Claude Code with MCP support
  • Understanding of SQL and database concepts (tables, schemas, queries, transactions)
  • Understanding of read-only transaction safety (SELECT queries only, no data modification)

Schema details

Install type
package
Reading time
1 min
Difficulty score
1
Troubleshooting
Yes
Breaking changes
No
Package metadata
Package verified
Yes
SHA-256
2935644e5353e573faf8b78d11f376a7f99e6662b4687ae8f40d2ad39d1fde83
Skill and platform metadata
Retrieval sources
https://modelcontextprotocol.io/introduction
Collection metadata
Estimated setup
3 minutes
Difficulty
beginner
Full copyable content
{
  "postgres": {
    "args": [
      "-y",
      "@modelcontextprotocol/server-postgres",
      "postgresql://localhost/mydb"
    ],
    "command": "npx"
  }
}

About this resource

Content

Streamline your database exploration and analysis by connecting Claude to PostgreSQL. Inspect schemas and relationships, execute safe SELECT queries, discover table structures, access metadata, perform data analysis, generate reports, create documentation, and validate data integrity—all through natural language commands. Leverage the official Anthropic PostgreSQL MCP Server with read-only transaction safety, SSL support, and comprehensive schema inspection capabilities.

Features

  • Read-only access for safe database exploration (SELECT queries only)
  • Automatic discovery of table structures and columns (schema inspection)
  • Execute SELECT queries within read-only transactions (safe query execution)
  • Access detailed database metadata and structure (tables, schemas, indexes)
  • Perform data analysis without altering database state (read-only operations)
  • Support for SSL connections and authentication (secure connections)
  • Query execution with transaction safety (automatic rollback on errors)
  • Schema relationship discovery (foreign keys, constraints, relationships)
  • Advanced PostgreSQL database management with query execution, schema introspection, and transaction handling
  • Batch operations support for efficient bulk database operations, data migration, and query optimization with automatic error handling
  • Real-time database monitoring capabilities with connection pooling support for tracking database performance and triggering automated workflows

Use Cases

  • Understand database schema and relationships (comprehensive schema analysis)
  • Generate reports from existing data (data aggregation and reporting)
  • Analyze data patterns and distributions (statistical analysis)
  • Create documentation from database structure (auto-generated documentation)
  • Write and test SELECT queries (query development and testing)
  • Explore unfamiliar database schemas (schema discovery and exploration)
  • Debug data issues without modifying data (safe troubleshooting)
  • Validate data integrity and relationships (constraint and relationship verification)
  • Build automated database management workflows that sync external systems with PostgreSQL for real-time data operations and analytics

Installation

Claude Code

  1. Ensure PostgreSQL is running and accessible
  2. Create a read-only database user with SELECT permissions (if needed)
  3. Construct your PostgreSQL connection string: postgresql://user:password@host:port/database
  4. Create a .mcp.json file in your project root with PostgreSQL server configuration
  5. Add the postgres server config with npx command and connection string as argument
  6. Verify installation: claude mcp list
  7. Test connection: claude mcp status postgres

Claude Desktop

  1. Ensure PostgreSQL is running and accessible
  2. Create a read-only database user with SELECT permissions (if needed)
  3. Construct your PostgreSQL connection string: postgresql://user:password@host:port/database
  4. Open Claude Desktop configuration file (see configPath below)
  5. Add the PostgreSQL MCP server configuration with npx command and connection string
  6. Add connection string as argument to the server command
  7. Restart Claude Desktop
  8. Ask Claude to list tables to verify connection

Requirements

  • PostgreSQL database (local or remote PostgreSQL server)
  • PostgreSQL connection string (postgresql://user:password@host:port/database format)
  • Node.js and npx (for running @modelcontextprotocol/server-postgres package)
  • Network access (if connecting to remote PostgreSQL server)
  • Database user with SELECT permissions (read-only access required)
  • Understanding of PostgreSQL connection string format (postgresql:// URI scheme)
  • Understanding of PostgreSQL authentication methods (password, certificate, peer)
  • Claude Desktop 0.7.0+ or Claude Code with MCP support
  • Understanding of SQL and database concepts (tables, schemas, queries, transactions)
  • Understanding of read-only transaction safety (SELECT queries only, no data modification)

Configuration

{
  "postgres": {
    "args": [
      "-y",
      "@modelcontextprotocol/server-postgres",
      "postgresql://localhost/mydb"
    ],
    "command": "npx"
  }
}

Examples

What tables exist in my database?

Common usage pattern for this MCP server

Ask Claude: "What tables exist in my database?"

Describe the structure of the users table

Common usage pattern for this MCP server

Ask Claude: "Describe the structure of the users table"

How many records are in each table?

Common usage pattern for this MCP server

Ask Claude: "How many records are in each table?"

Write a query to find active users from last month

Common usage pattern for this MCP server

Ask Claude: "Write a query to find active users from last month"

Generate documentation for my database schema

Common usage pattern for this MCP server

Ask Claude: "Generate documentation for my database schema"

Execute Query

Execute a parameterized PostgreSQL query with prepared statement

// Execute PostgreSQL query
const result = await postgres.query({
  text: "SELECT * FROM users WHERE email = $1",
  values: ["user@example.com"],
});

Security

  • All queries execute in read-only transactions (INSERT, UPDATE, DELETE prevented)
  • Supports SSL/TLS encryption for connections (sslmode parameter in connection string)
  • Respects existing database user permissions (SELECT only, no schema modifications)
  • Safe exploration without data modification risks (read-only access enforced)
  • Connection string credentials should be stored securely (environment variables or secure config)
  • PostgreSQL connection strings and credentials must be securely stored and never exposed in client-side code or public repositories - use environment variables and secure credential management
  • PostgreSQL database credentials should use role-based access control (RBAC) with minimal required permissions following the principle of least privilege - regularly audit database permissions
  • PostgreSQL database, schema, and table names may expose data architecture and application structure - ensure PostgreSQL resource identifiers are kept private and not shared in public configurations
  • Rate limiting and connection management are critical for PostgreSQL MCP servers - implement proper connection pooling, query timeout handling, and resource monitoring to prevent service disruption
  • PostgreSQL query results and database metadata may contain sensitive data - ensure query results are properly secured and access-controlled according to data privacy requirements

Troubleshooting

Connection refused or database not accessible

Verify PostgreSQL is running with pg_isready command. Check connection string format: postgresql://user:password@host:port/database. Test with psql command first (psql 'postgresql://user:password@host:port/database'). Verify firewall allows connections on port 5432 (default). Check PostgreSQL is listening on correct interface (localhost vs 0.0.0.0). Verify hostname resolves correctly for remote connections.

SSL connection error - wrong version number or verify failed

Add sslmode parameter: postgresql://host/db?sslmode=require. Verify PostgreSQL supports TLS version (check pg_config --configure). Use sslmode=disable for local dev only (not recommended for production). Use sslmode=verify-ca or verify-full for production. Check certificate matches CA in ssl_ca_file. Verify SSL is enabled in postgresql.conf (ssl = on).

Authentication failed for user or password rejected

Verify username/password in connection string exact match (case-sensitive). Check pg_hba.conf allows connection method (md5, scram-sha-256, trust for local). Ensure user exists with GRANT SELECT permissions. Test auth with psql -U username -d database. Check password special characters are URL-encoded in connection string. Verify user has CONNECT privilege on database.

Certificate authentication failed - CN mismatch

Verify certificate CN matches PostgreSQL username exactly. Configure pg_ident.conf for username mapping if needed. Check ssl_cert_file and ssl_key_file permissions (owned by postgres user, mode 600). Ensure client cert trusted by server CA. Verify sslmode=verify-full for certificate validation. Check certificate hasn't expired.

Permission denied on table or schema access error

Grant SELECT permissions: GRANT SELECT ON ALL TABLES IN SCHEMA public TO username. For future tables: ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO username. Verify read-only user has pg_read_all_data role (GRANT pg_read_all_data TO username). Check schema permissions with \dp command in psql. Ensure user connected to correct database. Grant USAGE on schema: GRANT USAGE ON SCHEMA public TO username.

PostgreSQL MCP server authentication errors with connection strings

Verify connection string is valid and credentials are correct. Check database host, port, username, and password. Ensure SSL/TLS configuration is correct for secure connections. Verify database user has required permissions.

PostgreSQL connection pool exhaustion or timeout errors

Check connection pool size and configuration. Reduce connection timeout values. Implement connection pooling with proper limits. Monitor active connections and close idle connections. Check database max_connections setting.

PostgreSQL query execution failures or performance issues

Check query syntax and parameter binding. Verify table and column names are correct. Review query execution plans for optimization. Check database indexes and statistics. Monitor slow query logs for performance bottlenecks.

PostgreSQL MCP server connection timeouts or network errors

Check network connectivity to PostgreSQL server. Verify firewall rules allow database connections. Increase connection timeout values. Implement connection retry mechanisms with exponential backoff.

Source citations

Add this badge to your README

Show that Postgresql MCP Server - MCP Servers is listed on HeyClaude. Paste this Markdown into your README — it renders the badge and links back to this page.

Listed on HeyClaude
[![Listed on HeyClaude](https://heyclau.de/badge/mcp/postgresql-mcp-server.svg)](https://heyclau.de/entry/mcp/postgresql-mcp-server)

How it compares

Postgresql MCP Server - MCP Servers side by side with 3 alternatives on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.

1 trust signal differ across this comparison (Source provenance).

Field

Official MCP server providing read-only access to PostgreSQL databases with schema inspection and query capabilities

Open dossier

Official MCP server providing Git repository tools for reading, searching, and manipulating Git repositories

Open dossier

Official MCP server providing secure file system operations for Claude Desktop and Claude Code

Open dossier

Analyze, troubleshoot, and optimize Plaid integrations for banking data and financial account linking

Open dossier
Next steps
Trust
Review statusReviewedMaintainer reviewedReviewedMaintainer reviewedReviewedMaintainer reviewedReviewedMaintainer reviewed
Package trustPackage verifiedPackage verifiedPackage verifiedPackage verified
Source provenanceDiffersSource-backedNo submission linkNo submission linkNo submission link
Submitter
Install riskLow riskLow riskLow riskLow risk
Notes Safety Privacy Safety Privacy Safety Privacy Safety Privacy
BrandAnthropic logoAnthropicAnthropic logoAnthropicAnthropic logoAnthropicPlaid logoPlaid
Categorymcpmcpmcpmcp
Sourcefirst-partyfirst-partyfirst-partyfirst-party
AuthorAnthropicAnthropicAnthropicPlaid
Added2025-09-162025-09-162025-09-152025-09-18
Platforms
Claude CodeClaude Desktop
Claude CodeClaude Desktop
Claude CodeClaude Desktop
Claude CodeClaude Desktop
Source repo
Safety notesUse a read-only database user with restricted schemas unless write access is explicitly needed and reviewed.Restrict access to intended repositories and review write operations because commands can alter branches, commits, and working trees.Limit allowed roots to the specific folders Claude needs because file operations can read, write, overwrite, or delete local data.Use sandbox or restricted Plaid credentials and avoid exposing production banking tokens outside the required workflow.
Privacy notesQueried schemas, table names, rows, connection details, and application data may be exposed through tool calls.Source code, commit history, author metadata, file paths, and repository configuration may be sent through tool calls.Local file contents, filenames, directory structure, and system paths may be sent through the MCP client and model context.Account-linking data, balances, transactions, institution identifiers, and financial metadata may be sent through model context.
Prerequisites
  • PostgreSQL database (local or remote PostgreSQL server)
  • PostgreSQL connection string (postgresql://user:password@host:port/database format)
  • Node.js and npx (for running @modelcontextprotocol/server-postgres package)
  • Network access (if connecting to remote PostgreSQL server)
  • Git installed (verify with: git --version, install via sudo apt install git (Linux) or brew install git (macOS))
  • Node.js and npx available (comes with Node.js, verify with: npx --version)
  • Local Git repository (server works with local repositories only, navigate to repository root directory)
  • File system read permissions for repository directory (check with ls -l or icacls)
  • Node.js 14 or higher installed (verify with: node --version)
  • npx available (comes with Node.js, verify with: npx --version)
  • File system read/write permissions for directories you want to access
  • Understanding of absolute vs relative paths (must use absolute paths in configuration for security)
  • Plaid account (create account on Plaid Dashboard to get API credentials)
  • API credentials (client_id and secret from Plaid Dashboard)
  • SSE or HTTP transport support (remote MCP server at https://api.dashboard.plaid.com/mcp/sse or https://api.dashboard.plaid.com/mcp)
  • Internet connection (remote Plaid API access required)
Install
claude mcp list && claude mcp status postgres
claude mcp list && claude mcp status git
claude mcp list && claude mcp status filesystem
claude mcp list && claude mcp status plaid
Config
Manual-only setup:
{
  "postgres": {
    "args": [
      "-y",
      "@modelcontextprotocol/server-postgres",
      "postgresql://localhost/mydb"
    ],
    "command": "npx"
  }
}
{
  "mcpServers": {
    "git": {
      "args": [
        "-y",
        "@modelcontextprotocol/server-git"
      ],
      "command": "npx",
      "type": "stdio"
    }
  }
}
Manual-only setup:
{
  "filesystem": {
    "args": [
      "-y",
      "@modelcontextprotocol/server-filesystem",
      "/path/to/allowed/directory"
    ],
    "command": "npx"
  }
}
{
  "mcpServers": {
    "plaid": {
      "url": "https://api.dashboard.plaid.com/mcp/sse",
      "type": "sse"
    }
  }
}
Citations
ClaimUnclaimedUnclaimedUnclaimedUnclaimed
Open 4 picks in the interactive comparison tool

Signals

Loading live community signals…

More like this, weekly

A short, calm digest of reviewed Claude resources. Unsubscribe any time.