MCP Postgres
MCP server by kristofer84 Verified · npm:mcp-postgres
MCP PostgreSQL Server gives AI assistants access to PostgreSQL databases through the Model Context Protocol. It lists tables, inspects schemas and runs SELECT queries. It suits developers who want an assistant to work with a PostgreSQL database.
Install MCP Postgres
Built from the published package, never by AI.
claude mcp add mcp-postgres -- npx -y mcp-postgresRun in your terminal. Add --scope user to use it in every project.
{
"mcpServers": {
"mcp-postgres": {
"args": [
"-y",
"mcp-postgres"
],
"command": "npx"
}
}
}Settings, Developer, Edit config. Paste into claude_desktop_config.json and restart.
{
"mcpServers": {
"mcp-postgres": {
"args": [
"-y",
"mcp-postgres"
],
"command": "npx"
}
}
}Add to ~/.cursor/mcp.json (all projects) or .cursor/mcp.json (this project).
{
"servers": {
"mcp-postgres": {
"args": [
"-y",
"mcp-postgres"
],
"command": "npx"
}
}
}Add to .vscode/mcp.json. VS Code uses "servers", not "mcpServers".
codex mcp add mcp-postgres -- npx -y mcp-postgres{
"mcpServers": {
"mcp-postgres": {
"args": [
"-y",
"mcp-postgres"
],
"command": "npx"
}
}
}Add to ~/.gemini/config/mcp_config.json (all projects) or .agents/mcp_config.json (this project).
gemini mcp add mcp-postgres npx -y mcp-postgresGemini 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 mcp-postgres block.
About
MCP PostgreSQL Server is a Model Context Protocol server that provides PostgreSQL database access and operations. It is installed from npm as mcp-postgres and can be run with npx. The MCP client configuration sets connection details through variables such as DB_HOST, DB_USER and DB_PASSWORD, or through a single DATABASE_URL. A config.json file is also supported.
The server offers tools to list tables, get schema information, describe a table, sample rows and run SELECT queries. Setting DB_READ_ONLY to true hides write and DDL tools and makes the database session read-only. For AWS RDS endpoints, the server downloads and caches the RDS certificate bundle automatically. It suits developers who want an AI assistant to query PostgreSQL with controlled access.
Written from the project's README and checked against it.
Tools it gives your assistant
list_tablesLists all tables in the database with their types.get_schemaGets database schema information, including tables and columns.execute_queryExecutes a SQL query, limited to SELECT statements for safety.describe_tableGets detailed table information, including indexes and constraints.get_table_sampleGets a sample of rows from a table, up to 100 rows.check_certificate_cacheChecks the status of the AWS RDS certificate cache.
What you need
- Node.js 22 or newer
- A PostgreSQL database and connection details
Try asking
- List all tables in the database
- Show me the schema for the users table
- Get a sample of 20 rows from the orders table
Good to know
- execute_query only accepts SELECT statements.
- DB_READ_ONLY=true disables write and DDL tools.
- Read-only mode is not a substitute for a SELECT-only database role, according to the source.
- Requires Node.js 22 or newer.
Security check
ANo download-and-run commands, hidden instructions or signs of sending keys out were found.
Checked automatically: README.md, package.json. This looks for known risky patterns and is not a full audit. How grades work
Alternatives to MCP Postgres
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
MCP Postgres: common questions
Can the assistant change data in my database?
The execute_query tool accepts SELECT statements only. Setting DB_READ_ONLY=true disables write and DDL tools, and the source recommends a SELECT-only database role for stronger isolation.
Does it work with AWS RDS?
Yes. The server detects RDS endpoints, downloads the AWS RDS Global Certificate Bundle, caches it for 30 days and configures SSL with it.
Which database engine does it support?
It is an MCP server for PostgreSQL database operations, and it connects using PostgreSQL connection settings or a DATABASE_URL.
How do I install MCP Postgres?
In Claude Code run claude mcp add mcp-postgres -- npx -y mcp-postgres. For Claude Desktop, Cursor and VS Code, paste the config shown above and restart. See the install guides.
Is MCP Postgres the official server?
MCP Postgres is published by npm:mcp-postgres from its verified domain in the official MCP Registry.
Is MCP Postgres free?
The code is published under the MIT licence. The service it connects to may have its own pricing.
Is MCP Postgres safe to use?
It scores 81 of 100. Grades: maintenance A, licence A, quality C. 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 MCP Postgres?
Similar MCP servers: Supabase, ArcadeDB MCP Server, DBHub, MCP Toolbox for Databases.
Does MCP Postgres 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.
