feat(mcp): add Telegram Bot API server#2
Open
kaebmoo wants to merge 11 commits into
Open
Conversation
branch `feat/telegram-mcp` ปรับหลัก ๆ: - Telegram HTTP 400/403 จะ parse JSON body ก่อน `raise_for_status()` แล้ว surface `description` เช่น `chat not found` - SSE default bind จาก `0.0.0.0` เป็น `127.0.0.1`, override ได้ด้วย `MCP_HOST` - เพิ่ม `TELEGRAM_ALLOWED_FILE_ROOTS` สำหรับ sandbox ไฟล์ upload - เพิ่ม size guard: photo 10 MB, document 50 MB - `_telegram_result` คืน raw result แล้ว caller จัดการเอง - validate `parse_mode` และข้อความเกิน 4096 chars - `getUpdates` 409 webhook conflict จะบอก hint เรื่อง `deleteWebhook` - รองรับ update kinds เพิ่ม: `my_chat_member`, `chat_member`, `chat_join_request` - README เพิ่ม config/security notes และปรับ install command ไม่ hardcode upstream path ที่ยังไม่มีไฟล์ก่อน PR merge เพิ่ม tests จาก 10 เป็น 19 ตัว และผ่านทั้งหมด: ```bash PYTHONPATH=mcp/telegram-mcp/src python3 -m pytest mcp/telegram-mcp/tests # 19 passed ``` ไฟล์ที่แก้: - [server.py](/Users/seal/Documents/GitHub/thclaws-marketplace/mcp/telegram-mcp/src/telegram_mcp/server.py) - [test_server.py](/Users/seal/Documents/GitHub/thclaws-marketplace/mcp/telegram-mcp/tests/test_server.py) - [README.md](/Users/seal/Documents/GitHub/thclaws-marketplace/mcp/telegram-mcp/README.md)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a Telegram MCP server under
mcp/telegram-mcpso thClaws agents can send messages, photos, documents, and read recent bot updates through the Telegram Bot API.Scope
This is an MCP tool surface for agent-initiated Telegram communication. It is intentionally not a Telegram UI bridge for thClaws.
Included tools:
telegram_send_messagetelegram_send_phototelegram_send_documenttelegram_get_updatesSecurity
TELEGRAM_BOT_TOKENTELEGRAM_ALLOWED_CHAT_IDSTELEGRAM_ALLOWED_FILE_ROOTSfor file uploadsO_NOFOLLOWwhere supported127.0.0.1by defaultDocumentation
The README covers:
.thclaws/mcp.jsonsetupTesting
PYTHONPATH=mcp/telegram-mcp/src python3 -m pytest mcp/telegram-mcp/teststools/liststdio smoke testtelegram_send_messagestdio smoke testNotes
This PR does not modify thClaws core. A full Telegram chat UI would require a separate bridge or core transport design and is documented as future work.