@bossforce.ai/mcp-postgres
v0.1.0
Published
MCP server for **PostgreSQL**, built on the [`pg`](https://node-postgres.com/) driver. Read-only by default — a good fit for reporting and data lookups.
Downloads
38
Readme
@bossforce.ai/mcp-postgres
MCP server for PostgreSQL, built on the pg
driver. Read-only by default — a good fit for reporting and data lookups.
Credentials
| Env | How to obtain |
| ---------------------------- | --------------------------------------------------------------------------- |
| POSTGRES_CONNECTION_STRING | postgres://user:password@host:port/database for your database. |
| POSTGRES_ALLOW_WRITES | Optional. Set to true to permit writes; omit for read-only (recommended). |
The connection string is read lazily, so the server boots and answers
tools/list without it; calls fail with an auth error until it is set. For
defence in depth, point it at a read-only database role when writes aren't
needed.
Tools
| Tool | Arguments | Returns |
| ---------------- | -------------------------- | ----------------------------- |
| query | sql, params? | { rows, row_count, fields } |
| list_tables | schema? (default public) | { tables: [...] } |
| describe_table | table, schema? | { columns: [...] } |
Safety
By default every statement runs inside a BEGIN READ ONLY transaction, so any
INSERT/UPDATE/DELETE/DDL fails at the database (SQLSTATE 25006). Set
POSTGRES_ALLOW_WRITES=true to allow writes. Always pass user-supplied values
through params ($1, $2, …) rather than concatenating them into the SQL.
Develop
pnpm --filter @bossforce.ai/mcp-postgres build
pnpm --filter @bossforce.ai/mcp-postgres testTests inject a fake query implementation, so they run without a real database. Regenerate the tools/list snapshot after an intentional signature change:
UPDATE_SNAPSHOTS=1 pnpm --filter @bossforce.ai/mcp-postgres test