Skip to main content
Glama
NekoTarou

kingbase-mcp-server

by NekoTarou

KingBase MCP Server

License Build & Test npm version npm downloads Node.js Version MCP Badge

English | 中文

直连 KingBase(PostgreSQL 兼容)数据库的 MCP Server,让 AI 助手(Claude 等)能够直接查询和管理 KingBase 数据库。

快速使用

无需克隆代码,直接在 MCP 客户端中配置即可使用:

{
  "mcpServers": {
    "kingbase": {
      "command": "npx",
      "args": ["-y", "kingbase-mcp-server"],
      "env": {
        "DB_HOST": "localhost",
        "DB_PORT": "54321",
        "DB_USER": "system",
        "DB_PASSWORD": "your_password",
        "DB_NAME": "kingbase",
        "DB_SCHEMA": "public",
        "ACCESS_MODE": "readonly"
      }
    }
  }
}

也可以全局安装后使用:

npm install -g kingbase-mcp-server
kingbase-mcp-server

Related MCP server: Kingbase MCP Server

功能

Tool

说明

类型

kb_query

执行只读查询 (SELECT/WITH/SHOW)

只读

kb_execute

执行 DML (INSERT/UPDATE/DELETE)

读写

kb_execute_ddl

执行 DDL (CREATE/ALTER/DROP)

读写

kb_list_schemas

列出所有 schema

只读

kb_list_tables

列出表和视图

只读

kb_describe_table

查看表结构(列、类型、约束、注释)

只读

kb_list_indexes

查看索引信息

只读

kb_list_constraints

查看约束信息

只读

kb_explain

查看执行计划 (EXPLAIN)

只读

kb_table_data

预览表数据(带分页和过滤)

只读

kb_table_stats

查看表统计信息(大小、行数等)

只读

提示词 (Prompts)

Prompt

说明

kb_query_prompt

查询助手:描述需求,自动构造 SQL 查询

kb_schema_overview

Schema 概览:获取数据库结构的全面分析

资源 (Resources)

URI

说明

kingbase://config

当前数据库连接配置(不含密码等敏感信息)

kingbase://status

服务器运行状态(版本、连接状态、运行时间)

环境变量

变量

说明

默认值

DB_HOST

数据库主机

localhost

DB_PORT

数据库端口

54321

DB_USER

用户名

system

DB_PASSWORD

密码

(空)

DB_NAME

数据库名

kingbase

DB_SCHEMA

默认 schema

public

TRANSPORT

传输模式:stdiohttp

stdio

MCP_PORT

HTTP 模式监听端口

3000

MCP_HOST

HTTP 模式监听地址

0.0.0.0

ACCESS_MODE

权限模式(见下方说明)

readonly

SKIP_CONFIRM

跳过写操作确认(见下方说明)

false

权限模式

通过 ACCESS_MODE 环境变量控制数据库操作权限,分为 4 个递增级别:

级别

允许的操作

只读

readonly(默认)

SELECT 查询、查看 schema/表结构/索引/约束/统计/执行计划

允许修改

readwrite

只读 + INSERT / UPDATE

允许删除

full

读写 + DELETE

管理员

admin

完全权限 + DDL(CREATE / ALTER / DROP / TRUNCATE)

默认为 readonly(只读模式),防止误操作。根据实际需要调整。

安全确认机制

kb_execute(DML)和 kb_execute_ddl(DDL)工具使用 MCP Elicitation 机制进行用户确认:

  • 当工具被调用时,服务端通过 elicitation 在协议层面阻塞等待用户确认

  • 客户端会弹出确认对话框,用户必须明确点击确认/拒绝后操作才会继续

  • AI 助手无法绕过此确认流程,确保数据安全

⚠️ 客户端不支持 Elicitation 时:如果你的 MCP 客户端不支持 Elicitation(如旧版本客户端),写操作将默认拒绝执行并提示错误。如果你了解风险并希望跳过确认,可以设置环境变量 SKIP_CONFIRM=true

⚠️ 警告:设置 SKIP_CONFIRM=true 将跳过所有 DML/DDL 操作的用户确认,AI 助手将直接执行写操作,请自行承担风险!

配置示例

# 只读模式(默认,推荐用于日常查询)
ACCESS_MODE=readonly

# 允许增改(适用于数据维护)
ACCESS_MODE=readwrite

# 允许删除(适用于数据清理)
ACCESS_MODE=full

# 管理员模式(适用于 DDL 操作,如建表/改表)
ACCESS_MODE=admin

传输模式

stdio 模式(默认)

适用于本地使用,客户端直接启动 MCP Server 进程。

HTTP 模式

适用于远程部署,团队成员通过网络连接。使用 MCP Streamable HTTP 传输协议。

启动 HTTP 模式:

TRANSPORT='http' MCP_PORT='3000' DB_HOST='你的数据库地址' DB_PASSWORD='你的密码' node dist/index.js
# 或
npm run start:http

验证:

curl -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'

在 Claude Code 中使用

stdio 模式(推荐)

编辑 ~/.claude.json,在对应的空间下添加,或者在当前目录中创建.mcp.json文件,添加如下内容:

{
  "mcpServers": {
    "kingbase": {
      "command": "npx",
      "args": ["-y", "kingbase-mcp-server"],
      "env": {
        "DB_HOST": "你的数据库地址",
        "DB_PORT": "54321",
        "DB_USER": "system",
        "DB_PASSWORD": "你的密码",
        "DB_NAME": "数据库名",
        "DB_SCHEMA": "public",
        "ACCESS_MODE": "readonly"
      }
    }
  }
}

HTTP 模式(远程连接)

在服务器上启动 HTTP 模式后,客户端配置:

{
  "mcpServers": {
    "kingbase": {
      "url": "http://你的服务器地址:3000/mcp"
    }
  }
}

构建

npm install
npm run build

配置文件

项目支持 .env 配置文件,避免在 shell 中直接传入含特殊字符的密码导致解析失败

# 复制模板
cp .env.example .env

# 编辑配置(密码中的特殊字符无需转义)
vi .env

.env 文件示例:

DB_HOST=192.168.1.100
DB_PORT=54321
DB_USER=system
DB_PASSWORD=P@ss(w0rd)!#$
DB_NAME=mydb
DB_SCHEMA=public
TRANSPORT=http
MCP_PORT=3000
ACCESS_MODE=readonly

配置好后直接启动即可,无需在命令行传递环境变量:

node dist/index.js
# 或
npm start

.env 已在 .gitignore 中,不会被提交到仓库。命令行传入的环境变量优先级高于 .env 文件。

服务器部署(HTTP 模式)

1. 安装

# 方式一:npm 全局安装(推荐)
npm install -g kingbase-mcp-server

# 方式二:从源码安装
git clone https://github.com/NekoTarou/kingbase-mcp-server.git
cd kingbase-mcp-server
npm install
npm run build

2. 直接启动

TRANSPORT='http' \
MCP_PORT='3000' \
ACCESS_MODE='readonly' \
DB_HOST='192.168.1.100' \
DB_PORT='54321' \
DB_USER='system' \
DB_PASSWORD='your_password' \
DB_NAME='mydb' \
node dist/index.js

3. 使用 systemd 管理(推荐)

创建环境变量文件 /etc/kingbase-mcp-server.env

TRANSPORT=http
MCP_PORT=3000
MCP_HOST=0.0.0.0
ACCESS_MODE=readonly
DB_HOST=192.168.1.100
DB_PORT=54321
DB_USER=system
DB_PASSWORD=your_password
DB_NAME=mydb
DB_SCHEMA=public

创建服务文件 /etc/systemd/system/kingbase-mcp.service

[Unit]
Description=KingBase MCP Server
After=network.target

[Service]
Type=simple
EnvironmentFile=/etc/kingbase-mcp-server.env
WorkingDirectory=/opt/kingbase-mcp-server
ExecStart=/usr/bin/node dist/index.js
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

启动服务:

sudo systemctl daemon-reload
sudo systemctl enable kingbase-mcp
sudo systemctl start kingbase-mcp
sudo systemctl status kingbase-mcp   # 查看状态
sudo journalctl -u kingbase-mcp -f   # 查看日志

4. 验证

curl -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'

成功会返回 JSON 响应,response header 中包含 mcp-session-id

5. 安全提示

当前未内置认证机制。如果服务暴露在公网,建议:

  • 通过防火墙限制访问来源 IP

  • 在前面加 nginx 反向代理 + 基础认证

  • 后续可按需添加 OAuth 认证


English

MCP (Model Context Protocol) server for KingBase — a PostgreSQL-compatible enterprise database widely used in Chinese government and enterprise environments.

Quick Start

{
  "mcpServers": {
    "kingbase": {
      "command": "npx",
      "args": ["-y", "kingbase-mcp-server"],
      "env": {
        "DB_HOST": "localhost",
        "DB_PORT": "54321",
        "DB_USER": "system",
        "DB_PASSWORD": "your_password",
        "DB_NAME": "kingbase",
        "ACCESS_MODE": "readonly"
      }
    }
  }
}

Features

  • 11 database tools: query, DML, DDL, schema inspection, statistics

  • 2 prompts: query helper, schema overview

  • 2 resources: database config, server status

  • Two transport modes: stdio (local) and Streamable HTTP (remote)

  • Fine-grained access control: readonly / readwrite / full / admin

  • Secure confirmation for write operations via MCP Elicitation (with two-phase fallback)

  • Auto schema qualification for table names

  • Parameterized queries for safe value substitution

See above sections for detailed documentation (in Chinese).

License

MIT

Available Tools

11 tools
kb_describe_tableDescribe TableA
Read-onlyIdempotent

Get detailed structure of a table or view, including columns, types, constraints, and comments.

Args:

  • table (string): Table or view name

  • schema (string, optional): Schema name, defaults to DB_SCHEMA env or 'public'

Returns: Table structure with column names, data types, nullable, defaults, and comments.

ParametersJSON Schema
NameRequiredDescriptionDefault
tableYesTable or view name to describe
schemaNoSchema name (default: from DB_SCHEMA env or 'public')

TDQS

A4.1/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true, destructiveHint=false, and idempotentHint=true. The description adds no further behavioral context (e.g., permissions, performance implications) beyond stating that it returns structure information, thus adding some but limited value.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise with two clear sections (Args and Returns), no redundant words, and front-loaded with the main action. Every sentence contributes meaningful information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simple parameter set (2 params, 1 required) and the presence of annotations indicating safety, the description provides sufficient detail about the return structure (columns, types, etc.) and default schema behavior. No output schema needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, and the description essentially repeats the schema's parameter descriptions without adding new semantics such as format constraints or examples. Baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb ('Get detailed structure') and explicitly names the resource ('table or view'), clearly distinguishing it from sibling tools like kb_list_tables, kb_list_indexes, and kb_list_constraints, which serve different purposes.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The purpose of obtaining table structure is clear, but the description does not provide explicit guidance on when to use this tool over alternatives such as kb_table_stats or kb_explain. However, the sibling tool names and the context of schema exploration imply appropriate usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

kb_executeExecute DMLA
Destructive

Execute a DML statement (INSERT, UPDATE, DELETE) against the KingBase database.

Returns the number of affected rows. Use parameterized queries ($1, $2, ...) for safe value substitution.

🔑 Auto-schema feature: Unqualified table names (without schema prefix) are automatically qualified with the configured schema (DB_SCHEMA env var). You can optionally override this with the 'schema' parameter.

Args:

  • sql (string): The DML statement to execute

  • params (array, optional): Parameter values for $1, $2, ... placeholders

  • schema (string, optional): Override the default schema for auto-qualifying table names

Returns: Number of rows affected by the operation.

Examples:

  • sql: "UPDATE users SET status = $1 WHERE id = $2", params: ["inactive", 123]

  • sql: "INSERT INTO users (name, email) VALUES ($1, $2)", params: ["John", "john@example.com"]

  • sql: "DELETE FROM logs WHERE created_at < $1", params: ["2024-01-01"]

ParametersJSON Schema
NameRequiredDescriptionDefault
sqlYesDML statement (INSERT/UPDATE/DELETE) to execute
paramsNoOptional parameterized query values ($1, $2, ...)
schemaNoSchema name for tables without explicit schema prefix (default: from DB_SCHEMA env or 'public')

TDQS

A4.6/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already indicate destructiveHint=true. The description adds crucial details: returns number of affected rows, parameterized queries for safety, and the auto-schema qualification feature, all beyond what annotations provide.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Well-structured with sections, front-loaded purpose, and efficient use of brief bullet-like list for Args and Returns. No unnecessary words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Covers main purpose, parameters with examples, and return value. Though no output schema, the return type is explicitly stated. Could mention error handling, but adequate for a DML execution tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline 3. The description adds value by explaining the auto-schema behavior for the 'schema' parameter and providing real examples for params, enhancing understanding beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool executes DML statements (INSERT, UPDATE, DELETE) against the KingBase database, distinguishing it from query and DDL tools among siblings.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides clear context for when to use (DML operations) and includes examples. Could explicitly mention not to use for SELECT or DDL, but the sibling names imply the distinction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

kb_execute_ddlExecute DDLA
Destructive

Execute a DDL statement (CREATE, ALTER, DROP, TRUNCATE, etc.) against the KingBase database.

WARNING: DDL operations modify database structure and can be destructive. DROP and TRUNCATE operations are irreversible.

🔑 Auto-schema feature: Unqualified table names (without schema prefix) are automatically qualified with the configured schema (DB_SCHEMA env var). You can optionally override this with the 'schema' parameter.

Args:

  • sql (string): The DDL statement to execute

  • schema (string, optional): Override the default schema for auto-qualifying table names

Returns: Confirmation message. For dangerous operations (DROP/TRUNCATE/CASCADE), a warning is included.

Examples:

  • sql: "CREATE TABLE test (id SERIAL PRIMARY KEY, name VARCHAR(100))"

  • sql: "ALTER TABLE users ADD COLUMN phone VARCHAR(20)"

  • sql: "CREATE INDEX idx_users_email ON users(email)"

ParametersJSON Schema
NameRequiredDescriptionDefault
sqlYesDDL statement (CREATE/ALTER/DROP/TRUNCATE) to execute
schemaNoSchema name for tables without explicit schema prefix (default: from DB_SCHEMA env or 'public')

TDQS

A4.6/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description explicitly warns that DDL operations modify database structure and that DROP/TRUNCATE are irreversible. It also details the confirmation message and warnings for dangerous operations. This adds behavioral context beyond the destructiveHint annotation, which is already true.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with sections (warning, auto-schema, args, returns, examples) and front-loaded with the warning. It is slightly lengthy but each sentence adds value; no redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has no output schema, the description adequately states the return is a confirmation message with optional warnings for dangerous operations. It covers all key aspects: purpose, parameters, behavior, and examples, leaving no major gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the schema already documents parameters. The description adds meaning by explaining the auto-schema feature for unqualified table names and how the optional 'schema' parameter overrides the default. Examples further clarify usage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool executes DDL statements (CREATE, ALTER, DROP, TRUNCATE) against KingBase, using a specific verb and resource. It distinguishes from sibling tools, which include query, description, and other non-DDL operations, making the purpose unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides a warning about destructive operations and explains auto-schema qualification, but does not explicitly contrast with sibling tools like kb_execute or specify when not to use it. However, the warning and focus on DDL implicitly guide usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

kb_explainExplain QueryA
Idempotent

Get the execution plan for a SQL query using EXPLAIN.

Use this to analyze query performance, identify full table scans, and optimize queries.

Args:

  • sql (string): The SQL query to explain

  • analyze (boolean, default false): If true, actually executes the query (EXPLAIN ANALYZE) for real timing data

  • format ('text' | 'json' | 'yaml'): Output format (default: 'text')

Returns: Query execution plan showing scan types, costs, and join strategies.

Examples:

  • sql: "SELECT * FROM users WHERE email = 'test@example.com'"

  • sql: "SELECT u., o. FROM users u JOIN orders o ON u.id = o.user_id", analyze: true

ParametersJSON Schema
NameRequiredDescriptionDefault
sqlYesSQL query to explain
formatNoOutput format for the execution plantext
analyzeNoRun EXPLAIN ANALYZE (actually executes the query) for real timing data

TDQS

A4.6/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description notes that setting analyze=true actually executes the query, which is a critical behavioral detail beyond the annotations. Annotations indicate readOnlyHint=false and idempotentHint=true; the description clarifies the execution risk when analyze is true. Missing is any mention of locking or performance impact of ANALYZE.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise, well-structured with paragraphs and examples, and every sentence adds value. It fits within a few lines without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity and the lack of an output schema, the description adequately explains the return type ('execution plan showing scan types, costs, and join strategies'). No missing context for agent usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

All three parameters (sql, analyze, format) are fully described in the input schema, and the description adds examples and clarifies the effect of analyze and the format options. Schema coverage is 100%, and the description complements it well.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description explicitly states the tool's purpose: 'Get the execution plan for a SQL query using EXPLAIN.' This clearly distinguishes it from sibling tools like kb_query (which executes) and kb_execute (which runs DML).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description says 'Use this to analyze query performance, identify full table scans, and optimize queries,' providing clear context for when to use. It lacks explicit when-not-to-use guidance, but the context is sufficient given the sibling tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

kb_list_constraintsList ConstraintsA
Read-onlyIdempotent

List all constraints (PK, FK, UNIQUE, CHECK) on a table.

Args:

  • table (string): Table name

  • schema (string, optional): Schema name, defaults to DB_SCHEMA env or 'public'

Returns: List of constraints with name, type, columns, and referenced table (for FK).

ParametersJSON Schema
NameRequiredDescriptionDefault
tableYesTable name to list constraints for
schemaNoSchema name (default: from DB_SCHEMA env or 'public')

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations indicate read-only and idempotent behavior. The description adds return structure details (name, type, columns, referenced table for FK), providing transparency beyond annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences for purpose, then structured Args/Returns sections. Front-loaded and no unnecessary words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a read-only tool with no output schema, the description covers parameters and return structure adequately. Missing error handling but overall complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%. The description adds the default value for schema (from DB_SCHEMA env or 'public'), which is not in the schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'List all constraints (PK, FK, UNIQUE, CHECK) on a table.', specifying both the action and the resource. It distinguishes from siblings like kb_list_indexes by naming constraint types.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use this tool vs alternatives. The description implies usage for constraint listing but doesn't provide context or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

kb_list_indexesList IndexesA
Read-onlyIdempotent

List all indexes on a table including columns, uniqueness, and index type.

Args:

  • table (string): Table name

  • schema (string, optional): Schema name, defaults to DB_SCHEMA env or 'public'

Returns: List of indexes with name, columns, uniqueness, and method (btree/hash/gin/gist).

ParametersJSON Schema
NameRequiredDescriptionDefault
tableYesTable name to list indexes for
schemaNoSchema name (default: from DB_SCHEMA env or 'public')

TDQS

A4.1/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true, destructiveHint=false, and idempotentHint=true, indicating a safe read operation. The description adds useful context about default schema behavior and the specific fields returned, enhancing transparency beyond structured fields.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is succinct, using a clear docstring format with Args and Returns sections. Every sentence adds value, and the purpose is front-loaded in the first sentence. No redundant or irrelevant information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple read-only list tool, the description covers the input parameters, default behavior, and return structure comprehensively. Annotations confirm safety, and no output schema is needed since the return is self-explanatory. The tool is fully specified for agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% and the description repeats the same parameter descriptions verbatim, adding no new meaning beyond what the input schema provides. Baseline score of 3 is appropriate since the schema already documents both parameters adequately.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states 'List all indexes on a table including columns, uniqueness, and index type,' specifying the exact resource and returned attributes. Differentiates from siblings like kb_list_constraints and kb_describe_table by focusing on indexes.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Describes what the tool does but does not provide explicit guidance on when to use it versus alternatives such as kb_list_constraints or kb_describe_table. The description is adequate but lacks exclusion criteria or context for selection among ten sibling tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

kb_list_schemasList SchemasA
Read-onlyIdempotent

List all schemas in the KingBase database.

Returns schema names excluding internal PostgreSQL/KingBase system schemas.

Args: None

Returns: List of schema names with their owners.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A4.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true and destructiveHint=false, so safety is covered. The description adds behavioral detail: it excludes system schemas and returns schema names with owners. This goes beyond annotations by clarifying scope and return format.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise (2 sentences plus structured Args/Returns). Every sentence adds value: purpose, scope (excludes system schemas), and return content. No wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple read-only listing tool, the description is complete. It covers what the tool does, what it excludes, what it returns, and that it takes no arguments. Annotations cover safety, and no output schema is needed given the verbal description of return values.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has no parameters, and the input schema confirms this (100% coverage). The description explicitly states 'Args: None', which provides clarity. With 0 parameters, baseline is 4.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool lists all schemas in the KingBase database, distinguishing it from sibling tools focused on tables, queries, and execution. The verb 'List' and resource 'schemas' are specific and unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description mentions that it returns schema names excluding internal system schemas, which provides context on when to use it (to get clean user schema lists). However, it does not explicitly state when not to use it or suggest alternatives, though sibling tool names make the distinction clear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

kb_list_tablesList TablesA
Read-onlyIdempotent

List all tables and/or views in a schema.

Args:

  • schema (string, optional): Schema name, defaults to DB_SCHEMA env or 'public'

  • type ('table' | 'view' | 'all'): Filter by type (default: 'all')

Returns: List of tables/views with their type, owner, and estimated row count.

ParametersJSON Schema
NameRequiredDescriptionDefault
typeNoFilter by object type: 'table', 'view', or 'all' (default: 'all')all
schemaNoSchema name (default: from DB_SCHEMA env or 'public')

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already indicate idempotent, read-only, non-destructive behavior. The description adds information about the return format (type, owner, estimated row count) and default parameter values, which is beyond what annotations provide.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence followed by a structured list of arguments and returns. Every part is necessary, concise, and front-loaded with the core purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple list tool with full schema coverage and annotations, the description covers the key aspects: purpose, parameters, and return structure. It lacks details about edge cases (e.g., empty schema) but is otherwise complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3. The description adds value by specifying the default for 'schema' from DB_SCHEMA env or 'public', which is not in the schema definition, and clarifies the default for 'type'.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'List all tables and/or views in a schema', specifying a specific verb and resource. It distinguishes itself from sibling tools like kb_list_schemas (schemas) and kb_describe_table (single table details).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explains what it does and its parameters but does not explicitly tell when to use this over alternatives like kb_describe_table or kb_list_schemas. Usage is implied but not guided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

kb_queryExecute QueryA
Read-onlyIdempotent

Execute a read-only SQL query (SELECT/WITH/SHOW) against the KingBase database.

Returns query results as a formatted table. Use parameterized queries ($1, $2, ...) for safe value substitution.

Only read-only statements are allowed. For INSERT/UPDATE/DELETE use kb_execute; for DDL use kb_execute_ddl.

🔑 Auto-schema feature: Unqualified table names (without schema prefix) are automatically qualified with the configured schema (DB_SCHEMA env var). You can optionally override this with the 'schema' parameter.

Args:

  • sql (string): The SELECT query to execute

  • params (array, optional): Parameter values for $1, $2, ... placeholders

  • schema (string, optional): Override the default schema for auto-qualifying table names

Returns: Formatted table of query results with row count.

Examples:

  • sql: "SELECT * FROM biz_cm_attachment LIMIT 5" (auto-qualified with configured schema)

  • sql: "SELECT * FROM users WHERE status = $1", params: ["active"]

  • sql: "SELECT * FROM public.sys_user" (explicit schema, not auto-qualified)

ParametersJSON Schema
NameRequiredDescriptionDefault
sqlYesSELECT query to execute. Only read-only statements are allowed.
paramsNoOptional parameterized query values ($1, $2, ...)
schemaNoSchema name for tables without explicit schema prefix (default: from DB_SCHEMA env or 'public'). When specified, unqualified table names will be automatically prefixed with this schema.

TDQS

A4.7/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true, idempotentHint=true, destructiveHint=false, but the description adds value by explaining the return format (formatted table with row count) and the auto-schema feature. No contradictions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Well-structured with paragraphs, bullet-like arg list, and examples. Slight redundancy ('Only read-only statements are allowed' appears in both description and schema), but overall efficient and front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With rich annotations and full schema coverage, the description is complete. It explains return format, safety, and auto-schema. No output schema, but mentions return is a formatted table with row count, which suffices.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with descriptions for each parameter. The description adds extra context: for sql, it clarifies read-only constraint; for params, explains $1, $2 substitution; for schema, details auto-qualification and default from env var. Adds significant meaning beyond schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool executes read-only SQL queries (SELECT/WITH/SHOW) against the KingBase database, with a specific verb and resource. It distinguishes from siblings by noting DML and DDL are handled by other tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly states when to use (read-only queries) and when not ('For INSERT/UPDATE/DELETE use kb_execute; for DDL use kb_execute_ddl'). Also advises using parameterized queries for safety.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

kb_table_dataPreview Table DataA
Read-onlyIdempotent

Preview data from a table with optional filtering and pagination.

A convenient shortcut for common SELECT operations without writing full SQL.

Args:

  • table (string): Table name

  • schema (string, optional): Schema name, defaults to DB_SCHEMA env or 'public'

  • limit (number, default 100, max 1000): Number of rows

  • offset (number, default 0): Rows to skip

  • where (string, optional): WHERE condition (without WHERE keyword)

  • order_by (string, optional): ORDER BY clause (without ORDER BY keyword)

Returns: Formatted table of row data with total count.

Examples:

  • table: "users", limit: 10, where: "status = 'active'", order_by: "created_at DESC"

  • table: "orders", limit: 50, offset: 100

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNoNumber of rows to return (default: 100, max: 1000)
tableYesTable name to preview data from
whereNoOptional WHERE clause (without the WHERE keyword), e.g. "status = 'active'"
offsetNoNumber of rows to skip (default: 0)
schemaNoSchema name (default: from DB_SCHEMA env or 'public')
order_byNoOptional ORDER BY clause (without the ORDER BY keyword), e.g. "created_at DESC"

TDQS

A4.3/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already convey read-only, non-destructive, and idempotent behavior. The description adds that it returns a formatted table with total count, enhancing transparency. It does not disclose performance limitations, but given the annotations, the additional context is sufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and well-structured, front-loading the purpose and then detailing parameters and examples. It contains no wasted words, though the examples could be slightly trimmed without losing clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema, the description explains the return format (formatted table with total count). It covers all parameters and examples, fitting well with sibling tools. Minor gaps like performance caveats prevent a perfect score.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema coverage, the baseline is 3. The description adds value through an Args block with defaults and concrete examples (e.g., table: 'users', where: "status = 'active'"), clarifying usage beyond the schema's descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool previews table data with filtering and pagination, using a specific verb and resource. It distinguishes from sibling tools like kb_query, which require full SQL, by positioning itself as a shortcut for common SELECT operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for quick previews without writing SQL, providing clear context. However, it lacks explicit when-not-to-use or direct alternatives like kb_query for complex queries, though sibling context partially compensates.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

kb_table_statsTable StatisticsA
Read-onlyIdempotent

Get storage and usage statistics for a table, including row count, size, and dead tuples.

Args:

  • table (string): Table name

  • schema (string, optional): Schema name, defaults to DB_SCHEMA env or 'public'

Returns: Table size, row count, index size, dead tuples, and last vacuum/analyze times.

ParametersJSON Schema
NameRequiredDescriptionDefault
tableYesTable name to get statistics for
schemaNoSchema name (default: from DB_SCHEMA env or 'public')

TDQS

A3.5/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true, idempotentHint=true, destructiveHint=false, covering safety. Description adds specifics of returned statistics but no extra behavioral traits beyond output details. Moderate value given annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Description is concise, with clear purpose statement and separate args/returns sections. However, the args section partially duplicates schema descriptions, slightly reducing efficiency.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema, but description lists return fields. For a simple read-only stats tool, it's complete enough. Could mention prerequisites (e.g., table must exist) but not critical.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, with both parameters having descriptions. The description's 'Args' section largely mirrors the schema, adding no new semantics beyond formatting. Baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool retrieves storage and usage statistics for a table, listing specific metrics (row count, size, dead tuples). This distinguishes it from sibling tools like kb_describe_table (structure) and kb_list_tables (list of tables).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use this tool vs alternatives like kb_describe_table or kb_list_indexes. The description implies use when needing table stats, but lacks context for selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 11 tool updatesv1.0.6
    • First observedkb_describe_table
    • First observedkb_execute
    • First observedkb_execute_ddl
    • First observedkb_explain
    • First observedkb_list_constraints
    • First observedkb_list_indexes
    • First observedkb_list_schemas
    • First observedkb_list_tables
    • First observedkb_query
    • First observedkb_table_data
    • First observedkb_table_stats

TDQS

A4.3/5.0

Scored across 11 tools

Disambiguation5/5

Each tool targets a distinct database operation: schema listing, table description, read-only queries, DML, DDL, stats, etc. Even the overlapping kb_query and kb_table_data are clearly differentiated by generality vs. convenience with pagination.

Naming Consistency5/5

All tools start with the 'kb_' prefix, and most follow a verb_noun pattern (e.g., kb_list_schemas, kb_describe_table). The few single-verb names (kb_query, kb_execute) are still clear and consistent within the domain.

Tool Count5/5

11 tools is an ideal size for a database MCP server, covering all essential operations without overwhelming the agent.

Completeness5/5

The tool set provides full lifecycle coverage: schema inspection, table metadata, indexes, constraints, stats, explain plans, and both DML and DDL execution via kb_execute and kb_execute_ddl. The convenient kb_table_data tool fills a common use case.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    MCP server for DaMeng database, enabling AI assistants to execute SQL queries, list tables, describe table structures, and retrieve schema information.
    24 npm
    7
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A Cursor-integrated MCP server for Kingbase (人大金仓) databases, enabling schema queries, document generation, and SQL execution with configurable security modes (readonly, limited_write, full_access).
    5
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A unified MCP server for querying and managing multiple database types (PostgreSQL, MySQL, SQL Server, etc.) via natural language through AI assistants.
    GPL 3.0
  • A
    license
    A
    quality
    D
    maintenance
    MCP server enabling AI assistants to connect and query Dameng DM8 databases via JDBC. Supports SQL queries, listing tables, and describing schemas.
    3
    23 npm
    MIT