MCP.so
ログイン

PostgreSQL MCP Server

@leixiaotian1

基本情報

カテゴリ

データベース

ライセンス

MIT

トランスポート

stdio

作者

leixiaotian1

PostgreSQL MCP Server について

一款用golang实现的操作pg数据库的mcp server,支持创建表、查询表、插入数据,查看数据,分析sql语句等功能,欢迎共建!!!

PostgreSQL MCP Server の設定

以下の設定を使って、このサーバーを MCP 対応クライアントに追加してください。

{
  "mcpServers": {
    "pgsql-mcp-server": {
      "command": "docker",
      "args": [
        "network",
        "create",
        "sql-mcp-network"
      ]
    }
  }
}

PostgreSQL MCP Server のツール

ツール一覧はまだありません

この掲載には表示できるツール一覧がまだありません。サーバーにツールがないという意味ではありません。対応機能はプロジェクトのドキュメントをご確認ください。

ツールは README から自動的に抽出されます。メンテナーは ## Tools という見出しの下に記載することで、このタブに反映できます。

概要

What is PostgreSQL MCP Server?

PostgreSQL MCP Server is a Model Context Protocol server that provides tools for AI assistants to interact with a PostgreSQL database. It enables executing SQL queries, explaining statements, creating tables, and listing tables via the MCP protocol.

How to use PostgreSQL MCP Server?

Clone the repository, install dependencies with go mod download, and build with go build -o pgsql-mcp-server. Configure database connection via environment variables in a .env file (e.g., DB_HOST, DB_PORT, DB_NAME, DB_USER, DB_PASSWORD, DB_SSLMODE, SERVER_MODE). Run the server with ./pgsql-mcp-server or configure it in your MCP client’s JSON settings.

Key features of PostgreSQL MCP Server

  • Interact with PostgreSQL databases through AI assistants.
  • Separate read and write operations for security (read_query, write_query).
  • Create tables and list existing tables (create_table, list_tables).
  • Analyze query execution plans (explain_query).
  • Supports multiple transport modes: stdio, SSE, and streamableHttp.
  • Environment-based configuration via .env file.

Use cases of PostgreSQL MCP Server

  • Let an AI assistant query and analyze PostgreSQL data.
  • Allow AI to create database tables based on user requests.
  • Enable AI to review query execution plans for optimization.
  • Manage database schemas through natural language prompts.

よくある質問

1

What dependencies are required?

Go 1.23 or later and a running PostgreSQL database server are required.

2

How do I configure the database connection?

Set environment variables in a `.env` file: `DB_HOST`, `DB_PORT`, `DB_NAME`, `DB_USER`, `DB_PASSWORD`, `DB_SSLMODE`, and optionally `SERVER_MODE`. These can also be passed directly in the MCP client’s configuration JSON.

3

What transport modes does the server support?

Three modes are supported: `stdio` (default), `sse` (Server-Sent Events over HTTP), and `streamableHttp`. Select the mode by setting the `SERVER_MODE` environment variable.

4

How are read and write operations separated?

The server exposes distinct tools: `read_query` for SELECT queries, `write_query` for INSERT/UPDATE/DELETE, and `create_table` for CREATE TABLE statements. This allows clients to authorize each operation type separately.

5

Is there a Docker deployment guide?

Yes, the README includes a detailed Docker deployment guide with steps to create a shared network, start a PostgreSQL container, and build/run the application container using the provided `Makefile`.

コメント

「データベース」の他のコンテンツ