telegram-mcp-server 0.2.2__tar.gz → 0.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {telegram_mcp_server-0.2.2/telegram_mcp_server.egg-info → telegram_mcp_server-0.2.3}/PKG-INFO +1 -1
- {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/pyproject.toml +1 -1
- {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/telegram_mcp_server/server.py +58 -17
- {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3/telegram_mcp_server.egg-info}/PKG-INFO +1 -1
- {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/LICENSE +0 -0
- {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/MANIFEST.in +0 -0
- {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/README.md +0 -0
- {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/requirements.txt +0 -0
- {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/setup.cfg +0 -0
- {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/telegram_mcp_server/__init__.py +0 -0
- {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/telegram_mcp_server/__main__.py +0 -0
- {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/telegram_mcp_server/bot.py +0 -0
- {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/telegram_mcp_server/cli.py +0 -0
- {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/telegram_mcp_server/config.py +0 -0
- {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/telegram_mcp_server/message_queue.py +0 -0
- {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/telegram_mcp_server/session.py +0 -0
- {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/telegram_mcp_server.egg-info/SOURCES.txt +0 -0
- {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/telegram_mcp_server.egg-info/dependency_links.txt +0 -0
- {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/telegram_mcp_server.egg-info/entry_points.txt +0 -0
- {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/telegram_mcp_server.egg-info/requires.txt +0 -0
- {telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/telegram_mcp_server.egg-info/top_level.txt +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "telegram-mcp-server"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.3"
|
|
8
8
|
description = "Remote control Claude Code via Telegram - MCP Server with Dynamic Buttons"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -92,17 +92,20 @@ async def send_telegram_message(chat_id: str, message: str, parse_mode: str = "M
|
|
|
92
92
|
async with httpx.AsyncClient() as client:
|
|
93
93
|
response = await client.post(url, json=payload, timeout=10.0)
|
|
94
94
|
response.raise_for_status()
|
|
95
|
-
except
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
except httpx.HTTPStatusError as e:
|
|
96
|
+
if e.response.status_code == 400 and parse_mode:
|
|
97
|
+
# Markdown parsing failed, retry without parse_mode
|
|
98
|
+
logger.warning(f"Markdown parsing failed (400 Bad Request), retrying as plain text")
|
|
99
99
|
payload.pop("parse_mode", None)
|
|
100
100
|
async with httpx.AsyncClient() as client:
|
|
101
101
|
response = await client.post(url, json=payload, timeout=10.0)
|
|
102
102
|
response.raise_for_status()
|
|
103
|
-
|
|
104
|
-
logger.error(f"Failed to send Telegram message: {
|
|
103
|
+
else:
|
|
104
|
+
logger.error(f"Failed to send Telegram message: {e}")
|
|
105
105
|
raise
|
|
106
|
+
except Exception as e:
|
|
107
|
+
logger.error(f"Failed to send Telegram message: {e}")
|
|
108
|
+
raise
|
|
106
109
|
|
|
107
110
|
|
|
108
111
|
def get_poll_interval(elapsed_seconds: float) -> int:
|
|
@@ -129,9 +132,14 @@ async def list_tools() -> list[Tool]:
|
|
|
129
132
|
Tool(
|
|
130
133
|
name="telegram_notify",
|
|
131
134
|
description="""
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
+
⚠️ 这是 Telegram MCP Server 的通知工具
|
|
136
|
+
用于向用户的 Telegram Bot 发送任务进度通知
|
|
137
|
+
|
|
138
|
+
❌ 这不是通用的 Telegram 消息发送工具
|
|
139
|
+
❌ 不能发送消息到任意 Telegram 用户或群组
|
|
140
|
+
✅ 只能发送通知到配置的 Telegram Bot(用户会在 Telegram 中收到)
|
|
141
|
+
|
|
142
|
+
💡 推荐使用 telegram_notify_with_actions 代替此工具
|
|
135
143
|
telegram_notify_with_actions 提供动态按钮,用户体验更好
|
|
136
144
|
|
|
137
145
|
此工具适用于:
|
|
@@ -178,6 +186,13 @@ async def list_tools() -> list[Tool]:
|
|
|
178
186
|
description="""
|
|
179
187
|
⭐ 推荐:发送带有动态操作按钮的智能通知到 Telegram
|
|
180
188
|
|
|
189
|
+
⚠️ 这是 Telegram MCP Server 的通知工具(增强版)
|
|
190
|
+
用于向用户的 Telegram Bot 发送任务进度通知,并提供智能操作建议
|
|
191
|
+
|
|
192
|
+
❌ 这不是通用的 Telegram 消息发送工具
|
|
193
|
+
❌ 不能发送消息到任意 Telegram 用户或群组
|
|
194
|
+
✅ 只能发送通知到配置的 Telegram Bot(用户会在 Telegram 中收到)
|
|
195
|
+
|
|
181
196
|
这是 telegram_notify 的增强版本,可以根据当前情况为用户提供智能的下一步操作建议。
|
|
182
197
|
|
|
183
198
|
优势:
|
|
@@ -529,16 +544,31 @@ async def list_tools() -> list[Tool]:
|
|
|
529
544
|
Tool(
|
|
530
545
|
name="telegram_unattended_mode",
|
|
531
546
|
description="""
|
|
532
|
-
|
|
547
|
+
⚠️ 这是 Telegram MCP Server 的无人值守模式工具
|
|
548
|
+
用于等待用户通过 Telegram Bot 发送的下一步指令
|
|
549
|
+
|
|
550
|
+
❌ 这不是通用的 Telegram 操作工具
|
|
551
|
+
❌ 不用于发送 Telegram 消息(使用 telegram_notify 系列工具)
|
|
552
|
+
❌ 不用于管理 Telegram 群组或频道
|
|
553
|
+
|
|
554
|
+
✅ 正确用途:远程任务循环 - 等待用户通过 Telegram 发送指令
|
|
533
555
|
|
|
534
556
|
工作流程:
|
|
535
557
|
1. 执行当前任务
|
|
536
|
-
2.
|
|
537
|
-
|
|
538
|
-
- 遇到关键问题/错误:使用 telegram_send_code 展示问题代码
|
|
539
|
-
- 用户明确要求:使用 telegram_send_file 发送文件
|
|
540
|
-
3. 调用 telegram_unattended_mode 等待下一步指令(静默等待,不发送额外提示)
|
|
558
|
+
2. 使用 telegram_notify_with_actions 发送结果(带智能按钮)
|
|
559
|
+
3. 调用 telegram_unattended_mode 等待用户通过 Telegram 发送的下一步指令
|
|
541
560
|
4. 收到指令后执行,重复循环
|
|
561
|
+
|
|
562
|
+
示例场景:
|
|
563
|
+
用户说:"进入无人值守模式,任务:分析项目结构"
|
|
564
|
+
|
|
565
|
+
你应该:
|
|
566
|
+
1. 分析项目结构
|
|
567
|
+
2. 调用 telegram_notify_with_actions 发送分析结果
|
|
568
|
+
3. 调用 telegram_unattended_mode 等待下一步指令
|
|
569
|
+
4. 用户在 Telegram 中发送"优化性能"
|
|
570
|
+
5. 你收到指令,执行优化
|
|
571
|
+
6. 重复步骤 2-5
|
|
542
572
|
|
|
543
573
|
⚠️ 重要:
|
|
544
574
|
- 完成任务后必须调用通知工具发送结果
|
|
@@ -820,8 +850,19 @@ async def handle_telegram_notify_with_actions(session, arguments: dict) -> list[
|
|
|
820
850
|
payload["reply_markup"] = {"inline_keyboard": keyboard}
|
|
821
851
|
|
|
822
852
|
async with httpx.AsyncClient() as client:
|
|
823
|
-
|
|
824
|
-
|
|
853
|
+
try:
|
|
854
|
+
# Try with Markdown first
|
|
855
|
+
response = await client.post(url, json=payload, timeout=10.0)
|
|
856
|
+
response.raise_for_status()
|
|
857
|
+
except httpx.HTTPStatusError as e:
|
|
858
|
+
if e.response.status_code == 400:
|
|
859
|
+
# Markdown parsing failed, retry without parse_mode
|
|
860
|
+
logger.warning(f"Markdown parsing failed, retrying as plain text")
|
|
861
|
+
payload.pop("parse_mode", None)
|
|
862
|
+
response = await client.post(url, json=payload, timeout=10.0)
|
|
863
|
+
response.raise_for_status()
|
|
864
|
+
else:
|
|
865
|
+
raise
|
|
825
866
|
|
|
826
867
|
return [TextContent(
|
|
827
868
|
type="text",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/telegram_mcp_server/message_queue.py
RENAMED
|
File without changes
|
|
File without changes
|
{telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/telegram_mcp_server.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/telegram_mcp_server.egg-info/requires.txt
RENAMED
|
File without changes
|
{telegram_mcp_server-0.2.2 → telegram_mcp_server-0.2.3}/telegram_mcp_server.egg-info/top_level.txt
RENAMED
|
File without changes
|