GaussDB-MCP
Provides tools for interacting with Huawei GaussDB databases, enabling SQL queries, data manipulation, schema and table management, transaction handling, and metadata retrieval.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@GaussDB-MCP list all tables in the public schema"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
GaussDB MCP
Huawei Cloud GaussDB cloud database MCP server. Built on Huawei's official GaussDB dedicated Node.js driver gaussdb-node, following the MCP 2026-07-28 specification, providing 24 tools and 1 table structure resource covering connection testing, querying, data writing, transactions, metadata, diagnostics and operations, user permissions, etc.
Quick Start
npm install
cp .env.example .env # Windows: copy .env.example .env 后编辑
# 编辑 .env,填入 GaussDB 实例地址、密码等
npm run build
node build/index.js # 启动(stdio,供 MCP 客户端拉起)Requires Node.js ≥ 20.
Related MCP server: mcp-database
Connection Configuration
All Environment Variables
Variable | Required | Default | Description |
| Yes | — | GaussDB instance address; for primary/standby multi-node, separate with English commas (e.g. |
| No |
| Database port; Huawei Cloud GaussDB cloud instances default to 8000 |
| No |
| Database name |
| No |
| Login user; default administrator is root |
| Yes | — | Login password |
| No | — | Default schema, corresponding to JDBC's |
| No |
| For primary/standby multi-node, connect only to the primary node (corresponds to JDBC |
| No |
| Set to |
| No | — | CA root certificate path (download |
| No | — | Client certificate path (only needed for mutual authentication) |
| No | — | Client private key path (only needed for mutual authentication) |
| No |
| Whether to verify the server certificate; can be set to |
Intranet Connection Configuration
Used when the application and the GaussDB instance are in the same VPC. SSL is not required (intranet traffic does not leak externally; Huawei Cloud officially defaults to direct intranet connection):
GAUSSDB_HOST=10.0.1.11 # 实例"节点列表"中的内网地址
GAUSSDB_PORT=8000
GAUSSDB_DATABASE=postgres
GAUSSDB_USER=root
GAUSSDB_PASSWORD=你的密码
# 不设置任何 GAUSSDB_SSL_* 变量,保持 GAUSSDB_SSL=0(默认)Public Network Connection Configuration
Used when the application is not in the instance's VPC and accesses it via an elastic public IP. SSL must be enabled and a CA certificate configured (Huawei Cloud official sslmode=verify-ca approach):
GAUSSDB_HOST=114.114.114.114 # 实例绑定的弹性公网 IP
GAUSSDB_PORT=8000
GAUSSDB_DATABASE=postgres
GAUSSDB_USER=root
GAUSSDB_PASSWORD=你的密码
GAUSSDB_SSL=1
GAUSSDB_SSL_CA=C:/path/to/root.crt # 华为云控制台下载的 CA 证书(公网连接必需)
GAUSSDB_SSL_REJECT_UNAUTHORIZED=trueBefore public network connection, you also need to allow the client's egress IP access to port 8000 in the Huawei Cloud console security group.
How to Add Environment Variables
Two methods, choose either one (when both exist, environment variables take precedence over .env):
Project
.envfile (recommended): Copy.env.exampleto.envin the project root directory and fill it in. The.envlocation is anchored to the project root directory, independent of which directory the server is started from — the MCP client can read it when launchingbuild/index.jsfrom any working directory. Write either of the two configurations above directly into.env.MCP client
envfield: Pass environment variables directly in themcpServersconfiguration (see integration examples below), suitable for scenarios where you don't want to put credential files in the project.
For primary/standby deployments, separate multiple node IPs in GAUSSDB_HOST with English commas. The server tries connecting to each in sequence at startup and automatically selects the first available node.
Tool Overview (24 tools)
All tools are annotated with annotations (readOnlyHint/destructiveHint) per the MCP specification, allowing clients to prompt for confirmation on write operations.
Connection and Status
Tool | Description |
| Test connection, returns GaussDB version, current database, current user |
Query and Write
Tool | Description |
| Execute read-only queries (starting with SELECT/WITH/EXPLAIN/SHOW/VALUES, single statement; write statements and multi-statements are rejected), truncated by limit (default 100)/offset, optional |
| Execute arbitrary SQL (DDL/DML), returns affected row count, optional |
| Parameterized batch insert (table name + row array, optional schema) |
| Parameterized update (set + where, where is required to prevent accidental full-table updates, optional schema) |
| Parameterized delete (where is required to prevent accidental full-table deletes, optional schema, destructive annotation) |
Transactions (explicit handle mode)
Tool | Description |
| Begin a transaction, returns |
| Commit the transaction |
| Roll back the transaction |
Usage: transaction_begin → multiple query/execute (passing the same tx_handle) → transaction_commit or transaction_rollback.
Metadata (read-only)
Tool | Description |
| Database / schema / table lists |
| Column definitions: type, length, nullable, default, primary key |
| Index / view / sequence lists |
Diagnostics and Operations (read-only)
Tool | Description |
| Execution plan; with |
| Current active sessions |
| Lock conflicts (blocked party and blocking source) |
| Version, database size, connection count, server address and time |
Users and Permissions
Tool | Description |
| User list (read-only) |
| Create a login-enabled user |
| Grant / revoke (e.g. |
Resources
Resource URI | Description |
| Read table structure as JSON |
MCP Client Integration
After building, register in the client configuration file (using Claude Desktop / Cursor's mcpServers format as an example). Windows uses double backslash paths (E:\\MCP\\GaussDBMCP\\build\\index.js), Linux/macOS uses forward slashes (/home/user/GaussDBMCP/build/index.js).
Intranet Connection Integration
{
"mcpServers": {
"gaussdb": {
"command": "node",
"args": ["E:\\MCP\\GaussDBMCP\\build\\index.js"],
"env": {
"GAUSSDB_HOST": "10.0.1.11",
"GAUSSDB_PORT": "8000",
"GAUSSDB_DATABASE": "postgres",
"GAUSSDB_USER": "root",
"GAUSSDB_PASSWORD": "你的密码"
}
}
}
}Intranet connection does not require SSL; simply do not set any GAUSSDB_SSL_* variables.
Public Network Connection Integration
{
"mcpServers": {
"gaussdb": {
"command": "node",
"args": ["E:\\MCP\\GaussDBMCP\\build\\index.js"],
"env": {
"GAUSSDB_HOST": "114.114.114.114",
"GAUSSDB_PORT": "8000",
"GAUSSDB_DATABASE": "postgres",
"GAUSSDB_USER": "root",
"GAUSSDB_PASSWORD": "你的密码",
"GAUSSDB_SSL": "1",
"GAUSSDB_SSL_CA": "C:\\path\\to\\root.crt",
"GAUSSDB_SSL_REJECT_UNAUTHORIZED": "true"
}
}
}
}Public network connection must enable SSL and configure a CA certificate, and ensure the security group allows the client's egress IP access to port 8000.
You can also omit env and rely on the .env file in the project root directory (automatically read at server startup, anchored to the project root, independent of the startup directory).
Multi-Tenant Isolation (stream = schema)
GAUSSDB_SEARCH_PATH also serves as the MCP-layer schema whitelist: once configured, access is restricted to the corresponding stream's own schema, and tables of other streams cannot be seen.
MCP-layer interception (reliable, based on structural parameters):
list_schemasonly returns schemas in the whitelist, not leaking other schema nameslist_tables/list_indexes/list_views/list_sequencesdefault to pinning to the first whitelisted schema when no schema is passed, no longer returning all database tablesdescribe_table/insert_rows/update_rows/delete_rowswith an explicitschemaparameter will directly error and reject if it is not in the whitelistThe table structure resource
gaussdb://{schema}/{table}/schemais also subject to the whitelist; cross-schema reads are rejected
Database permission-layer fallback (required, cannot be omitted): execute accepts arbitrary SQL, and the MCP layer does not parse SQL (a hand-written parser will always have bypass paths); although query enforces read-only (first-keyword whitelist + write-keyword blacklist + rejection of multi-statements), side-effect functions in SELECT form (such as pg_terminate_backend, setval) cannot be exhaustively intercepted. Cross-schema access and side-effect functions are guaranteed by GaussDB permissions. Each stream uses an independent restricted account, authorized only for its own schema:
-- 以管理员执行:为 stream 建受限账号,只授予自己 schema 的权限
CREATE USER gycwd_app WITH PASSWORD 'xxx' LOGIN;
REVOKE ALL ON DATABASE postgres FROM PUBLIC; -- 收紧库级默认权限
GRANT CONNECT ON DATABASE postgres TO gycwd_app;
GRANT USAGE ON SCHEMA gycwd TO gycwd_app; -- 只给自己的 schema
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA gycwd TO gycwd_app;
-- 该账号未授予其他 schema 的 USAGE,即使手写跨 schema SQL 也会被数据库拒绝Then in .env set GAUSSDB_USER=gycwd_app, GAUSSDB_SEARCH_PATH=gycwd, with two layers combined: structural entry points intercepted by MCP, arbitrary SQL intercepted by the database.
Security Notes
stdio server logs are all written to stderr; stdout only carries MCP messages
Identifiers such as table names/column names/user names in structured tools (insert_rows/update_rows/delete_rows, etc.) are all character-validated, and values always use parameterized placeholders to prevent SQL injection;
query/explain_queryare free-form SQL entry points, narrowed down by read-only validation and single-statement restrictions (see above)delete_rows/update_rowsenforce a where conditionexplain_querywith analyze=true actually executes the statement, only allowing statements starting with SELECT/WITH and automatically wrapping in a transaction rollback (sequence advancement and function side effects are not rollback-able)Statements such as
DROP/TRUNCATEcan be executed viaexecute; clients should rely on the destructiveHint annotation for confirmationDo not commit
.envto version control
Development and Build
npm run build # tsc 编译到 build/Source structure: src/config.ts (configuration), src/db.ts (connection pool and transaction handles), src/sql.ts (SQL construction and read-only validation), src/format.ts (result formatting), src/index.ts (MCP server and tool registration).
Once you have a real GaussDB instance: fill in .env → npm run build → node build/index.js and test with any MCP client; or first verify the connection separately: configure env and run the test_connection tool.
Available Tools
24 toolscreate_userB
创建可登录的数据库用户
Inputs: password (required), username (required).
database_statsARead-only
查看数据库统计:版本、大小、连接数、当前用户、服务器地址与时间
Inputs: no named parameters.
delete_rowsADestructiveIdempotent
参数化删除:指定表名与 WHERE(列→值,AND 连接,必填防全表误删除),可选 schema
Inputs: table (required), where (required), schema.
describe_tableARead-only
查看表结构:列名、数据类型、长度、可空、默认值、是否主键
Inputs: table (required), schema.
executeBDestructiveIdempotent
执行任意 SQL(INSERT/UPDATE/DELETE/DDL 等),返回受影响行数。可选 tx_handle 在事务内执行。危险操作(DROP/TRUNCATE/DELETE)请谨慎
Inputs: sql (required), tx_handle.
explain_queryARead-only
查看 SQL 执行计划。analyze=true 时真实执行并统计耗时(自动包裹事务回滚,写语句不落盘)
Inputs: sql (required), analyze.
grant_privilegeB
授予权限。privilege 示例:SELECT ON TABLE t、ALL PRIVILEGES ON DATABASE d、USAGE ON SCHEMA s
Inputs: grantee (required), privilege (required).
insert_rowsA
参数化批量插入:指定表名与行数组(对象数组,键为列名),可选 schema(缺省 public)
Inputs: rows (required), table (required), schema.
list_databasesARead-only
列出 GaussDB 实例中所有可连接的数据库及大小
Inputs: no named parameters.
list_indexesARead-only
列出索引及所属表,可选按 schema 过滤
Inputs: schema.
list_lock_conflictsARead-only
查看当前锁冲突:被阻塞会话与阻塞来源
Inputs: no named parameters.
list_schemasARead-only
列出当前数据库的所有 schema(排除系统 schema);配置白名单后仅列出允许的 schema
Inputs: no named parameters.
list_sequencesBRead-only
列出序列,可选按 schema 过滤
Inputs: schema.
list_sessionsBRead-only
查看当前活跃会话(pg_stat_activity)
Inputs: no named parameters.
list_tablesARead-only
列出当前数据库的所有表及大小,可选按 schema 过滤
Inputs: schema.
list_usersARead-only
列出数据库用户及属性
Inputs: no named parameters.
list_viewsARead-only
列出视图,可选按 schema 过滤
Inputs: schema.
queryARead-only
在 GaussDB 上执行只读查询(SELECT/WITH/EXPLAIN/SHOW/VALUES 开头,单语句,写语句会被拒绝)并返回结果行。支持 limit/offset 截断返回(不修改 SQL 本身),可选 tx_handle 在事务内执行
Inputs: sql (required), limit, offset, tx_handle. Returns: rows, rowCount, truncated
revoke_privilegeCDestructiveIdempotent
回收权限。privilege 格式同 grant_privilege
Inputs: grantee (required), privilege (required).
test_connectionARead-only
测试 GaussDB 连接,返回数据库版本、当前库、当前用户与服务器时间
Inputs: no named parameters.
transaction_beginA
开启 GaussDB 事务,返回事务句柄 tx_handle。后续 query/execute/写入工具可传入该句柄在同一事务内执行。空闲 5 分钟自动回滚回收
Inputs: no named parameters.
transaction_commitA
提交事务。需提供 transaction_begin 返回的句柄
Inputs: tx_handle (required).
transaction_rollbackBDestructiveIdempotent
回滚事务。需提供 transaction_begin 返回的句柄
Inputs: tx_handle (required).
update_rowsA
参数化更新:指定表名、SET(列→新值)与 WHERE(列→值,AND 连接,必填防全表误更新),可选 schema
Inputs: set (required), table (required), where (required), schema.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 24 tools
大部分工具以资源类型清晰区分,list_*、query/execute、insert/update/delete_rows、事务三件套等边界明确。但 test_connection 与 database_stats 在返回版本、当前用户、时间等信息上存在重叠,可能造成轻微混淆。
整体采用蛇形命名,且以动词开头为主,如 list_tables、create_user、grant_privilege、delete_rows。但 database_stats、query、execute、transaction_begin 等少量工具偏离 verb_noun 模式,存在轻微不一致。
24 个工具落在 16-25 的偏重区间,虽然每个工具都有明确用途,但元数据浏览、写操作、事务控制、权限管理等维度拆分较细,整体数量感觉偏多,仍有合并空间。
覆盖了查询、写入、批量操作、事务、权限、元数据与监控,核心数据库操作较为完整。但用户管理仅有 create_user 而无 alter/drop_user,表级 DDL 也主要依赖通用 execute,存在可通过 execute 弥补的轻微生命周期缺口。
Maintenance
Related MCP Connectors
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Hosted SQL Server MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Hosted PostgreSQL MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Hosted MySQL MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Related MCP Servers
- AlicenseNot gradedqualityNot gradedmaintenanceMCP server for connecting to databases (PostgreSQL, MySQL, SQL Server, Redis) enabling SQL queries, table exploration, and Redis key-value operations.1MIT
- AlicenseNot gradedqualityCmaintenanceMCP server for multiple databases (PostgreSQL, MySQL, MariaDB, SQLite, MongoDB, Redis) with tools for schema inspection, querying, performance diagnostics, and safe write operations, featuring access modes, PII masking, and audit logging.Apache 2.0
- AlicenseAqualityCmaintenanceA comprehensive PostgreSQL MCP server providing 27 tools for database management and administration, including connection management, query execution, schema introspection, CRUD operations, and server monitoring.2738 npmAGPL 3.0
- AlicenseAqualityCmaintenanceA multi-database MCP server that supports MySQL, GaussDB, Oracle, and DM8, providing a unified interface for executing queries, data manipulation, and schema inspection via natural language.51MIT