Skip to main content

MCP Server for Kingdee K3Cloud ERP — connect AI assistants to 金蝶云星空 via natural language

Project description

Kingdee K3Cloud MCP

PyPI version Python License CI

金蝶云星空 K3Cloud MCP Server,让 AI 助手(Claude Desktop、Claude Code、Cursor、Cline、Cherry Studio、Openclaw 等任意支持 MCP 协议的客户端)通过自然语言查询和操作金蝶 ERP 系统。

提示:Claude Code 用户可配合 kingdee-k3cloud-skill 获得更佳体验。Skill 为 Claude Code 注入金蝶表单字段、常用查询模式和工作流知识,大幅减少试错次数。

MCP Server for Kingdee K3Cloud ERP. Connect AI assistants to your ERP system via the Model Context Protocol.

功能特性

  • 11 个 MCP 工具:覆盖查询、新增、提交、审核、反审核、删除、下推等核心操作
  • 通用接口设计:单一 form_id 参数支持物料、客户、销售订单、采购订单等所有表单,无需为每种业务单独配置
  • 只读/读写模式:可限制 AI 只能查询,防止误操作
  • 自动会话恢复:长时间运行时自动处理会话超时,无需人工干预
  • 多传输协议:支持 stdio(本地)、SSE、streamable-http(远程共享)

快速开始

方式一:uvx 直接运行(推荐)

无需克隆仓库,直接通过 uvx 运行:

# 确保已安装 uv: https://docs.astral.sh/uv/
uvx kingdee-k3cloud-mcp

方式二:从源码运行

git clone https://github.com/adamzhang1987/kingdee-k3cloud-mcp.git
cd kingdee-k3cloud-mcp
uv sync
uv run kingdee-k3cloud-mcp

配置

复制环境变量模板并填写:

cp .env.example .env
环境变量 说明 示例
KD_SERVER_URL 金蝶服务器地址(必须以 /k3cloud/ 结尾) https://your-server/k3cloud/
KD_ACCT_ID 账套 ID your_acct_id
KD_USERNAME 用户名 your_username
KD_APP_ID 第三方应用 ID your_app_id
KD_APP_SEC 第三方应用密钥 your_app_secret
KD_LCID 语言(默认 2052 中文) 2052
KD_ORG_NUM 组织编码(可选)

第三方应用 ID 和密钥需在金蝶云星空管理端的「第三方系统登录授权」中申请。

客户端配置

Claude Desktop

编辑 ~/Library/Application Support/Claude/claude_desktop_config.json(macOS):

{
  "mcpServers": {
    "kingdee-k3cloud": {
      "command": "uvx",
      "args": ["kingdee-k3cloud-mcp"],
      "env": {
        "KD_SERVER_URL": "https://your-server/k3cloud/",
        "KD_ACCT_ID": "your_acct_id",
        "KD_USERNAME": "your_username",
        "KD_APP_ID": "your_app_id",
        "KD_APP_SEC": "your_app_secret",
        "KD_LCID": "2052"
      }
    }
  }
}

Claude Code

在项目目录下创建 .mcp.json

{
  "mcpServers": {
    "kingdee-k3cloud": {
      "command": "uvx",
      "args": ["kingdee-k3cloud-mcp"],
      "env": {
        "KD_SERVER_URL": "https://your-server/k3cloud/",
        "KD_ACCT_ID": "your_acct_id",
        "KD_USERNAME": "your_username",
        "KD_APP_ID": "your_app_id",
        "KD_APP_SEC": "your_app_secret",
        "KD_LCID": "2052"
      }
    }
  }
}

Cursor / Windsurf 及其他 MCP 客户端

配置方式与 Claude Desktop 类似,参考各客户端的 MCP 配置文档,使用相同的 uvx 命令和环境变量。

SSE 模式(远程共享)

如需多人共用同一个服务实例:

# 启动 SSE 服务(默认端口 8000)
FASTMCP_HOST=0.0.0.0 FASTMCP_PORT=8080 uvx kingdee-k3cloud-mcp --transport sse

客户端连接地址:http://your-server:8080/sse

可通过 MCP_API_KEY 环境变量启用 Bearer Token 鉴权。

可用工具

工具 类型 说明
query_bill 查询 查询单据数据(返回二维数组)
query_bill_json 查询 查询单据数据(返回 JSON,字段名作为 key)
view_bill 查询 查看单条记录完整详情
query_metadata 查询 查询表单字段结构(元数据)
save_bill 写入 保存/新增单据
submit_bill 写入 提交单据
audit_bill 写入 审核单据
unaudit_bill 写入 反审核单据
delete_bill 写入 删除单据
execute_operation 写入 执行自定义操作(禁用、反禁用等)
push_bill 写入 下推单据(如销售订单→发货通知单)

所有工具通过 form_id 参数支持任意表单(物料、客户、供应商、销售订单、采购订单等)。

只读模式

通过 --mode readonlyMCP_MODE=readonly 限制服务器只暴露 4 个查询工具,防止 AI 误操作写入数据。

"args": ["kingdee-k3cloud-mcp", "--mode", "readonly"]

或:

"env": {
  "MCP_MODE": "readonly",
  ...
}

调试

使用 MCP Inspector 可视化调试工具:

uvx mcp dev src/kingdee_k3cloud_mcp/server.py

架构说明

AI 助手(Claude Desktop / Claude Code / Cursor / Cline / Openclaw 等)
        │  MCP 协议
        ▼
kingdee-k3cloud-mcp(本项目)
        │  Kingdee Web API SDK
        ▼
金蝶云星空 K3Cloud

本项目使用官方金蝶 Python SDK(kingdee-cdp-webapi-sdk)与 K3Cloud API 通信,并通过 FastMCP 将其封装为标准 MCP 工具。

配套 Skill(Claude Code 用户)

kingdee-k3cloud-skill 是面向 Claude Code 的配套 Skill,提供:

  • 常用表单 ID 速查表(BD_MATERIAL、SAL_SaleOrder 等)
  • 已验证字段名列表(避免字段名错误导致 500)
  • 日报、客户查询、销售分析、库存分析、订单追踪等完整工作流

安装后 Claude Code 可自动掌握金蝶 ERP 的正确查询方式,无需反复试错。

许可证

Apache License 2.0 — 详见 LICENSE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kingdee_k3cloud_mcp-1.0.0.tar.gz (99.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kingdee_k3cloud_mcp-1.0.0-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file kingdee_k3cloud_mcp-1.0.0.tar.gz.

File metadata

  • Download URL: kingdee_k3cloud_mcp-1.0.0.tar.gz
  • Upload date:
  • Size: 99.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for kingdee_k3cloud_mcp-1.0.0.tar.gz
Algorithm Hash digest
SHA256 246cc62fdd37a47912446f5d759d078c8bee5bb92e657097347d193a4f68c441
MD5 e698e191c66884983617626ed790dec1
BLAKE2b-256 b7b7a0ac76ebd55f7d3c0fee3fe5aa7f5fb0f87e384c82a98bbe9dced18ea488

See more details on using hashes here.

Provenance

The following attestation bundles were made for kingdee_k3cloud_mcp-1.0.0.tar.gz:

Publisher: release.yml on adamzhang1987/kingdee-k3cloud-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kingdee_k3cloud_mcp-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for kingdee_k3cloud_mcp-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b2ea3293ec21cccd7c4ca57855db62509ab14f40bdc54c6652d6114345a6da77
MD5 2925e5f9088ea422ea098305f1205199
BLAKE2b-256 983ba6d61f4ce570c38b6f1fae4f073aceddf145e258ed22ef2a3f39c1824aec

See more details on using hashes here.

Provenance

The following attestation bundles were made for kingdee_k3cloud_mcp-1.0.0-py3-none-any.whl:

Publisher: release.yml on adamzhang1987/kingdee-k3cloud-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page