飞书/Lark机器人-发送文本消息
lark_send_textSend text or markdown messages to Feishu or Lark group robots using a bot key.
Instructions
飞书/Lark群机器人发送文本或Markdown消息
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | 消息内容 | |
| msgtype | No | 内容类型,仅支持: text/markdown | markdown |
| bot_key | No | 飞书/Lark机器人key,uuid格式,默认从环境变量获取 | |
| is_lark | No | 根据用户描述识别 0:飞书 1:Lark |
Implementation Reference
- mcp_notify/other.py:71-98 (handler)The actual handler function for the 'lark_send_text' tool. Sends text/markdown messages to Feishu/Lark bot via their API. Accepts text content, msgtype, bot_key, and is_lark flag. Builds the request body, resolves bot_key from params or env vars, determines base URL based on is_lark flag, and sends the POST request.
def lark_send_text( text: str = Field(description="消息内容"), msgtype: str = Field("markdown", description="内容类型,仅支持: text/markdown"), bot_key: str = Field("", description="飞书/Lark机器人key,uuid格式,默认从环境变量获取"), is_lark: int = Field(0, description="根据用户描述识别 0:飞书 1:Lark"), ): """ https://open.feishu.cn/document/ukTMukTMukTM/ucTM5YjL3ETO24yNxkjN https://open.larksuite.com/document/client-docs/bot-v3/add-custom-bot """ if msgtype == "markdown": body = { "msg_type": "interactive", "card": {"elements": [{"tag": msgtype, "content": text}]}, } else: body = {"msg_type": msgtype, "content": {"text": text}} if not bot_key: bot_key = os.getenv("LARK_BOT_KEY" if is_lark else "FEISHU_BOT_KEY", "") if is_lark: base = os.getenv("LARK_BASE_URL") or "https://open.larksuite.com" else: base = os.getenv("FEISHU_BASE_URL") or "https://open.feishu.cn" res = requests.post( f"{base}/open-apis/bot/v2/hook/{bot_key}", json=body, ) return res.json() - mcp_notify/other.py:71-76 (schema)Input schema/parameters for lark_send_text defined via Pydantic Field annotations: text (required str), msgtype (default 'markdown'), bot_key (default ''), is_lark (default 0).
def lark_send_text( text: str = Field(description="消息内容"), msgtype: str = Field("markdown", description="内容类型,仅支持: text/markdown"), bot_key: str = Field("", description="飞书/Lark机器人key,uuid格式,默认从环境变量获取"), is_lark: int = Field(0, description="根据用户描述识别 0:飞书 1:Lark"), ): - mcp_notify/other.py:67-70 (registration)Registration of the tool via @mcp.tool() decorator with title and description metadata.
@mcp.tool( title="飞书/Lark机器人-发送文本消息", description="飞书/Lark群机器人发送文本或Markdown消息", ) - mcp_notify/__init__.py:21-23 (registration)Top-level registration: other.add_tools(mcp) is called in __init__.py which triggers the @mcp.tool() decorator registration.
other.add_tools(mcp) hass.add_tools(mcp) util.add_tools(mcp)