npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dameng-mcp-server-x

v1.1.1

Published

Extended MCP Server for DaMeng Database with execution plan support

Readme

DaMeng MCP Server X

达梦数据库 的 MCP (Model Context Protocol) 扩展实现。项目 Fork 自 zqeast/dameng-mcp-server,增加普通 EXPLAIN 执行计划返回与结构化解析能力。

GitHub Release npm License Node Version

功能特性

  • 执行 SQL 查询
  • 返回并解析普通 EXPLAIN 执行计划
  • 列出数据库表
  • 描述表结构
  • 获取数据库模式信息
  • 支持连接池管理
  • 安全返回 BIGINT、CLOB 和 BLOB,避免 JSON 序列化失败或大整数精度丢失
  • 完整的输入验证

快速开始

使用 npx 运行

直接运行最新版:

npx -y dameng-mcp-server-x

生产环境建议固定版本,确保不同机器运行相同代码:

npx -y [email protected]

也可以直接从 GitHub Tag 运行:

npx -y --package=github:xiaohan815/dameng-mcp-server-x#v1.1.1 -- dameng-mcp-server-x

本地开发:

git clone https://github.com/xiaohan815/dameng-mcp-server-x.git
cd dameng-mcp-server-x
npm ci
npm start

配置

创建 .env 文件并配置数据库连接信息:

cp .env.example .env

编辑 .env 文件:

DAMENG_HOST=localhost
DAMENG_PORT=5236
DAMENG_USER=SYSDBA
DAMENG_PASSWORD=your_password
DAMENG_SCHEMA=SYSDBA
DAMENG_POOL_SIZE=10

在 Trae IDE 中使用

  1. 打开 MCP 设置
  2. 手动添加 MCP
  3. 使用以下配置:
{
  "mcpServers": {
    "dameng-mcp-server-x": {
      "command": "npx",
      "args": [
        "-y",
        "[email protected]"
      ],
      "env": {
        "DAMENG_HOST": "localhost",
        "DAMENG_PORT": "5236",
        "DAMENG_USER": "SYSDBA",
        "DAMENG_PASSWORD": "your_password",
        "DAMENG_SCHEMA": "SYSDBA",
        "DAMENG_POOL_SIZE": "10"
      }
    }
  }
}

MCP 工具

execute_sql

执行 SQL 查询并返回结果。

参数:

| 参数 | 类型 | 必需 | 说明 | |------|------|--------|------| | sql | string | 是 | 要执行的 SQL 语句 |

示例:

{
  "sql": "SELECT * FROM users LIMIT 10"
}

list_tables

列出数据库中的所有表。

参数: 无

explain_sql

使用达梦普通 EXPLAIN 获取 SQL 的文本执行计划,并返回原始计划、结构化节点以及扫描、连接、排序和最高代价节点摘要。该工具只生成执行计划,不执行目标 DML。

参数:

| 参数 | 类型 | 必需 | 说明 | |------|------|------|------| | sql | string | 是 | 单条 SELECT、WITH、INSERT、UPDATE、DELETE 或 MERGE 语句 |

示例:

{
  "sql": "SELECT * FROM USERS WHERE ID = 10"
}

返回内容包含:

  • 达梦原始文本执行计划
  • 每个计划节点的操作符、层级、代价、估算行数和字节数
  • 表名、索引名、扫描方式与扫描范围
  • 扫描、连接、排序和最高代价节点摘要

describe_table

描述指定表的结构,包括列名、数据类型等信息。

参数:

| 参数 | 类型 | 必需 | 说明 | |------|------|--------|------| | table_name | string | 是 | 要描述的表名 |

示例:

{
  "table_name": "users"
}

get_schema_info

获取数据库模式信息,包括所有表和视图的详细信息。

参数: 无

环境变量

| 变量 | 必需 | 默认值 | 说明 | |-------|--------|----------|------| | DAMENG_HOST | 是 | - | 数据库主机地址 | | DAMENG_PORT | 是 | - | 数据库端口(默认 5236) | | DAMENG_USER | 是 | - | 数据库用户名 | | DAMENG_PASSWORD | 是 | - | 数据库密码 | | DAMENG_SCHEMA | 是 | - | 数据库模式名 | | DAMENG_POOL_SIZE | 否 | 10 | 连接池大小 |

项目结构

dameng-mcp-server-x/
├── src/
│   ├── index.js          # MCP 服务器主入口
│   ├── database.js       # 达梦数据库连接模块
│   └── explain.js        # EXPLAIN 校验、解析与摘要
├── test/
│   ├── database.test.js  # 驱动返回路径测试
│   └── explain.test.js   # 执行计划解析测试
├── .github/
│   └── workflows/
│       └── release.yml    # GitHub Release 工作流
├── package.json
├── .env.example
├── .npmignore
├── LICENSE
└── README.md

技术栈

  • @modelcontextprotocol/sdk: MCP SDK
  • dmdb: 达梦数据库 Node.js 驱动
  • zod: 输入验证
  • dotenv: 环境变量管理

系统要求

  • Node.js >= 18.0.0

故障排除

连接失败

  • 确认达梦数据库服务已启动
  • 检查 .env 文件中的连接配置
  • 验证网络连接和防火墙设置

dmdb 驱动问题

首次使用 dmdb 驱动可能需要编译,确保系统已安装必要的编译工具:

Ubuntu/Debian:

sudo apt-get install build-essential

macOS:

xcode-select --install

Windows: 安装 Visual Studio Build Tools

贡献

欢迎提交 Issue 和 Pull Request!上游通用修复应优先考虑回馈原项目。

许可证

MIT

作者

zqeast [email protected]

扩展维护:xiaohan815

相关链接