PostgreSQL
OfficialMCP server for PostgreSQL database access - query and explore database schemas.
claude mcp add --transport stdio modelcontextprotocol-server-postgres npx -y @modelcontextprotocol/server-postgres
How to use
The PostgreSQL MCP server enables seamless access to PostgreSQL databases, allowing you to query and explore database schemas effortlessly. With its built-in capabilities, you can execute read-only SQL queries to retrieve data without altering the database state, making it an essential tool for developers looking to integrate PostgreSQL databases into their applications.
Once connected to the PostgreSQL MCP server, you can utilize the query tool to execute your read-only SQL queries. This allows you to pull data from specific tables or explore database schemas by writing SQL commands. For optimal interaction, focus on well-structured SELECT statements to retrieve the information you need, ensuring to follow your database's schema conventions.
How to install
Prerequisites
Before installing the PostgreSQL MCP server, ensure that you have Node.js installed on your machine. You can verify your Node.js installation by running node -v in your terminal.
Option A: Quick Start with npx
To quickly start using the PostgreSQL MCP server, you can use the following command:
npx -y @modelcontextprotocol/server-postgres
Option B: Global Install Alternative
If you prefer to install the package globally for easier access, run:
npm install -g @modelcontextprotocol/server-postgres
After installation, you can start the server by running server-postgres in your terminal.
Additional notes
When configuring the PostgreSQL MCP server, make sure to set your database connection parameters correctly, such as DATABASE_URL, which typically includes the username, password, and database name. A common gotcha is forgetting to grant the necessary permissions to the user specified in your connection string, which can result in access errors when executing queries.
Available tools
query
Execute a read-only SQL query
Related MCP Servers
turbular
A MCP server allowing LLM agents to easily connect and retrieve data from any database
neurondb
PostgreSQL extension for vector search, embeddings, and ML, plus NeuronAgent runtime and NeuronMCP server.
sequel
MCP Database servers for Claude, Cursor and Windsuf
mcp-libsql
Secure MCP server for libSQL databases with comprehensive tools, connection pooling, and transaction support. Built with TypeScript for Claude Desktop, Claude Code, Cursor, and other MCP clients.
zenstack -auth
ZenStack Remote MCP Server with Authorization
mantora
The open-source run log for MCP agents. Get a shareable report to verify and reproduce what the agent did — plus a protective mode for common dangerous SQL.