Skip to main content
Glama

go-mcp-postgres

概要

https://github.com/Zhwt/go-mcp-mysql/からコードをコピーし、AIの助けを借りて、データベースをmysqlからpostgresに変更しました。Postgresとのやり取りや自動化のための、負担ゼロですぐに使えるModel Context Protocol(MCP)サーバーです。Node.jsやPython環境は必要ありません。このサーバーは、MySQLデータベースとテーブルに対してCRUD操作を行うツールと、予期せぬ書き込み操作を防ぐ読み取り専用モードを提供します。また、--with-explain-checkフラグを追加することで、クエリ実行前にEXPLAINステートメントを使用してMCPサーバーにクエリプランをチェックさせること--with-explain-check

これは進行中の作業であり、まだ実稼働環境での使用には適さない可能性があることにご注意ください。

Related MCP server: MCP Server for PostgreSQL

インストール

  1. 最新リリースを入手し、 $PATHまたは簡単にアクセスできる場所に配置します。

  2. または、Go がインストールされている場合は、ソースからビルドできます。

go install -v github.com/guoling2008/go-mcp-postgres@latest

使用法

方法A: stdioモードのコマンドライン引数を使用する

{
  "mcpServers": {
    "postgres": {
      "command": "go-mcp-postgres",
      "args": [
        "--dsn",
        "postgresql://user:pass@host:port/db"
      ]
    }
  }
}

注意: バイナリを$PATHの外部に置く場合は、 go-mcp-postgresバイナリのフルパスに置き換える必要があります。たとえば、バイナリをダウンロードフォルダに置く場合は、次のパスを使用できます。

{
  "mcpServers": {
    "postgres": {
      "command": "C:\\Users\\<username>\\Downloads\\go-mcp-postgres.exe",
      "args": [
        ...
      ]
    }
  }
}

方法B: SSEモードのコマンドライン引数を使用する

./go-mcp-postgres --t sse --ip xxxx --port nnnn --dsn postgresql://user:pass@host:port/db --lang en

オプションフラグ

  • --lang : 言語オプション(en/zh-CN)を設定します。デフォルトはシステム言語です。

  • --read-onlyフラグを追加すると、読み取り専用モードが有効になります。このモードでは、 listread_desc_で始まるツールのみが使用可能です。このフラグを追加した後は、MCPサーバーを更新/再起動してください。

  • デフォルトでは、CRUDクエリは最初にEXPLAIN ?ステートメントで実行され、生成されたクエリプランが想定されるパターンと一致するかどうかが確認されます。この動作を無効にするには--with-explain-checkフラグを追加してください。

ツール

多言語サポート: すべてのツールの説明は、langパラメータに基づいて自動的にローカライズされます。

独自の言語サポートを追加したい場合は、[locales](i18n用)フォルダを参照してください。コマンドラインで使用する場合は、新しいlocales/xxx/active-xx.tomlファイルを作成する必要があります。

スキーマツール

  1. list_database

    • ${mcp.tool.list_database.desc}

    • パラメータ: なし

    • 戻り値: 一致するデータベース名のリスト。

  2. list_table

    • ${mcp.tool.list_table.desc}

    • パラメータ:

      • name : 指定されている場合は、指定された名前のテーブルを一覧表示します。指定されていない場合は、すべてのテーブルを一覧表示します。

    • 戻り値: 一致するテーブル名のリスト。

  3. create_table

    • ${mcp.tool.create_table.desc}

    • パラメータ:

      • query : テーブルを作成するための SQL クエリ。

    • 戻り値: 影響を受ける x 行。

  4. alter_table

    • Postgresサーバーの既存のテーブルを変更します。LLMには、既存のテーブルまたは列を削除しないように指示されます。

    • パラメータ:

      • query : テーブルを変更するための SQL クエリ。

    • 戻り値: 影響を受ける x 行。

  5. desc_table

    • テーブルの構造について説明します。

    • パラメータ:

      • name : 説明するテーブルの名前。

    • 戻り値: テーブルの構造。

データツール

  1. read_query

    • 読み取り専用の SQL クエリを実行します。

    • パラメータ:

      • query : 実行する SQL クエリ。

    • 戻り値: クエリの結果。

  2. write_query

    • 書き込み SQL クエリを実行します。

    • パラメータ:

      • query : 実行する SQL クエリ。

    • 戻り値: 影響を受けた行数 x、最後の挿入 ID: <last_insert_id>。

  3. update_query

    • 更新 SQL クエリを実行します。

    • パラメータ:

      • query : 実行する SQL クエリ。

    • 戻り値: 影響を受ける x 行。

  4. delete_query

    • 削除 SQL クエリを実行します。

    • パラメータ:

      • query : 実行する SQL クエリ。

    • 戻り値: 影響を受ける x 行。

  5. count_query

    • 特定のテーブル内の行数を照会します。

    • パラメータ:

      • name : カウントするテーブルの名前。

    • 戻り値: テーブルの行番号。

https://github.com/Zhwt/go-mcp-mysql/に改めて感謝します。

ライセンス

マサチューセッツ工科大学

A
license - permissive license
Not graded
quality - not tested
D
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    A Model Context Protocol server that enables performing PostgreSQL database operations (create, read, update, delete) on User and Post entities through MCP tools.
    539
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    A 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.
  • A
    license
    Not graded
    quality
    D
    maintenance
    An open-source MCP server for PostgreSQL schema introspection and guarded read-only queries. It enables MCP clients to discover schemas, tables, columns, indexes, relationships, and safe queryable data from a configured PostgreSQL database.
    13
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    A standardized Model Context Protocol server for interacting with PostgreSQL databases, enabling full CRUD operations, schema management, and database introspection.
    1

View all related MCP servers

Related MCP Connectors

  • MCP server for managing Prisma Postgres.

  • MCP server for interacting with the Supabase platform

  • Butterbase MCP server — manage your backend: schemas, auth, functions, storage, RAG, deploys.

View all MCP Connectors

Latest Blog Posts

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/guoling2008/go-mcp-postgres'

If you have feedback or need assistance with the MCP directory API, please join our Discord server