MCP PostgreSQLサーバー
これは、PostgreSQLデータベースとやり取りするためのモデルコンテキストプロトコル(CMP)サーバーです。PostgreSQLデータベースへのクエリとスキーマの検査を行うための読み取り専用インターフェースを提供します。
インストール
構成
サーバーは複数の方法で構成できます。優先順位は次のとおりです。
環境変数
POSTGRES_URL: 完全なデータベース URL (例:postgres://user:pass@host:5432/dbname)個別の接続パラメータ:
POSTGRES_HOST: データベースホストPOSTGRES_PORT: データベースポート(デフォルト: 5432)POSTGRES_DB: データベース名POSTGRES_USER: データベースユーザーPOSTGRES_PASSWORD: データベースパスワードPOSTGRES_SSL: SSL モードを有効にする (有効にするには 'true' に設定)POSTGRES_SCHEMA: データベーススキーマ(デフォルト: 'public')
追加構成:
DOTENV_PATH: .env ファイルへのカスタムパスDEBUG_MCP: デバッグログを有効にする(有効にするには「true」に設定)
コマンドライン
npx @hthuong09/postgres-mcp "postgres://user:pass@host:5432/dbname"
リソース
テーブルスキーマ: データベース内の各テーブルはリソースとして公開されます
リソース URI 形式:
postgres://user@host/dbname/table_name/schemaレスポンス形式: 列定義のJSON配列(名前とデータ型)
使用例
環境変数の使用:
export POSTGRES_HOST=localhost export POSTGRES_DB=mydb export POSTGRES_USER=myuser export POSTGRES_PASSWORD=mypassword npx @hthuong09/postgres-mcp接続 URL の使用:
npx @hthuong09/postgres-mcp "postgres://myuser:mypassword@localhost:5432/mydb"SSL で環境変数を使用する:
export POSTGRES_HOST=db.example.com export POSTGRES_DB=mydb export POSTGRES_USER=myuser export POSTGRES_PASSWORD=mypassword export POSTGRES_SSL=true npx @hthuong09/postgres-mcpカスタム .env ファイルの場所を使用する:
DOTENV_PATH=/path/to/.env npx @hthuong09/postgres-mcp
セキュリティに関する考慮事項
データベースの資格情報は安全に保管する必要がある
プロセスリストで資格情報が公開されないように、本番環境ではコマンドライン引数の代わりに環境変数または .env ファイルを使用します。
実稼働環境ではSSLの使用を検討する
サーバーは安全のため読み取り専用トランザクションのみを許可します
パスワードはリソースURIから自動的に削除されます
発達
ローカルでサーバーを構築するには:
開発中にウォッチモードで実行するには:
デバッグ
デバッグログを有効にするには、 DEBUG_MCP=trueを設定します。ログは次の場所に書き込まれます。
Unix/macOS:
/tmp/postgres-mcp-debug.jsonWindows:
%TEMP%/postgres-mcp-debug.json
ライセンス
マサチューセッツ工科大学
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
PostgreSQL データベースと対話してテーブルを一覧表示したり、スキーマを取得したり、読み取り専用 SQL クエリを実行したりできるようにするモデル コンテキスト プロトコル サーバー。
Related MCP Servers
- -securityFlicense-qualityA Model Context Protocol server providing both read and write access to PostgreSQL databases, enabling LLMs to query data, modify records, and manage database schemas.Last updated -6088
- AsecurityAlicenseAqualityA Model Context Protocol server that enables powerful PostgreSQL database management capabilities including analysis, schema management, data migration, and monitoring through natural language interactions.Last updated -181,751126AGPL 3.0
- AsecurityAlicenseAqualityA Model Context Protocol server that enables interaction with PostgreSQL databases for analyzing setups, debugging issues, managing schemas, migrating data, and monitoring performance.Last updated -111MIT License
- -securityFlicense-qualityA Model Context Protocol server implementation that provides a simple interface to interact with PostgreSQL databases, enabling SQL queries, database operations, and schema management through MCP.Last updated -