DingTalk v2 MCP server

Provides integration with the DingTalk API, enabling easy deployment and scaling of services like chatbots and data processing pipelines.
Back to servers
Setup instructions
Provider
wllcnm
Release date
Jan 04, 2025
Language
Python
Stats
4 stars

The DingTalk MCP Server V2 is a Model Control Protocol implementation that allows integration with DingTalk robots. It provides functionality for sending messages, retrieving conversation information, user details, and calendar events through DingTalk's platform.

Prerequisites

  • Python 3.10+
  • MCP 0.1.0+
  • aiohttp 3.9.1+

Environment Variables

Before using the server, you need to set the following environment variables:

  • DINGTALK_APP_KEY: Your DingTalk application's AppKey
  • DINGTALK_APP_SECRET: Your DingTalk application's AppSecret

Setup in Claude Client

Configuration

Add the following configuration to your claude_desktop_config.json:

{
  "mcpServers": {
    "dingding": {
      "command": "sh",
      "args": [
        "-c",
        "docker ps -a | grep mcp-dingding-v2 | awk '{print $1}' | xargs -r docker rm -f > /dev/null 2>&1; docker pull ghcr.io/wllcnm/mcp-dingding-v2:latest > /dev/null 2>&1; docker run -i --rm --name mcp-dingding-v2 -e DINGTALK_APP_KEY=your_AppKey -e DINGTALK_APP_SECRET=your_AppSecret ghcr.io/wllcnm/mcp-dingding-v2:latest"
      ]
    }
  }
}

Installation Steps

  1. Replace your_AppKey and your_AppSecret in the configuration with your actual DingTalk credentials
  2. Save the configuration file
  3. Restart the Claude client

Note: The startup command will:

  • Find and delete any old mcp-dingding-v2 containers
  • Pull the latest image from GitHub
  • Assign a fixed name to the container
  • Automatically remove the container when it stops

Running Locally

Installation

pip install -r requirements.txt

Running the Server

Run the server directly:

python src/server.py

Run using Docker:

# Clean up old containers
docker ps -a | grep mcp-dingding-v2 | awk '{print $1}' | xargs -r docker rm -f

# Build and run new container
docker build -t dingding-mcp-v2 .
docker run -i --rm --name mcp-dingding-v2 \
  -e DINGTALK_APP_KEY=your_app_key \
  -e DINGTALK_APP_SECRET=your_app_secret \
  dingding-mcp-v2

Available APIs

1. send_message

Sends a message to a DingTalk conversation.

Parameters:

  • conversation_id: The conversation ID
  • message: Message content
  • msg_type: Message type (optional, defaults to "text")

2. get_conversation_info

Retrieves information about a DingTalk conversation.

Parameters:

  • conversation_id: The conversation ID

3. get_user_info

Retrieves information about a DingTalk user.

Parameters:

  • user_id: The user ID

4. get_calendar_list

Queries a user's calendar events.

Parameters:

  • userid: User ID (required)
  • start_time: Start timestamp in milliseconds (optional)
  • end_time: End timestamp in milliseconds (optional)
  • max_results: Maximum number of results (optional, defaults to 50)
  • next_token: Pagination token (optional)

Returns:

  • Event details including summary, times, location, organizer, description, status, and attendees
  • Pagination information

Usage Examples

In Claude, you can use the tools as follows:

Sending a Message

{
  "tool": "send_message",
  "arguments": {
    "conversation_id": "your_conversation_id",
    "message": "Hello, DingTalk!",
    "msg_type": "text"
  }
}

Querying Calendar Events

{
  "tool": "get_calendar_list",
  "arguments": {
    "userid": "user_id",
    "start_time": 1704067200000,  // 2024-01-01 00:00:00
    "end_time": 1704153600000,    // 2024-01-02 00:00:00
    "max_results": 10
  }
}

Troubleshooting Tips

  • Verify your API credentials are correct
  • Ensure your network connection is working properly
  • Check the log output for detailed error information
  • Make sure to keep your DingTalk API credentials secure

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "dingding" '{"command":"sh","args":["-c","docker ps -a | grep mcp-dingding-v2 | awk '{print $1}' | xargs -r docker rm -f > /dev/null 2>&1; docker pull ghcr.io/wllcnm/mcp-dingding-v2:latest > /dev/null 2>&1; docker run -i --rm --name mcp-dingding-v2 -e DINGTALK_APP_KEY=\u4f60\u7684AppKey -e DINGTALK_APP_SECRET=\u4f60\u7684AppSecret ghcr.io/wllcnm/mcp-dingding-v2:latest"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "dingding": {
            "command": "sh",
            "args": [
                "-c",
                "docker ps -a | grep mcp-dingding-v2 | awk '{print $1}' | xargs -r docker rm -f > /dev/null 2>&1; docker pull ghcr.io/wllcnm/mcp-dingding-v2:latest > /dev/null 2>&1; docker run -i --rm --name mcp-dingding-v2 -e DINGTALK_APP_KEY=\u4f60\u7684AppKey -e DINGTALK_APP_SECRET=\u4f60\u7684AppSecret ghcr.io/wllcnm/mcp-dingding-v2:latest"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "dingding": {
            "command": "sh",
            "args": [
                "-c",
                "docker ps -a | grep mcp-dingding-v2 | awk '{print $1}' | xargs -r docker rm -f > /dev/null 2>&1; docker pull ghcr.io/wllcnm/mcp-dingding-v2:latest > /dev/null 2>&1; docker run -i --rm --name mcp-dingding-v2 -e DINGTALK_APP_KEY=\u4f60\u7684AppKey -e DINGTALK_APP_SECRET=\u4f60\u7684AppSecret ghcr.io/wllcnm/mcp-dingding-v2:latest"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later