MCP server for read-only PostgreSQL database queries in Claude Desktop
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
We haven't yet run this listing's install command through our automated sandbox check. This isn't a red flag β we're steadily working through the catalog.
π‘ Paste the JSON block into your client's configuration file under mcpServers, then restart the application.
Inspect callable tools, capabilities, and parameters exposed to AI agents by Read Only Local Postgres MCP Server.
connectConnect to a PostgreSQL database using a connection string. The connection persists for subsequent queries until changed or disconnected. The target must be `DB_HOST:DB_PORT` or listed in `DB_ALLOWED_HOSTS`.
disconnectDisconnect from the current runtime database and revert to the default environment-configured connection.
queryRun a read-only SQL query against the currently connected database. Optionally override the connection for a single query.
A Model Context Protocol (MCP) server that enables Claude Desktop to interact with PostgreSQL databases through natural language queries.
READ ONLY transactionsThen set your database environment variables:
Done! Restart Claude Code and ask: "What tables are in my database?"
1. Open your config file:
2. Add this configuration:
3. Save, restart Claude Desktop, and test!
This server is published in the Model Context Protocol Registry as capital.hove/read-only-local-postgres-mcp-server.
Then configure your database credentials using environment variables. Restart Claude Code and you're done!
Benefits:
For Claude Desktop:
Edit ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
For Claude Code:
Edit ~/.config/claude-code/settings.json (macOS/Linux) or %APPDATA%\claude-code\settings.json (Windows):
If you're using Claude Code, you can easily install this MCP server:
Then configure Claude Code by adding to your MCP settings.
Save the repository to a directory on your system:
Note: If you installed via Option 1 (MCP Registry with npx), you've already configured everything! This section is for users who chose Options 2, 3, or 4 (npm or manual installation).
If you're using Claude Code with a manual installation, add the PostgreSQL server to your MCP settings:
Open your Claude Code settings (typically in ~/.config/claude-code/settings.json on macOS/Linux or %APPDATA%\claude-code\settings.json on Windows)
Add the PostgreSQL MCP server configuration:
If you're using Claude Desktop with a manual installation, open your Claude Desktop configuration file:
macOS:
Windows:
Add the PostgreSQL server configuration:
If you're using mise for Node.js version management, make sure to use the full path to the Node.js executable in your configuration.
| Variable | Description | Default |
|---|---|---|
DB_HOST | PostgreSQL server hostname | localhost |
DB_PORT | PostgreSQL server port | 5432 |
DB_DATABASE | Database name | postgres |
DB_USERNAME | PostgreSQL username | postgres |
DB_PASSWORD | PostgreSQL password | (empty) |
DB_SSL | Enable SSL connection | false |
DB_ALLOWED_HOSTS | Comma-separated host:port pairs that runtime connection strings may target, in addition to DB_HOST:DB_PORT | (empty) |
This MCP server exposes three tools that Claude can use to interact with PostgreSQL databases.
connectConnect to a PostgreSQL database using a connection string. The connection persists for subsequent queries until changed or disconnected. The target must be DB_HOST:DB_PORT or listed in DB_ALLOWED_HOSTS.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
connectionString | string | Yes | PostgreSQL connection string |
Connection String Format:
SSL Modes Supported:
sslmode=require - Require SSL (recommended for remote connections)sslmode=verify-full - Require SSL with certificate verificationExample Usage (natural language):
Response:
disconnectDisconnect from the current runtime database and revert to the default environment-configured connection.
Parameters: None
Example Usage (natural language):
Response:
queryRun a read-only SQL query against the currently connected database. Optionally override the connection for a single query.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
sql | string | Yes | SQL query to execute (SELECT only) |
connectionString | string | No | Override connection for this query only |
Example Usage (natural language):
Response:
When using this MCP server, Claude can:
Query the default database (configured via environment variables):
Connect to a different database dynamically:
Factual signals from GitHub, npm, and our automated checks β not a rating.
No reviews yet β be the first to share how this listing worked for you.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/read-only-local-postgres-mcp-server)<a href="https://allmcps.com/mcp/read-only-local-postgres-mcp-server"><img src="https://allmcps.com/api/badge/read-only-local-postgres-mcp-server?style=directory" alt="Read Only Local Postgres MCP Server on AllMCPs" /></a>