dingtalk-mcp
# dingtalk-mcp
钉钉群机器人 MCP Server — 通过 [Model Context Protocol](https://modelcontextprotocol.io/) 向钉钉群发送消息。
## 功能
| 工具名 | 功能 |
|--------|------|
| `send_text` | 发送纯文本消息 |
| `send_markdown` | 发送 Markdown 格式消息 |
| `send_image` | 发送图片(通过 URL) |
| `send_news` | 发送图文消息(标题+描述+链接+图片) |
| `send_template_card` | 发送模板卡片消息 |
> **注意**:钉钉自定义机器人(webhook)仅支持 text / link / markdown / actionCard / feedCard 五种消息类型,不支持文件上传。
## 环境变量
| 变量名 | 必填 | 说明 |
|--------|------|------|
| `DINGTALK_ACCESS_TOKEN` | 是 | 钉钉机器人的 access_token(Webhook URL 中 `access_token=` 后面的部分) |
| `DINGTALK_SECRET` | 否 | 钉钉机器人加签密钥(安全设置 → 加签 → SEC 开头的字符串) |
## 快速开始
```bash
git clone https://github.com/leonleonlei/MCP-DTalk.git
cd MCP-DTalk
npm install
node server.js
```
## MCP 客户端配置
```json
{
"mcpServers": {
"dingtalk": {
"command": "node",
"args": ["/path/to/MCP-DTalk/server.js"],
"env": {
"DINGTALK_ACCESS_TOKEN": "your-access-token",
"DINGTALK_SECRET": "SECxxxxxxxx"
}
}
}
}
```
## 使用示例
配置完成后,AI 助手可以直接调用工具:
- "给钉钉群发一条消息:今天下午3点开会"
- "把这份周报以 Markdown 格式发送到钉钉群"
- "在钉钉群里发一个卡片通知,标题是'系统告警'"
## 获取钉钉机器人凭证
1. 打开钉钉群 → 群设置 → 智能群助手 → 添加机器人 → 自定义
2. 安全设置选择「加签」,记录 SEC 开头的密钥(即 `DINGTALK_SECRET`)
3. 记录 Webhook URL 中 `access_token=` 后面的值(即 `DINGTALK_ACCESS_TOKEN`)
## 技术细节
- 基于 `@modelcontextprotocol/sdk` 构建
- 使用 stdio 传输协议
- Node.js >= 18
- ESM 模块
## License
MIT
TDQS
Scored across 5 tools
Each tool maps to a distinct DingTalk message type (image, text, markdown, news, template card), so the boundaries are clear once the desired format is known. The only mild ambiguity is choosing between markdown/news/template_card for rich content, since all can convey formatted text and links.
All five tools follow the exact same verb_noun convention with a shared `send_` prefix, differing only by message type suffix. This is a fully predictable, uniform pattern.
Five tools is a well-scoped set for a one-way DingTalk messaging integration, each covering one message format. Nothing appears redundant or missing at the count level.
The surface covers all major DingTalk message formats, which is the core of the domain. Minor gaps remain: no file/document sending, no @-mention or recipient targeting parameters, and no webhook/config management or message status/recall operations.