Connect the model to a PostgreSQL database with read-only access so it can inspect schemas and run queries safely.
registry version 0.6.2
Python (uvx)
uvx postgres-mcp --access-mode=restrictedPython (uvx)
uvx postgres-mcp@0.6.2 --access-mode=restricted
Pick your client — the config below is generated for this server (local stdio). Copy respects the “Pin version” switch above.
claude_desktop_config.json
{
"mcpServers": {
"postgres": {
"command": "uvx",
"args": [
"postgres-mcp",
"--access-mode=restricted"
],
"env": {
"DATABASE_URI": "<YOUR_DATABASE_URI>"
}
}
}
}{
"mcpServers": {
"postgres": {
"command": "uvx",
"args": [
"postgres-mcp@0.6.2",
"--access-mode=restricted"
],
"env": {
"DATABASE_URI": "<YOUR_DATABASE_URI>"
}
}
}
}Format verified against the official Claude Desktop docs ↗.
terminal
claude mcp add --env DATABASE_URI=<YOUR_DATABASE_URI> postgres -- uvx postgres-mcp --access-mode=restricted
claude mcp add --env DATABASE_URI=<YOUR_DATABASE_URI> postgres -- uvx postgres-mcp@0.6.2 --access-mode=restricted
Format verified against the official Claude Code docs ↗.
.cursor/mcp.json
{
"mcpServers": {
"postgres": {
"command": "uvx",
"args": [
"postgres-mcp",
"--access-mode=restricted"
],
"env": {
"DATABASE_URI": "<YOUR_DATABASE_URI>"
}
}
}
}{
"mcpServers": {
"postgres": {
"command": "uvx",
"args": [
"postgres-mcp@0.6.2",
"--access-mode=restricted"
],
"env": {
"DATABASE_URI": "<YOUR_DATABASE_URI>"
}
}
}
}Format verified against the official Cursor docs ↗.
.vscode/mcp.json
{
"servers": {
"postgres": {
"command": "uvx",
"args": [
"postgres-mcp",
"--access-mode=restricted"
],
"env": {
"DATABASE_URI": "<YOUR_DATABASE_URI>"
}
}
}
}{
"servers": {
"postgres": {
"command": "uvx",
"args": [
"postgres-mcp@0.6.2",
"--access-mode=restricted"
],
"env": {
"DATABASE_URI": "<YOUR_DATABASE_URI>"
}
}
}
}Format verified against the official VS Code docs ↗.
mcp_config.json
{
"mcpServers": {
"postgres": {
"command": "uvx",
"args": [
"postgres-mcp",
"--access-mode=restricted"
],
"env": {
"DATABASE_URI": "<YOUR_DATABASE_URI>"
}
}
}
}{
"mcpServers": {
"postgres": {
"command": "uvx",
"args": [
"postgres-mcp@0.6.2",
"--access-mode=restricted"
],
"env": {
"DATABASE_URI": "<YOUR_DATABASE_URI>"
}
}
}
}Format verified against the official Windsurf docs ↗.
Defined in the server's official registry manifest. Required secrets are shown as <YOUR_…> placeholders in the configs above.
DATABASE_URI required secret — Standard PostgreSQL connection string, e.g. postgresql://user:password@localhost:5432/dbname. Keep it in your client config, not on the command line. Get it: Your Postgres deployment (or its provider's connection panel)Reference server ARCHIVED — recommended local option: crystaldba/postgres-mcp
The original @modelcontextprotocol/server-postgres reference server is archived (modelcontextprotocol/servers-archived). The maintained local option recommended by the community is crystaldba/postgres-mcp. This listing previously pointed at a hosted third-party gateway (waystation.ai) — commands below are for the maintained local server, which keeps your database credentials on your own machine.
Run with --access-mode=restricted (the documented default recommendation) to keep the server read-only-ish; unrestricted mode enables writes and DDL. Source: github.com/crystaldba/postgres-mcp ↗
Check DATABASE_URI: postgresql://user:password@host:5432/dbname. For hosted databases, allow the client IP or use the provider's proxy connection string. Source: github.com/crystaldba/postgres-mcp ↗
The index analysis tooling benefits from optional Postgres extensions (documented in the README); without them only the basic analyses work. Source: github.com/crystaldba/postgres-mcp ↗
Independent, non-official implementations of the PostgreSQL MCP server maintained by the community.
Last verified: 2026-10-15 | Sources: crystaldba/postgres-mcp README ↗ · modelcontextprotocol/servers-archived ↗
⭐ 3,397 stars · 最近更新于 73 天前 · MIT license
Postgres MCP Pro does much more than wrap a database connection. Features include: Postgres MCP Pro supports both the Standard Input/Output (stdio) and Server-Sent Events (SSE) transports, for flexibility in different environments. For additional background on why we built Postgres MCP Pro
Summary from the project README — github.com/modelcontextprotocol/servers
Distributed as npm, listed under Databases. Review our MCP security guide before granting access to real data.
Postgres MCP Pro does much more than wrap a database connection. Features include: Postgres MCP Pro supports both the Standard Input/Output (stdio) and Server-Sent Events (SSE) transports, for flexibility in different environments. For additional background on why we built Postgres MCP Pro
Run the install command shown above, then paste the config for your client (Claude Desktop, Claude Code, Cursor, VS Code or Windsurf) into its MCP settings and restart the client.
The MCP server itself is free to install. The source is public on https://github.com/modelcontextprotocol/servers. Any third-party service it calls may require its own API key and account.
Any MCP-compatible client can use it, including Claude Desktop, Claude Code, Cursor, VS Code, Windsurf and custom agents.
Publish this server? Link back with a badge on your README or site — copy either snippet.
Markdown
[](https://mcpnav.net/server/postgres/)
HTML
<a href="https://mcpnav.net/server/postgres/"><img src="https://mcpnav.net/badge/postgres.svg" alt="Listed on MCPNav" height="20"></a>