# DingTalk MCP

> DingTalk MCP connects your agent directly into Alibaba’s B2B office platform. You gain instant access to core corporate functions—from mapping complex organizational charts and tracking who's where, to managing attendance records and automating approval requests. Manage user profiles, send rich notifications, and process leave or reimbursement workflows all without opening the DingTalk app. It gives your agent a real set of tools for enterprise operations.

## Overview
- **Category:** industry-titans
- **Price:** Free
- **Tags:** enterprise-messaging, workflow-automation, attendance-tracking, b2b-operations, task-management, notifications

## Description

DingTalk is Alibaba’s main platform for corporate communication and collaboration. Connecting it through an MCP means you can tell your AI client to perform complex office tasks using natural conversation, instead of needing to log into multiple dashboards. Your agent can pull user lists by department, map the company's reporting structure, or check if a leave request passed approval—all in one go. You don't just get data; you trigger actions. For example, your agent handles checking timesheets and flagging late arrivals based on recorded attendance. Whether you’re an HR manager needing to monitor patterns or an operations leader tracking purchase approvals, this MCP gives your agent the necessary tools. Vinkius makes connecting this massive system simple, letting any compatible client access all these functions immediately.

## Tools

### create_approval_process
Starts a new workflow instance for things like leave, reimbursement, or purchases by defining the required fields and process type.

### get_approval_instance
Retrieves the current status of an approval request, showing who reviewed it and what decisions were made.

### get_attendance_records
Pulls timestamps and checkout types to show employee attendance data for specific date ranges.

### get_department_info
Gets detailed information about a single department, useful for understanding its scope or leadership.

### get_user_info
Looks up specific employee details using their unique user ID.

### list_all_departments
Provides a complete list of every top-level department in the entire company structure.

### list_sub_departments
Lists all smaller teams that fall under a specific parent department.

### list_users_by_department
Retrieves the full list of users and their basic profile info within a designated department.

### send_markdown_message
Sends highly formatted, structured text reports or alerts with titles and links to specific employees.

### send_work_notification
Sends a direct work notification message containing basic text or markdown details to one or more users.

## Prompt Examples

**Prompt:** 
```
List all users in department ID 12345.
```

**Response:** 
```
📋 I found 8 users in department 12345: Zhang Wei (Engineering Lead), Li Na (Senior Developer), Wang Fang (Developer), Chen Ming (QA Engineer), Liu Yang (Designer), Zhao Lei (Product Manager), Sun Li (Business Analyst), and Zhou Tao (DevOps). Would you like detailed profiles for any specific user?
```

**Prompt:** 
```
Send a markdown notification to user1,user2 with title 'Sprint Review' and content about tomorrow's meeting at 2pm.
```

**Response:** 
```
✅ Markdown notification sent successfully! Task ID: 987654321. The message with title 'Sprint Review' has been delivered to user1 and user2. The notification includes formatted details about tomorrow's 2pm meeting with agenda items and meeting link.
```

**Prompt:** 
```
Check attendance records for user1,user2 from 2024-01-15 to 2024-01-19.
```

**Response:** 
```
📊 Attendance report (Jan 15-19, 2024): **user1** - Mon: Check-in 08:55, Check-out 18:02 (Normal); Tue: Check-in 09:12 (Late by 12min), Check-out 18:00; Wed-Fri: Normal attendance. **user2** - All days normal with average check-in at 08:50. Both users show good attendance patterns with only one late occurrence.
```

## Capabilities

### Map Organizational Structure
List and explore departments and sub-departments to understand the company's full reporting hierarchy.

### Manage User Directory
Search for, retrieve details on, or list profiles of specific employees using their IDs.

### Monitor Time and Attendance
Pull employee check-in/check-out records to verify timesheets, track late arrivals, or monitor overall attendance patterns.

### Process Approvals
Initiate new approval workflows for things like leave requests or purchases, and check the current status of any running process.

### Send Rich Notifications
Send formatted announcements, alerts, or detailed reports to multiple team members directly through DingTalk's messaging feed.

## Use Cases

### The Payroll Audit
A manager needs to audit attendance records for three employees across two weeks. They ask their agent, who uses `get_attendance_records` and then compiles a clean report showing all late arrivals, saving hours of spreadsheet work.

### The Restructuring Announcement
HR needs to announce new reporting lines. The agent first calls `list_all_departments` and then uses the department IDs to send a formatted message via `send_markdown_message`, ensuring everyone gets the update.

### The Expense Check
An employee submits an expense report. Instead of emailing a manager, the agent automatically calls `create_approval_process` for reimbursement, and the manager uses `get_approval_instance` to review its status immediately.

### Finding Team Contacts
A developer needs contact info for the entire Product Marketing team. The agent first runs `list_sub_departments` to find the right group, then uses `list_users_by_department` to pull all necessary user IDs and names.

## Benefits

- Stop manually checking timesheets. Instead, use `get_attendance_records` to ask your agent for an immediate report on who was late or absent between two dates.
- Managing complex team communication is easier. Use `send_markdown_message` to send out structured reports—like quarterly results or policy changes—with professional formatting and links.
- Don't get lost in the org chart. Running `list_all_departments` immediately gives you a clear, actionable map of every department and its ID for future queries.
- Skip the paperwork trail. If an employee needs time off, your agent can use `create_approval_process` to start the request instantly, which you then track with `get_approval_instance`.
- You always know who's on the team. By calling `list_users_by_department`, you get a current roster of user IDs and names for any department in seconds.

## How It Works

The bottom line is you talk naturally to your agent, and it executes the necessary DingTalk function behind the scenes.

1. Subscribe to this MCP and provide your required DingTalk App Key and App Secret.
2. Your AI client authenticates using these credentials, granting the connection access to corporate data.
3. You prompt your agent with a natural language request (e.g., 'Check attendance for last week' or 'List all users in Marketing').

## Frequently Asked Questions

**How do I find all departments using list_all_departments?**
Running `list_all_departments` provides a complete, top-level list of every department ID in the organization. This is your starting point for mapping or querying other groups.

**Can I check an employee's profile using get_user_info?**
Yes, you must provide the user’s unique ID to `get_user_info`. It pulls up their detailed contact and profile information instantly for verification.

**What should I use to send a formatted announcement? Is it send_work_notification?**
For anything that needs structure—like an alert with bold text or clickable links—you must use `send_markdown_message`. This ensures the message looks professional and organized.

**If I need to track a purchase, do I use create_approval_process?**
Yes. You start by calling `create_approval_process` with the required details (like process code and user ID). This sets up the official workflow instance.

**I need to check if a department has sub-teams; what parameters should I use with `list_sub_departments`?**
You pass the parent department's ID to `list_sub_departments`. This command maps out the full organizational depth under that specific unit, helping you pinpoint niche teams or regional offices.
It’s essential for understanding complex reporting lines and ensuring your notifications go to the right group.

**If I want to check if a pending leave request was approved or rejected, which tool should I use: `get_approval_instance`?**
Use `get_approval_instance`. You simply provide the process instance ID. The function returns the current status (pending, approved, rejected) along with who made the last decision and when.
This is your quickest way to identify bottlenecks in any workflow.

**How do I use `get_attendance_records` to find all instances of late or early check-ins?**
When calling `get_attendance_records`, you must specify the date range. The output includes a flag for normal vs. abnormal attendance.
This allows HR teams to filter directly on discrepancies, skipping through clean data and focusing only on issues.

**I know the Department ID; how can I use `list_users_by_department` to get a full roster of users?**
Pass the department's unique ID into `list_users_by_department`. The function returns names, IDs, and avatars for every user associated with that team.
This is more efficient than listing all company users because you get exactly who belongs in that specific group.

**How do I get my DingTalk App Key and App Secret?**
Log in to the [DingTalk Developer Console](https://open-dev.dingtalk.com/), create an **Internal Enterprise Application**, then navigate to **App Information** > **Credentials** to find your AppKey and AppSecret. Make sure your application has the required API permissions (User Management, Department Management, Attendance, Approval) before using these tools.

**Can I send messages to external contacts or only internal employees?**
This MCP server uses **Internal Enterprise Application** authentication, which means it can only send messages to users within your organization's DingTalk tenant. For external contacts or customer notifications, you would need a different DingTalk application type with extended permissions. All user IDs must belong to employees in your enterprise directory.

**How does the attendance tracking work? What data can I retrieve?**
The attendance tool retrieves check-in/check-out records from DingTalk's attendance system. For each record, you get the user ID, timestamp, checkout type (上班签到=check-in, 下班签退=check-out), location information, and whether the attendance was normal or abnormal (late, early leave, missing punch). Date ranges are specified in YYYY-MM-DD format. This data integrates with DingTalk's physical attendance devices and mobile check-in features.