
Multigres
io.github.JoongHyuk-Shin由 GitHub 帳號 JoongHyuk-Shin 發布v0.1.2更新於 Nov 7, 2026
Postgres diagnostics and cluster operations for Multigres clusters.
概覽
針對 Multigres Postgres 叢集的 MCP 伺服器,讓助理檢視結構物件、執行唯讀 SQL、取得查詢計畫與索引建議,並檢查叢集健康與備份。
- 可以做什麼
- 檢視結構、資料表、檢視表、序列與擴充套件,並讀取其欄位、限制與索引
- 執行單一唯讀語句、解釋查詢(可選 ANALYZE 或假設索引),列出最慢或成本最高的查詢
- 針對整體工作負載或最多 10 條指定查詢提供索引建議,不會建立任何物件
- 執行健康檢查,涵蓋膨脹、vacuum、鎖定、活動、等待、慢查詢、缺少索引、快取、日誌、複寫與限制
- 設定管理位址後:讀取叢集狀態、列出並驗證備份、查看備份工作狀態、讀取節點的 Postgres 日誌
- 非受限模式下:執行寫入 SQL、切換分片主節點、建立或到期備份、開關 Postgres 自動重新啟動
- 適用情境
- 當你使用 Multigres 叢集,希望助理診斷慢查詢、評估索引機會或檢查叢集與備份狀態,而不必手寫 SQL 與管理呼叫時適用。預設為唯讀,適合在刻意啟用寫入工具前進行探索性分析。
- 執行需求
- 以 stdio 本機程序執行,可從 MCP Bundle 或隨附二進位檔安裝(Linux、macOS、Windows amd64)。需要 DATABASE_URI,即 Multigres 閘道的 Postgres 連線字串。叢集工具需要 MULTIGRES_ADMIN_URL,若 multiadmin 啟用驗證還需 MULTIGRES_ADMIN_TOKEN。選用:MULTIGRES_MCP_ACCESS_MODE、MULTIGRES_MCP_SQL_TIMEOUT、MULTIGRES_NODE_HOST_MAP。需能連線至閘道與 multiadmin。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Multigres,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
multigres-mcp
An MCP server for Multigres clusters. It gives an MCP client two groups of tools:
- Postgres diagnostics through the Multigres gateway: schemas and objects, read-only SQL, query plans with hypothetical indexes, top queries, index advice and a health check. These follow the tools of postgres-mcp.
- Cluster tools through multiadmin: cluster status, backups, node logs, and in the unrestricted mode switching the primary and starting or expiring backups.
The server is read-only by default. Write tools are registered only in the unrestricted mode.
It has been tested against a local Multigres Docker cluster built from commit 49e7a2f7d4fe (2026-11-02, PostgreSQL 17.7, two cells) on Linux with Docker Engine. Other setups have not been tested.
Install
Each release has a multigres-mcp-<version>.mcpb file. It is an MCP Bundle: clients that install bundles ask for the settings under "Configuration" and run the server. It is also a zip file whose server/ directory holds binaries for Linux and macOS on amd64 and arm64 and for Windows on amd64, which any other client can run directly.
Build
Requires Go 1.26 or later.
The server talks MCP over standard input and output. ./multigres-mcp --help prints the options.
packaging/build-mcpb.sh builds the release bundle into dist/. It also needs jq, Node.js and openssl.
Configuration
Every option can be given as a flag or as an environment variable. A flag wins over the variable.
Direct node connections reuse the user, password and database of --database-url and take the host and port from multiadmin.
In the local Docker cluster both nodes report the host localhost, while their Postgres ports are reachable only at the container's address. Find that address in the Multigres checkout with:
and pass it as --node-host-map localhost=<address>.
Adding it to an MCP client
With Claude Code, for the local Docker cluster (replace 172.18.0.2 with the address found above):
Other clients take the same command, arguments and environment in their server configuration, for example:
Tools
That is 14 tools in the restricted mode and 19 in the unrestricted mode, or 9 and 10 without --admin-url. diagnose and get_top_queries take an optional node to read one node directly instead of through the gateway, for example the old primary after a failover.
Safety
The restricted mode does not register any tool that can write. Writing SQL is a tool of its own, execute_write_sql, so a client permission given to execute_sql never covers a write, even after the server is restarted in the unrestricted mode.
Every statement that execute_sql, explain_query and analyze_query_indexes receive passes these checks. They do not rely on each other: checks 1, 3 and 4 each stop a write on their own.
- It is parsed with the Multigres parser. It must be exactly one statement, the top statement must be
SELECT,EXPLAINof aSELECT, orSHOW, and the tree must not contain data-changing statements,SELECT INTOor locking clauses. Functions must be on an allow list (the postgres-mcp list with functions that have side effects removed), and a schema-qualified function must be inpg_catalog. - It is sent with the extended query protocol, which carries one statement only.
- The read-only connection is opened with
default_transaction_read_only=on. - It runs in
BEGIN TRANSACTION READ ONLY, which is always rolled back. search_pathis pinned, and a statement that calls an unqualified function whose name also exists outsidepg_catalogis not sent.- A statement timeout is set.
This covers the statements the model sends and the functions they call directly. The bodies of objects already in the database (views, functions, operators, policies) are trusted and not checked. Against a production database, connect as a read-only role as well. cluster_status shows whether the connected user is a superuser.
Multigres hands pooled Postgres connections from one client to the next. Within the same transaction, the server removes the hypothetical indexes and session advisory locks a tool call may have left on its connection. If that cleanup fails, it ends its own Postgres session rather than hand the state on. execute_write_sql rejects transaction control, session-level SET and RESET, multigres.* settings, hypopg functions, and statements that leave session state behind (temporary objects, PREPARE, LISTEN, DECLARE ... WITH HOLD, LOAD, DISCARD, DO). Session settings (set_config(..., false)) and the random seed (setseed) changed inside the body of a function or trigger are not removed and can reach the next client of that connection; like the other object bodies, they are trusted.
Direct node connections run fixed queries only, never SQL from the model.
The multiadmin address (in full and as host:port), the admin token and the database password are removed from tool results and error messages. The removal replaces text, so a password that is a common word is masked wherever that word appears. A password equal to the user or database name is not masked, because results show those names; the server prints a warning when it starts.
Things to know
--sql-timeoutdefaults to 25s because the multipooler ends a transaction's connection when one statement runs past--connpool-user-reserved-inactivity-timeout(default 30s). To use a longer timeout, raise that pooler setting too.- The results of
execute_sqlandexecute_write_sqlend with a line naming the settings the server set for that call only (statement_timeout,lock_timeout, and for readssearch_path), and thestatement_timeoutits own session had before. The gateway enforcesstatement_timeoutitself without setting it on the node, so the node'spg_settingsshows 0 for it whileSHOWthrough the gateway answers with the gateway's value. - Cumulative statistics are kept per node. After a failover the new primary's statistics do not include what happened on the old primary. The tools that use statistics start with the period they cover; the
nodeoption ofdiagnoseandget_top_queriesreads another node. - Index sizes in the advice are hypopg estimates and ignore btree deduplication. On a column with many repeated values the estimate can be several times the real size (on 200,000 rows with 1,000 distinct values: 4,644,864 bytes estimated, 1,384,448 bytes real).
- The gateway truncates the query text it keeps to
--query-metrics-sql-max-bytes(default 4096) without a marker. Plans and index advice use thepg_stat_statementstext or the full statement you give. - Statement texts from
pg_stat_statementsare shown in full. One very long statement can fill the 50,000-character result:diagnosethen leaves out the rest of the slow query check and the checks after it, andget_top_queriesleaves out the gateway part. The result says it was cut. Askdiagnosefor the later checks by name, andget_top_queriesforsource: gateway. VACUUMandCREATE INDEX CONCURRENTLYcannot run in a transaction, soexecute_write_sqlcannot run them.- Calls to multiadmin time out after 30 seconds,
verify_backupsafter 10 minutes. - If
execute_write_sqlgets no reply to itsCOMMIT, it says it does not know whether the statement was committed. Check the data before sending it again.
Tests
runs the unit tests. The integration and end-to-end tests have the build tag cluster and need a local Multigres Docker cluster with pg_stat_statements preloaded and hypopg installed. They switch the primary, drop and recreate the two extensions, and end sessions, so do not point them at a cluster you care about. They fail rather than skip when the cluster cannot be reached.
Start the cluster from a Multigres checkout:
Wait until docker compose ps shows the container as healthy, then install hypopg and create both extensions:
Then, in this repository, with MULTIGRES_MCP_TEST_NODE_HOST set to the container address from the docker inspect command above:
-p 1 runs one package at a time, because the packages share the cluster's primary, extensions and connection pools. The tests use the gateway at localhost:15432, multiadmin at localhost:15000 and the node ports 25432 and 25433 of the Docker cluster; MULTIGRES_MCP_TEST_GATEWAY_URL and MULTIGRES_MCP_TEST_ADMIN_URL change the first two. test/facts-map.md maps the Multigres behaviour the design relies on to the test that checks it.
License
Apache License 2.0, see LICENSE. Parts adapted from postgres-mcp are under the MIT License, see THIRD_PARTY_NOTICES.md.
來源:README.md,提交 45fc7b1
工具
0版本歷史
3- v0.1.2最新Nov 7, 2026
- v0.1.1Nov 6, 2026
- v0.1.0Nov 5, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分