What is PG_MCP_SERVER?
PG_MCP_SERVER is a general-purpose PostgreSQL MCP (Model Context Protocol) server that provides efficient schema context to large language models by pre-processing table structures. It supports PostGIS and PgVector extensions and communicates via Stdio or SSE transports.
How to use PG_MCP_SERVER?
Configure the database connection string either in main.go via RegisterConnection or by setting the SCHEMA_LOAD_DB_URL environment variable. Run with Docker (docker run -d -p 8181:8181 pg-mcp-server:latest) or directly with go run ./cmd/server/main.go after cloning and installing dependencies.
Key features of PG_MCP_SERVER
- Pre-fetches database schema to reduce token usage.
- Uses MCP Tool descriptions and Resources for implicit schema context.
- Supports PostGIS geometry types, indexes, and EPSG codes.
- Native PgVector extension support.
- Implements Stdio and SSE transports.
- Docker deployment available.
Use cases of PG_MCP_SERVER
- Provide LLMs with optimized database context without repeated schema queries.
- Query spatial data in PostGIS-enabled databases through natural language.
- Manage vector embeddings stored with PgVector via LLM agents.
- Enable secure, role-based read-only database access for MCP applications.
Comments