MCPVault
Blog
ReviewAugust 19, 20268 min read

Postgres MCP Server: Run SQL Queries From Claude [2026]

Connect Claude to PostgreSQL with a read-only MCP server. Follow the npx setup, configure stdio, inspect schemas, and check its current grade before setup.

What is the Postgres MCP Server?

The Postgres MCP Server connects an AI client to a PostgreSQL database through the Model Context Protocol. This particular package, published as @ahmedmustahid/postgres-mcp-server, supports stdio for desktop clients and Streamable HTTP for networked integrations. Its main database tool is deliberately narrow: it executes read-only SQL queries.

That makes it useful for asking Claude to inspect tables, explore data, and answer questions without giving the model a direct shell or unrestricted write path. It is not a complete database administration layer, and you should treat the connection as production infrastructure, not as a harmless chat plugin.

The package is listed on MCPVault, where the current record shows two declared tools, a D quality grade, 31 GitHub stars, no detected license, and an update signal of one year ago. Those details matter. The install is straightforward, but the listing signals that you should review the repository and use a restricted database account before connecting anything important.

Install the Postgres MCP Server with npx

The repository README documents an npm-based setup. You need Node.js, npm, and a PostgreSQL connection that the process can reach.

npx @ahmedmustahid/postgres-mcp-server stdio

The stdio argument is the important part for Claude Desktop. Without it, the package starts its Streamable HTTP transport on port 3000 by default. The README also documents the HTTP form:

npx @ahmedmustahid/postgres-mcp-server

Before starting either mode, provide database credentials. The package accepts one POSTGRES_URL connection string, or separate variables:

export POSTGRES_USERNAME=readonly_user
export POSTGRES_PASSWORD='replace-with-a-secret'
export POSTGRES_HOST=localhost
export POSTGRES_PORT=5432
export POSTGRES_DATABASE=app_database

npx @ahmedmustahid/postgres-mcp-server stdio

You can put the same values in a .env file in the directory where you run npx. Do not commit that file, paste credentials into a prompt, or use a superuser account just because it is convenient.

The install command and environment variable names above come from the project README, not from a generic MCP template. That distinction is worth checking because several unrelated projects use similar names and different package managers.

Configure Claude Desktop

The repository includes a Claude Desktop example. Add an entry under mcpServers in claude_desktop_config.json:

{
  "mcpServers": {
    "postgres-mcp-server": {
      "command": "npx",
      "args": [
        "@ahmedmustahid/postgres-mcp-server",
        "stdio"
      ],
      "env": {
        "POSTGRES_USERNAME": "readonly_user",
        "POSTGRES_PASSWORD": "replace-with-a-secret",
        "POSTGRES_HOST": "localhost",
        "POSTGRES_DATABASE": "app_database"
      }
    }
  }
}

On macOS, Claude Desktop normally reads ~/Library/Application Support/Claude/claude_desktop_config.json. On Windows, the file is under %APPDATA%\Claude\claude_desktop_config.json. After saving the JSON, restart Claude Desktop and look for the server in the tools list.

If Claude reports that the server is disconnected, first run the same command in a terminal with the environment variables set. This separates a database or Node.js problem from a Claude configuration problem. Also check that npx is available to the desktop process. GUI applications sometimes have a different PATH from your interactive shell.

What tools and resources does it expose?

The MCPVault listing currently shows two tools:

| Tool | What it does | |---|---| | query | Executes read-only SQL using a required sql string. | | sql | Executes read-only SQL using a required sql string. |

The repository README also describes database resources for tables and table schemas. These let the client discover the shape of the database before constructing a query. It additionally includes a simple hello://world resource for testing.

The small tool surface is a feature if your goal is controlled analysis. It is a limitation if you expect migrations, inserts, updates, monitoring, or a full DBA workflow. The server does not become safe merely because the tool is named query. Enforce read-only behavior at the PostgreSQL role and network layer as well.

A sensible first test is a harmless metadata query:

SELECT table_schema, table_name
FROM information_schema.tables
WHERE table_schema NOT IN ('pg_catalog', 'information_schema')
ORDER BY table_schema, table_name;

Then ask Claude to describe what it found, rather than immediately requesting a large export. Keep result sizes bounded while you are validating the connection.

Stdio or Streamable HTTP?

Use stdio when Claude Desktop launches the server locally. The MCP process runs as a child process, and credentials can be passed through the env object in the client configuration.

Use Streamable HTTP when another application needs to connect over a network, or when you want to run the server as a separate service. The README says the default HTTP port is 3000 and the MCP endpoint is /mcp.

HTTP is more flexible, but it increases the security surface. Do not bind a database bridge to a public interface without authentication, origin controls, TLS, and a narrowly scoped database role. The project exposes HOST, PORT, and CORS_ORIGIN configuration, but those settings do not replace authentication.

Compatibility and quality check

MCP clients can support the protocol while still differing in configuration format, transport support, and process discovery. The current MCPVault record explicitly shows compatibility with Claude Desktop. It does not claim Cursor, Windsurf, VS Code, Zed, Cline, or ChatGPT compatibility for this listing.

That does not prove those clients cannot use it. It means there is no compatibility signal on this public record that we can responsibly turn into a promise. Test another client with its documented stdio or HTTP configuration, then record the result rather than assuming that every MCP client behaves the same way.

MCPVault gives this listing a D grade based on public repository signals. The record is automated and the repository has not been maintainer-reviewed on the page. The grade reflects signals such as maintenance recency, adoption, license clarity, and documentation. It is not a claim that the package is malicious or unusable. It is a reason to do more verification before production use.

For context, MCPVault's grade documentation explains how these signals are interpreted. A quality grade is a screening aid, not a substitute for reading the source, pinning a version, and testing with a disposable database.

The listing is also not marked verified. Verified status means a server has passed MCPVault's live handshake process, in addition to the public-record checks. You can read how the verified badge works before treating a listing as tested.

A safer PostgreSQL setup

Create a dedicated role with only the permissions the agent needs. For a read-only reporting database, the broad shape is:

CREATE ROLE mcp_readonly LOGIN PASSWORD 'use-a-secret-manager';
GRANT CONNECT ON DATABASE app_database TO mcp_readonly;
GRANT USAGE ON SCHEMA public TO mcp_readonly;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO mcp_readonly;
ALTER DEFAULT PRIVILEGES IN SCHEMA public
GRANT SELECT ON TABLES TO mcp_readonly;

Adjust the database, schema, and table permissions for your environment. If your application uses multiple schemas, grant them explicitly. If the database contains personal, financial, or operationally sensitive data, consider a reporting replica or curated views instead of exposing application tables directly.

Avoid embedding a production password in a shared config file. Use environment injection or your operating system's secret storage where possible. Pin the package version after testing rather than using latest forever, and keep a record of which commit or npm version your client is running.

Before enabling the server, test three things: the role cannot write, the network path is limited, and the client can discover only the intended schemas. Then ask a deliberately invalid query and confirm that the error is understandable without exposing credentials or connection details.

See the Postgres MCP Server on MCPVault for the live grade, tools, compatibility signals, and install details: Postgres MCP Server listing.

Frequently Asked Questions

Does the Postgres MCP Server work with Claude Desktop?

Yes. The repository includes a Claude Desktop configuration using npx and the stdio transport, and the MCPVault listing currently records Claude Desktop compatibility.

Is this Postgres MCP Server read-only?

Its documented query tool is described as read-only, but you should enforce read-only access in PostgreSQL with a dedicated role. Never rely on an MCP tool description as your only database safety control.

Can I use the server over HTTP?

Yes. Running the package without the stdio argument starts its Streamable HTTP mode on port 3000 by default. Secure the endpoint before exposing it beyond the local machine.

Why does MCPVault give this listing a D grade?

The current public record shows weak or incomplete signals, including an update signal of one year ago, no detected license, and 31 stars. The grade is an automated screening signal, not a security verdict. Read the source and test the exact version you plan to run.

Can I use it with Cursor or Windsurf?

The current MCPVault listing does not record compatibility for Cursor or Windsurf. You may be able to configure either client through stdio or HTTP, but test that integration yourself and treat it as unconfirmed until documented.


Your server in the vault.

If you built an MCP server, claim the listing and get it in front of developers who are actively looking. Free to claim, with verification free during early access and a do-follow link when the requirements are met.

Claim your listing or submit a server if it is not indexed yet.

MCP ServerClaude DesktopDatabasesInstall Guide