@fre4x/telegram 1.1.3 → 1.1.4
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.
- package/README.md +10 -5
- package/dist/index.js +41 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Telegram MCP server implementing Claude Code Channels for bidirectional communic
|
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
- **Push Notifications:** Sends incoming Telegram messages
|
|
7
|
+
- **Push Notifications:** Sends incoming Telegram messages to the connected MCP client via `notifications/message` (claude/channel protocol).
|
|
8
8
|
- **Bidirectional Chat:** Allows Claude to send messages to Telegram using the `send_telegram_message` tool.
|
|
9
9
|
- **Security:** Filters incoming messages based on an allowed user ID.
|
|
10
10
|
- **Remote Control:** (Planned) Approve or deny Claude's tool-use prompts from your mobile device.
|
|
@@ -62,14 +62,19 @@ If you are using this plugin as a bidirectional Claude Code channel rather than
|
|
|
62
62
|
claude --channels plugin:telegram --dangerously-load-development-channels
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
-
##
|
|
65
|
+
## Mock Mode
|
|
66
|
+
|
|
67
|
+
Run without a real bot token (returns fixture data of identical shape):
|
|
66
68
|
|
|
67
69
|
```bash
|
|
68
|
-
|
|
70
|
+
MOCK=true npx @fre4x/telegram
|
|
69
71
|
```
|
|
70
72
|
|
|
71
|
-
|
|
73
|
+
## Development
|
|
72
74
|
|
|
73
75
|
```bash
|
|
74
|
-
npm run
|
|
76
|
+
npm run dev # tsx, no build
|
|
77
|
+
npm run build # esbuild → dist/
|
|
78
|
+
npm test # vitest unit tests (MOCK=true)
|
|
79
|
+
npm run inspector # MCP Inspector (MOCK=true)
|
|
75
80
|
```
|
package/dist/index.js
CHANGED
|
@@ -28622,10 +28622,24 @@ var server = new Server(
|
|
|
28622
28622
|
},
|
|
28623
28623
|
{
|
|
28624
28624
|
capabilities: {
|
|
28625
|
-
tools: {}
|
|
28626
|
-
|
|
28625
|
+
tools: {},
|
|
28626
|
+
logging: {},
|
|
28627
|
+
// Required by SDK for notifications/message
|
|
28628
|
+
experimental: {
|
|
28629
|
+
"claude/channel": {
|
|
28630
|
+
description: "Telegram events are delivered via channel notifications"
|
|
28631
|
+
}
|
|
28632
|
+
}
|
|
28633
|
+
},
|
|
28634
|
+
instructions: "Telegram MCP server. Delivers inbound Telegram messages as channel notifications via notifications/message."
|
|
28627
28635
|
}
|
|
28628
28636
|
);
|
|
28637
|
+
var isInitialized = false;
|
|
28638
|
+
server.oninitialized = () => {
|
|
28639
|
+
isInitialized = true;
|
|
28640
|
+
};
|
|
28641
|
+
var seenMessageIds = /* @__PURE__ */ new Set();
|
|
28642
|
+
var MAX_SEEN_IDS = 500;
|
|
28629
28643
|
var isImage = (filePath) => {
|
|
28630
28644
|
const ext = path.extname(filePath).toLowerCase();
|
|
28631
28645
|
return [".jpg", ".jpeg", ".png", ".gif", ".webp", ".bmp"].includes(ext);
|
|
@@ -28962,18 +28976,37 @@ if (bot) {
|
|
|
28962
28976
|
if (messageHistory.length > MAX_HISTORY) {
|
|
28963
28977
|
messageHistory.shift();
|
|
28964
28978
|
}
|
|
28979
|
+
if (!isInitialized) {
|
|
28980
|
+
console.warn(
|
|
28981
|
+
`[telegram] Pre-init notification dropped (message_id=${metadata.message_id})`
|
|
28982
|
+
);
|
|
28983
|
+
return;
|
|
28984
|
+
}
|
|
28985
|
+
const msgId = metadata.message_id;
|
|
28986
|
+
if (seenMessageIds.has(msgId)) {
|
|
28987
|
+
return;
|
|
28988
|
+
}
|
|
28989
|
+
if (seenMessageIds.size >= MAX_SEEN_IDS) {
|
|
28990
|
+
seenMessageIds.delete(seenMessageIds.values().next().value);
|
|
28991
|
+
}
|
|
28992
|
+
seenMessageIds.add(msgId);
|
|
28965
28993
|
try {
|
|
28966
28994
|
await server.notification({
|
|
28967
|
-
method: "notifications/
|
|
28995
|
+
method: "notifications/message",
|
|
28968
28996
|
params: {
|
|
28969
|
-
|
|
28970
|
-
|
|
28971
|
-
|
|
28972
|
-
|
|
28997
|
+
_meta: {
|
|
28998
|
+
channel: "telegram"
|
|
28999
|
+
},
|
|
29000
|
+
content: [
|
|
29001
|
+
{
|
|
29002
|
+
type: "text",
|
|
29003
|
+
text: `New message from ${senderId} in ${chatTitle} (${chatId}): ${messageContent}`
|
|
29004
|
+
}
|
|
29005
|
+
]
|
|
28973
29006
|
}
|
|
28974
29007
|
});
|
|
28975
29008
|
} catch (error48) {
|
|
28976
|
-
console.error("Failed to push notification:", error48);
|
|
29009
|
+
console.error("Failed to push channel notification:", error48);
|
|
28977
29010
|
}
|
|
28978
29011
|
});
|
|
28979
29012
|
}
|
package/package.json
CHANGED