Skip to main content
Glama

go-mcp-postgres

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

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

インストール

  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@host/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/に改めて感謝します。

ライセンス

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

-
security - not tested
A
license - permissive license
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

go-mcp-postgres とは何ですか? go-mcp-postgres は、Postgres データベースと対話するために設計された Model Context Protocol (MCP) サーバーであり、Node.js または Python 環境を必要とせずに簡単な CRUD 操作と自動化を可能にします。

  1. 概要
    1. インストール
      1. 使用法
        1. 方法A: stdioモードのコマンドライン引数を使用する
        2. 方法B: SSEモードのコマンドライン引数を使用する
        3. オプションフラグ
      2. ツール
        1. スキーマツール
        2. データツール
      3. ライセンス

        Related MCP Servers

        • A
          security
          A
          license
          A
          quality
          A beginner-friendly Model Context Protocol (MCP) server that helps users understand MCP concepts, provides interactive examples, and lists available MCP servers. This server is designed to be a helpful companion for developers working with MCP. Also comes with a huge list of servers you can install.
          Last updated -
          3
          9
          36
          JavaScript
          Apache 2.0
        • -
          security
          F
          license
          -
          quality
          A server implementing the Model Context Protocol (MCP) for Cursor that allows using a PostgreSQL database as storage for model contexts, enabling secure database exploration and querying.
          Last updated -
          JavaScript
          • Linux
          • Apple
        • A
          security
          A
          license
          A
          quality
          A dynamic service that creates and manages Model Context Protocol (MCP) servers, allowing users to spawn, customize, and control multiple MCP servers as child processes.
          Last updated -
          5
          65
          TypeScript
          MIT License
          • Apple
          • Linux
        • -
          security
          F
          license
          -
          quality
          A Model Context Protocol server that enables performing PostgreSQL database operations (create, read, update, delete) on User and Post entities through MCP tools.
          Last updated -
          TypeScript

        View all related MCP servers

        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