MCP.so
登录

PG_MCP_SERVER

@cbc3929

关于 PG_MCP_SERVER

暂无概览

基本信息

分类

其他

运行时

go

传输方式

stdio

发布者

cbc3929

配置

使用下面的配置,将此服务器添加到你的 MCP 客户端。

{
  "mcpServers": {
    "pg_mcp_server": {
      "command": "docker",
      "args": [
        "build",
        "-t",
        "pg-mcp-server:latest",
        "."
      ]
    }
  }
}

工具

未检测到工具

工具是从 README 中自动提取的。维护者可以在 ## Tools 标题下列出工具,即可填充这部分内容。

概览

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.

FAQ from PG_MCP_SERVER

Why does PG_MCP_SERVER pre-process the database schema instead of reading it on every call?

Reading the schema on each call consumes significant time and token context. Pre-processing caches table structures, columns, constraints, foreign keys, indexes, geometry types, and EPSG codes during initialization.

What database permissions does PG_MCP_SERVER require?

It recommends creating a dedicated role with SELECT on the public schema and all privileges on a temp schema. Configuring a role limits SQL injection risk and protects sensitive data.

Which PostgreSQL extensions are supported?

PostGIS and PgVector are fully supported. PgRouting support is marked as partial (⭕).

What transport protocols are available?

PG_MCP_SERVER supports Stdio and SSE transports via the go-mcp library.

How do I configure the database connection?

Set the connection string in main.go with schemaLoadConnID, err := dbService.RegisterConnection(tempCtx, "postgres://user:pass@host:port/db") or use the SCHEMA_LOAD_DB_URL environment variable in a .env file.

评论

其他 分类下的更多 MCP 服务器