MCP server
pgops
Safe, audited PostgreSQL operations for AI agents: queries, migrations, EXPLAIN…
Runs locallyStatus and history
- Pricing
- Open source
- Runs
- Locally
- Version
- 0.1.9
- Listing updated
- 4 days ago
About pgops
pgops is an open-source MCP server. It runs locally on your machine and is started by your AI client.
Safe, audited PostgreSQL operations for AI agents: queries, migrations, EXPLAIN, containers
Install
Run in a terminal
claude mcp add pgops-mcp --env PGOPS_DSN='<PGOPS_DSN>' --env PGOPS_READONLY_DSN='<PGOPS_READONLY_DSN>' -- uvx pgops-mcpAdd to claude_desktop_config.json
{
"mcpServers": {
"pgops-mcp": {
"command": "uvx",
"args": [
"pgops-mcp"
],
"env": {
"PGOPS_DSN": "<PGOPS_DSN>",
"PGOPS_READONLY_DSN": "<PGOPS_READONLY_DSN>"
}
}
}
}Add to ~/.cursor/mcp.json
{
"mcpServers": {
"pgops-mcp": {
"command": "uvx",
"args": [
"pgops-mcp"
],
"env": {
"PGOPS_DSN": "<PGOPS_DSN>",
"PGOPS_READONLY_DSN": "<PGOPS_READONLY_DSN>"
}
}
}
}Add to .vscode/mcp.json
{
"servers": {
"pgops-mcp": {
"type": "stdio",
"command": "uvx",
"args": [
"pgops-mcp"
],
"env": {
"PGOPS_DSN": "<PGOPS_DSN>",
"PGOPS_READONLY_DSN": "<PGOPS_READONLY_DSN>"
}
}
}
}Add to ~/.codeium/windsurf/mcp_config.json
{
"mcpServers": {
"pgops-mcp": {
"command": "uvx",
"args": [
"pgops-mcp"
],
"env": {
"PGOPS_DSN": "<PGOPS_DSN>",
"PGOPS_READONLY_DSN": "<PGOPS_READONLY_DSN>"
}
}
}
}Add to your client's MCP settings (most use this shape)
{
"mcpServers": {
"pgops-mcp": {
"command": "uvx",
"args": [
"pgops-mcp"
],
"env": {
"PGOPS_DSN": "<PGOPS_DSN>",
"PGOPS_READONLY_DSN": "<PGOPS_READONLY_DSN>"
}
}
}
}Configuration
PGOPS_DSNPostgreSQL connection string for the database to operate on.RequiredPGOPS_READONLY_DSNOptional separate DSN for the read-only pool. Use a role with no write grants to enforce read-only at the database rather than only in the server.PGOPS_READ_ONLYSet to 1 to withhold every mutating tool. Write tools are not registered at all, so an agent cannot call them.PGOPS_APPROVAL_MODESet to 1 to register container.restart and container.exec. Off by default: Docker socket access is root-equivalent on the host.PGOPS_AUDIT_LOGPath to the append-only JSONL audit log.PGOPS_DEFAULT_TIMEOUT_MSStatement timeout applied to every query unless a tool call overrides it.PGOPS_MAX_TIMEOUT_MSCeiling a caller-supplied timeout is clamped to.PGOPS_DEFAULT_ROW_LIMITRows returned by query.read when the caller does not specify a limit.PGOPS_DSNPostgreSQL connection string. From inside a container, localhost is the container itself — use host.docker.internal or the compose service name.RequiredPGOPS_READ_ONLYSet to 1 to withhold every mutating tool.PGOPS_AUDIT_LOGPath to the audit log inside the container. Mount a volume at this path or the log dies with the container.
Pricing
Open source
pgops FAQ
Is pgops free?
Yes. pgops is open source, so you can use and self-host it for free.
How do I add pgops to Claude Code?
Run this command in your terminal: claude mcp add pgops-mcp --env PGOPS_DSN='<PGOPS_DSN>' --env PGOPS_READONLY_DSN='<PGOPS_READONLY_DSN>' -- uvx pgops-mcp