PostgreSQL MCP Server

Integrations

  • Supports containerized deployment using Docker, allowing the server to connect to PostgreSQL databases from within containers.

  • Provides special connectivity options when running in Docker on macOS, using host.docker.internal to connect to databases on the host machine.

  • Provides read-only access to PostgreSQL databases, enabling schema inspection and execution of read-only SQL queries against connected databases.

PostgreSQL

PostgreSQLデータベースへの読み取り専用アクセスを提供するモデルコンテキストプロトコル(CMP)サーバー。このサーバーにより、LLMはデータベーススキーマを検査し、読み取り専用クエリを実行できます。

コンポーネント

ツール

  • クエリ
    • 接続されたデータベースに対して読み取り専用のSQLクエリを実行する
    • 入力: sql (文字列): 実行するSQLクエリ
    • すべてのクエリは読み取り専用トランザクション内で実行されます

リソース

サーバーは、データベース内の各テーブルのスキーマ情報を提供します。

  • テーブルスキーマ( postgres://<host>/<table>/schema )
    • 各テーブルのJSONスキーマ情報
    • 列名とデータ型が含まれます
    • データベースのメタデータから自動的に検出

Claude Desktopでの使用

このサーバーを Claude Desktop アプリで使用するには、 claude_desktop_config.jsonの「mcpServers」セクションに次の構成を追加します。

ドッカー

  • macOSでdockerを実行する場合、サーバーがホストネットワーク(例:localhost)上で実行されている場合はhost.docker.internalを使用します。
  • ユーザー名/パスワードはpostgresql://user:password@host:port/db-nameのように postgresql の URL に追加できます。
{ "mcpServers": { "postgres": { "command": "docker", "args": [ "run", "-i", "--rm", "mcp/postgres", "postgresql://host.docker.internal:5432/mydb"] } } }

NPX

{ "mcpServers": { "postgres": { "command": "npx", "args": [ "-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost/mydb" ] } } }

/mydbデータベース名に置き換えます。

建物

ドッカー:

docker build -t mcp/postgres -f src/postgres/Dockerfile .

ライセンス

このMCPサーバーはMITライセンスに基づいてライセンスされています。つまり、MITライセンスの条件に従って、ソフトウェアを自由に使用、改変、配布することができます。詳細については、プロジェクトリポジトリのLICENSEファイルをご覧ください。

-
security - not tested
F
license - not found
-
quality - not tested

PostgreSQL データベースへの読み取り専用アクセスを提供し、LLM がデータベース スキーマを検査し、読み取り専用の SQL クエリを実行できるようにします。

  1. Components
    1. Tools
    2. Resources
  2. Usage with Claude Desktop
    1. Docker
    2. NPX
  3. Building
    1. License
      ID: 0fpj51gah9