PostgreSQL Model Context Protocol (PG-MCP) Server
@stuzero
关于 PostgreSQL Model Context Protocol (PG-MCP) Server
暂无概览
基本信息
配置
使用下面的配置,将此服务器添加到你的 MCP 客户端。
{
"mcpServers": {
"pg-mcp-server": {
"command": "uv",
"args": [
"sync"
]
}
}
}工具
未检测到工具
工具是从 README 中自动提取的。维护者可以在 ## Tools 标题下列出工具,即可填充这部分内容。
概览
What is PostgreSQL Model Context Protocol (PG-MCP) Server?
PG-MCP is a server implementation of the Model Context Protocol (MCP) for PostgreSQL databases. It provides a comprehensive API for AI agents to discover, connect to, query, and understand PostgreSQL databases through MCP’s resource-oriented architecture. The server includes multi-database support, rich catalog information, built-in extension context (e.g., PostGIS, pgvector), and query explanation tools.
How to use PostgreSQL Model Context Protocol (PG-MCP) Server?
Install via Docker (docker-compose up -d) or manually (uv sync, then python -m server.app). Use the provided test scripts (test.py and example-clients/claude_cli.py) to verify functionality. For AI agents, use the server’s tools (connect, disconnect, pg_query, pg_explain) and explore schema resources via pgmcp://{conn_id}/ URIs.
Key features of PostgreSQL Model Context Protocol (PG-MCP) Server
- Connect tool to register PostgreSQL connection strings and get a secure connection ID
- Read-only SQL execution (
pg_query) with connection ID pg_explaintool to analyze query execution plans in JSON- Schema discovery: list schemas, tables, columns, constraints, indexes, extensions
- Sample table data with pagination and approximate row counts
- Built-in YAML-based context for extensions like PostGIS and pgvector
Use cases of PostgreSQL Model Context Protocol (PG-MCP) Server
- AI agents exploring and understanding database schemas autonomously
- Natural language to SQL conversion via Claude-powered CLI
- Analyzing query execution plans for performance tuning
- Programmatic inspection of table relationships, constraints, and indexes
FAQ from PostgreSQL Model Context Protocol (PG-MCP) Server
How do I connect to a database?
Use the connect tool with a PostgreSQL connection string. It returns a secure connection ID used for subsequent operations.
Is the server read-only?
Yes, read-only mode is enforced via transaction settings by default.
What PostgreSQL extensions are supported?
Built-in context is provided for PostGIS and pgvector. Additional extensions can be added via YAML configuration files.
How are database credentials handled?
Credentials are sent once during initial connection and are never exposed in resource URLs—only opaque connection IDs are used.
What runtime and transport does the server require?
It requires Python 3.13+ and uses SSE (Server-Sent Events) transport for production use.
数据库 分类下的更多 MCP 服务器
Database Gateway
centralmindUniversal MCP-Server for your Databases optimized for LLMs and AI-Agents.
Elasticsearch/OpenSearch MCP Server
cr7258A Model Context Protocol (MCP) server implementation that provides Elasticsearch and OpenSearch interaction.
Chroma MCP Server
chroma-coreA Model Context Protocol (MCP) server implementation that provides database capabilities for Chroma
MongoDB Lens
furey🍃🔎 MongoDB Lens: Full Featured MCP Server for MongoDB Databases
Sail MCP Server for Spark SQL
lakehqDrop-in Apache Spark replacement written in Rust, unifying batch processing, stream processing, and compute-intensive AI workloads.
评论