MCP Server for PostgreSQL
PostgreSQL用MCPサーバー
PostgreSQL 用のモデル コンテキスト プロトコル (MCP) サーバー実装。MCP を介して PostgreSQL データベースと対話するためのシンプルなインターフェイスを提供します。
特徴
パラメータ化された入力でSQLクエリを実行する
INSERT/UPDATE/DELETE操作を実行する
新しいデータベースを作成する
テーブルスキーマの作成または更新
PostgreSQL接続のデバッグ
Dockerでコンテナ化して簡単に導入できる
環境ベースの構成
Related MCP server: MCP PostgreSQL Server
前提条件
Python 3.8以上
PostgreSQL 10以上
Docker (オプション、コンテナ化されたデプロイメント用)
Docker Compose(オプション、開発用)
インストール
Dockerの使用(推奨)
リポジトリをクローンします。
git clone https://github.com/asadudin/mcp-server-postgres.git cd mcp-server-postgresサンプル環境ファイルをコピーします。
cp .env.example .envPostgreSQL の資格情報を使用して
.envファイルを更新します。PG_HOST=postgres PG_PORT=5432 PG_USER=postgres PG_PASSWORD=your_password PG_DATABASE=your_database HOST=0.0.0.0 PORT=8056Docker Compose を使用してサービスを開始します。
docker-compose up -d
手動インストール
リポジトリをクローンします。
git clone https://github.com/asadudin/mcp-server-postgres.git cd mcp-server-postgres仮想環境を作成してアクティブ化します。
python -m venv venv source venv/bin/activate # On Windows: .\venv\Scripts\activate依存関係をインストールします:
pip install -r requirements.txtサンプル環境ファイルをコピーして更新します。
cp .env.example .env # Edit .env with your configurationサーバーを実行します。
python mcp_server_postgres.py
使用法
MCP サーバーは次のエンドポイントを提供します。
sql_query
SELECT クエリを実行し、結果を JSON として返します。
パラメータ:
query: SQLクエリ文字列params: クエリパラメータのオプションのJSON文字列(リストまたは辞書)
例:
{
"query": "SELECT * FROM users WHERE id = $1",
"params": [1]
}sql_execute
INSERT/UPDATE/DELETE ステートメントを実行します。
パラメータ:
query: SQL文params: クエリパラメータのオプションのJSON文字列(リストまたは辞書)
例:
{
"query": "INSERT INTO users (name, email) VALUES ($1, $2)",
"params": ["John Doe", "john@example.com"]
}create_database
新しい PostgreSQL データベースを作成します。
パラメータ:
database_name: 作成するデータベースの名前
create_or_update_table
テーブル スキーマを作成または更新します。
パラメータ:
sql: CREATE TABLE または ALTER TABLE SQL ステートメント
debug_postgres_connection
PostgreSQL 接続をデバッグします。
環境変数
変数 | デフォルト | 説明 |
PG_ホスト | ローカルホスト | PostgreSQLホスト |
PG_ポート | 5432 | PostgreSQL ポート |
PG_ユーザー | ポストグル | PostgreSQLユーザー名 |
PG_パスワード | PostgreSQLパスワード | |
PG_データベース | ポストグル | デフォルトのデータベース名 |
ホスト | 0.0.0.0 | MCPサーバーをバインドするホスト |
ポート | 8056 | MCPサーバーを実行するポート |
発達
テストの実行
# Install test dependencies
pip install -r requirements-dev.txt
# Run tests
pytestDockerイメージの構築
docker build -t mcp-server-postgres .APIドキュメント
詳細な API ドキュメントについては、 OpenAPI 仕様を参照してください。
貢献
貢献を歓迎します!お気軽にプルリクエストを送信してください。
ライセンス
このプロジェクトは MIT ライセンスに基づいてライセンスされています - 詳細についてはLICENSEファイルを参照してください。
謝辞
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
No tool schema history has been recorded yet.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
- SupabaseOAuthcom.supabase
MCP server for interacting with the Supabase platform
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Analytical memory for AI agents: a real Postgres queried in plain English over MCP. One command.
Related MCP Servers
- AlicenseBqualityBmaintenanceA Model Context Protocol server that enables powerful PostgreSQL database management capabilities including analysis, schema management, data migration, and monitoring through natural language interactions.181,692198AGPL 3.0
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that enables performing PostgreSQL database operations (create, read, update, delete) on User and Post entities through MCP tools.751MIT
- AlicenseNot gradedqualityCmaintenanceA Model Context Protocol server that enables interaction with PostgreSQL databases to list tables, retrieve schemas, and execute read-only SQL queries.29MIT
- FlicenseNot gradedqualityDmaintenanceAn MCP server that enables AI assistants to interact with PostgreSQL databases by executing SQL queries and inspecting database schemas. It provides tools for standardized database exploration and management through the Model Context Protocol.-
Appeared in Searches
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/asadudin/mcp-server-postgres'
If you have feedback or need assistance with the MCP directory API, please join our Discord server