
stuzero/pg-mcp-server
Developer toolsこのページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る
AIエージェント向けの強化機能を備えたPostgreSQLデータベース向けのモデルコンテキストプロトコル(MCP)サーバー。
概要
AIエージェント向けの強化機能を備えたPostgreSQLデータベース向けのモデルコンテキストプロトコル(MCP)サーバー。 PG-MCPは、PostgreSQLデータベース向けのモデルコンテキストプロトコルのサーバー実装です。これは、MCPのリソース指向アーキテクチャを通じて、AIエージェントがPostgreSQLデータベースを発見し、接続し、クエリし、理解するための包括的なAPIを提供します。 この実装は、参照版Postgres MCP実装を基盤とし、いくつかの重要な強化を加えています。 1. : 本番環境向けのSSEトランスポートを備えた完全なサーバーとして構築 2.: 複数のPostgreSQLデータベースに同時に接続 3.: データベースカタログからテーブル/列の記述を抽出・公開 4.: PostGISやpgvector 5などのPostgreSQL拡張に関する詳細なYAMLベースの知識を提供します。: クエリ実行計画を解析するための専用ツールを含みます 6.
概要(AI 翻訳)
AIエージェント向けの強化機能を備えたPostgreSQLデータベース向けのモデルコンテキストプロトコル(MCP)サーバー。
PG-MCPプロジェクトの詳細はこちら:
https://stuzero.github.io/pg-mcp/
概要
PG-MCPは、PostgreSQLデータベース向けのモデルコンテキストプロトコルのサーバー実装です。これは、MCPのリソース指向アーキテクチャを通じて、AIエージェントがPostgreSQLデータベースを発見し、接続し、クエリし、理解するための包括的なAPIを提供します。
この実装は、参照版Postgres MCP実装を基盤とし、いくつかの重要な強化を加えています。
- フルサーバー実装:本番環境向けにSSEトランスポートを備えた完全なサーバーとして構築
- マルチデータベースサポート:複数のPostgreSQLデータベースに同時に接続
- リッチカタログ情報:データベースカタログからテーブル/カラムの記述を抽出・公開
- 拡張コンテキスト:PostGISやpgvectorなどのPostgreSQL拡張に関する詳細なYAMLベースの知識を提供します
- クエリ説明:クエリ実行計画を分析するための専用ツールが含まれています
- 堅牢な接続管理:安全な接続ID処理を備えたデータベース接続の適切なライフサイクル
特徴
このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。
README
以下は原文 README の抜粋です。原文を見る。
PostgreSQL Model Context Protocol (PG-MCP) Server
A Model Context Protocol (MCP) server for PostgreSQL databases with enhanced capabilities for AI agents.
More info on the pg-mcp project here:
https://stuzero.github.io/pg-mcp/
Overview
PG-MCP is a server implementation of the Model Context Protocol 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.
This implementation builds upon and extends the reference Postgres MCP implementation with several key enhancements:
- Full Server Implementation: Built as a complete server with SSE transport for production use
- Multi-database Support: Connect to multiple PostgreSQL databases simultaneously
- Rich Catalog Information: Extracts and exposes table/column descriptions from the database catalog
- Extension Context: Provides detailed YAML-based knowledge about PostgreSQL extensions like PostGIS and pgvector
- Query Explanation: Includes a dedicated tool for analyzing query execution plans
- Robust Connection Management: Proper lifecycle for database connections with secure connection ID handling
Features
Connection Management
- Connect Tool: Register PostgreSQL connection strings and get a secure connection ID
- Disconnect Tool: Explicitly close database connections when done
- Connection Pooling: Efficient connection management with pooling
Query Tools
- pg_query: Execute read-only SQL queries using a connection ID
- pg_explain: Analyze query execution plans in JSON format
Schema Discovery Resources
- List schemas with descriptions
- List tables with descriptions and row counts
- Get column details with data types and descriptions
- View table constraints and indexes
- Explore database extensions
Data Access Resources
- Sample table data (with pagination)
- Get approximate row counts
Extension Context
Built-in contextual information for PostgreSQL extensions like:
- PostGIS: Spatial data types, functions, and examples
- pgvector: Vector similarity search functions and best practices
Additional extensions can be easily added via YAML config files.
Installation
Prerequisites
- Python 3.13+
- PostgreSQL database(s)
Using Docker
# Clone the repository
git clone https://github.com/stuzero/pg-mcp-server.git
cd pg-mcp-server
# Build and run with Docker Compose
docker-compose up -d
Manual Installation
# Clone the repository
git clone https://github.com/stuzero/pg-mcp-server.git
cd pg-mcp-server
# Install dependencies and create a virtual environment ( .venv )
uv sync
# Activate the virtual environment
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Run the server
インストール
This server does not publish a one-line install command.
Open the repository installation guide MCP 初心者?mcpskill.org のガイドから始めましょう →