Skip to main content
Glama
lianekai

mcp-dm8-server

by lianekai

mcp-dm8-server

lianekai 维护的 TypeScript 版达梦 DM8 Model Context Protocol (MCP) 服务,提供表结构浏览和只读查询能力,便于在支持 MCP 的客户端(如 Claude Desktop、mcp-router、mcp-use)中直接操作达梦数据库。

目录

  1. 主要特性

  2. 环境要求

  3. 安装与构建

  4. 配置方式

  5. 在 MCP 客户端中注册

  6. 可用工具说明

  7. 开发与测试指南

  8. 常见问题

Related MCP server: mysql-mcp-zag

主要特性

  • list_tablesdescribe_tableexecute_query 覆盖 Schema 列表、表结构和只读 SQL 操作。

  • 参数统一校验,自动规避 schema/table 注入风险,并强制限制为 SELECT/SHOW/DESCRIBE/EXPLAIN。

  • 支持环境变量、CLI 以及 .env 文件组合配置,易于部署。

  • 默认使用 stdio 传输,可与任意 MCP 客户端对接。

环境要求

  • Node.js >= 16(推荐 16.x;若使用 18.x 需追加 --openssl-legacy-provider,原因是 Node 18 内置的 OpenSSL 3 默认禁用旧算法,而达梦官方 dmdb 驱动仍依赖 legacy provider)。

  • npm >= 9 或兼容包管理器。

  • 达梦 DM8 数据库实例及具备权限的账号。

  • 达梦 Node 原生驱动依赖(dmdb 已在 package.json 中声明,必要时按官方文档安装系统库)。

安装与构建

git clone https://github.com/lianekai/mcp-dm8-server.git
cd mcp-dm8-server
npm install
npm run build

构建完成后即可运行:

DM_HOST=127.0.0.1 DM_PORT=5236 DM_USERNAME=SYSDBA DM_PASSWORD=密码 DM_SCHEMA=SYSDBA \
  node dist/index.js

也可以直接使用 npx 调用已经构建好的 CLI(等价于 node dist/index.js,更方便在 Codex 或其他 MCP 调度器中引用):

npx mcp-dm8 --host 127.0.0.1 --port 5236 --username SYSDBA --password 密码 --schema SYSDBA

注意:首次执行前需要先运行 npm run build 生成 dist/cli.js

配置方式

支持命令行参数、setConfig 运行时注入、环境变量/.env。优先级:CLI > 运行时 > 环境变量。

配置项

CLI 参数

环境变量

默认值

用户名

--username

DM_USERNAME

密码

--password

DM_PASSWORD

主机

--host

DM_HOST

端口

--port

DM_PORT

5236

默认 Schema

--schema

DM_SCHEMA

示例 .env

DM_HOST=localhost
DM_PORT=5236
DM_USERNAME=SYSDBA
DM_PASSWORD=••••••
DM_SCHEMA=SYSDBA

查看版本:

node dist/index.js --version

快速启动

node 版本选择上,请注意:使用 Node.js 16.x 时可以直接启动;若使用 Node.js 18.x,则必须通过命令行参数显式追加 --openssl-legacy-provider 以启用被默认禁用的旧 OpenSSL 算法,否则启动会失败。

  • npm 脚本:仓库内已提供 npm run start:dm8,会自动为当前进程注入 NODE_OPTIONS=--openssl-legacy-provider。Windows 环境若需兼容,可改用 cross-env NODE_OPTIONS=--openssl-legacy-provider node dist/index.js

  • Shell 启动器:执行 ./start-dm8.sh --host 127.0.0.1 --port 5236 --username SYSDBA --password 密码 --schema SYSDBA,脚本会自动附加 legacy provider 并将参数透传给 dist/index.js

  • Direnv 环境变量:仓库根目录提供 .envrc,如果你使用 direnv,在项目目录执行一次 direnv allow,进入目录时会自动设置 NODE_OPTIONS=--openssl-legacy-provider。若不需要该行为,可删除或忽略 .envrc

在 MCP 客户端中注册

Claude Desktop

claude_desktop_config.json 追加:

{
  "mcpServers": {
    "dm8": {
      "command": "node",
      "args": ["/path/to/mcp-dm8-server/dist/index.js"],
      "env": {
        "DM_HOST": "127.0.0.1",
        "DM_PORT": "5236",
        "DM_USERNAME": "SYSDBA",
        "DM_PASSWORD": "your-password",
        "DM_SCHEMA": "SYSDBA"
      }
    }
  }
}

mcp-router / mcp-use

config.json 追加:

{
  "servers": {
    "dm8": {
      "command": "node",
      "args": ["/path/to/mcp-dm8-server/dist/index.js"],
      "env": {
        "DM_HOST": "127.0.0.1",
        "DM_PORT": "5236",
        "DM_USERNAME": "SYSDBA",
        "DM_PASSWORD": "your-password",
        "DM_SCHEMA": "SYSDBA"
      }
    }
  }
}

如果想直接使用源码运行,可把 args 替换为 npx tsx src/index.ts,并确保本地已安装 tsx

Codex CLI

  1. 构建产物(若尚未执行过):npm run build

  2. 编辑 ~/.codex/config.toml,确保将项目路径标记为可信,例如:

    [projects."/Users/your-user/software/mcp/mcp-dm8-server"]
    trust_level = "trusted"
  3. 在同一文件的 [mcp_servers] 段落追加达梦服务定义:

    [mcp_servers.dm8]
    command = "node"
    args = [
      "/Users/your-user/software/mcp/mcp-dm8-server/dist/index.js",
      "--host", "127.0.0.1",
      "--port", "5236",
      "--username", "SYSDBA",
      "--password", "your-password",
      "--schema", "SYSDBA"
    ]

    如果希望在运行时切换配置,可把上述敏感参数改为环境变量并结合 .env,或使用 --username 等 CLI 参数覆盖。

  4. 保存后重新启动 Codex CLI 会话(或执行 codex reset)以加载新的 MCP 服务器。随后在 Codex 中执行 list_tables / describe_table / execute_query 等工具即可访问 DM8。

可用工具说明

工具名

描述

关键参数

list_tables

列出指定 Schema 的所有表

schema(可选)

describe_table

显示列类型、长度、可空属性

schema(可选)、table(必填)

execute_query

执行只读 SQL

schema(可选)、query(必填,只允许 SELECT/SHOW/DESCRIBE/EXPLAIN)

所有工具都会对 schema/table 名称做正则校验,并在执行前自动设置 Schema。

开发与测试指南

npm run dev   # tsx watch
npm test      # Vitest 单元测试
npm run build # 生成 dist + d.ts

默认 dmdb.outFormat = dmdb.OUT_FORMAT_OBJECT,如需兼容旧格式可在 src/utils/db.ts 修改。

常见问题

Q: 驱动安装失败怎么办? 参考达梦官方《Node.js 框架 | 达梦技术文档》,确保系统具备 snappy/snappyjs 等依赖。

Q: 可以执行 DML/DDL 吗? 当前仅允许只读操作,如需扩展请严格控制权限并补充测试。

Q: 如何反馈问题?Issues 提交或发起 PR。

Available Tools

3 tools
dm8_describe_table显示 DM8 表结构B

返回列名、类型、长度以及是否可空信息

ParametersJSON Schema
NameRequiredDescriptionDefault
schemaNo数据库 Schema,默认为配置中的 DM_SCHEMA
tableYes表名称

TDQS

B3.4/5.0
Behavior2/5

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

No annotations provided; the description lacks disclosure of behavioral traits such as being read-only, authentication needs, or potential side effects. While it implicitly suggests a read operation, this is not explicitly stated, leaving room for ambiguity.

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, efficient sentence that conveys all necessary information without extraneous content. It is well-structured and avoids redundancy.

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 the tool's simplicity and lack of output schema, the description adequately covers what is returned (column names, types, lengths, nullable). However, it might omit additional metadata like default values or precision, leaving minor gaps.

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%, with each parameter having a clear description. However, the tool description adds no further detail beyond the schema, maintaining a baseline score. No additional semantic value provided.

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?

Description explicitly states it returns column name, type, length, and nullable information, which clearly defines the tool's function. It distinguishes from siblings: dm8_list_tables lists table names, dm8_execute_query executes queries, while this tool provides table schema metadata.

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 guidance on when to use this tool vs alternatives. The description implies it is for obtaining table structure, but it does not mention situations where dm8_list_tables or dm8_execute_query would be more appropriate, nor any prerequisites or context.

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

dm8_execute_query执行 DM8 只读 SQLA

仅允许 SELECT/SHOW/DESCRIBE/EXPLAIN 语句

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYes只读 SQL 语句
schemaNo数据库 Schema,默认为配置中的 DM_SCHEMA

TDQS

A4.2/5.0
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses the core behavioral trait (read-only, allowed statement types) but lacks details on error handling for non-allowed statements, authentication requirements, rate limits, or return format. This is adequate but not comprehensive.

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 concise sentence that front-loads the key restriction. Every word serves a purpose, with no wasted information.

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 read-only query execution tool with no output schema, the description provides enough information to understand its purpose and restrictions. However, it could be slightly improved by noting what happens if an invalid statement is submitted, but given the simplicity, it is largely 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% with both parameters described. The description adds meaningful value by specifying the allowed statement types for the query parameter, going beyond the schema's '只读 SQL 语句'. This helps the agent construct valid queries.

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 and lists exactly which statement types are allowed (SELECT/SHOW/DESCRIBE/EXPLAIN). This distinguishes it from sibling tools dm8_describe_table and dm8_list_tables, which are more specific table 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 provides clear context that only certain statement types are allowed, implicitly indicating when to use this tool (for custom read-only queries) and when not to (for modifications). However, it does not explicitly mention alternatives or exclusion cases beyond the allowed types.

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

dm8_list_tables列出 DM8 数据库中的所有表B

返回指定 Schema 下的所有表名

ParametersJSON Schema
NameRequiredDescriptionDefault
schemaNo数据库 Schema,默认为配置中的 DM_SCHEMA

TDQS

B3.4/5.0
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic operation. It does not disclose default behavior when schema is omitted, error handling, ordering, or permissions. For a listing operation, this leaves agents uncertain about side effects or constraints.

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, front-loaded sentence with no wasted words. It efficiently conveys the core functionality.

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 one optional parameter, the description is mostly adequate. However, it lacks details on output format and what happens if schema is not specified (e.g., uses default schema). An explicit mention of the expected output (e.g., 'list of table names') would improve completeness.

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?

The input schema is fully covered (100%), and the parameter description clarifies the default value. The tool description adds no additional meaning beyond the schema. Baseline 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 clearly states that the tool returns all table names under a specified Schema, using a specific verb ('返回') and resource ('所有表名'). It distinctly differentiates from siblings: dm8_describe_table describes a specific table and dm8_execute_query runs arbitrary queries.

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 guidance is provided on when to use this tool versus the siblings. There is no mention of when not to use it, prerequisites, or alternatives. The description merely states the function without context.

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. Dates show when Glama detected each change.

  1. 3 tool updatesv1.1.0
    • First observeddm8_describe_table
    • First observeddm8_execute_query
    • First observeddm8_list_tables

TDQS

A3.9/5.0
Disambiguation5/5

Each tool has a clearly distinct purpose: listing tables, describing a table's schema, and executing read-only queries. No overlap in functionality.

Naming Consistency5/5

All tools follow a consistent 'dm8_verb_noun' pattern (e.g., list_tables, describe_table, execute_query). Naming is predictable and uniform.

Tool Count4/5

3 tools is minimal but appropriate for a read-only database inspector. Covers basic operations without being wasteful.

Completeness4/5

The set covers listing tables, describing a table, and querying data. Lacks operations like retrieving row counts or schema listing, but is adequate for a focused read-only utility.

Maintenance

ActivityInactive
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    B
    quality
    D
    maintenance
    Enables interaction with Oracle databases through MCP by executing SELECT queries, describing table structures, and listing available tables with secure, read-only access.
    3
    19
    2
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Read-only SQL Server MCP server enabling safe database queries, table listing, and schema inspection with built-in security protections.
    MIT
  • A
    license
    B
    quality
    C
    maintenance
    Read-only MCP server for exploring and analyzing SQL Server objects (tables, views, triggers, stored procedures) from Claude Code.
    8
    907
    MIT

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/lianekai/mcp-dm8-server'

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