钉钉群机器人-发送文本消息
ding_send_textSend text or Markdown messages to DingTalk group robots via Webhook. Configure the bot access token through environment variable or direct input.
Instructions
钉钉群机器人发送文本或Markdown消息
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"text": "<text>"
},
"name": "ding_send_text"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | 消息内容 | |
| title | No | 消息标题 | |
| msgtype | No | 内容类型,仅支持: text/markdown | markdown |
| bot_key | No | 钉钉群机器人access_token,默认从环境变量获取 |
Implementation Reference
- mcp_notify/other.py:44-64 (handler)The handler function that executes the ding_send_text tool logic. It accepts text, title, msgtype, and bot_key parameters, builds the request body based on msgtype (markdown or text), retrieves the bot token from parameter or DINGTALK_BOT_KEY env var, and sends a POST request to DingTalk's robot API endpoint, returning the JSON response.
def ding_send_text( text: str = Field(description="消息内容"), title: str = Field("", description="消息标题"), msgtype: str = Field("markdown", description="内容类型,仅支持: text/markdown"), bot_key: str = Field("", description="钉钉群机器人access_token,默认从环境变量获取"), ): """ https://open.dingtalk.com/document/development/custom-robots-send-group-messages """ if msgtype == "markdown": body = {"title": title, "text": text} else: body = {"content": f'{title}\n{text}'.strip()} if not bot_key: bot_key = os.getenv("DINGTALK_BOT_KEY", "") base = os.getenv("DINGTALK_BASE_URL") or "https://oapi.dingtalk.com" res = requests.post( f"{base}/robot/send?access_token={bot_key}", json={"msgtype": msgtype, msgtype: body}, ) return res.json() - mcp_notify/other.py:38-43 (registration)The add_tools function that registers ding_send_text as an MCP tool via the @mcp.tool decorator, with title '钉钉群机器人-发送文本消息' and Chinese description. It also registers other tools (lark, bark, ntfy, pushplus) in the same function.
def add_tools(mcp: FastMCP, logger=None): @mcp.tool( title="钉钉群机器人-发送文本消息", description="钉钉群机器人发送文本或Markdown消息", ) - mcp_notify/other.py:44-48 (schema)Input schema for ding_send_text defined via Pydantic Field annotations: text (required string), title (optional string, default ''), msgtype (string, default 'markdown', only text/markdown), bot_key (string, optional, defaults to DINGTALK_BOT_KEY env var).
def ding_send_text( text: str = Field(description="消息内容"), title: str = Field("", description="消息标题"), msgtype: str = Field("markdown", description="内容类型,仅支持: text/markdown"), bot_key: str = Field("", description="钉钉群机器人access_token,默认从环境变量获取"), - mcp_notify/__init__.py:18-23 (registration)Top-level registration: creates the FastMCP server instance and calls other.add_tools(mcp) to register all tools including ding_send_text.
mcp = FastMCP(name="mcp-notify", version="0.1.11") wework.add_tools(mcp) tgbot.add_tools(mcp) other.add_tools(mcp) hass.add_tools(mcp) util.add_tools(mcp)