Post

Postgres MCP

Postgres MCP

Postgres MCP

crystaldba/postgres-mcp — a Model Context Protocol server that exposes the cluster’s PostgreSQL instance to MCP-compatible AI clients (e.g. Claude, other LLM tooling) over SSE. Runs in the default namespace of the k3s cluster.

Deployment

ItemValue
Imagecrystaldba/postgres-mcp:latest
Namespacedefault
Replicas1
ServiceLoadBalancer, port 8000 (MetalLB-assigned external IP 192.168.1.38)
TransportSSE (--transport sse --sse-host 0.0.0.0)
Access moderestricted (--access-mode restricted)
Auto-reloadreloader.stakater.com/auto: "true"

Configuration

Connects to the cluster’s PostgreSQL instance over the in-cluster service DNS name, not the external LoadBalancer IP:

1
DATABASE_URI = postgresql://$(POSTGRES_USER):$(POSTGRES_PASSWORD)@postgres.default.svc.cluster.local:5432/$(POSTGRES_DB)

POSTGRES_USER, POSTGRES_PASSWORD, and POSTGRES_DB are all injected from the same postgres-secret Secret that backs the PostgreSQL deployment itself, so credentials stay in one place.

The --access-mode restricted flag limits the MCP server to safer, read-oriented operations rather than full unrestricted SQL access.

This post is licensed under CC BY 4.0 by the author.