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

dingtalk-mcp-server

v0.1.8

Published

钉钉MCP服务器 - 让Claude Code能操作钉钉(消息/待办/日程)

Readme

钉钉 MCP Server

npm version License: MIT

让 Claude Code、Cline 等 AI 助手能操作钉钉的 MCP (Model Context Protocol) 服务器。

✨ 功能特性

  • 📨 消息管理: 发送文本消息、发送 Markdown 消息、获取联系人列表
  • 待办管理: 创建待办事项、查询待办列表、更新待办状态
  • 📅 日程管理: 创建日程、查询日程列表

📦 安装

npm 安装(推荐)

npm install dingtalk-mcp-server

源码安装

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

⚙️ 配置

1. 创建钉钉应用

  1. 登录 钉钉开发者平台
  2. 创建企业内部应用
  3. 获取应用的 AppKeyAppSecretAgentId
  4. 配置应用权限:
    • contact:read - 读取通讯录
    • chat:write - 发送消息
    • todo:write - 待办管理
    • calendar:write - 日程管理

2. Claude Code 配置

在 Claude Code 的 settings.json 中添加 MCP 服务器配置:

方式一:全局安装后使用

{
  "mcpServers": {
    "dingtalk": {
      "command": "npx",
      "args": ["dingtalk-mcp-server"],
      "env": {
        "DINGTALK_APP_KEY": "your_app_key",
        "DINGTALK_APP_SECRET": "your_app_secret",
        "DINGTALK_AGENT_ID": "your_agent_id"
      }
    }
  }
}

方式二:本地路径

{
  "mcpServers": {
    "dingtalk": {
      "command": "node",
      "args": ["/path/to/dingtalk-mcp-server/dist/index.js"],
      "env": {
        "DINGTALK_APP_KEY": "your_app_key",
        "DINGTALK_APP_SECRET": "your_app_secret",
        "DINGTALK_AGENT_ID": "your_agent_id"
      }
    }
  }
}

3. Cline / VS Code 配置

在 VS Code 的 MCP 配置中添加:

{
  "mcp": {
    "servers": {
      "dingtalk": {
        "command": "npx",
        "args": ["dingtalk-mcp-server"],
        "env": {
          "DINGTALK_APP_KEY": "your_app_key",
          "DINGTALK_APP_SECRET": "your_app_secret",
          "DINGTALK_AGENT_ID": "your_agent_id"
        }
      }
    }
  }
}

🛠️ 可用工具

消息工具

| 工具名称 | 描述 | 参数 | |---------|------|------| | dingtalk_message_send_text | 发送文本消息 | userid, content | | dingtalk_message_send_markdown | 发送 Markdown 消息 | userid, title, content | | dingtalk_message_get_contacts | 获取联系人列表 | 无 |

待办工具

| 工具名称 | 描述 | 参数 | |---------|------|------| | dingtalk_todo_create | 创建待办事项 | subject, executorUserIds, description?, dueTime?, participantUserIds? | | dingtalk_todo_list | 获取待办列表 | userid, status? | | dingtalk_todo_update | 更新待办状态 | recordId, status |

日程工具

| 工具名称 | 描述 | 参数 | |---------|------|------| | dingtalk_calendar_create | 创建日程 | summary, startTime, endTime, organizerUserid, attendeeUserids, description?, location?, reminder? | | dingtalk_calendar_list | 获取日程列表 | userid, startTime, endTime |

📝 使用示例

在 Claude Code 中使用

用户: 帮我给张三发一条钉钉消息,告诉他明天开会
Claude: 我来帮您发送钉钉消息。

[调用 dingtalk_message_send_text 工具]
参数:
- userid: "zhangsan"
- content: "明天有会议,请注意时间安排"

消息已成功发送给张三!

用户: 帮我创建一个待办,标题是"完成项目报告",截止时间是明天
Claude: 我来帮您创建待办事项。

[调用 dingtalk_todo_create 工具]
参数:
- subject: "完成项目报告"
- dueTime: 1711276800 (明天的 Unix 时间戳)
- executorUserIds: ["your_userid"]

待办已创建成功!

代码示例

import { DingTalkAPI } from 'dingtalk-mcp-server';

const api = new DingTalkAPI(
  process.env.DINGTALK_APP_KEY!,
  process.env.DINGTALK_APP_SECRET!,
  process.env.DINGTALK_AGENT_ID!
);

// 发送消息
await api.sendTextMessage('userid', '你好,这是测试消息');

// 创建待办
await api.createTodo({
  subject: '完成项目报告',
  executorUserIds: ['userid'],
  dueTime: Math.floor(Date.now() / 1000) + 86400, // 明天
});

// 创建日程
await api.createCalendarEvent({
  summary: '项目评审会议',
  startTime: Math.floor(Date.now() / 1000) + 3600, // 1小时后
  endTime: Math.floor(Date.now() / 1000) + 7200,   // 2小时后
  organizerUserid: 'userid',
  attendeeUserids: ['user1', 'user2'],
  location: '会议室A',
});

🔐 钉钉 API 权限

使用此 MCP 服务器需要以下钉钉应用权限:

| 权限 | 用途 | |------|------| | contact:read | 读取通讯录,获取联系人列表 | | chat:write | 发送消息给用户 | | todo:write | 创建和管理待办事项 | | calendar:write | 创建和管理日程 |

🔧 开发

# 安装依赖
npm install

# 开发模式(监听文件变化)
npm run dev

# 构建
npm run build

# 运行
npm start

📋 环境变量

| 变量名 | 描述 | 必填 | |--------|------|------| | DINGTALK_APP_KEY | 钉钉应用的 AppKey | ✅ | | DINGTALK_APP_SECRET | 钉钉应用的 AppSecret | ✅ | | DINGTALK_AGENT_ID | 钉钉应用的 AgentId | ✅ |

🐛 常见问题

Q: 发送消息失败?

检查以下几点:

  1. 应用权限是否正确配置
  2. 用户是否在应用可见范围内
  3. AppKey、AppSecret、AgentId 是否正确

Q: 获取联系人列表为空?

确保应用有 contact:read 权限,并且通讯录可见范围设置正确。

Q: 如何获取用户 ID?

可以通过以下方式获取:

  1. 在钉钉管理后台查看
  2. 使用 getUserId 方法通过免登码获取

📄 License

MIT License - 详见 LICENSE 文件


📬 联系我们

微信公众号

关注公众号「什么什么周」,获取更多AI工具推荐和实战教程:

  • 每天挖掘一个AI赚钱工具
  • OpenClaw/Claude Code实战教程
  • 企业AI应用案例

微信交流

扫码添加微信,备注"dingtalk-mcp":

微信号:190569625

微信公众号

微信扫码关注公众号「什么什么周」:

公众号二维码

问题反馈

🤝 贡献

欢迎提交 Issue 和 Pull Request!

📚 相关链接