PostgreSQL MCP Server
MCP PostgreSQLサーバー
これは、PostgreSQLデータベースとやり取りするためのモデルコンテキストプロトコル(CMP)サーバーです。PostgreSQLデータベースへのクエリとスキーマの検査を行うための読み取り専用インターフェースを提供します。
インストール
npm install -g @hthuong09/postgres-mcpRelated MCP server: PostgreSQL MCP Server
構成
サーバーは複数の方法で構成できます。優先順位は次のとおりです。
環境変数
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から自動的に削除されます
発達
ローカルでサーバーを構築するには:
npm install
npm run build開発中にウォッチモードで実行するには:
npm run watchデバッグ
デバッグログを有効にするには、 DEBUG_MCP=trueを設定します。ログは次の場所に書き込まれます。
Unix/macOS:
/tmp/postgres-mcp-debug.jsonWindows:
%TEMP%/postgres-mcp-debug.json
ライセンス
マサチューセッツ工科大学
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Hosted PostgreSQL MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Text-to-SQL MCP server: read-only queries on PostgreSQL, MySQL and SQL Server with your real schema
A Model Context Protocol server for Wix AI tools
Related MCP Servers
- -licenseNot gradedqualityBmaintenanceA Model Context Protocol server that provides read-only access to PostgreSQL databases. This server enables LLMs to inspect database schemas and execute read-only queries.139,311 npm92,301MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server providing LLMs read-only access to PostgreSQL databases for inspecting schemas and executing queries.27MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that provides read-only access to PostgreSQL databases, enabling LLMs to inspect database schemas and execute read-only queries.MIT
- FlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that enables querying PostgreSQL databases with tools for executing SELECT queries, inspecting database schemas, and listing tables through natural language.-