Can it write to my database?
Only when you set `PG_ALLOW_WRITE=true`. With the default off, the `execute` tool is visible but refuses, and every read runs inside a read-only transaction that PostgreSQL rolls back.

@antonorlov
MCP PostgreSQL Server
使用下面的配置,将此服务器添加到你的 MCP 客户端。
{
"mcpServers": {
"postgres": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"mcp-postgres-server"
],
"env": {
"DATABASE_URL": "postgres://user:password@localhost:5432/mydb",
"PG_ALLOW_WRITE": "false"
}
}
}
}Run one read-only SQL statement against the connected PostgreSQL database and get rows back as JSON. Send exactly one statement per call (SELECT, WITH, EXPLAIN, or SHOW). It runs inside an engine-enforced read-only transaction, so any write is refused by the database. Use this tool for all data reading, aggregation, and query planning. Returns {rows, rowCount, returnedRows, truncated}, plus hint when truncated is true. Prefer $1, $2 placeholders with the params array over interpolating values. Results are capped at ~32768 bytes; truncated:true means rows were dropped - add LIMIT/WHERE or select fewer columns.
Run a data-modifying SQL statement (INSERT/UPDATE/DELETE or DDL). Currently DISABLED: the server is read-only, so this returns an error and changes nothing. To enable writes, the operator must start the server with PG_ALLOW_WRITE=true.
List every schema in the connected database. Start here when exploring an unfamiliar database, then call list_tables for the schema you care about. Returns {schemas: [name, ...]}.
List all tables in a schema (default: 'public'). Use this before querying tables you have not seen yet, then call describe_table for column details. Returns {tables: [name, ...]}.
Show the structure of one table: column names, data types, nullability, defaults, and primary-key membership. Call this before writing non-trivial queries against a table. Returns {columns: [{column, type, nullable, default, is_primary_key}, ...]}.
An MCP server that connects an AI agent to a PostgreSQL database over stdio. It reaches local and Docker databases, managed Postgres on RDS, Neon and Supabase, and a database that is only available through an SSH bastion. Writes are off by default.
Run it with npx -y mcp-postgres-server and point it at a database with a single DATABASE_URL. It works in any MCP client that speaks stdio: VS Code, Cursor, Claude Code, Codex, Windsurf. Set PG_ALLOW_WRITE=true when the agent should be able to write.
BEGIN READ ONLY transaction, not by client-side SQL parsingDATABASE_URL with full TLS control: sslmode from disable to verify-full, custom CA$1, $2, bound by the driver, never spliced into SQL texttruncated flagOnly when you set `PG_ALLOW_WRITE=true`. With the default off, the `execute` tool is visible but refuses, and every read runs inside a read-only transaction that PostgreSQL rolls back.
PostgreSQL-style `$1`, `$2` only. The legacy `?` style was removed in 0.2.0.
Yes. Set `PG_SSH_HOST` plus auth and a pinned `PG_SSH_FINGERPRINT`. Host-key verification is mandatory and the tunnel refuses to connect without it.
Universal MCP-Server for your Databases optimized for LLMs and AI-Agents.
Zero-dependency, token-efficient database MCP server for Postgres, MySQL, SQL Server, MariaDB, SQLite.
A Model Context Protocol (MCP) server implementation that provides database capabilities for Chroma

Model Context Protocol Servers

Healthcare provider data for AI assistants, from the official CMS NPPES dataset (updated weekly). Look up any NPI (active or deactivated), search providers and organizations by name, city, state, ZIP, taxonomy code or pl
评论