Sponsored by Deepsite.site

Mcp Dingtalk Doc

Created By
hykffta month ago
Content

钉钉文档解析 MCP 服务器 仅在MAC上测试

一个用于解析钉钉文档内容并生成HTML的MCP服务器。

✨ 功能特性

  • 🔐 完整解析流程: GET → 提取dentryKey → POST → 生成HTML
  • 📊 多元素支持: 段落、表格、图片、代码块
  • 🎨 美观渲染: 渐变色UI + 深色代码主题
  • 📋 代码复制: 代码块支持一键复制
  • 🌐 灵活输入: 支持完整URL或NODE_ID
  • 📁 自动归档: 按NODE_ID创建独立文件夹

📦 安装

方式一: 从源码安装

cd mcp_dingtalk_doc
pip install -e .

方式二: 使用 uv

uv pip install -e mcp_dingtalk_doc

⚙️ 配置

环境变量

在使用前,需要设置钉钉Cookie和输出目录(可选),也可以直接在配置文件里:

export DINGTALK_COOKIE="your_dingtalk_cookie_here"
export DINGTALK_DOC_OUTPUT_DIR="~/Documents/cursor-mcp/dingDoc"  # 可选,默认值

获取Cookie方法

  1. 打开钉钉文档页面
  2. 按 F12 打开开发者工具
  3. 切换到 Network 标签
  4. 刷新页面
  5. 找到请求,复制 Cookie 字段

测试运行 (5秒)

cd ~/Documents/AIGC/dingtalk_api/mcp_dingtalk_doc
python3 server.py

看到服务启动(没有错误)就OK!按 Ctrl+C 停止。

MCP 配置

在 Cursor 或其他支持MCP的客户端中配置:

{
  "mcpServers": {
    "dingtalk-doc": {
      "command": "python3",
      "args": [
        "~/Documents/AIGC/dingtalk_api/mcp_dingtalk_doc/server.py"
      ],
      "env": {
        "DINGTALK_COOKIE": "你的Cookie",
        "DINGTALK_DOC_OUTPUT_DIR": "~/Documents/cursor-mcp/dingDoc"
      }
    }
  }
}

注: command: 如果你有很多python版本,可以写python的绝对路径例如:"~/anaconda3/envs/coderunner/bin/python" args:改成你自己文件夹的地址

🚀 使用方法

重启Cursor,然后在聊天框输入:

请帮我解析这个钉钉文档:
https://alidocs.dingtalk.com/i/nodes/em7AML0b9lBV2Kxqa19qJnNyqOD6vwro

AI会自动调用 parse_document 工具!

Tool 1: parse_document

prompt:

使用 dingtalk-doc 服务的 parse_document 工具,解析这个文档:https://alidocs.dingtalk.com/i/nodes/oP0MALyR8k7Ao9wCZ092D9N83bzYmDO 请保存所有文件。

参数:

  • url_or_node_id (必需): 钉钉文档URL或NODE_ID
  • save_files (可选): 是否保存文件,默认true
  • output_dir (可选): 输出目录路径(未提供时使用环境变量 DINGTALK_DOC_OUTPUT_DIR,默认值为 ~/Documents/cursor-mcp/dingDoc

示例:

{
  "url_or_node_id": "https://alidocs.dingtalk.com/i/nodes/em7AML0b9lBV2Kxqa19qnNyqOD6vwro",
  "save_files": true
}

输出:

dingtalk_doc_{NODE_ID}/
├── {NODE_ID}_mainsite.json      # GET请求数据,用于获取nodeId
├── {NODE_ID}_document.json      # POST请求数据 获取文档的内容documentContent.content
├── {NODE_ID}_content.json       # 文档的详细内容,里面是钉钉自定义的标签
└── {NODE_ID}.html               # 生成的HTML ⭐

Tool 2: get_html

prompt: 使用 dingtalk-doc 服务的 get_html 工具,快速获取这个文档的HTML内容(不保存文件):https://alidocs.dingtalk.com/i/nodes/oP0MALyR8k7Aow9wCZ092D9N83YmDO

参数:

  • url_or_node_id (必需): 钉钉文档URL或NODE_ID
  • cookie (可选): 钉钉Cookie

示例:

{
  "url_or_node_id": "em7AML0b9lBV2Kxqa19qnyqOD6vwro"
}

📖 支持的元素

元素标签功能
段落p文本段落、富文本
文本样式span粗体、颜色、字号
表格table完整表格、单元格合并
图片img图片显示、懒加载
代码块code11种语言、一键复制

🎨 HTML样式特点

  • 🌈 渐变色背景(紫色系)
  • 📱 响应式设计
  • 💻 深色代码主题(VS Code Dark+)
  • ✨ 流畅动画效果
  • 📋 一键复制代码

🔧 开发

项目结构

mcp_dingtalk_doc/
├── __init__.py
├── server.py          # MCP服务器主文件
├── pyproject.toml     # 项目配置
└── README.md          # 说明文档

🐛 已知限制

  • ⚠️ OSS加密的文档内容暂不支持完整解密
  • ⚠️ 部分特殊元素(列表、引用块等)待支持
  • ⚠️ 需要有效的Cookie(会话过期需要更新)

📝 版本历史

v1.0.0 (2025-11-03)

  • ✅ 初始版本
  • ✅ 支持文档解析和HTML生成
  • ✅ 支持5种文档元素
  • ✅ 代码块一键复制功能

📄 许可

本项目仅供学习和研究使用。

👨‍💻 作者

黄云堃 (Yunkun Huang)


MCP版本: 1.0.0
Python版本: >=3.10
最后更新: 2025-11-03

Server Config

{
  "mcpServers": {
    "dingtalk-doc": {
      "command": "python3",
      "args": [
        "~/Documents/AIGC/dingtalk_api/mcp_dingtalk_doc/server.py"
      ],
      "env": {
        "DINGTALK_COOKIE": "你的Cookie",
        "DINGTALK_DOC_OUTPUT_DIR": "~/Documents/cursor-mcp/dingDoc"
      }
    }
  }
}
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Playwright McpPlaywright MCP server
Serper MCP ServerA Serper MCP Server
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Tavily Mcp
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
DeepChatYour AI Partner on Desktop
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
ChatWiseThe second fastest AI chatbot™
Amap Maps高德地图官方 MCP Server
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
WindsurfThe new purpose-built IDE to harness magic
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
CursorThe AI Code Editor
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.