send_message
Send messages to Telegram entities with optional markup and reply functionality, enabling clear and structured communication via the Telegram MCP Server.
Instructions
Send a message to an entity with optional markup and reply
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | No | ||
| entity_id | Yes | ||
| reply_to_message_id | No |
Implementation Reference
- mcp-server/mcp-server.py:50-63 (handler)MCP tool handler for 'send_message' that makes a POST request to the HTTP API endpoint to send the message.async def send_message( entity_id: int | str, content: str = "", reply_to_message_id: int = None, ) -> dict: return post( f"{api_endpoint}send_message", json={ "entity": entity_id, "content": content, "reply_to_message_id": reply_to_message_id, }, headers={"Content-Type": "application/json"}, ).json()
- mcp-server/mcp-server.py:46-49 (registration)Registration of the 'send_message' MCP tool using the @mcp.tool decorator.@mcp.tool( name="send_message", description="Send a message to an entity with optional markup and reply", )
- http-server/http-api.py:142-146 (schema)Pydantic schema (BaseModel) for the input parameters of the send_message HTTP endpoint, matching the MCP tool parameters.class SendMessagePost(BaseModel): entity: int | str content: str reply_message_id: int = None
- http-server/http-api.py:148-163 (handler)HTTP POST endpoint handler for send_message that executes the actual Telegram client.send_message call.@app.post("/send_message") async def send_message(post_msg: SendMessagePost): e_obj = await get_entity(entity=post_msg.entity, raw=True) message = await client.send_message( entity=e_obj, message=post_msg.content, reply_to=post_msg.reply_message_id, parse_mode="html", ) if isinstance(message, types.Message) and message.id: return {"message_id": message.id} else: raise HTTPException(status_code=404, detail="Error sending message")