Skip to main content
Glama

send_markdown_message

Send formatted markdown messages with titles, mentions, and notifications to DingTalk group chats using a custom robot.

Instructions

Send a markdown message

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYesThe title of the message
textYesThe text content to send
atMobilesNoThe mobile numbers of users to @mention (ping) individually in the group chat
atAllNoWhether to @all the users in the group

Implementation Reference

  • Handler function for the 'send_markdown_message' tool. It invokes dingtalkBot.sendMarkdown and formats success or error response.
    async ({ title, text, atMobiles, atAll }) => { const response = await dingtalkBot.sendMarkdown(title, text, atMobiles, atAll); if (response.errcode !== 0) { return { content: [{ type: "text", text: `Failed to send message, code: ${response.errcode}, message: ${response.errmsg}` }], }; } return { content: [{ type: "text", text: "Message sent successfully" }], }; }
  • Zod input schema defining parameters for send_markdown_message tool: title, text, optional atMobiles and atAll.
    { title: z.string().describe("The title of the message"), text: z.string().describe("The text content to send"), atMobiles: z.array(z.string()).optional().describe("The mobile numbers of users to @mention (ping) individually in the group chat"), atAll: z.boolean().optional().describe("Whether to @all the users in the group"), },
  • src/index.ts:43-63 (registration)
    Registration of the 'send_markdown_message' tool on the MCP server, including name, description, input schema, and handler function.
    server.tool( 'send_markdown_message', 'Send a markdown message', { title: z.string().describe("The title of the message"), text: z.string().describe("The text content to send"), atMobiles: z.array(z.string()).optional().describe("The mobile numbers of users to @mention (ping) individually in the group chat"), atAll: z.boolean().optional().describe("Whether to @all the users in the group"), }, async ({ title, text, atMobiles, atAll }) => { const response = await dingtalkBot.sendMarkdown(title, text, atMobiles, atAll); if (response.errcode !== 0) { return { content: [{ type: "text", text: `Failed to send message, code: ${response.errcode}, message: ${response.errmsg}` }], }; } return { content: [{ type: "text", text: "Message sent successfully" }], }; } );
  • Core implementation of sending markdown message: constructs MarkdownMessage payload and performs authenticated POST request to DingTalk robot API.
    async sendMarkdown( title: string, text: string, atMobiles?: string[], atAll: boolean = false ): Promise<MessageResponse> { const data: MarkdownMessage = { msgtype: 'markdown', markdown: { title, text, }, at: { atMobiles: atMobiles || [], isAtAll: atAll, }, }; const response = await fetch(this.getSignedUrl(), { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(data), }); return response.json() as Promise<MessageResponse>; }
  • Utility method to generate signed URL for DingTalk API requests using HMAC-SHA256 signature if secret is provided.
    private getSignedUrl(): string { const timestamp = Date.now(); if (this.secret) { const stringToSign = `${timestamp}\n${this.secret}`; const hmac = crypto.createHmac('sha256', this.secret); const sign = encodeURIComponent( hmac.update(stringToSign).digest('base64') ); return `${this.baseUrl}?access_token=${this.accessToken}&timestamp=${timestamp}&sign=${sign}`; } return `${this.baseUrl}?access_token=${this.accessToken}`; }
Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Shawyeok/mcp-dingding-bot'

If you have feedback or need assistance with the MCP directory API, please join our Discord server