dingtalk_send_text
Send text messages to DingTalk groups from Claude Code for task alerts and notifications, with optional @all mentions.
Instructions
Send a text message to DingTalk group
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | Text content to send | |
| atAll | No | Whether to @all members |
Implementation Reference
- src/index.ts:266-285 (handler)MCP tool handler function that prepares the message by appending the git username and calls DingTalkClient.sendText to send the text message to DingTalk.private async handleSendText(args: { content: string; atAll?: boolean }) { if (!this.dingTalkClient) { throw new Error('DingTalk client not configured. Use dingtalk_configure first or set environment variables (DINGTALK_WEBHOOK, DINGTALK_SECRET).'); } const gitUsername = this.getGitUsername(); const contentWithUser = `${args.content}\n\n---\n👤 发送者: ${gitUsername}`; const success = await this.dingTalkClient.sendText(contentWithUser, args.atAll); return { content: [ { type: 'text', text: success ? '✅ Text message sent successfully' : '❌ Failed to send text message', }, ], }; }
- src/index.ts:88-102 (schema)Input schema definition for the dingtalk_send_text tool, specifying content as required string and optional atAll boolean.inputSchema: { type: 'object', properties: { content: { type: 'string', description: 'Text content to send', }, atAll: { type: 'boolean', description: 'Whether to @all members', default: false, }, }, required: ['content'], },
- src/index.ts:85-103 (registration)Tool registration in the listTools response, including name, description, and input schema.{ name: 'dingtalk_send_text', description: 'Send a text message to DingTalk group', inputSchema: { type: 'object', properties: { content: { type: 'string', description: 'Text content to send', }, atAll: { type: 'boolean', description: 'Whether to @all members', default: false, }, }, required: ['content'], }, },
- src/dingtalk.ts:69-75 (helper)Helper method in DingTalkClient that constructs the text message payload and delegates to sendMessage.async sendText(content: string, atAll = false): Promise<boolean> { return this.sendMessage({ msgtype: 'text', text: { content }, at: { isAtAll: atAll } }); }
- src/dingtalk.ts:46-67 (helper)Core helper function that handles HTTP POST to DingTalk webhook, including optional signature generation for security.async sendMessage(message: DingTalkMessage): Promise<boolean> { try { const signParams = this.generateSign(); const url = signParams ? `${this.config.webhook}&${signParams}` : this.config.webhook; const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(message), }); const result = await response.json(); return result.errcode === 0; } catch (error) { console.error('DingTalk notification failed:', error); return false; } }