PostgreSQL MCP
Provides read-only SQL access to PostgreSQL databases, enabling schema discovery, table metadata retrieval, and safe SELECT queries within read-only transactions.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@PostgreSQL MCPlist all tables in the public schema"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
PostgreSQL MCP
Read-only Model Context Protocol server for PostgreSQL. Gives LLM agents safe SQL access: schema discovery, table metadata, and SELECT queries inside READ ONLY transactions.
Built as a maintained alternative to the deprecated @modelcontextprotocol/server-postgres package.
Features
query— read-only SQL (SELECT,WITH,EXPLAIN,SHOW) with row capslist_tables— list tables in a schemadescribe_table— column names, types, nullability, defaultsResources — per-table schema JSON via MCP resources
Safety — SQL keyword guard +
BEGIN READ ONLYtransactionsConfig — connection string via CLI arg or
DATABASE_URL/MCP_POSTGRES_URL
Related MCP server: PostgreSQL MCP Server
Quick start
git clone https://github.com/vallaksa/postgresql-mcp.git
cd postgresql-mcp
npm install
npm run buildRun with a connection string:
export DATABASE_URL="postgresql://mcp_reader:password@localhost:5432/devstrom"
npm startOr pass the URL as the first argument:
node dist/index.js "postgresql://mcp_reader:password@localhost:5432/devstrom"Cursor / Claude Desktop
Add to .cursor/mcp.json or Claude config:
{
"mcpServers": {
"postgresql": {
"command": "node",
"args": [
"/absolute/path/to/postgresql-mcp/dist/index.js",
"postgresql://mcp_reader:password@localhost:5432/devstrom"
]
}
}
}After publishing to npm:
{
"mcpServers": {
"postgresql": {
"command": "npx",
"args": ["-y", "postgresql-mcp", "postgresql://mcp_reader:password@localhost:5432/devstrom"]
}
}
}Read-only database user
Create a dedicated reader (example for Dev-Strom):
psql -U postgres -d devstrom -f scripts/setup_readonly_user.sqlSet MCP_READER_PASSWORD before running the script.
Environment variables
Variable | Description |
| PostgreSQL connection string |
| Alias for |
| Max rows per query (default |
Dev-Strom integration
In Dev-Strom, point scripts/start_mcp.sh at this server and set MCP_POSTGRES_URL in .env.
Development
npm test
npm run typecheck
npm run dev -- "postgresql://..."License
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/vallaksa/postgresql-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server