dingtalk_send_link
Send link messages with titles, descriptions, and optional images to DingTalk groups from Claude Code for notifications and alerts.
Instructions
Send a link message to DingTalk group
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes | Link title | |
| text | Yes | Link description text | |
| messageUrl | Yes | Target URL | |
| picUrl | No | Optional image URL |
Implementation Reference
- src/index.ts:127-152 (registration)Registration of the 'dingtalk_send_link' tool in the ListTools handler, including name, description, and input schema.{ name: 'dingtalk_send_link', description: 'Send a link message to DingTalk group', inputSchema: { type: 'object', properties: { title: { type: 'string', description: 'Link title', }, text: { type: 'string', description: 'Link description text', }, messageUrl: { type: 'string', description: 'Target URL', }, picUrl: { type: 'string', description: 'Optional image URL', }, }, required: ['title', 'text', 'messageUrl'], }, },
- src/index.ts:308-324 (handler)Main handler function for the dingtalk_send_link tool, called from the switch statement in CallToolRequestSchema handler. Checks client configuration and delegates to DingTalkClient.sendLink.private async handleSendLink(args: { title: string; text: string; messageUrl: string; picUrl?: string }) { if (!this.dingTalkClient) { throw new Error('DingTalk client not configured. Use dingtalk_configure first or set environment variables (DINGTALK_WEBHOOK, DINGTALK_SECRET).'); } const success = await this.dingTalkClient.sendLink(args.title, args.text, args.messageUrl, args.picUrl); return { content: [ { type: 'text', text: success ? '✅ Link message sent successfully' : '❌ Failed to send link message', }, ], }; }
- src/dingtalk.ts:85-90 (handler)Core implementation of sending a link message in DingTalkClient, constructs the DingTalkMessage object and calls sendMessage.async sendLink(title: string, text: string, messageUrl: string, picUrl?: string): Promise<boolean> { return this.sendMessage({ msgtype: 'link', link: { title, text, messageUrl, picUrl } }); }
- src/dingtalk.ts:46-67 (helper)Generic sendMessage helper in DingTalkClient that handles HTTP POST to webhook with optional signature, used by all message types including link.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; } }
- src/dingtalk.ts:18-23 (schema)Type definition for link message in DingTalkMessage interface, used to structure the payload for DingTalk API.link?: { title: string; text: string; picUrl?: string; messageUrl: string; };