sw-postgres-mcp
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., "@sw-postgres-mcpwhat's in this database?"
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.
sw-postgres-mcp
Safe-write Postgres MCP server — an agent can read and modify a database without being able to cause an unrecoverable accident.
Quick start
docker compose up -d
npm install
npm test
npm run buildPoint Claude Desktop at the server (see config.example.json and Claude Desktop section below).
Related MCP server: mcp-enterprise-starter
Configuration
Copy config.example.json to config.json (or set SW_POSTGRES_CONFIG to a custom path):
{
"database": {
"readonlyConnectionString": "postgres://readonly:readonly_password@localhost:5432/mcp_test",
"writerConnectionString": "postgres://writer:writer_password@localhost:5432/mcp_test"
},
"allowlist": {
"read": { "schemas": ["public"], "tables": [] },
"write": { "schemas": [], "tables": [] }
}
}allowlist.read— schemas/tables the agent may see viadescribe_schema/query. If empty, all tables are readable. Iftablesis non-empty, only those fully-qualified tables are listed.allowlist.write— schemas/tables the agent may mutate. Defaults to deny: if bothschemasandtablesare empty, nothing is writable. Add entries explicitly.Environment variables
DATABASE_URL_READONLY/DATABASE_URL_WRITERoverride the file.
Two connection pools are created with distinct Postgres roles (readonly vs writer). Read-only is enforced by the database grants, not by parsing SQL — a bug in our code cannot turn a read tool into a write tool.
Claude Desktop
Add to claude_desktop_config.json:
{
"mcpServers": {
"sw-postgres-mcp": {
"command": "node",
"args": ["/absolute/path/to/sw-postgres-mcp/dist/index.js"],
"env": {
"DATABASE_URL_READONLY": "postgres://readonly:readonly_password@localhost:5432/mcp_test",
"DATABASE_URL_WRITER": "postgres://writer:writer_password@localhost:5432/mcp_test"
}
}
}
}Restart Claude Desktop. Ask "what's in this database?" — describe_schema returns tables, columns with types, foreign keys, and row-count estimates for exactly the allowlisted schemas/tables.
Docker
docker compose up starts a disposable Postgres (postgres:16-alpine) with both roles provisioned via docker/init/01-roles.sql. No manual setup required for tests or local dev.
Tests
docker compose up -d --wait
npm testIntegration tests verify against a live Postgres: role separation, readonly cannot write, describe_schema fields, and allowlist filtering.
Tools
describe_schema— tables, columns with types, foreign keys, row-count estimates (respects read allowlist).
More tools (query, explain_plan, insert_rows, update_rows, delete_rows, run_migration, execute_plan) arrive in later slices.
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.
Related MCP Servers
- Flicense-qualityCmaintenanceAn MCP server that gives an AI agent scoped, safe access to your Postgres databases with per-connection access control, row caps, timeouts, and defense-in-depth read-only enforcement.
- AlicenseAqualityDmaintenanceA production-grade MCP server that gives AI agents safe, authenticated access to a PostgreSQL database.3MIT
- Alicense-qualityAmaintenanceA hardened, read-only Postgres MCP server that enables LLMs to safely query databases without write, DDL, shell, or credential exposure.MIT
- FlicenseAqualityBmaintenanceAn MCP server that enables AI agents to securely interact with PostgreSQL databases with least-privilege scopes, PII masking, and human approval for writes.4
Related MCP Connectors
Analytical memory for AI agents: a real Postgres queried in plain English over MCP. One command.
MCP server for managing Prisma Postgres.
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- 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/jpka/sw-postgres-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server