Microsoft Postgres MCP Setup for Claude Code, Cursor and Other Apps
Not the official PostgreSQL MCP server. This one is built by the community. PostgreSQL makes its own: MCP Toolbox for Databases →
Lets Claude and other assistants query PostgreSQL, read your schema, load CSVs and diagnose slow queries.
This is Microsoft's server for PostgreSQL, from the microsoft/postgres-mcp project. It runs on your computer and connects to any reachable PostgreSQL database, local or on Azure, AWS or Google Cloud. You save a connection once, and the password goes to your system keyring instead of a config file. A saved connection allows write tools by default, so mark it read-only if the assistant should only look.
Good for
- Developers who want Claude to write and run queries against their database
- Teams on Azure Database for PostgreSQL who sign in with Microsoft Entra ID
- Engineers diagnosing a slow server or slow queries
- Anyone loading CSV files into PostgreSQL tables
Works in
12 should work
Tap an app to see how to set it up and any known problems.
Supports local MCP servers.
Supports local MCP servers.
Supports local MCP servers.
Supports local MCP servers.
Supports local MCP servers.
Supports local MCP servers.
Supports local MCP servers.
Supports local MCP servers.
Supports local MCP servers.
Supports local MCP servers.
Supports local MCP servers.
Supports local MCP servers.
Client does not support this transport.
Client does not support this transport.
Install postgres MCP
Claude Code
- 1
Copy this prompt.
Add the postgres MCP server to Claude Code. Run this command: claude mcp add postgres -- npx -y @microsoft/postgres-mcp run Then check that it loaded and tell me if I need to sign in or restart.
- 2
Paste it into Claude Code. It shows the change and asks before running it.
Requires Node.js, A reachable PostgreSQL database.
Read-only mode: Save the connection profile with access mode ro, and use a read-only database user.
Needs Node.js 22 or newer. Before first use, save a connection profile with the package's own connection add and connection set-password commands (see the README quick start). The client config holds no credentials. The profile is writable unless you set access mode ro. Add --no-telemetry after run to turn off usage telemetry.
Built from the package data we hold. Not yet tested by us.
Tools
Runs a read-only SQL query
Runs a SELECT-style query against the connected database and returns the rows. It is the read-only way to look at your data.
Try: “Show me the 10 most recent orders.”
Network ·
postgres_mcp_queryShows how tables and other objects are defined
Returns the CREATE scripts for tables, indexes, functions, sequences and similar objects, so the assistant understands your schema.
Try: “Show me the definition of the orders table and its indexes.”
Network ·
postgres_mcp_db_contextLists the databases on the server
Returns the databases available on the connected PostgreSQL server.
Try: “Which databases are on this server?”
Network ·
postgres_mcp_list_databasesCollects performance numbers from the server
Gathers a group of performance and diagnostic metrics from the database to help find what is slowing it down.
Try: “What is slowing down my database right now?”
Network ·
postgres_mcp_get_metrics_groupChecks which diagnostics this server supports
Probes the connected database to see which diagnostic features are available before asking for metrics.
Try: “Which diagnostics can you run on this database?”
Network ·
postgres_mcp_get_server_capabilitiesRuns SQL that changes the database
Runs DDL and DML such as CREATE, ALTER, INSERT and UPDATE, and anything else the database user is allowed to do, including deleting data. Blocked when the profile is set to read-only.
Try: “Add an index on orders.customer_id.”
Delete ·
postgres_mcp_modifyDescribes the columns in a CSV file
Reads a CSV file you point to and returns its structure as YAML. It can only read the startup folder and paths you approve.
Try: “Describe the structure of /data/orders.csv.”
Files ·
postgres_mcp_describe_csvLoads a CSV file into a table
Imports a CSV into a table using PostgreSQL COPY. It reads only from the startup folder and approved paths.
Try: “Load /data/orders.csv into the orders table.”
Write ·
postgres_mcp_bulk_load_csvLists your saved database connections
Shows the connection profiles saved on your machine, plus one from the environment if you set it.
Try: “Which database connections do I have saved?”
Files ·
postgres_mcp_list_connection_profilesOpens a connection to a saved profile
Opens a pooled connection to the database using a saved profile, so later queries can run.
Try: “Connect to my local profile.”
Network ·
postgres_mcp_connectCloses a database connection
Closes an open connection.
Try: “Disconnect from the database.”
Network ·
postgres_mcp_disconnectSaves a new database connection profile
Adds a named profile, optionally read-only. It never takes a password, which you set separately so it goes to your system keyring.
Try: “Add a read-only profile called staging for this connection string.”
Write ·
postgres_mcp_add_connectionDeletes a saved connection profile
Removes a profile from your machine and tries to clear its stored password from the keyring.
Try: “Remove the old staging profile.”
Delete ·
postgres_mcp_remove_connection
From the official docs
Permissions
high risk · 4 things to watch
High risk
The assistant runs SQL as the database user in your saved connection, so anything that user can do, including dropping tables, the assistant can do. Save the connection as read-only and give it a database user with read-only permissions.
What it can do
- Read your data
- Create and change things
- Delete things
- Read-only modeHow to turn it on
Watch out for
New connections allow writes and deletes
A profile without read-only access mode lets the assistant run DDL and DML as your database user. Set the access mode to ro and use a read-only database role. github.com
The server does not limit what SQL runs
The docs say it passes requests to PostgreSQL and cannot tell a tricked request from a real one. Your database permissions and your client's approval prompts are the real protection. github.com
CSV tools read local files
By default they can read the folder the server started in and any path you approve. Start it from a folder with no sensitive files, or set the disable-working-folder option. github.com
It sends usage telemetry by default
The docs say it sends pseudonymous machine and session IDs with tool names, durations and outcomes, but no query text or data. Turn it off with the no-telemetry flag on the run command. github.com
Technical details
| Turning on read-only | Set the connection profile's access mode to ro, which blocks the write tools. The docs also say to use a read-only database role. |
|---|---|
| Talks to | Your PostgreSQL server. Microsoft, for anonymous usage telemetry unless you turn it off |
| Sign-in and keys | Passwords are stored in your OS keyring. Profiles without a stored password on Azure use Microsoft Entra ID. Profile details live in ~/.postgres-mcp/connections.yaml. |
Questions
Is the Microsoft Postgres MCP server official?
It is made by Microsoft, but PostgreSQL is not a Microsoft product, so we do not call it the official PostgreSQL server. It works with any PostgreSQL database, including Azure, Amazon RDS and Google Cloud SQL.
Can I make it read-only?
Yes. Save the connection with access mode ro, which blocks the write tools, and give it a database user with read-only permissions. The docs recommend both.
Where does my database password go?
Into your OS keyring, set through the connection set-password command. It is never written to the client config or taken as a tool argument.
Does it work with Azure Database for PostgreSQL?
Yes. Azure profiles without a stored password use Microsoft Entra ID sign-in automatically. Managed identity is off unless you enable it.
What do I need installed?
Node.js 22 or newer, and a reachable PostgreSQL database. It runs on Linux, macOS and Windows x64, plus ARM on Linux and macOS.
Why does it ask me to save a connection first?
The client config holds no credentials. The server reads your saved profile at runtime. The README also lets you pass a connection string through an environment variable for headless use.
Does it collect data about me?
It sends pseudonymous usage telemetry by default, with machine and session IDs, tool names and timing, but no queries or data. You can disable it with a flag on the run command.
Information
updated Nov 2, 2026
- Publisher
- Community
- Package
@microsoft/postgres-mcp- Registry
- npm
- Transport
- stdio
- Auth
- None
- Version
- 0.3.0
- License
- MIT
- Last commit
- Oct 29, 2026
- Open issues
- 7
Other PostgreSQL MCP servers
Sources
Docs, issue trackers and discussions this page is built from. Issues, quotes and findings above link to their own source.
Show all 3Hide
- github.com · github.com
- github.com · github.com
- registry.npmjs.org · registry.npmjs.org