@ebowwa/mcp-telegram 0.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/auth-signin.js +182 -0
- package/auth-signin.ts +122 -0
- package/auth-verify.js +234 -0
- package/auth-verify.ts +180 -0
- package/auth.js +154 -0
- package/auth.ts +98 -0
- package/bun.lock +302 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +807 -0
- package/dist/index.js.map +1 -0
- package/package.json +52 -0
- package/src/index.js +918 -0
- package/src/index.ts +907 -0
- package/tg.sh +44 -0
- package/tsconfig.json +20 -0
package/src/index.js
ADDED
|
@@ -0,0 +1,918 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* @ebowwa/telegram-mcp - Telegram MTProto Client MCP Server
|
|
5
|
+
*
|
|
6
|
+
* Full-featured Telegram user account integration using GramJS:
|
|
7
|
+
* - Connect/authenticate with API ID and hash
|
|
8
|
+
* - Send messages to users, groups, channels
|
|
9
|
+
* - Get dialogs (chat list)
|
|
10
|
+
* - Get messages from chats
|
|
11
|
+
* - Get entity info (users, chats, channels)
|
|
12
|
+
*
|
|
13
|
+
* Prerequisites:
|
|
14
|
+
* 1. Get API ID and API Hash from https://my.telegram.org/apps
|
|
15
|
+
* 2. First connection requires phone number + verification code
|
|
16
|
+
* 3. Session string is saved for subsequent connections
|
|
17
|
+
*/
|
|
18
|
+
var __assign = (this && this.__assign) || function () {
|
|
19
|
+
__assign = Object.assign || function(t) {
|
|
20
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
21
|
+
s = arguments[i];
|
|
22
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
23
|
+
t[p] = s[p];
|
|
24
|
+
}
|
|
25
|
+
return t;
|
|
26
|
+
};
|
|
27
|
+
return __assign.apply(this, arguments);
|
|
28
|
+
};
|
|
29
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
30
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
31
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
32
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
33
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
34
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
35
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
39
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
40
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
41
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
42
|
+
function step(op) {
|
|
43
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
44
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
45
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
46
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
47
|
+
switch (op[0]) {
|
|
48
|
+
case 0: case 1: t = op; break;
|
|
49
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
50
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
51
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
52
|
+
default:
|
|
53
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
54
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
55
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
56
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
57
|
+
if (t[2]) _.ops.pop();
|
|
58
|
+
_.trys.pop(); continue;
|
|
59
|
+
}
|
|
60
|
+
op = body.call(thisArg, _);
|
|
61
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
62
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
66
|
+
var index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
|
|
67
|
+
var stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
68
|
+
var types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
69
|
+
var telegram_1 = require("telegram");
|
|
70
|
+
var sessions_1 = require("telegram/sessions");
|
|
71
|
+
var telegram_2 = require("telegram");
|
|
72
|
+
var big_integer_1 = require("big-integer");
|
|
73
|
+
var os_1 = require("os");
|
|
74
|
+
var path_1 = require("path");
|
|
75
|
+
var fs_1 = require("fs");
|
|
76
|
+
// ==============
|
|
77
|
+
// Configuration
|
|
78
|
+
// ==============
|
|
79
|
+
var SESSION_DIR = (0, path_1.join)((0, os_1.homedir)(), ".telegram-mcp");
|
|
80
|
+
var SESSION_FILE = (0, path_1.join)(SESSION_DIR, "session.txt");
|
|
81
|
+
// Ensure session directory exists
|
|
82
|
+
if (!(0, fs_1.existsSync)(SESSION_DIR)) {
|
|
83
|
+
(0, fs_1.mkdirSync)(SESSION_DIR, { recursive: true });
|
|
84
|
+
}
|
|
85
|
+
// Global client instance
|
|
86
|
+
var client = null;
|
|
87
|
+
var sessionString = "";
|
|
88
|
+
// ==============
|
|
89
|
+
// Helper Functions
|
|
90
|
+
// ==============
|
|
91
|
+
function loadSession() {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
93
|
+
return __generator(this, function (_a) {
|
|
94
|
+
if ((0, fs_1.existsSync)(SESSION_FILE)) {
|
|
95
|
+
return [2 /*return*/, (0, fs_1.readFileSync)(SESSION_FILE, "utf-8").trim()];
|
|
96
|
+
}
|
|
97
|
+
return [2 /*return*/, ""];
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
function saveSession(session) {
|
|
102
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
103
|
+
return __generator(this, function (_a) {
|
|
104
|
+
(0, fs_1.writeFileSync)(SESSION_FILE, session, "utf-8");
|
|
105
|
+
return [2 /*return*/];
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
function getClient() {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
111
|
+
var apiId, apiHash, savedSession, session;
|
|
112
|
+
return __generator(this, function (_a) {
|
|
113
|
+
switch (_a.label) {
|
|
114
|
+
case 0:
|
|
115
|
+
if (client && client.connected) {
|
|
116
|
+
return [2 /*return*/, client];
|
|
117
|
+
}
|
|
118
|
+
apiId = parseInt(process.env.TELEGRAM_API_ID || "0");
|
|
119
|
+
apiHash = process.env.TELEGRAM_API_HASH;
|
|
120
|
+
if (!apiId || !apiHash) {
|
|
121
|
+
throw new Error("TELEGRAM_API_ID and TELEGRAM_API_HASH environment variables required.");
|
|
122
|
+
}
|
|
123
|
+
return [4 /*yield*/, loadSession()];
|
|
124
|
+
case 1:
|
|
125
|
+
savedSession = _a.sent();
|
|
126
|
+
if (!savedSession) {
|
|
127
|
+
throw new Error("No saved session. Run telegram_connect with phone number first.");
|
|
128
|
+
}
|
|
129
|
+
session = new sessions_1.StringSession(savedSession);
|
|
130
|
+
client = new telegram_1.TelegramClient(session, apiId, apiHash, {
|
|
131
|
+
connectionRetries: 5,
|
|
132
|
+
});
|
|
133
|
+
return [4 /*yield*/, client.connect()];
|
|
134
|
+
case 2:
|
|
135
|
+
_a.sent();
|
|
136
|
+
return [4 /*yield*/, client.checkAuthorization()];
|
|
137
|
+
case 3:
|
|
138
|
+
if (!(_a.sent())) {
|
|
139
|
+
client = null;
|
|
140
|
+
throw new Error("Session expired. Run telegram_connect again.");
|
|
141
|
+
}
|
|
142
|
+
return [2 /*return*/, client];
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
function formatEntity(entity) {
|
|
148
|
+
var _a;
|
|
149
|
+
if (!entity)
|
|
150
|
+
return null;
|
|
151
|
+
var base = {
|
|
152
|
+
id: (_a = entity.id) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
153
|
+
className: entity.className,
|
|
154
|
+
};
|
|
155
|
+
if (entity.className === "User") {
|
|
156
|
+
return __assign(__assign({}, base), { firstName: entity.firstName, lastName: entity.lastName, username: entity.username, phone: entity.phone, bot: entity.bot });
|
|
157
|
+
}
|
|
158
|
+
if (entity.className === "Chat" || entity.className === "Channel") {
|
|
159
|
+
return __assign(__assign({}, base), { title: entity.title, username: entity.username, megagroup: entity.megagroup });
|
|
160
|
+
}
|
|
161
|
+
return base;
|
|
162
|
+
}
|
|
163
|
+
function formatMessage(message) {
|
|
164
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
165
|
+
if (!message)
|
|
166
|
+
return null;
|
|
167
|
+
return {
|
|
168
|
+
id: message.id,
|
|
169
|
+
date: message.date ? new Date(message.date * 1000).toISOString() : null,
|
|
170
|
+
message: message.message,
|
|
171
|
+
fromId: ((_b = (_a = message.fromId) === null || _a === void 0 ? void 0 : _a.userId) === null || _b === void 0 ? void 0 : _b.toString()) || ((_c = message.fromId) === null || _c === void 0 ? void 0 : _c.toString()),
|
|
172
|
+
peerId: ((_e = (_d = message.peerId) === null || _d === void 0 ? void 0 : _d.userId) === null || _e === void 0 ? void 0 : _e.toString()) || ((_g = (_f = message.peerId) === null || _f === void 0 ? void 0 : _f.chatId) === null || _g === void 0 ? void 0 : _g.toString()) || ((_j = (_h = message.peerId) === null || _h === void 0 ? void 0 : _h.channelId) === null || _j === void 0 ? void 0 : _j.toString()),
|
|
173
|
+
out: message.out,
|
|
174
|
+
media: (_k = message.media) === null || _k === void 0 ? void 0 : _k.className,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
// ==============
|
|
178
|
+
// MCP Server
|
|
179
|
+
// ==============
|
|
180
|
+
var server = new index_js_1.Server({
|
|
181
|
+
name: "@ebowwa/telegram-mcp",
|
|
182
|
+
version: "0.1.0",
|
|
183
|
+
}, {
|
|
184
|
+
capabilities: {
|
|
185
|
+
tools: {},
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
// List available tools
|
|
189
|
+
server.setRequestHandler(types_js_1.ListToolsRequestSchema, function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
190
|
+
return __generator(this, function (_a) {
|
|
191
|
+
return [2 /*return*/, {
|
|
192
|
+
tools: [
|
|
193
|
+
// Connection Management
|
|
194
|
+
{
|
|
195
|
+
name: "telegram_connect",
|
|
196
|
+
description: "Connect to Telegram with API credentials. Requires TELEGRAM_API_ID and TELEGRAM_API_HASH env vars. First connection needs phone/code verification.",
|
|
197
|
+
inputSchema: {
|
|
198
|
+
type: "object",
|
|
199
|
+
properties: {
|
|
200
|
+
phoneNumber: {
|
|
201
|
+
type: "string",
|
|
202
|
+
description: "Phone number with country code (e.g., +1234567890). Required for first connection.",
|
|
203
|
+
},
|
|
204
|
+
code: {
|
|
205
|
+
type: "string",
|
|
206
|
+
description: "Verification code received via Telegram. Required after initial phone submission.",
|
|
207
|
+
},
|
|
208
|
+
password: {
|
|
209
|
+
type: "string",
|
|
210
|
+
description: "2FA password if enabled on account.",
|
|
211
|
+
},
|
|
212
|
+
sessionString: {
|
|
213
|
+
type: "string",
|
|
214
|
+
description: "Existing session string to restore (optional, overrides saved session).",
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
name: "telegram_disconnect",
|
|
221
|
+
description: "Disconnect from Telegram and clear the session.",
|
|
222
|
+
inputSchema: {
|
|
223
|
+
type: "object",
|
|
224
|
+
properties: {},
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
name: "telegram_get_session",
|
|
229
|
+
description: "Get the current session string for backup/restore purposes.",
|
|
230
|
+
inputSchema: {
|
|
231
|
+
type: "object",
|
|
232
|
+
properties: {},
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
name: "telegram_get_me",
|
|
237
|
+
description: "Get information about the currently authenticated user.",
|
|
238
|
+
inputSchema: {
|
|
239
|
+
type: "object",
|
|
240
|
+
properties: {},
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
// Messaging
|
|
244
|
+
{
|
|
245
|
+
name: "telegram_send_message",
|
|
246
|
+
description: "Send a message to a user, group, or channel.",
|
|
247
|
+
inputSchema: {
|
|
248
|
+
type: "object",
|
|
249
|
+
properties: {
|
|
250
|
+
entity: {
|
|
251
|
+
type: "string",
|
|
252
|
+
description: "Username, phone, or entity ID to send message to (e.g., 'username', '+1234567890', '123456789')",
|
|
253
|
+
},
|
|
254
|
+
message: {
|
|
255
|
+
type: "string",
|
|
256
|
+
description: "Message text to send",
|
|
257
|
+
},
|
|
258
|
+
parseMode: {
|
|
259
|
+
type: "string",
|
|
260
|
+
enum: ["md", "html", ""],
|
|
261
|
+
description: "Parse mode for formatting (md=Markdown, html=HTML)",
|
|
262
|
+
},
|
|
263
|
+
replyTo: {
|
|
264
|
+
type: "number",
|
|
265
|
+
description: "Message ID to reply to (optional)",
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
required: ["entity", "message"],
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
name: "telegram_get_dialogs",
|
|
273
|
+
description: "Get list of all chats/conversations (dialogs).",
|
|
274
|
+
inputSchema: {
|
|
275
|
+
type: "object",
|
|
276
|
+
properties: {
|
|
277
|
+
limit: {
|
|
278
|
+
type: "number",
|
|
279
|
+
description: "Maximum number of dialogs to return (default: 100)",
|
|
280
|
+
},
|
|
281
|
+
offsetDate: {
|
|
282
|
+
type: "number",
|
|
283
|
+
description: "Offset date for pagination",
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
name: "telegram_get_messages",
|
|
290
|
+
description: "Get messages from a chat/conversation.",
|
|
291
|
+
inputSchema: {
|
|
292
|
+
type: "object",
|
|
293
|
+
properties: {
|
|
294
|
+
entity: {
|
|
295
|
+
type: "string",
|
|
296
|
+
description: "Username, phone, or entity ID of the chat",
|
|
297
|
+
},
|
|
298
|
+
limit: {
|
|
299
|
+
type: "number",
|
|
300
|
+
description: "Maximum number of messages to return (default: 100)",
|
|
301
|
+
},
|
|
302
|
+
offsetId: {
|
|
303
|
+
type: "number",
|
|
304
|
+
description: "Message ID to start from (for pagination)",
|
|
305
|
+
},
|
|
306
|
+
minId: {
|
|
307
|
+
type: "number",
|
|
308
|
+
description: "Minimum message ID to fetch",
|
|
309
|
+
},
|
|
310
|
+
maxId: {
|
|
311
|
+
type: "number",
|
|
312
|
+
description: "Maximum message ID to fetch",
|
|
313
|
+
},
|
|
314
|
+
reverse: {
|
|
315
|
+
type: "boolean",
|
|
316
|
+
description: "Fetch messages in reverse order (oldest first)",
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
required: ["entity"],
|
|
320
|
+
},
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
name: "telegram_get_entity",
|
|
324
|
+
description: "Get information about a user, chat, or channel by username or ID.",
|
|
325
|
+
inputSchema: {
|
|
326
|
+
type: "object",
|
|
327
|
+
properties: {
|
|
328
|
+
entity: {
|
|
329
|
+
type: "string",
|
|
330
|
+
description: "Username, phone, or entity ID to look up",
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
required: ["entity"],
|
|
334
|
+
},
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
name: "telegram_mark_read",
|
|
338
|
+
description: "Mark messages as read in a chat.",
|
|
339
|
+
inputSchema: {
|
|
340
|
+
type: "object",
|
|
341
|
+
properties: {
|
|
342
|
+
entity: {
|
|
343
|
+
type: "string",
|
|
344
|
+
description: "Username, phone, or entity ID of the chat",
|
|
345
|
+
},
|
|
346
|
+
maxId: {
|
|
347
|
+
type: "number",
|
|
348
|
+
description: "Maximum message ID to mark as read (default: latest)",
|
|
349
|
+
},
|
|
350
|
+
},
|
|
351
|
+
required: ["entity"],
|
|
352
|
+
},
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
name: "telegram_delete_messages",
|
|
356
|
+
description: "Delete messages from a chat.",
|
|
357
|
+
inputSchema: {
|
|
358
|
+
type: "object",
|
|
359
|
+
properties: {
|
|
360
|
+
entity: {
|
|
361
|
+
type: "string",
|
|
362
|
+
description: "Username, phone, or entity ID of the chat",
|
|
363
|
+
},
|
|
364
|
+
messageIds: {
|
|
365
|
+
type: "array",
|
|
366
|
+
items: { type: "number" },
|
|
367
|
+
description: "Array of message IDs to delete",
|
|
368
|
+
},
|
|
369
|
+
revoke: {
|
|
370
|
+
type: "boolean",
|
|
371
|
+
description: "Delete for both parties (default: true)",
|
|
372
|
+
},
|
|
373
|
+
},
|
|
374
|
+
required: ["entity", "messageIds"],
|
|
375
|
+
},
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
name: "telegram_edit_message",
|
|
379
|
+
description: "Edit a sent message.",
|
|
380
|
+
inputSchema: {
|
|
381
|
+
type: "object",
|
|
382
|
+
properties: {
|
|
383
|
+
entity: {
|
|
384
|
+
type: "string",
|
|
385
|
+
description: "Username, phone, or entity ID of the chat",
|
|
386
|
+
},
|
|
387
|
+
messageId: {
|
|
388
|
+
type: "number",
|
|
389
|
+
description: "ID of the message to edit",
|
|
390
|
+
},
|
|
391
|
+
message: {
|
|
392
|
+
type: "string",
|
|
393
|
+
description: "New message text",
|
|
394
|
+
},
|
|
395
|
+
parseMode: {
|
|
396
|
+
type: "string",
|
|
397
|
+
enum: ["md", "html", ""],
|
|
398
|
+
description: "Parse mode for formatting",
|
|
399
|
+
},
|
|
400
|
+
},
|
|
401
|
+
required: ["entity", "messageId", "message"],
|
|
402
|
+
},
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
name: "telegram_forward_messages",
|
|
406
|
+
description: "Forward messages to another chat.",
|
|
407
|
+
inputSchema: {
|
|
408
|
+
type: "object",
|
|
409
|
+
properties: {
|
|
410
|
+
fromEntity: {
|
|
411
|
+
type: "string",
|
|
412
|
+
description: "Source chat username or ID",
|
|
413
|
+
},
|
|
414
|
+
toEntity: {
|
|
415
|
+
type: "string",
|
|
416
|
+
description: "Destination chat username or ID",
|
|
417
|
+
},
|
|
418
|
+
messageIds: {
|
|
419
|
+
type: "array",
|
|
420
|
+
items: { type: "number" },
|
|
421
|
+
description: "Array of message IDs to forward",
|
|
422
|
+
},
|
|
423
|
+
},
|
|
424
|
+
required: ["fromEntity", "toEntity", "messageIds"],
|
|
425
|
+
},
|
|
426
|
+
},
|
|
427
|
+
// Contacts & Users
|
|
428
|
+
{
|
|
429
|
+
name: "telegram_get_contacts",
|
|
430
|
+
description: "Get list of contacts.",
|
|
431
|
+
inputSchema: {
|
|
432
|
+
type: "object",
|
|
433
|
+
properties: {
|
|
434
|
+
limit: {
|
|
435
|
+
type: "number",
|
|
436
|
+
description: "Maximum number of contacts to return",
|
|
437
|
+
},
|
|
438
|
+
},
|
|
439
|
+
},
|
|
440
|
+
},
|
|
441
|
+
// Chats & Channels
|
|
442
|
+
{
|
|
443
|
+
name: "telegram_create_group",
|
|
444
|
+
description: "Create a new group chat.",
|
|
445
|
+
inputSchema: {
|
|
446
|
+
type: "object",
|
|
447
|
+
properties: {
|
|
448
|
+
title: {
|
|
449
|
+
type: "string",
|
|
450
|
+
description: "Group title",
|
|
451
|
+
},
|
|
452
|
+
users: {
|
|
453
|
+
type: "array",
|
|
454
|
+
items: { type: "string" },
|
|
455
|
+
description: "Array of user usernames or IDs to add",
|
|
456
|
+
},
|
|
457
|
+
},
|
|
458
|
+
required: ["title", "users"],
|
|
459
|
+
},
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
name: "telegram_get_participants",
|
|
463
|
+
description: "Get participants of a group or channel.",
|
|
464
|
+
inputSchema: {
|
|
465
|
+
type: "object",
|
|
466
|
+
properties: {
|
|
467
|
+
entity: {
|
|
468
|
+
type: "string",
|
|
469
|
+
description: "Group/channel username or ID",
|
|
470
|
+
},
|
|
471
|
+
limit: {
|
|
472
|
+
type: "number",
|
|
473
|
+
description: "Maximum number of participants to return",
|
|
474
|
+
},
|
|
475
|
+
},
|
|
476
|
+
required: ["entity"],
|
|
477
|
+
},
|
|
478
|
+
},
|
|
479
|
+
],
|
|
480
|
+
}];
|
|
481
|
+
});
|
|
482
|
+
}); });
|
|
483
|
+
// Handle tool calls
|
|
484
|
+
server.setRequestHandler(types_js_1.CallToolRequestSchema, function (request) { return __awaiter(void 0, void 0, void 0, function () {
|
|
485
|
+
var _a, name, args, _b, apiId, apiHash, savedSession, _c, session, phoneNumber_1, code_1, password_1, startOptions, me, c, me, c, entity, result, c, limit, dialogs, formatted, c, entity, messages, formatted, c, entity, c, entity, c, entity, c, entity, result, c, fromEntity, toEntity, result, c, result, contacts, c_1, users, result, c, entity, result, participants, error_1;
|
|
486
|
+
var _d, _e, _f;
|
|
487
|
+
return __generator(this, function (_g) {
|
|
488
|
+
switch (_g.label) {
|
|
489
|
+
case 0:
|
|
490
|
+
_a = request.params, name = _a.name, args = _a.arguments;
|
|
491
|
+
_g.label = 1;
|
|
492
|
+
case 1:
|
|
493
|
+
_g.trys.push([1, 61, , 62]);
|
|
494
|
+
_b = name;
|
|
495
|
+
switch (_b) {
|
|
496
|
+
case "telegram_connect": return [3 /*break*/, 2];
|
|
497
|
+
case "telegram_disconnect": return [3 /*break*/, 8];
|
|
498
|
+
case "telegram_get_session": return [3 /*break*/, 11];
|
|
499
|
+
case "telegram_get_me": return [3 /*break*/, 14];
|
|
500
|
+
case "telegram_send_message": return [3 /*break*/, 17];
|
|
501
|
+
case "telegram_get_dialogs": return [3 /*break*/, 21];
|
|
502
|
+
case "telegram_get_messages": return [3 /*break*/, 24];
|
|
503
|
+
case "telegram_get_entity": return [3 /*break*/, 28];
|
|
504
|
+
case "telegram_mark_read": return [3 /*break*/, 31];
|
|
505
|
+
case "telegram_delete_messages": return [3 /*break*/, 35];
|
|
506
|
+
case "telegram_edit_message": return [3 /*break*/, 39];
|
|
507
|
+
case "telegram_forward_messages": return [3 /*break*/, 43];
|
|
508
|
+
case "telegram_get_contacts": return [3 /*break*/, 48];
|
|
509
|
+
case "telegram_create_group": return [3 /*break*/, 51];
|
|
510
|
+
case "telegram_get_participants": return [3 /*break*/, 55];
|
|
511
|
+
}
|
|
512
|
+
return [3 /*break*/, 59];
|
|
513
|
+
case 2:
|
|
514
|
+
apiId = parseInt(process.env.TELEGRAM_API_ID || "0");
|
|
515
|
+
apiHash = process.env.TELEGRAM_API_HASH;
|
|
516
|
+
if (!apiId || !apiHash) {
|
|
517
|
+
throw new Error("TELEGRAM_API_ID and TELEGRAM_API_HASH environment variables required. Get them from https://my.telegram.org/apps");
|
|
518
|
+
}
|
|
519
|
+
_c = (args === null || args === void 0 ? void 0 : args.sessionString);
|
|
520
|
+
if (_c) return [3 /*break*/, 4];
|
|
521
|
+
return [4 /*yield*/, loadSession()];
|
|
522
|
+
case 3:
|
|
523
|
+
_c = (_g.sent());
|
|
524
|
+
_g.label = 4;
|
|
525
|
+
case 4:
|
|
526
|
+
savedSession = _c;
|
|
527
|
+
session = new sessions_1.StringSession(savedSession);
|
|
528
|
+
client = new telegram_1.TelegramClient(session, apiId, apiHash, {
|
|
529
|
+
connectionRetries: 5,
|
|
530
|
+
});
|
|
531
|
+
phoneNumber_1 = args === null || args === void 0 ? void 0 : args.phoneNumber;
|
|
532
|
+
code_1 = args === null || args === void 0 ? void 0 : args.code;
|
|
533
|
+
password_1 = args === null || args === void 0 ? void 0 : args.password;
|
|
534
|
+
startOptions = {
|
|
535
|
+
onError: function (err) { return console.error("Telegram auth error:", err); },
|
|
536
|
+
};
|
|
537
|
+
if (phoneNumber_1) {
|
|
538
|
+
startOptions.phoneNumber = function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
539
|
+
return [2 /*return*/, phoneNumber_1];
|
|
540
|
+
}); }); };
|
|
541
|
+
}
|
|
542
|
+
if (code_1) {
|
|
543
|
+
startOptions.phoneCode = function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
544
|
+
return [2 /*return*/, code_1];
|
|
545
|
+
}); }); };
|
|
546
|
+
}
|
|
547
|
+
if (password_1) {
|
|
548
|
+
startOptions.password = function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
549
|
+
return [2 /*return*/, password_1];
|
|
550
|
+
}); }); };
|
|
551
|
+
}
|
|
552
|
+
return [4 /*yield*/, client.start(startOptions)];
|
|
553
|
+
case 5:
|
|
554
|
+
_g.sent();
|
|
555
|
+
// Save session for future use
|
|
556
|
+
sessionString = client.session.save();
|
|
557
|
+
return [4 /*yield*/, saveSession(sessionString)];
|
|
558
|
+
case 6:
|
|
559
|
+
_g.sent();
|
|
560
|
+
return [4 /*yield*/, client.getMe()];
|
|
561
|
+
case 7:
|
|
562
|
+
me = _g.sent();
|
|
563
|
+
return [2 /*return*/, {
|
|
564
|
+
content: [{
|
|
565
|
+
type: "text",
|
|
566
|
+
text: JSON.stringify({
|
|
567
|
+
success: true,
|
|
568
|
+
message: "Connected to Telegram",
|
|
569
|
+
user: formatEntity(me),
|
|
570
|
+
sessionString: sessionString,
|
|
571
|
+
}, null, 2),
|
|
572
|
+
}],
|
|
573
|
+
}];
|
|
574
|
+
case 8:
|
|
575
|
+
if (!client) return [3 /*break*/, 10];
|
|
576
|
+
return [4 /*yield*/, client.disconnect()];
|
|
577
|
+
case 9:
|
|
578
|
+
_g.sent();
|
|
579
|
+
client = null;
|
|
580
|
+
sessionString = "";
|
|
581
|
+
_g.label = 10;
|
|
582
|
+
case 10: return [2 /*return*/, {
|
|
583
|
+
content: [{
|
|
584
|
+
type: "text",
|
|
585
|
+
text: JSON.stringify({ success: true, message: "Disconnected from Telegram" }),
|
|
586
|
+
}],
|
|
587
|
+
}];
|
|
588
|
+
case 11:
|
|
589
|
+
if (!(!sessionString && (0, fs_1.existsSync)(SESSION_FILE))) return [3 /*break*/, 13];
|
|
590
|
+
return [4 /*yield*/, loadSession()];
|
|
591
|
+
case 12:
|
|
592
|
+
sessionString = _g.sent();
|
|
593
|
+
_g.label = 13;
|
|
594
|
+
case 13: return [2 /*return*/, {
|
|
595
|
+
content: [{
|
|
596
|
+
type: "text",
|
|
597
|
+
text: JSON.stringify({ sessionString: sessionString || null }),
|
|
598
|
+
}],
|
|
599
|
+
}];
|
|
600
|
+
case 14: return [4 /*yield*/, getClient()];
|
|
601
|
+
case 15:
|
|
602
|
+
c = _g.sent();
|
|
603
|
+
return [4 /*yield*/, c.getMe()];
|
|
604
|
+
case 16:
|
|
605
|
+
me = _g.sent();
|
|
606
|
+
return [2 /*return*/, {
|
|
607
|
+
content: [{
|
|
608
|
+
type: "text",
|
|
609
|
+
text: JSON.stringify(formatEntity(me), null, 2),
|
|
610
|
+
}],
|
|
611
|
+
}];
|
|
612
|
+
case 17:
|
|
613
|
+
if (!(args === null || args === void 0 ? void 0 : args.entity) || !(args === null || args === void 0 ? void 0 : args.message)) {
|
|
614
|
+
throw new Error("entity and message are required");
|
|
615
|
+
}
|
|
616
|
+
return [4 /*yield*/, getClient()];
|
|
617
|
+
case 18:
|
|
618
|
+
c = _g.sent();
|
|
619
|
+
return [4 /*yield*/, c.getInputEntity(args.entity)];
|
|
620
|
+
case 19:
|
|
621
|
+
entity = _g.sent();
|
|
622
|
+
return [4 /*yield*/, c.sendMessage(entity, {
|
|
623
|
+
message: args.message,
|
|
624
|
+
parseMode: args.parseMode,
|
|
625
|
+
replyTo: args.replyTo,
|
|
626
|
+
})];
|
|
627
|
+
case 20:
|
|
628
|
+
result = _g.sent();
|
|
629
|
+
return [2 /*return*/, {
|
|
630
|
+
content: [{
|
|
631
|
+
type: "text",
|
|
632
|
+
text: JSON.stringify({
|
|
633
|
+
success: true,
|
|
634
|
+
message: formatMessage(result),
|
|
635
|
+
}, null, 2),
|
|
636
|
+
}],
|
|
637
|
+
}];
|
|
638
|
+
case 21: return [4 /*yield*/, getClient()];
|
|
639
|
+
case 22:
|
|
640
|
+
c = _g.sent();
|
|
641
|
+
limit = (args === null || args === void 0 ? void 0 : args.limit) || 100;
|
|
642
|
+
return [4 /*yield*/, c.getDialogs({ limit: limit })];
|
|
643
|
+
case 23:
|
|
644
|
+
dialogs = _g.sent();
|
|
645
|
+
formatted = dialogs.map(function (d) {
|
|
646
|
+
var _a;
|
|
647
|
+
return ({
|
|
648
|
+
id: (_a = d.id) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
649
|
+
name: d.name,
|
|
650
|
+
unreadCount: d.unreadCount,
|
|
651
|
+
archived: d.archived,
|
|
652
|
+
pinned: d.pinned,
|
|
653
|
+
entity: formatEntity(d.entity),
|
|
654
|
+
});
|
|
655
|
+
});
|
|
656
|
+
return [2 /*return*/, {
|
|
657
|
+
content: [{
|
|
658
|
+
type: "text",
|
|
659
|
+
text: JSON.stringify(formatted, null, 2),
|
|
660
|
+
}],
|
|
661
|
+
}];
|
|
662
|
+
case 24:
|
|
663
|
+
if (!(args === null || args === void 0 ? void 0 : args.entity)) {
|
|
664
|
+
throw new Error("entity is required");
|
|
665
|
+
}
|
|
666
|
+
return [4 /*yield*/, getClient()];
|
|
667
|
+
case 25:
|
|
668
|
+
c = _g.sent();
|
|
669
|
+
return [4 /*yield*/, c.getInputEntity(args.entity)];
|
|
670
|
+
case 26:
|
|
671
|
+
entity = _g.sent();
|
|
672
|
+
return [4 /*yield*/, c.getMessages(entity, {
|
|
673
|
+
limit: args.limit || 100,
|
|
674
|
+
offsetId: args.offsetId,
|
|
675
|
+
minId: args.minId,
|
|
676
|
+
maxId: args.maxId,
|
|
677
|
+
reverse: args.reverse,
|
|
678
|
+
})];
|
|
679
|
+
case 27:
|
|
680
|
+
messages = _g.sent();
|
|
681
|
+
formatted = messages.map(formatMessage);
|
|
682
|
+
return [2 /*return*/, {
|
|
683
|
+
content: [{
|
|
684
|
+
type: "text",
|
|
685
|
+
text: JSON.stringify({
|
|
686
|
+
total: messages.total,
|
|
687
|
+
messages: formatted,
|
|
688
|
+
}, null, 2),
|
|
689
|
+
}],
|
|
690
|
+
}];
|
|
691
|
+
case 28:
|
|
692
|
+
if (!(args === null || args === void 0 ? void 0 : args.entity)) {
|
|
693
|
+
throw new Error("entity is required");
|
|
694
|
+
}
|
|
695
|
+
return [4 /*yield*/, getClient()];
|
|
696
|
+
case 29:
|
|
697
|
+
c = _g.sent();
|
|
698
|
+
return [4 /*yield*/, c.getEntity(args.entity)];
|
|
699
|
+
case 30:
|
|
700
|
+
entity = _g.sent();
|
|
701
|
+
return [2 /*return*/, {
|
|
702
|
+
content: [{
|
|
703
|
+
type: "text",
|
|
704
|
+
text: JSON.stringify(formatEntity(entity), null, 2),
|
|
705
|
+
}],
|
|
706
|
+
}];
|
|
707
|
+
case 31:
|
|
708
|
+
if (!(args === null || args === void 0 ? void 0 : args.entity)) {
|
|
709
|
+
throw new Error("entity is required");
|
|
710
|
+
}
|
|
711
|
+
return [4 /*yield*/, getClient()];
|
|
712
|
+
case 32:
|
|
713
|
+
c = _g.sent();
|
|
714
|
+
return [4 /*yield*/, c.getInputEntity(args.entity)];
|
|
715
|
+
case 33:
|
|
716
|
+
entity = _g.sent();
|
|
717
|
+
return [4 /*yield*/, c.invoke(new telegram_2.Api.messages.ReadHistory({
|
|
718
|
+
peer: entity,
|
|
719
|
+
maxId: args.maxId || 0,
|
|
720
|
+
}))];
|
|
721
|
+
case 34:
|
|
722
|
+
_g.sent();
|
|
723
|
+
return [2 /*return*/, {
|
|
724
|
+
content: [{
|
|
725
|
+
type: "text",
|
|
726
|
+
text: JSON.stringify({ success: true, message: "Messages marked as read" }),
|
|
727
|
+
}],
|
|
728
|
+
}];
|
|
729
|
+
case 35:
|
|
730
|
+
if (!(args === null || args === void 0 ? void 0 : args.entity) || !(args === null || args === void 0 ? void 0 : args.messageIds)) {
|
|
731
|
+
throw new Error("entity and messageIds are required");
|
|
732
|
+
}
|
|
733
|
+
return [4 /*yield*/, getClient()];
|
|
734
|
+
case 36:
|
|
735
|
+
c = _g.sent();
|
|
736
|
+
return [4 /*yield*/, c.getInputEntity(args.entity)];
|
|
737
|
+
case 37:
|
|
738
|
+
entity = _g.sent();
|
|
739
|
+
return [4 /*yield*/, c.deleteMessages(entity, args.messageIds, { revoke: args.revoke !== false })];
|
|
740
|
+
case 38:
|
|
741
|
+
_g.sent();
|
|
742
|
+
return [2 /*return*/, {
|
|
743
|
+
content: [{
|
|
744
|
+
type: "text",
|
|
745
|
+
text: JSON.stringify({ success: true, message: "Messages deleted" }),
|
|
746
|
+
}],
|
|
747
|
+
}];
|
|
748
|
+
case 39:
|
|
749
|
+
if (!(args === null || args === void 0 ? void 0 : args.entity) || !(args === null || args === void 0 ? void 0 : args.messageId) || !(args === null || args === void 0 ? void 0 : args.message)) {
|
|
750
|
+
throw new Error("entity, messageId, and message are required");
|
|
751
|
+
}
|
|
752
|
+
return [4 /*yield*/, getClient()];
|
|
753
|
+
case 40:
|
|
754
|
+
c = _g.sent();
|
|
755
|
+
return [4 /*yield*/, c.getInputEntity(args.entity)];
|
|
756
|
+
case 41:
|
|
757
|
+
entity = _g.sent();
|
|
758
|
+
return [4 /*yield*/, c.editMessage(entity, {
|
|
759
|
+
message: args.messageId,
|
|
760
|
+
text: args.message,
|
|
761
|
+
parseMode: args.parseMode,
|
|
762
|
+
})];
|
|
763
|
+
case 42:
|
|
764
|
+
result = _g.sent();
|
|
765
|
+
return [2 /*return*/, {
|
|
766
|
+
content: [{
|
|
767
|
+
type: "text",
|
|
768
|
+
text: JSON.stringify({
|
|
769
|
+
success: true,
|
|
770
|
+
message: formatMessage(result),
|
|
771
|
+
}, null, 2),
|
|
772
|
+
}],
|
|
773
|
+
}];
|
|
774
|
+
case 43:
|
|
775
|
+
if (!(args === null || args === void 0 ? void 0 : args.fromEntity) || !(args === null || args === void 0 ? void 0 : args.toEntity) || !(args === null || args === void 0 ? void 0 : args.messageIds)) {
|
|
776
|
+
throw new Error("fromEntity, toEntity, and messageIds are required");
|
|
777
|
+
}
|
|
778
|
+
return [4 /*yield*/, getClient()];
|
|
779
|
+
case 44:
|
|
780
|
+
c = _g.sent();
|
|
781
|
+
return [4 /*yield*/, c.getInputEntity(args.fromEntity)];
|
|
782
|
+
case 45:
|
|
783
|
+
fromEntity = _g.sent();
|
|
784
|
+
return [4 /*yield*/, c.getInputEntity(args.toEntity)];
|
|
785
|
+
case 46:
|
|
786
|
+
toEntity = _g.sent();
|
|
787
|
+
return [4 /*yield*/, c.forwardMessages(toEntity, {
|
|
788
|
+
messages: args.messageIds,
|
|
789
|
+
fromPeer: fromEntity,
|
|
790
|
+
})];
|
|
791
|
+
case 47:
|
|
792
|
+
result = _g.sent();
|
|
793
|
+
return [2 /*return*/, {
|
|
794
|
+
content: [{
|
|
795
|
+
type: "text",
|
|
796
|
+
text: JSON.stringify({
|
|
797
|
+
success: true,
|
|
798
|
+
forwarded: result.length,
|
|
799
|
+
}, null, 2),
|
|
800
|
+
}],
|
|
801
|
+
}];
|
|
802
|
+
case 48: return [4 /*yield*/, getClient()];
|
|
803
|
+
case 49:
|
|
804
|
+
c = _g.sent();
|
|
805
|
+
return [4 /*yield*/, c.invoke(new telegram_2.Api.contacts.GetContacts({
|
|
806
|
+
hash: (0, big_integer_1.default)(0),
|
|
807
|
+
}))];
|
|
808
|
+
case 50:
|
|
809
|
+
result = _g.sent();
|
|
810
|
+
contacts = ((_d = result.users) === null || _d === void 0 ? void 0 : _d.map(formatEntity)) || [];
|
|
811
|
+
return [2 /*return*/, {
|
|
812
|
+
content: [{
|
|
813
|
+
type: "text",
|
|
814
|
+
text: JSON.stringify(contacts, null, 2),
|
|
815
|
+
}],
|
|
816
|
+
}];
|
|
817
|
+
case 51:
|
|
818
|
+
if (!(args === null || args === void 0 ? void 0 : args.title) || !(args === null || args === void 0 ? void 0 : args.users)) {
|
|
819
|
+
throw new Error("title and users are required");
|
|
820
|
+
}
|
|
821
|
+
return [4 /*yield*/, getClient()];
|
|
822
|
+
case 52:
|
|
823
|
+
c_1 = _g.sent();
|
|
824
|
+
return [4 /*yield*/, Promise.all(args.users.map(function (u) { return c_1.getInputEntity(u); }))];
|
|
825
|
+
case 53:
|
|
826
|
+
users = _g.sent();
|
|
827
|
+
return [4 /*yield*/, c_1.invoke(new telegram_2.Api.messages.CreateChat({
|
|
828
|
+
users: users,
|
|
829
|
+
title: args.title,
|
|
830
|
+
}))];
|
|
831
|
+
case 54:
|
|
832
|
+
result = _g.sent();
|
|
833
|
+
return [2 /*return*/, {
|
|
834
|
+
content: [{
|
|
835
|
+
type: "text",
|
|
836
|
+
text: JSON.stringify({
|
|
837
|
+
success: true,
|
|
838
|
+
chat: formatEntity((_e = result.chats) === null || _e === void 0 ? void 0 : _e[0]),
|
|
839
|
+
}, null, 2),
|
|
840
|
+
}],
|
|
841
|
+
}];
|
|
842
|
+
case 55:
|
|
843
|
+
if (!(args === null || args === void 0 ? void 0 : args.entity)) {
|
|
844
|
+
throw new Error("entity is required");
|
|
845
|
+
}
|
|
846
|
+
return [4 /*yield*/, getClient()];
|
|
847
|
+
case 56:
|
|
848
|
+
c = _g.sent();
|
|
849
|
+
return [4 /*yield*/, c.getInputEntity(args.entity)];
|
|
850
|
+
case 57:
|
|
851
|
+
entity = _g.sent();
|
|
852
|
+
return [4 /*yield*/, c.invoke(new telegram_2.Api.channels.GetParticipants({
|
|
853
|
+
channel: entity,
|
|
854
|
+
filter: new telegram_2.Api.ChannelParticipantsRecent(),
|
|
855
|
+
limit: args.limit || 100,
|
|
856
|
+
offset: 0,
|
|
857
|
+
}))];
|
|
858
|
+
case 58:
|
|
859
|
+
result = _g.sent();
|
|
860
|
+
participants = ((_f = result.participants) === null || _f === void 0 ? void 0 : _f.map(function (p) {
|
|
861
|
+
var _a;
|
|
862
|
+
return ({
|
|
863
|
+
userId: (_a = p.userId) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
864
|
+
date: p.date ? new Date(p.date * 1000).toISOString() : null,
|
|
865
|
+
className: p.className,
|
|
866
|
+
});
|
|
867
|
+
})) || [];
|
|
868
|
+
return [2 /*return*/, {
|
|
869
|
+
content: [{
|
|
870
|
+
type: "text",
|
|
871
|
+
text: JSON.stringify({
|
|
872
|
+
total: result.count,
|
|
873
|
+
participants: participants,
|
|
874
|
+
}, null, 2),
|
|
875
|
+
}],
|
|
876
|
+
}];
|
|
877
|
+
case 59: throw new Error("Unknown tool: ".concat(name));
|
|
878
|
+
case 60: return [3 /*break*/, 62];
|
|
879
|
+
case 61:
|
|
880
|
+
error_1 = _g.sent();
|
|
881
|
+
return [2 /*return*/, {
|
|
882
|
+
content: [{
|
|
883
|
+
type: "text",
|
|
884
|
+
text: JSON.stringify({
|
|
885
|
+
error: true,
|
|
886
|
+
message: error_1.message,
|
|
887
|
+
stack: error_1.stack,
|
|
888
|
+
}, null, 2),
|
|
889
|
+
}],
|
|
890
|
+
isError: true,
|
|
891
|
+
}];
|
|
892
|
+
case 62: return [2 /*return*/];
|
|
893
|
+
}
|
|
894
|
+
});
|
|
895
|
+
}); });
|
|
896
|
+
// ==============
|
|
897
|
+
// Start Server
|
|
898
|
+
// ==============
|
|
899
|
+
function main() {
|
|
900
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
901
|
+
var transport;
|
|
902
|
+
return __generator(this, function (_a) {
|
|
903
|
+
switch (_a.label) {
|
|
904
|
+
case 0:
|
|
905
|
+
transport = new stdio_js_1.StdioServerTransport();
|
|
906
|
+
return [4 /*yield*/, server.connect(transport)];
|
|
907
|
+
case 1:
|
|
908
|
+
_a.sent();
|
|
909
|
+
console.error("Telegram MCP server running on stdio");
|
|
910
|
+
return [2 /*return*/];
|
|
911
|
+
}
|
|
912
|
+
});
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
main().catch(function (error) {
|
|
916
|
+
console.error("Fatal error:", error);
|
|
917
|
+
process.exit(1);
|
|
918
|
+
});
|