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-assistant-mcp

v1.1.0

Published

DingTalk AI Assistant MCP Server - TypeScript implementation for AI assistants interaction and management

Readme

DingTalk AI Assistant MCP Server

🤖 钉钉AI助理MCP服务器 - 为AI工具提供钉钉AI助理交互能力

✨ 特性

  • 🚀 智能对话封装:一键对话和多轮对话支持
  • 📡 流式交互:实时获取AI助理回复
  • 🔄 完整API覆盖:Thread、Message、Run、Assistant全生命周期管理
  • 🛡️ Token自动管理:智能缓存和自动刷新
  • 📊 类型安全:完整的TypeScript类型定义
  • 🔌 即插即用:符合MCP标准,可直接集成Cursor等AI工具

🎯 核心功能

🌟 高级封装工具

  • chatWithAssistant - 一键对话:自动创建线程→发送消息→运行AI助理→获取回复
  • continueChat - 多轮对话:在现有线程中继续对话

📋 基础管理工具

  • Thread管理:创建、获取线程信息
  • Message管理:发送消息、获取消息列表
  • Run管理:创建运行任务、查看状态(支持流式和非流式)
  • Assistant管理:创建、列出、获取AI助理信息

📦 安装

npm install dingtalk-assistant-mcp

🔧 配置

环境变量配置

创建 .env 文件:

# 方式1: 直接使用访问令牌(推荐用于测试)
DINGTALK_ACCESS_TOKEN=your_access_token_here

# 方式2: 使用应用凭证(推荐用于生产环境)
DINGTALK_Client_ID=your_client_id_here
DINGTALK_Client_Secret=your_client_secret_here

Cursor集成配置

在Cursor的MCP设置中添加:

{
  "dingtalk-assistant": {
    "command": "dingtalk-assistant-mcp",
    "env": {
      "DINGTALK_ACCESS_TOKEN": "your_access_token_here"
    }
  }
}

🚀 快速开始

一键对话示例

// 使用 chatWithAssistant 进行一键对话
{
  "assistantId": "your_assistant_id",
  "message": "你好,请介绍一下钉钉AI助理的功能",
  "stream": false
}

多轮对话示例

// 1. 首次对话 - 使用 chatWithAssistant
{
  "assistantId": "your_assistant_id", 
  "message": "请帮我制定一个项目计划",
  "stream": false
}
// 返回: { "threadId": "thread_123", "assistantReply": "..." }

// 2. 继续对话 - 使用 continueChat
{
  "threadId": "thread_123",
  "assistantId": "your_assistant_id",
  "message": "项目周期大概3个月",
  "stream": false
}

流式对话示例

// 启用流式输出,实时获取回复
{
  "assistantId": "your_assistant_id",
  "message": "请详细介绍机器学习的基本概念",
  "stream": true
}

📚 API工具列表

🌟 高级封装工具

| 工具名 | 描述 | 主要参数 | |--------|------|----------| | chatWithAssistant | 一键对话,自动处理完整流程 | assistantId, message, stream | | continueChat | 在现有线程中继续对话 | threadId, assistantId, message |

📋 基础管理工具

| 分类 | 工具名 | 描述 | |------|--------|------| | Thread | createThread | 创建新对话线程 | | | retrieveThread | 获取线程信息 | | Message | createMessage | 发送消息到线程 | | | listMessages | 获取线程消息列表 | | Run | createRun | 创建运行任务 | | | retrieveRun | 获取运行状态 | | Assistant | createAssistant | 创建AI助理 | | | listAssistants | 获取助理列表 | | | retrieveAssistant | 获取助理详情 |

🔄 工作流程

标准对话流程

  1. 创建线程 (createThread) - 建立对话会话
  2. 发送消息 (createMessage) - 用户提问
  3. 运行助理 (createRun) - AI处理和回复
  4. 获取结果 (listMessages) - 获取助理回复

智能封装流程

使用 chatWithAssistant 自动完成上述所有步骤!

🎨 使用场景

1. 智能客服

// 快速创建智能客服对话
{
  "assistantId": "customer_service_bot",
  "message": "我想咨询产品价格",
  "stream": true
}

2. 技术支持

// 技术问题咨询
{
  "assistantId": "tech_support_bot", 
  "message": "API调用返回401错误怎么解决?",
  "stream": false
}

3. 内容创作

// 文档撰写助手
{
  "assistantId": "content_writer_bot",
  "message": "帮我写一份技术方案文档",
  "stream": true
}

⚙️ 高级配置

流式输出配置

{
  "assistantId": "your_assistant_id",
  "message": "请详细解释...", 
  "stream": true,
  "instructions": "请用专业而通俗的语言回答"
}

自定义指令

{
  "assistantId": "your_assistant_id",
  "message": "分析这个数据",
  "instructions": "请以表格形式输出分析结果",
  "metadata": {
    "context": "monthly_report",
    "priority": "high"
  }
}

🔍 调试和监控

日志输出

服务器会在stderr输出详细的运行日志:

DingTalk Assistant MCP server running on stdio
Loaded 12 AI assistant tools from config
Created thread: thread_abc123
Created message: msg_def456
Created run: run_ghi789

错误处理

// 错误响应示例
{
  "isError": true,
  "content": [{
    "type": "text",
    "text": "Chat failed: Invalid assistant ID"
  }]
}

🤝 开发和贡献

本地开发

# 克隆项目
git clone https://github.com/your-org/dingtalk-assistant-mcp.git
cd dingtalk-assistant-mcp

# 安装依赖
npm install

# 构建项目
npm run build

# 运行测试
npm test

# 启动开发服务器
npm run dev

项目结构

dingtalk-assistant-mcp/
├── src/
│   ├── index.ts              # 主服务器类
│   ├── types.ts              # 类型定义
│   ├── cli.ts                # CLI入口
│   └── utils/
│       ├── streamParser.ts   # 流式数据解析
│       └── messageProcessor.ts # 消息处理器
├── dingtalk_assistant_mcp.yaml # 工具配置
├── package.json
└── README.md

📄 许可证

MIT License - 详见 LICENSE 文件

🆘 支持


⭐ 如果这个项目对你有帮助,请给个星星支持一下!