Skip to main content
Glama
mengqi1436

GaussDB-MCP

by mengqi1436

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-db-assistant

Connection Configuration

All Environment Variables

Variable

Required

Default

Description

GAUSSDB_HOST

Yes

GaussDB instance address; for primary/standby multi-node, separate with English commas (e.g. 10.0.0.1,10.0.0.2)

GAUSSDB_PORT

No

8000

Database port; Huawei Cloud GaussDB cloud instances default to 8000

GAUSSDB_DATABASE

No

postgres

Database name

GAUSSDB_USER

No

root

Login user; default administrator is root

GAUSSDB_PASSWORD

Yes

Login password

GAUSSDB_SEARCH_PATH

No

Default schema, corresponding to JDBC's currentSchema (delivered via connection options as the search_path GUC, e.g. gycwd)

GAUSSDB_MASTER_ONLY

No

0

For primary/standby multi-node, connect only to the primary node (corresponds to JDBC targetServerType=master, determined by pg_is_in_recovery())

GAUSSDB_SSL

No

0

Set to 1 to enable SSL encrypted connection

GAUSSDB_SSL_CA

No

CA root certificate path (download root.crt from Huawei Cloud console)

GAUSSDB_SSL_CERT

No

Client certificate path (only needed for mutual authentication)

GAUSSDB_SSL_KEY

No

Client private key path (only needed for mutual authentication)

GAUSSDB_SSL_REJECT_UNAUTHORIZED

No

true

Whether to verify the server certificate; can be set to false for debugging (insecure, testing only)

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=true

Before 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):

  1. Project .env file (recommended): Copy .env.example to .env in the project root directory and fill it in. The .env location is anchored to the project root directory, independent of which directory the server is started from — the MCP client can read it when launching build/index.js from any working directory. Write either of the two configurations above directly into .env.

  2. MCP client env field: Pass environment variables directly in the mcpServers configuration (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

Test connection, returns GaussDB version, current database, current user

Query and Write

Tool

Description

query

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 tx_handle

execute

Execute arbitrary SQL (DDL/DML), returns affected row count, optional tx_handle

insert_rows

Parameterized batch insert (table name + row array, optional schema)

update_rows

Parameterized update (set + where, where is required to prevent accidental full-table updates, optional schema)

delete_rows

Parameterized delete (where is required to prevent accidental full-table deletes, optional schema, destructive annotation)

Transactions (explicit handle mode)

Tool

Description

transaction_begin

Begin a transaction, returns tx_handle (auto-rollback and reclamation after 5 minutes idle)

transaction_commit

Commit the transaction

transaction_rollback

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

list_databases / list_schemas / list_tables

Database / schema / table lists

describe_table

Column definitions: type, length, nullable, default, primary key

list_indexes / list_views / list_sequences

Index / view / sequence lists

Diagnostics and Operations (read-only)

Tool

Description

explain_query

Execution plan; with analyze=true actually executes and collects statistics (auto transaction rollback, write statements not persisted); rejects multi-statements containing semicolons

list_sessions

Current active sessions

list_lock_conflicts

Lock conflicts (blocked party and blocking source)

database_stats

Version, database size, connection count, server address and time

Users and Permissions

Tool

Description

list_users

User list (read-only)

create_user

Create a login-enabled user

grant_privilege / revoke_privilege

Grant / revoke (e.g. ALL ON DATABASE d)

Resources

Resource URI

Description

gaussdb://{schema}/{table}/schema

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_schemas only returns schemas in the whitelist, not leaking other schema names

  • list_tables/list_indexes/list_views/list_sequences default to pinning to the first whitelisted schema when no schema is passed, no longer returning all database tables

  • describe_table/insert_rows/update_rows/delete_rows with an explicit schema parameter will directly error and reject if it is not in the whitelist

  • The table structure resource gaussdb://{schema}/{table}/schema is 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_query are free-form SQL entry points, narrowed down by read-only validation and single-statement restrictions (see above)

  • delete_rows/update_rows enforce a where condition

  • explain_query with 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/TRUNCATE can be executed via execute; clients should rely on the destructiveHint annotation for confirmation

  • Do not commit .env to 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 .envnpm run buildnode build/index.js and test with any MCP client; or first verify the connection separately: configure env and run the test_connection tool.

Install Server
F
license - not found
A
quality
B
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
    MCP server for connecting to databases (PostgreSQL, MySQL, SQL Server, Redis) enabling SQL queries, table exploration, and Redis key-value operations.
    1
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    A database operation server based on the MCP protocol, providing database connection, querying, schema exploration, data analysis, and SQL generation tools.
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    MCP 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
  • A
    license
    A
    quality
    C
    maintenance
    A comprehensive PostgreSQL MCP server providing 27 tools for database management and administration, including connection management, query execution, schema introspection, CRUD operations, and server monitoring.
    27
    38
    AGPL 3.0

View all related MCP servers

Related MCP Connectors

  • MCP server for managing Prisma Postgres.

  • GibsonAI MCP server: manage your databases with natural language

  • MCP server for interacting with the Supabase platform

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/mengqi1436/GaussDB-MCP'

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