@overpod/mcp-telegram 1.23.0 → 1.24.0
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 +43 -0
- package/dist/telegram-client.d.ts +26 -0
- package/dist/telegram-client.js +112 -0
- package/dist/tools/index.js +2 -0
- package/dist/tools/stickers.d.ts +3 -0
- package/dist/tools/stickers.js +139 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -130,6 +130,31 @@ mcp-telegram # run server
|
|
|
130
130
|
mcp-telegram login # QR login
|
|
131
131
|
```
|
|
132
132
|
|
|
133
|
+
### Pre-built binary (no runtime needed)
|
|
134
|
+
|
|
135
|
+
Download from [Releases](https://github.com/overpod/mcp-telegram/releases) — standalone single-file binaries, zero dependencies:
|
|
136
|
+
|
|
137
|
+
| Platform | Server | Login CLI |
|
|
138
|
+
|----------|--------|-----------|
|
|
139
|
+
| Linux x64 | `mcp-telegram-linux-x64` | `mcp-telegram-login-linux-x64` |
|
|
140
|
+
| Linux ARM64 | `mcp-telegram-linux-arm64` | `mcp-telegram-login-linux-arm64` |
|
|
141
|
+
| macOS x64 | `mcp-telegram-darwin-x64` | `mcp-telegram-login-darwin-x64` |
|
|
142
|
+
| macOS ARM64 | `mcp-telegram-darwin-arm64` | `mcp-telegram-login-darwin-arm64` |
|
|
143
|
+
| Windows x64 | `mcp-telegram-windows-x64.exe` | `mcp-telegram-login-windows-x64.exe` |
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
# Download (example for Linux x64)
|
|
147
|
+
curl -L -o mcp-telegram https://github.com/overpod/mcp-telegram/releases/latest/download/mcp-telegram-linux-x64
|
|
148
|
+
curl -L -o mcp-telegram-login https://github.com/overpod/mcp-telegram/releases/latest/download/mcp-telegram-login-linux-x64
|
|
149
|
+
chmod +x mcp-telegram mcp-telegram-login
|
|
150
|
+
|
|
151
|
+
# Login
|
|
152
|
+
TELEGRAM_API_ID=YOUR_ID TELEGRAM_API_HASH=YOUR_HASH ./mcp-telegram-login
|
|
153
|
+
|
|
154
|
+
# Run
|
|
155
|
+
./mcp-telegram
|
|
156
|
+
```
|
|
157
|
+
|
|
133
158
|
### From source
|
|
134
159
|
|
|
135
160
|
```bash
|
|
@@ -208,6 +233,24 @@ claude mcp add telegram -s user \
|
|
|
208
233
|
|
|
209
234
|
> **Note**: No terminal required! Login works entirely through Claude Desktop.
|
|
210
235
|
|
|
236
|
+
### Claude Desktop (Binary)
|
|
237
|
+
|
|
238
|
+
Same setup, but using the pre-built binary instead of npx:
|
|
239
|
+
|
|
240
|
+
```json
|
|
241
|
+
{
|
|
242
|
+
"mcpServers": {
|
|
243
|
+
"telegram": {
|
|
244
|
+
"command": "/path/to/mcp-telegram",
|
|
245
|
+
"env": {
|
|
246
|
+
"TELEGRAM_API_ID": "YOUR_ID",
|
|
247
|
+
"TELEGRAM_API_HASH": "YOUR_HASH"
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
211
254
|
### Claude Desktop (Docker)
|
|
212
255
|
|
|
213
256
|
1. Login via terminal first (see [Docker](#docker) section above).
|
|
@@ -370,4 +370,30 @@ export declare class TelegramService {
|
|
|
370
370
|
bio?: string;
|
|
371
371
|
}): Promise<void>;
|
|
372
372
|
updateUsername(username: string): Promise<void>;
|
|
373
|
+
getStickerSet(shortName: string): Promise<{
|
|
374
|
+
title: string;
|
|
375
|
+
shortName: string;
|
|
376
|
+
count: number;
|
|
377
|
+
stickers: Array<{
|
|
378
|
+
id: string;
|
|
379
|
+
accessHash: string;
|
|
380
|
+
emoji: string;
|
|
381
|
+
}>;
|
|
382
|
+
}>;
|
|
383
|
+
searchStickerSets(query: string): Promise<Array<{
|
|
384
|
+
title: string;
|
|
385
|
+
shortName: string;
|
|
386
|
+
count: number;
|
|
387
|
+
}>>;
|
|
388
|
+
getInstalledStickerSets(): Promise<Array<{
|
|
389
|
+
title: string;
|
|
390
|
+
shortName: string;
|
|
391
|
+
count: number;
|
|
392
|
+
}>>;
|
|
393
|
+
sendSticker(chatId: string, stickerSetShortName: string, stickerIndex: number, replyTo?: number): Promise<Api.Message | Api.UpdateShortSentMessage | undefined>;
|
|
394
|
+
getRecentStickers(): Promise<Array<{
|
|
395
|
+
id: string;
|
|
396
|
+
accessHash: string;
|
|
397
|
+
emoji: string;
|
|
398
|
+
}>>;
|
|
373
399
|
}
|
package/dist/telegram-client.js
CHANGED
|
@@ -1832,4 +1832,116 @@ export class TelegramService {
|
|
|
1832
1832
|
throw new Error(NOT_CONNECTED_ERROR);
|
|
1833
1833
|
await this.client.invoke(new Api.account.UpdateUsername({ username }));
|
|
1834
1834
|
}
|
|
1835
|
+
// ─── Stickers ──────────────────────────────────────────────
|
|
1836
|
+
async getStickerSet(shortName) {
|
|
1837
|
+
if (!this.client || !this.connected)
|
|
1838
|
+
throw new Error(NOT_CONNECTED_ERROR);
|
|
1839
|
+
const result = await this.client.invoke(new Api.messages.GetStickerSet({
|
|
1840
|
+
stickerset: new Api.InputStickerSetShortName({ shortName }),
|
|
1841
|
+
hash: 0,
|
|
1842
|
+
}));
|
|
1843
|
+
if (result instanceof Api.messages.StickerSetNotModified) {
|
|
1844
|
+
throw new Error("Sticker set was not modified");
|
|
1845
|
+
}
|
|
1846
|
+
const set = result.set;
|
|
1847
|
+
const packs = result.packs;
|
|
1848
|
+
// Build emoji map: document id -> emoji
|
|
1849
|
+
const emojiMap = new Map();
|
|
1850
|
+
for (const pack of packs) {
|
|
1851
|
+
for (const docId of pack.documents) {
|
|
1852
|
+
emojiMap.set(docId.toString(), pack.emoticon);
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
return {
|
|
1856
|
+
title: set.title,
|
|
1857
|
+
shortName: set.shortName,
|
|
1858
|
+
count: set.count,
|
|
1859
|
+
stickers: result.documents.map((doc) => ({
|
|
1860
|
+
id: doc.id.toString(),
|
|
1861
|
+
accessHash: doc.accessHash.toString(),
|
|
1862
|
+
emoji: emojiMap.get(doc.id.toString()) || "",
|
|
1863
|
+
})),
|
|
1864
|
+
};
|
|
1865
|
+
}
|
|
1866
|
+
async searchStickerSets(query) {
|
|
1867
|
+
if (!this.client || !this.connected)
|
|
1868
|
+
throw new Error(NOT_CONNECTED_ERROR);
|
|
1869
|
+
const result = await this.client.invoke(new Api.messages.SearchStickerSets({
|
|
1870
|
+
q: query,
|
|
1871
|
+
hash: bigInt(0),
|
|
1872
|
+
}));
|
|
1873
|
+
if (result instanceof Api.messages.FoundStickerSetsNotModified) {
|
|
1874
|
+
return [];
|
|
1875
|
+
}
|
|
1876
|
+
return result.sets.map((covered) => {
|
|
1877
|
+
const set = covered.set;
|
|
1878
|
+
return {
|
|
1879
|
+
title: set.title,
|
|
1880
|
+
shortName: set.shortName,
|
|
1881
|
+
count: set.count,
|
|
1882
|
+
};
|
|
1883
|
+
});
|
|
1884
|
+
}
|
|
1885
|
+
async getInstalledStickerSets() {
|
|
1886
|
+
if (!this.client || !this.connected)
|
|
1887
|
+
throw new Error(NOT_CONNECTED_ERROR);
|
|
1888
|
+
const result = await this.client.invoke(new Api.messages.GetAllStickers({ hash: bigInt(0) }));
|
|
1889
|
+
if (result instanceof Api.messages.AllStickersNotModified) {
|
|
1890
|
+
return [];
|
|
1891
|
+
}
|
|
1892
|
+
return result.sets.map((set) => ({
|
|
1893
|
+
title: set.title,
|
|
1894
|
+
shortName: set.shortName,
|
|
1895
|
+
count: set.count,
|
|
1896
|
+
}));
|
|
1897
|
+
}
|
|
1898
|
+
async sendSticker(chatId, stickerSetShortName, stickerIndex, replyTo) {
|
|
1899
|
+
if (!this.client || !this.connected)
|
|
1900
|
+
throw new Error(NOT_CONNECTED_ERROR);
|
|
1901
|
+
return await this.rateLimiter.execute(async () => {
|
|
1902
|
+
if (!Number.isInteger(stickerIndex)) {
|
|
1903
|
+
throw new Error(`Sticker index must be an integer, got ${stickerIndex}`);
|
|
1904
|
+
}
|
|
1905
|
+
// Fetch raw sticker set to get the actual Api.Document with valid fileReference
|
|
1906
|
+
const rawResult = await this.client?.invoke(new Api.messages.GetStickerSet({
|
|
1907
|
+
stickerset: new Api.InputStickerSetShortName({ shortName: stickerSetShortName }),
|
|
1908
|
+
hash: 0,
|
|
1909
|
+
}));
|
|
1910
|
+
if (!rawResult || rawResult instanceof Api.messages.StickerSetNotModified) {
|
|
1911
|
+
throw new Error("Sticker set not found");
|
|
1912
|
+
}
|
|
1913
|
+
const stickerSet = rawResult;
|
|
1914
|
+
if (stickerIndex < 0 || stickerIndex >= stickerSet.documents.length) {
|
|
1915
|
+
throw new Error(`Sticker index ${stickerIndex} out of range (0-${stickerSet.documents.length - 1})`);
|
|
1916
|
+
}
|
|
1917
|
+
const sticker = stickerSet.documents[stickerIndex];
|
|
1918
|
+
if (!(sticker instanceof Api.Document)) {
|
|
1919
|
+
throw new Error("Selected sticker is not a valid document");
|
|
1920
|
+
}
|
|
1921
|
+
const resolved = await this.resolvePeer(chatId);
|
|
1922
|
+
return await this.client?.sendFile(resolved, {
|
|
1923
|
+
file: sticker,
|
|
1924
|
+
...(replyTo ? { replyTo } : {}),
|
|
1925
|
+
});
|
|
1926
|
+
}, `sendSticker to ${chatId}`);
|
|
1927
|
+
}
|
|
1928
|
+
async getRecentStickers() {
|
|
1929
|
+
if (!this.client || !this.connected)
|
|
1930
|
+
throw new Error(NOT_CONNECTED_ERROR);
|
|
1931
|
+
const result = await this.client.invoke(new Api.messages.GetRecentStickers({ hash: bigInt(0) }));
|
|
1932
|
+
if (result instanceof Api.messages.RecentStickersNotModified) {
|
|
1933
|
+
return [];
|
|
1934
|
+
}
|
|
1935
|
+
const emojiMap = new Map();
|
|
1936
|
+
for (const pack of result.packs) {
|
|
1937
|
+
for (const docId of pack.documents) {
|
|
1938
|
+
emojiMap.set(docId.toString(), pack.emoticon);
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
return result.stickers.map((doc) => ({
|
|
1942
|
+
id: doc.id.toString(),
|
|
1943
|
+
accessHash: doc.accessHash.toString(),
|
|
1944
|
+
emoji: emojiMap.get(doc.id.toString()) || "",
|
|
1945
|
+
}));
|
|
1946
|
+
}
|
|
1835
1947
|
}
|
package/dist/tools/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import { registerExtraTools } from "./extras.js";
|
|
|
6
6
|
import { registerMediaTools } from "./media.js";
|
|
7
7
|
import { registerMessageTools } from "./messages.js";
|
|
8
8
|
import { registerReactionTools } from "./reactions.js";
|
|
9
|
+
import { registerStickerTools } from "./stickers.js";
|
|
9
10
|
export function registerTools(server, telegram) {
|
|
10
11
|
registerAuthTools(server, telegram);
|
|
11
12
|
registerMessageTools(server, telegram);
|
|
@@ -15,4 +16,5 @@ export function registerTools(server, telegram) {
|
|
|
15
16
|
registerReactionTools(server, telegram);
|
|
16
17
|
registerExtraTools(server, telegram);
|
|
17
18
|
registerAccountTools(server, telegram);
|
|
19
|
+
registerStickerTools(server, telegram);
|
|
18
20
|
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { fail, ok, READ_ONLY, requireConnection, sanitize, WRITE } from "./shared.js";
|
|
3
|
+
export function registerStickerTools(server, telegram) {
|
|
4
|
+
server.registerTool("telegram-get-sticker-set", {
|
|
5
|
+
description: "Get all stickers from a sticker set by its short name. Returns each sticker with index and emoji. Use the index with telegram-send-sticker to send a specific sticker",
|
|
6
|
+
inputSchema: {
|
|
7
|
+
shortName: z
|
|
8
|
+
.string()
|
|
9
|
+
.describe("Short name of the sticker set (e.g. 'AnimatedEmojis', 'HotCherry'). Find names via telegram-search-sticker-sets or from t.me/addstickers/<shortName> links"),
|
|
10
|
+
},
|
|
11
|
+
annotations: READ_ONLY,
|
|
12
|
+
}, async ({ shortName }) => {
|
|
13
|
+
const err = await requireConnection(telegram);
|
|
14
|
+
if (err)
|
|
15
|
+
return fail(new Error(err));
|
|
16
|
+
try {
|
|
17
|
+
const set = await telegram.getStickerSet(shortName);
|
|
18
|
+
const lines = [];
|
|
19
|
+
lines.push(`📦 ${set.title} (${set.shortName})`);
|
|
20
|
+
lines.push(`${set.count} stickers`);
|
|
21
|
+
lines.push("");
|
|
22
|
+
for (let i = 0; i < set.stickers.length; i++) {
|
|
23
|
+
const s = set.stickers[i];
|
|
24
|
+
lines.push(`[${i}] ${s.emoji}`);
|
|
25
|
+
}
|
|
26
|
+
lines.push("");
|
|
27
|
+
lines.push(`Send a sticker: telegram-send-sticker(chatId, stickerSet="${set.shortName}", index=N)`);
|
|
28
|
+
return ok(sanitize(lines.join("\n")));
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
return fail(e);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
server.registerTool("telegram-search-sticker-sets", {
|
|
35
|
+
description: "Search for sticker sets by name or keyword. Returns matching sticker pack names that can be used with telegram-get-sticker-set",
|
|
36
|
+
inputSchema: {
|
|
37
|
+
query: z.string().describe("Search query (e.g. 'cat', 'love', 'pepe', 'anime')"),
|
|
38
|
+
},
|
|
39
|
+
annotations: READ_ONLY,
|
|
40
|
+
}, async ({ query }) => {
|
|
41
|
+
const err = await requireConnection(telegram);
|
|
42
|
+
if (err)
|
|
43
|
+
return fail(new Error(err));
|
|
44
|
+
try {
|
|
45
|
+
const sets = await telegram.searchStickerSets(query);
|
|
46
|
+
if (sets.length === 0) {
|
|
47
|
+
return ok(`No sticker sets found for "${query}". Try different keywords.`);
|
|
48
|
+
}
|
|
49
|
+
const lines = [];
|
|
50
|
+
lines.push(`Found ${sets.length} sticker set(s) for "${query}":\n`);
|
|
51
|
+
for (const set of sets) {
|
|
52
|
+
const flags = "";
|
|
53
|
+
lines.push(`• ${set.title}${flags} — ${set.count} stickers`);
|
|
54
|
+
lines.push(` Short name: ${set.shortName}`);
|
|
55
|
+
}
|
|
56
|
+
lines.push("");
|
|
57
|
+
lines.push("Use telegram-get-sticker-set(shortName) to see individual stickers.");
|
|
58
|
+
return ok(sanitize(lines.join("\n")));
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
return fail(e);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
server.registerTool("telegram-get-installed-stickers", {
|
|
65
|
+
description: "List all sticker sets installed by the user. Returns pack names and short names for use with other sticker tools",
|
|
66
|
+
inputSchema: {},
|
|
67
|
+
annotations: READ_ONLY,
|
|
68
|
+
}, async () => {
|
|
69
|
+
const err = await requireConnection(telegram);
|
|
70
|
+
if (err)
|
|
71
|
+
return fail(new Error(err));
|
|
72
|
+
try {
|
|
73
|
+
const sets = await telegram.getInstalledStickerSets();
|
|
74
|
+
if (sets.length === 0) {
|
|
75
|
+
return ok("No sticker sets installed.");
|
|
76
|
+
}
|
|
77
|
+
const lines = [];
|
|
78
|
+
lines.push(`${sets.length} installed sticker set(s):\n`);
|
|
79
|
+
for (const set of sets) {
|
|
80
|
+
const flags = "";
|
|
81
|
+
lines.push(`• ${set.title}${flags} — ${set.count} stickers`);
|
|
82
|
+
lines.push(` Short name: ${set.shortName}`);
|
|
83
|
+
}
|
|
84
|
+
return ok(sanitize(lines.join("\n")));
|
|
85
|
+
}
|
|
86
|
+
catch (e) {
|
|
87
|
+
return fail(e);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
server.registerTool("telegram-send-sticker", {
|
|
91
|
+
description: "Send a sticker from a sticker set to a chat. First use telegram-get-sticker-set to browse available stickers and find the index",
|
|
92
|
+
inputSchema: {
|
|
93
|
+
chatId: z.string().describe("Chat ID or username"),
|
|
94
|
+
stickerSet: z.string().describe("Short name of the sticker set (e.g. 'HotCherry')"),
|
|
95
|
+
index: z
|
|
96
|
+
.number()
|
|
97
|
+
.int()
|
|
98
|
+
.nonnegative()
|
|
99
|
+
.describe("Index of the sticker in the set (0-based, get from telegram-get-sticker-set)"),
|
|
100
|
+
replyTo: z.number().int().optional().describe("Message ID to reply to"),
|
|
101
|
+
},
|
|
102
|
+
annotations: WRITE,
|
|
103
|
+
}, async ({ chatId, stickerSet, index, replyTo }) => {
|
|
104
|
+
const err = await requireConnection(telegram);
|
|
105
|
+
if (err)
|
|
106
|
+
return fail(new Error(err));
|
|
107
|
+
try {
|
|
108
|
+
await telegram.sendSticker(chatId, stickerSet, index, replyTo);
|
|
109
|
+
return ok(`Sticker sent from "${stickerSet}" [${index}] to ${chatId}`);
|
|
110
|
+
}
|
|
111
|
+
catch (e) {
|
|
112
|
+
return fail(e);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
server.registerTool("telegram-get-recent-stickers", {
|
|
116
|
+
description: "Get recently used stickers. Returns each sticker with its list index and associated emoji",
|
|
117
|
+
inputSchema: {},
|
|
118
|
+
annotations: READ_ONLY,
|
|
119
|
+
}, async () => {
|
|
120
|
+
const err = await requireConnection(telegram);
|
|
121
|
+
if (err)
|
|
122
|
+
return fail(new Error(err));
|
|
123
|
+
try {
|
|
124
|
+
const stickers = await telegram.getRecentStickers();
|
|
125
|
+
if (stickers.length === 0) {
|
|
126
|
+
return ok("No recent stickers.");
|
|
127
|
+
}
|
|
128
|
+
const lines = [];
|
|
129
|
+
lines.push(`${stickers.length} recent sticker(s):\n`);
|
|
130
|
+
for (let i = 0; i < stickers.length; i++) {
|
|
131
|
+
lines.push(`[${i}] ${stickers[i].emoji}`);
|
|
132
|
+
}
|
|
133
|
+
return ok(sanitize(lines.join("\n")));
|
|
134
|
+
}
|
|
135
|
+
catch (e) {
|
|
136
|
+
return fail(e);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
package/package.json
CHANGED