Postgres MCP
MCP server by microsoft Verified · npm:@microsoft
Postgres MCP lets AI coding agents query, modify and diagnose PostgreSQL databases over the Model Context Protocol. It is aimed at developers who want an assistant to work with their Postgres data and schema.
Install Postgres MCP
Built from the published package, never by AI.
claude mcp add postgres-mcp -- npx -y @microsoft/postgres-mcpRun in your terminal. Add --scope user to use it in every project.
{
"mcpServers": {
"postgres-mcp": {
"args": [
"-y",
"@microsoft/postgres-mcp"
],
"command": "npx"
}
}
}Settings, Developer, Edit config. Paste into claude_desktop_config.json and restart.
{
"mcpServers": {
"postgres-mcp": {
"args": [
"-y",
"@microsoft/postgres-mcp"
],
"command": "npx"
}
}
}Add to ~/.cursor/mcp.json (all projects) or .cursor/mcp.json (this project).
{
"servers": {
"postgres-mcp": {
"args": [
"-y",
"@microsoft/postgres-mcp"
],
"command": "npx"
}
}
}Add to .vscode/mcp.json. VS Code uses "servers", not "mcpServers".
codex mcp add postgres-mcp -- npx -y @microsoft/postgres-mcp{
"mcpServers": {
"postgres-mcp": {
"args": [
"-y",
"@microsoft/postgres-mcp"
],
"command": "npx"
}
}
}Add to ~/.gemini/config/mcp_config.json (all projects) or .agents/mcp_config.json (this project).
gemini mcp add postgres-mcp npx -y @microsoft/postgres-mcpGemini CLI was replaced by Antigravity CLI in June 2026 and remains only for enterprise licences and paid API keys.
MCP servers run with your permissions and can read what you give them access to. Some need an API key: check the README and add it under env in the postgres-mcp block.
About
Postgres MCP is a Model Context Protocol server that connects an AI coding agent to a PostgreSQL database. It can run read-only SQL queries, run DDL and DML statements, fetch CREATE scripts for tables and indexes, describe and bulk-load CSV files using COPY, and collect performance diagnostics.
The server speaks MCP over stdio and is started with npx, so no separate install is needed. Database passwords are stored in the OS keyring, and the coding agent connects using a saved connection profile rather than credentials in the client config. The server passes requests to PostgreSQL as the database user in the profile, so that user's permissions decide what is allowed. It is aimed at developers who want clients such as Claude Code, Cursor or VS Code to work with their PostgreSQL data.
Written from the project's README and checked against it.
Tools it gives your assistant
postgres_mcp_connectConnects the assistant to a saved connection profile.postgres_mcp_queryRuns read-only SQL queries against the PostgreSQL database.postgres_mcp_modifyRuns DDL and DML statements that change the database.postgres_mcp_bulk_load_csvBulk-loads a CSV file into a table using COPY.postgres_mcp_describe_csvDescribes the contents of a CSV file.
What you need
- Node.js 22 or later
- A reachable PostgreSQL database
- Linux x64 or arm64, macOS x64 or arm64, or Windows x64
- An MCP-compatible client such as Claude Code, Cursor or VS Code
Try asking
- List the tables in my PostgreSQL database.
- Show me the 10 most recent orders from my PostgreSQL database.
- What's slowing down my PostgreSQL server right now?
Good to know
- Profiles created with connection add permit write tools unless access_mode: ro is set.
- The server does not decide what is allowed. The database user's permissions do.
- Local file reads are limited to the startup working directory and paths set with allow-access-to-path.
- The postgres-mcp project itself is proprietary and its source code is not available under the MIT license.
Security check
ANo download-and-run commands, hidden instructions or signs of sending keys out were found.
Checked automatically: README.md. This looks for known risky patterns and is not a full audit. How grades work
Alternatives to Postgres MCP
All alternatives →Connects Supabase projects to AI assistants such as Cursor, Claude and Windsurf over the Model Context Protocol. It lets assistants manage tables, fetch config and query data in a Supabase project.
ArcadeDB MCP Server is the built-in Model Context Protocol server of the ArcadeDB multi-model database. It lets AI assistants and LLMs work with ArcadeDB's graph, document, time-series, vector and other data models. It suits people who already run ArcadeDB and want assistant access to it.
Connects MCP clients such as Claude Desktop, Cursor and VS Code to PostgreSQL, MySQL, MariaDB, SQL Server, Oracle, ClickHouse and SQLite. It exposes two tools by default, with read-only mode and query timeouts available as guardrails.
MCP Toolbox for Databases is an open source MCP server that connects AI agents, IDEs and applications to enterprise databases. It provides prebuilt tools for exploring schemas and running queries, plus a framework for custom tools. It is aimed at developers building agents that need database access.
Connects AI agents, IDEs and applications to enterprise databases through the Model Context Protocol. Offers prebuilt database tools for MCP clients and a framework for building custom tools for production agents.
MongoDB MCP Server lets AI assistants interact with MongoDB databases and MongoDB Atlas. It is an official server from mongodb-js, run locally with npx or Docker. It works with self-managed deployments and Atlas clusters.
Compare with Supabase, ArcadeDB MCP Server or DBHub
Postgres MCP: common questions
Does the AI need my database password in the client config?
No. The source says no credentials go in the client config. Passwords are stored in the OS keyring, and the agent connects to the saved profile at runtime.
Can the AI change data in my database?
Profiles created with connection add permit write tools unless access_mode: ro is set. The source recommends a read-only profile and a read-only database role for agents that should not write.
Which PostgreSQL servers does it work with?
The source lists local, Docker, on-premises, Azure Database for PostgreSQL, Amazon RDS and Aurora, Google Cloud SQL and AlloyDB, or any wire-compatible server.
How do I install Postgres MCP?
In Claude Code run claude mcp add postgres-mcp -- npx -y @microsoft/postgres-mcp. For Claude Desktop, Cursor and VS Code, paste the config shown above and restart. See the install guides.
Is Postgres MCP the official server?
Postgres MCP is published by npm:@microsoft from its verified domain in the official MCP Registry.
Is Postgres MCP free?
The code is published under the MIT licence. The service it connects to may have its own pricing.
Is Postgres MCP safe to use?
It scores 88 of 100. Grades: maintenance A, licence A, quality B. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.
What are alternatives to Postgres MCP?
Similar MCP servers: Supabase, ArcadeDB MCP Server, DBHub, MCP Toolbox for Databases.
Does Postgres MCP work with ChatGPT?
Not directly. It runs locally, and ChatGPT only connects to remote servers with a URL. Use it in Claude Code, Claude Desktop, Cursor, VS Code or Codex.
