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 。
これは進行中の作業であり、まだ実稼働環境での使用には適さない可能性があることにご注意ください。
Related MCP server: MCP Server for PostgreSQL
インストール
最新リリースを入手し、
$PATHまたは簡単にアクセスできる場所に配置します。または、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フラグを追加すると、読み取り専用モードが有効になります。このモードでは、list、read_、desc_で始まるツールのみが使用可能です。このフラグを追加した後は、MCPサーバーを更新/再起動してください。デフォルトでは、CRUDクエリは最初に
EXPLAIN ?ステートメントで実行され、生成されたクエリプランが想定されるパターンと一致するかどうかが確認されます。この動作を無効にするには--with-explain-checkフラグを追加してください。
ツール
多言語サポート: すべてのツールの説明は、langパラメータに基づいて自動的にローカライズされます。
独自の言語サポートを追加したい場合は、[locales](i18n用)フォルダを参照してください。コマンドラインで使用する場合は、新しいlocales/xxx/active-xx.tomlファイルを作成する必要があります。
スキーマツール
list_database${mcp.tool.list_database.desc}
パラメータ: なし
戻り値: 一致するデータベース名のリスト。
list_table${mcp.tool.list_table.desc}
パラメータ:
name: 指定されている場合は、指定された名前のテーブルを一覧表示します。指定されていない場合は、すべてのテーブルを一覧表示します。
戻り値: 一致するテーブル名のリスト。
create_table${mcp.tool.create_table.desc}
パラメータ:
query: テーブルを作成するための SQL クエリ。
戻り値: 影響を受ける x 行。
alter_tablePostgresサーバーの既存のテーブルを変更します。LLMには、既存のテーブルまたは列を削除しないように指示されます。
パラメータ:
query: テーブルを変更するための SQL クエリ。
戻り値: 影響を受ける x 行。
desc_tableテーブルの構造について説明します。
パラメータ:
name: 説明するテーブルの名前。
戻り値: テーブルの構造。
データツール
read_query読み取り専用の SQL クエリを実行します。
パラメータ:
query: 実行する SQL クエリ。
戻り値: クエリの結果。
write_query書き込み SQL クエリを実行します。
パラメータ:
query: 実行する SQL クエリ。
戻り値: 影響を受けた行数 x、最後の挿入 ID: <last_insert_id>。
update_query更新 SQL クエリを実行します。
パラメータ:
query: 実行する SQL クエリ。
戻り値: 影響を受ける x 行。
delete_query削除 SQL クエリを実行します。
パラメータ:
query: 実行する SQL クエリ。
戻り値: 影響を受ける x 行。
count_query特定のテーブル内の行数を照会します。
パラメータ:
name: カウントするテーブルの名前。
戻り値: テーブルの行番号。
https://github.com/Zhwt/go-mcp-mysql/に改めて感謝します。
ライセンス
マサチューセッツ工科大学
This server cannot be installed
Maintenance
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
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that enables performing PostgreSQL database operations (create, read, update, delete) on User and Post entities through MCP tools.539MIT
- FlicenseNot gradedqualityDmaintenanceA 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.
- AlicenseNot gradedqualityDmaintenanceAn 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.13MIT
- FlicenseNot gradedqualityDmaintenanceA standardized Model Context Protocol server for interacting with PostgreSQL databases, enabling full CRUD operations, schema management, and database introspection.1
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.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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