bn-telegram-mcp-server 0.0.1

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.
Files changed (99) hide show
  1. package/README.md +1031 -0
  2. package/dist/debug-middleware.d.ts +12 -0
  3. package/dist/debug-middleware.d.ts.map +1 -0
  4. package/dist/debug-middleware.js +36 -0
  5. package/dist/debug-middleware.js.map +1 -0
  6. package/dist/encryption.d.ts +11 -0
  7. package/dist/encryption.d.ts.map +1 -0
  8. package/dist/encryption.js +26 -0
  9. package/dist/encryption.js.map +1 -0
  10. package/dist/helpers.d.ts +27 -0
  11. package/dist/helpers.d.ts.map +1 -0
  12. package/dist/helpers.js +103 -0
  13. package/dist/helpers.js.map +1 -0
  14. package/dist/index.d.ts +3 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +176 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/logger.d.ts +29 -0
  19. package/dist/logger.d.ts.map +1 -0
  20. package/dist/logger.js +114 -0
  21. package/dist/logger.js.map +1 -0
  22. package/dist/request-context.d.ts +24 -0
  23. package/dist/request-context.d.ts.map +1 -0
  24. package/dist/request-context.js +32 -0
  25. package/dist/request-context.js.map +1 -0
  26. package/dist/resolvers.d.ts +36 -0
  27. package/dist/resolvers.d.ts.map +1 -0
  28. package/dist/resolvers.js +252 -0
  29. package/dist/resolvers.js.map +1 -0
  30. package/dist/schemas.d.ts +150 -0
  31. package/dist/schemas.d.ts.map +1 -0
  32. package/dist/schemas.js +216 -0
  33. package/dist/schemas.js.map +1 -0
  34. package/dist/telegram-client.d.ts +19 -0
  35. package/dist/telegram-client.d.ts.map +1 -0
  36. package/dist/telegram-client.js +112 -0
  37. package/dist/telegram-client.js.map +1 -0
  38. package/dist/tool-loader.d.ts +31 -0
  39. package/dist/tool-loader.d.ts.map +1 -0
  40. package/dist/tool-loader.js +121 -0
  41. package/dist/tool-loader.js.map +1 -0
  42. package/dist/tool-registry.d.ts +47 -0
  43. package/dist/tool-registry.d.ts.map +1 -0
  44. package/dist/tool-registry.js +58 -0
  45. package/dist/tool-registry.js.map +1 -0
  46. package/dist/tools/getChat.d.ts +28 -0
  47. package/dist/tools/getChat.d.ts.map +1 -0
  48. package/dist/tools/getChat.js +69 -0
  49. package/dist/tools/getChat.js.map +1 -0
  50. package/dist/tools/getChatMembers.d.ts +34 -0
  51. package/dist/tools/getChatMembers.d.ts.map +1 -0
  52. package/dist/tools/getChatMembers.js +150 -0
  53. package/dist/tools/getChatMembers.js.map +1 -0
  54. package/dist/tools/getContacts.d.ts +28 -0
  55. package/dist/tools/getContacts.d.ts.map +1 -0
  56. package/dist/tools/getContacts.js +73 -0
  57. package/dist/tools/getContacts.js.map +1 -0
  58. package/dist/tools/getFile.d.ts +21 -0
  59. package/dist/tools/getFile.d.ts.map +1 -0
  60. package/dist/tools/getFile.js +33 -0
  61. package/dist/tools/getFile.js.map +1 -0
  62. package/dist/tools/getGroup.d.ts +27 -0
  63. package/dist/tools/getGroup.d.ts.map +1 -0
  64. package/dist/tools/getGroup.js +100 -0
  65. package/dist/tools/getGroup.js.map +1 -0
  66. package/dist/tools/getMe.d.ts +17 -0
  67. package/dist/tools/getMe.d.ts.map +1 -0
  68. package/dist/tools/getMe.js +20 -0
  69. package/dist/tools/getMe.js.map +1 -0
  70. package/dist/tools/getMessageContext.d.ts +21 -0
  71. package/dist/tools/getMessageContext.d.ts.map +1 -0
  72. package/dist/tools/getMessageContext.js +164 -0
  73. package/dist/tools/getMessageContext.js.map +1 -0
  74. package/dist/tools/getMessages.d.ts +38 -0
  75. package/dist/tools/getMessages.d.ts.map +1 -0
  76. package/dist/tools/getMessages.js +123 -0
  77. package/dist/tools/getMessages.js.map +1 -0
  78. package/dist/tools/getUser.d.ts +22 -0
  79. package/dist/tools/getUser.d.ts.map +1 -0
  80. package/dist/tools/getUser.js +38 -0
  81. package/dist/tools/getUser.js.map +1 -0
  82. package/dist/tools/index.d.ts +11 -0
  83. package/dist/tools/index.d.ts.map +1 -0
  84. package/dist/tools/index.js +12 -0
  85. package/dist/tools/index.js.map +1 -0
  86. package/dist/tools/sendMessage.d.ts +39 -0
  87. package/dist/tools/sendMessage.d.ts.map +1 -0
  88. package/dist/tools/sendMessage.js +116 -0
  89. package/dist/tools/sendMessage.js.map +1 -0
  90. package/dist/transformers.d.ts +133 -0
  91. package/dist/transformers.d.ts.map +1 -0
  92. package/dist/transformers.js +335 -0
  93. package/dist/transformers.js.map +1 -0
  94. package/dist/types.d.ts +55 -0
  95. package/dist/types.d.ts.map +1 -0
  96. package/dist/types.js +2 -0
  97. package/dist/types.js.map +1 -0
  98. package/package.json +45 -0
  99. package/tools.json +252 -0
package/README.md ADDED
@@ -0,0 +1,1031 @@
1
+ # Telegram MCP Server Tools
2
+
3
+ ---
4
+
5
+ ## Quick Reference Table
6
+
7
+ | Tool | Description | Key Input | Key Output |
8
+ |------|-------------|-----------|------------|
9
+ | `getMe` | Current user info | *none* | `{id, name, status}` |
10
+ | `getChat` | Get/list chats | `chat?`, `limit?` | `{id, title, type}` or `{chats[], summary}` |
11
+ | `getMessages` | Get messages (history/specific/search) | `chat?`, `mode`, `query?` | `{messages[], total_count}` |
12
+ | `getMessageContext` | Get surrounding messages for context | `chat`, `mode`, `message_id?`, `query?` | `{contexts[], summary}` |
13
+ | `sendMessage` | Send/forward messages | `chat`, `action`, `text?` | `{id, content, date}` |
14
+ | `getUser` | User profile | `user` (name/ID) | `{id, name, status}` |
15
+ | `getContacts` | List/search contacts | `query?`, `limit?` | `{contacts[], total_count}` |
16
+ | `getFile` | Get file metadata | `file_id` | `{id, size, remote_id}` |
17
+ | `getGroup` | Group info (basic/super) | `group`, `type?` | `{id, name, member_count}` |
18
+ | `getChatMembers` | Chat members with filters | `chat`, `filter?` | `{members[], total_count}` |
19
+
20
+ ---
21
+
22
+ ## 1. getMe
23
+
24
+ **Description:** Get information about the current Telegram user (the authenticated user). Returns name, username, phone, status, and profile info.
25
+
26
+ ### Input Schema
27
+ ```json
28
+ {
29
+ "type": "object",
30
+ "properties": {}
31
+ }
32
+ ```
33
+ *No parameters required.*
34
+
35
+ ### Output Schema
36
+ ```typescript
37
+ {
38
+ id: number; // User's numeric ID
39
+ name: string; // Full name (e.g., "John Doe")
40
+ username?: string; // @username if set
41
+ phone?: string; // Phone number if visible
42
+ status: string; // Online status (e.g., "online", "last seen 2 hours ago")
43
+ is_contact: boolean;
44
+ is_premium: boolean;
45
+ is_verified: boolean;
46
+ }
47
+ ```
48
+
49
+ ### Use Cases
50
+
51
+ **Use Case 1: Check authenticated user**
52
+ ```bash
53
+ # Input
54
+ {}
55
+
56
+ # Output
57
+ {
58
+ "id": 111222333,
59
+ "name": "John Doe",
60
+ "phone": "+1234567890",
61
+ "status": "online",
62
+ "is_contact": false,
63
+ "is_premium": false,
64
+ "is_verified": false
65
+ }
66
+ ```
67
+
68
+ **Use Case 2: Verify connection status**
69
+ ```bash
70
+ # Call getMe to verify the Telegram session is active
71
+ # If successful, returns user info; if failed, session needs re-authentication
72
+ ```
73
+
74
+ ---
75
+
76
+ ## 2. getChat
77
+
78
+ **Description:** Get chat information - either a specific chat or list all chats. When `chat` is provided, returns single chat details. When `chat` is omitted, returns list of all chats.
79
+
80
+ ### Input Schema
81
+ ```json
82
+ {
83
+ "type": "object",
84
+ "properties": {
85
+ "chat": {
86
+ "type": ["number", "string"],
87
+ "description": "Optional: Chat identifier (name/title or numeric ID). If omitted, lists all chats."
88
+ },
89
+ "chat_list": {
90
+ "type": "string",
91
+ "enum": ["main", "archive"],
92
+ "description": "Which chat list to retrieve (default: main)"
93
+ },
94
+ "limit": {
95
+ "type": "number",
96
+ "description": "Maximum chats when listing (default: 100, max: 4000)"
97
+ }
98
+ }
99
+ }
100
+ ```
101
+
102
+ ### Output Schema (Single Chat)
103
+ ```typescript
104
+ {
105
+ id: number;
106
+ title: string;
107
+ type: string; // "private", "group", "supergroup", "channel"
108
+ unread_count: number;
109
+ last_message?: {
110
+ preview: string;
111
+ sender: string;
112
+ date: string;
113
+ date_relative: string;
114
+ };
115
+ is_pinned: boolean;
116
+ is_muted: boolean;
117
+ }
118
+ ```
119
+
120
+ ### Output Schema (List Chats)
121
+ ```typescript
122
+ {
123
+ chats: Array<{
124
+ id: number;
125
+ title: string;
126
+ type: string;
127
+ unread_count: number;
128
+ last_message?: { preview, sender, date, date_relative };
129
+ is_pinned: boolean;
130
+ is_muted: boolean;
131
+ }>;
132
+ total_count: number;
133
+ summary: string; // e.g., "15 chats loaded, 3 unread messages"
134
+ }
135
+ ```
136
+
137
+ ### Use Cases
138
+
139
+ **Use Case 1: List all chats**
140
+ ```bash
141
+ # Input
142
+ {"limit": 10}
143
+
144
+ # Output
145
+ {
146
+ "chats": [
147
+ {
148
+ "id": 555666777,
149
+ "title": "John Doe",
150
+ "type": "private",
151
+ "unread_count": 0,
152
+ "last_message": {
153
+ "preview": "Test message",
154
+ "sender": "User 111222333",
155
+ "date": "2025-12-04T08:41:54.000Z",
156
+ "date_relative": "4 hours ago"
157
+ }
158
+ }
159
+ ],
160
+ "total_count": 15,
161
+ "summary": "10 chats loaded, 0 unread messages"
162
+ }
163
+ ```
164
+
165
+ **Use Case 2: Get specific chat by name**
166
+ ```bash
167
+ # Input
168
+ {"chat": "John Doe"}
169
+
170
+ # Output
171
+ {
172
+ "id": 555666777,
173
+ "title": "John Doe",
174
+ "type": "private",
175
+ "unread_count": 0,
176
+ "is_pinned": false,
177
+ "is_muted": false
178
+ }
179
+ ```
180
+
181
+ **Use Case 3: Get archived chats**
182
+ ```bash
183
+ # Input
184
+ {"chat_list": "archive", "limit": 50}
185
+ ```
186
+
187
+ ---
188
+
189
+ ## 3. getMessages
190
+
191
+ **Description:** Get messages from a chat using different modes: paginated history, specific message IDs, or text search. Supports both chat-specific and global search.
192
+
193
+ ### Input Schema
194
+ ```json
195
+ {
196
+ "type": "object",
197
+ "properties": {
198
+ "chat": {
199
+ "type": ["number", "string"],
200
+ "description": "Chat identifier. Required for 'history'/'specific' modes, optional for 'search'"
201
+ },
202
+ "mode": {
203
+ "type": "string",
204
+ "enum": ["history", "specific", "search"],
205
+ "description": "Mode: 'history' (default), 'specific', or 'search'"
206
+ },
207
+ "from_message_id": {
208
+ "type": "number",
209
+ "description": "(history/chat search mode) Start from this message ID (0 for latest)"
210
+ },
211
+ "offset": {
212
+ "type": "number",
213
+ "description": "(history mode) Numeric pagination offset"
214
+ },
215
+ "limit": {
216
+ "type": "number",
217
+ "description": "Max messages to return (default: 50, max: 100)"
218
+ },
219
+ "only_local": {
220
+ "type": "boolean",
221
+ "description": "(history mode) Only return cached messages"
222
+ },
223
+ "message_ids": {
224
+ "type": "array",
225
+ "items": { "type": "number" },
226
+ "description": "(specific mode) Array of message IDs to retrieve"
227
+ },
228
+ "query": {
229
+ "type": "string",
230
+ "description": "(search mode) Search query text"
231
+ },
232
+ "next_offset": {
233
+ "type": "string",
234
+ "description": "(search mode) Cursor for pagination - pass the next_offset from previous response"
235
+ }
236
+ }
237
+ }
238
+ ```
239
+
240
+ ### Output Schema (History/Search)
241
+ ```typescript
242
+ {
243
+ messages: Array<{
244
+ id: number;
245
+ chat_id: number;
246
+ sender: string;
247
+ sender_id: number;
248
+ content: string;
249
+ content_type: string; // "Text", "Photo", "Video", etc.
250
+ date: string;
251
+ date_relative: string;
252
+ is_outgoing: boolean;
253
+ is_pinned: boolean;
254
+ file_id?: number;
255
+ }>;
256
+ total_count: number;
257
+ chat_title?: string; // (history mode)
258
+ search_query?: string; // (search mode)
259
+ next_offset?: string; // (search mode) For pagination
260
+ }
261
+ ```
262
+
263
+ ### Use Cases
264
+
265
+ **Use Case 1: Get chat history**
266
+ ```bash
267
+ # Input
268
+ {"chat": "John Doe", "mode": "history", "limit": 5}
269
+
270
+ # Output
271
+ {
272
+ "messages": [
273
+ {
274
+ "id": 14680064,
275
+ "chat_id": 555666777,
276
+ "sender": "User 111222333",
277
+ "content": "Test message from script",
278
+ "content_type": "Text",
279
+ "date": "2025-12-04T08:41:54.000Z",
280
+ "date_relative": "4 hours ago",
281
+ "is_outgoing": true
282
+ }
283
+ ],
284
+ "total_count": 1,
285
+ "chat_title": "John Doe"
286
+ }
287
+ ```
288
+
289
+ **Use Case 2: Get specific messages by IDs**
290
+ ```bash
291
+ # Input
292
+ {"chat": "John Doe", "mode": "specific", "message_ids": [9437184, 9437185]}
293
+
294
+ # Output
295
+ {
296
+ "messages": [...],
297
+ "count": 2,
298
+ "chat_title": "John Doe"
299
+ }
300
+ ```
301
+
302
+ **Use Case 3: Search messages globally**
303
+ ```bash
304
+ # Input
305
+ {"mode": "search", "query": "meeting", "limit": 10}
306
+
307
+ # Output
308
+ {
309
+ "messages": [...],
310
+ "total_count": 5,
311
+ "search_query": "meeting"
312
+ }
313
+ ```
314
+
315
+ **Use Case 4: Search in specific chat**
316
+ ```bash
317
+ # Input
318
+ {"chat": "Project Team", "mode": "search", "query": "deadline"}
319
+ ```
320
+
321
+ **Use Case 5: Search with pagination**
322
+ ```bash
323
+ # First request
324
+ {"mode": "search", "query": "meeting", "limit": 10}
325
+
326
+ # Response includes next_offset
327
+ {
328
+ "messages": [...],
329
+ "total_count": 50,
330
+ "next_offset": "abc123xyz",
331
+ "search_query": "meeting"
332
+ }
333
+
334
+ # Next page - pass the next_offset from previous response
335
+ {"mode": "search", "query": "meeting", "limit": 10, "next_offset": "abc123xyz"}
336
+ ```
337
+
338
+ ---
339
+
340
+ ## 4. getMessageContext
341
+
342
+ **Description:** Get surrounding messages for context around a specific message or search results. Returns messages before and after the target to understand the full conversation flow. Useful when you need to understand the context of a particular message.
343
+
344
+ ### Input Schema
345
+ ```json
346
+ {
347
+ "type": "object",
348
+ "properties": {
349
+ "chat": {
350
+ "type": ["number", "string"],
351
+ "description": "Chat identifier. Required for 'message_id' mode, optional for 'search' mode (global search if omitted)"
352
+ },
353
+ "mode": {
354
+ "type": "string",
355
+ "enum": ["message_id", "search"],
356
+ "description": "Mode: 'message_id' (default) or 'search'"
357
+ },
358
+ "message_id": {
359
+ "type": "number",
360
+ "description": "(message_id mode) The message ID to get context around"
361
+ },
362
+ "query": {
363
+ "type": "string",
364
+ "description": "(search mode) Search query to find messages"
365
+ },
366
+ "search_limit": {
367
+ "type": "number",
368
+ "description": "(search mode) Max search results to get context for (default: 5, max: 20)"
369
+ },
370
+ "context_count": {
371
+ "type": "number",
372
+ "description": "Messages to fetch before AND after target (default: 5, max: 50)"
373
+ }
374
+ }
375
+ }
376
+ ```
377
+
378
+ ### Output Schema
379
+ ```typescript
380
+ {
381
+ contexts: Array<{
382
+ messages: Array<{ // Single chronological array (easier for LLMs)
383
+ id: number;
384
+ chat_id: number;
385
+ sender: string;
386
+ content: string;
387
+ content_type: string;
388
+ date: string;
389
+ date_relative: string;
390
+ is_target: boolean; // true for the target message
391
+ }>;
392
+ target_message_id: number; // ID of the target message
393
+ context_count: number;
394
+ chat_id: number;
395
+ chat_title?: string;
396
+ }>;
397
+ total_matches: number;
398
+ search_query?: string; // Only present in search mode
399
+ summary: string; // Human-readable summary
400
+ }
401
+ ```
402
+
403
+ ### Use Cases
404
+
405
+ **Use Case 1: Get context around a specific message**
406
+ ```bash
407
+ # Input
408
+ {"chat": "Project Team", "mode": "message_id", "message_id": 12345, "context_count": 3}
409
+
410
+ # Output - Single chronological array with is_target flag
411
+ {
412
+ "contexts": [
413
+ {
414
+ "messages": [
415
+ {"id": 12342, "content": "Good morning everyone", "is_target": false, ...},
416
+ {"id": 12343, "content": "Hi team", "is_target": false, ...},
417
+ {"id": 12344, "content": "Ready for the standup?", "is_target": false, ...},
418
+ {"id": 12345, "content": "Let's discuss the deadline", "is_target": true, ...},
419
+ {"id": 12346, "content": "Sure, what about Friday?", "is_target": false, ...},
420
+ {"id": 12347, "content": "Friday works for me", "is_target": false, ...},
421
+ {"id": 12348, "content": "Let's set it for 3pm", "is_target": false, ...}
422
+ ],
423
+ "target_message_id": 12345,
424
+ "context_count": 3,
425
+ "chat_title": "Project Team"
426
+ }
427
+ ],
428
+ "total_matches": 1,
429
+ "summary": "Showing context for 1 message(s) (7 total messages)"
430
+ }
431
+ ```
432
+
433
+ **Use Case 2: Search and get context for each match**
434
+ ```bash
435
+ # Input
436
+ {"chat": "Project Team", "mode": "search", "query": "deadline", "search_limit": 3, "context_count": 2}
437
+
438
+ # Output
439
+ {
440
+ "contexts": [
441
+ {
442
+ "messages": [
443
+ {"id": 12343, "content": "Hi team", "is_target": false, ...},
444
+ {"id": 12344, "content": "Ready for the standup?", "is_target": false, ...},
445
+ {"id": 12345, "content": "Let's discuss the deadline", "is_target": true, ...},
446
+ {"id": 12346, "content": "Sure, what about Friday?", "is_target": false, ...},
447
+ {"id": 12347, "content": "Friday works for me", "is_target": false, ...}
448
+ ],
449
+ "target_message_id": 12345,
450
+ "chat_title": "Project Team"
451
+ },
452
+ {
453
+ "messages": [
454
+ {"id": 9874, "content": "Any updates?", "is_target": false, ...},
455
+ {"id": 9875, "content": "Yes, checking now", "is_target": false, ...},
456
+ {"id": 9876, "content": "The deadline is next week", "is_target": true, ...},
457
+ {"id": 9877, "content": "Got it, thanks", "is_target": false, ...},
458
+ {"id": 9878, "content": "I'll prepare the report", "is_target": false, ...}
459
+ ],
460
+ "target_message_id": 9876,
461
+ "chat_title": "Project Team"
462
+ }
463
+ ],
464
+ "total_matches": 5,
465
+ "search_query": "deadline",
466
+ "summary": "Found 5 match(es) for \"deadline\", showing context for 2 result(s) (10 total messages)"
467
+ }
468
+ ```
469
+
470
+ **Use Case 3: Global search with context**
471
+ ```bash
472
+ # Input - search across all chats
473
+ {"mode": "search", "query": "urgent", "search_limit": 5, "context_count": 3}
474
+
475
+ # Output - results may come from different chats
476
+ {
477
+ "contexts": [
478
+ {
479
+ "messages": [
480
+ {"id": 553, "content": "Please review", "is_target": false, ...},
481
+ {"id": 554, "content": "Will do", "is_target": false, ...},
482
+ {"id": 555, "content": "This is urgent!", "is_target": true, ...},
483
+ {"id": 556, "content": "On it now", "is_target": false, ...}
484
+ ],
485
+ "target_message_id": 555,
486
+ "chat_id": 1111111,
487
+ "chat_title": "Work Group"
488
+ },
489
+ {
490
+ "messages": [
491
+ {"id": 775, "content": "Schedule update", "is_target": false, ...},
492
+ {"id": 776, "content": "What time?", "is_target": false, ...},
493
+ {"id": 777, "content": "Urgent meeting tomorrow", "is_target": true, ...},
494
+ {"id": 778, "content": "I'll be there", "is_target": false, ...}
495
+ ],
496
+ "target_message_id": 777,
497
+ "chat_id": 2222222,
498
+ "chat_title": "Project Team"
499
+ }
500
+ ],
501
+ "total_matches": 12,
502
+ "search_query": "urgent",
503
+ "summary": "Found 12 match(es) for \"urgent\", showing context for 2 result(s) (8 total messages)"
504
+ }
505
+ ```
506
+
507
+ ---
508
+
509
+ ## 5. sendMessage
510
+
511
+ **Description:** Send or forward messages to a chat. Use `action="send"` to compose new messages, or `action="forward"` to forward existing messages from another chat.
512
+
513
+ ### Input Schema
514
+ ```json
515
+ {
516
+ "type": "object",
517
+ "properties": {
518
+ "chat": {
519
+ "type": ["number", "string"],
520
+ "description": "Target chat: name/title or numeric ID"
521
+ },
522
+ "action": {
523
+ "type": "string",
524
+ "enum": ["send", "forward"],
525
+ "description": "Action type (default: 'send')"
526
+ },
527
+ "text": {
528
+ "type": "string",
529
+ "description": "(send action) Text content of the message"
530
+ },
531
+ "reply_to_message_id": {
532
+ "type": "number",
533
+ "description": "(send action) ID of message to reply to"
534
+ },
535
+ "from_chat": {
536
+ "type": ["number", "string"],
537
+ "description": "(forward action) Source chat to forward from"
538
+ },
539
+ "message_ids": {
540
+ "type": "array",
541
+ "items": { "type": "number" },
542
+ "description": "(forward action) Message IDs to forward"
543
+ },
544
+ "send_copy": {
545
+ "type": "boolean",
546
+ "description": "(forward action) Send copies without forwarding header"
547
+ },
548
+ "remove_caption": {
549
+ "type": "boolean",
550
+ "description": "(forward action) Remove media captions"
551
+ }
552
+ },
553
+ "required": ["chat"]
554
+ }
555
+ ```
556
+
557
+ ### Output Schema (Send)
558
+ ```typescript
559
+ {
560
+ id: number;
561
+ chat_id: number;
562
+ sender: string;
563
+ content: string;
564
+ content_type: string;
565
+ date: string;
566
+ date_relative: string;
567
+ is_outgoing: true;
568
+ is_pinned: boolean;
569
+ }
570
+ ```
571
+
572
+ ### Output Schema (Forward)
573
+ ```typescript
574
+ {
575
+ forwarded: Array<{
576
+ id: number;
577
+ chat_id: number;
578
+ sender: string;
579
+ content: string;
580
+ date: string;
581
+ is_outgoing: boolean;
582
+ }>;
583
+ count: number;
584
+ }
585
+ ```
586
+
587
+ ### Use Cases
588
+
589
+ **Use Case 1: Send a new message**
590
+ ```bash
591
+ # Input
592
+ {"chat": "John Doe", "text": "Hello from MCP!"}
593
+
594
+ # Output
595
+ {
596
+ "id": 14680065,
597
+ "chat_id": 555666777,
598
+ "sender": "User 111222333",
599
+ "content": "Hello from MCP!",
600
+ "content_type": "Text",
601
+ "date": "2025-12-04T12:45:00.000Z",
602
+ "date_relative": "just now",
603
+ "is_outgoing": true
604
+ }
605
+ ```
606
+
607
+ **Use Case 2: Reply to a message**
608
+ ```bash
609
+ # Input
610
+ {"chat": "Project Team", "text": "I agree!", "reply_to_message_id": 12345}
611
+ ```
612
+
613
+ **Use Case 3: Forward messages**
614
+ ```bash
615
+ # Input
616
+ {
617
+ "chat": "John Doe",
618
+ "action": "forward",
619
+ "from_chat": "Project Team",
620
+ "message_ids": [100, 101, 102]
621
+ }
622
+
623
+ # Output
624
+ {
625
+ "forwarded": [...],
626
+ "count": 3
627
+ }
628
+ ```
629
+
630
+ **Use Case 4: Forward as copy (no "Forwarded from" header)**
631
+ ```bash
632
+ # Input
633
+ {
634
+ "chat": "John Doe",
635
+ "action": "forward",
636
+ "from_chat": "Project Team",
637
+ "message_ids": [100],
638
+ "send_copy": true
639
+ }
640
+ ```
641
+
642
+ ---
643
+
644
+ ## 6. getUser
645
+
646
+ **Description:** Get information about a Telegram user. You can use their name, @username, or numeric user ID.
647
+
648
+ ### Input Schema
649
+ ```json
650
+ {
651
+ "type": "object",
652
+ "properties": {
653
+ "user": {
654
+ "type": ["number", "string"],
655
+ "description": "User identifier: name, @username, or numeric ID"
656
+ }
657
+ },
658
+ "required": ["user"]
659
+ }
660
+ ```
661
+
662
+ ### Output Schema
663
+ ```typescript
664
+ {
665
+ id: number;
666
+ name: string;
667
+ username?: string;
668
+ phone?: string;
669
+ status: string; // "online", "last seen 2 hours ago", etc.
670
+ is_contact: boolean;
671
+ is_premium: boolean;
672
+ is_verified: boolean;
673
+ }
674
+ ```
675
+
676
+ ### Use Cases
677
+
678
+ **Use Case 1: Get user by numeric ID**
679
+ ```bash
680
+ # Input
681
+ {"user": 555666777}
682
+
683
+ # Output
684
+ {
685
+ "id": 555666777,
686
+ "name": "John Doe",
687
+ "phone": "+1234567890",
688
+ "status": "last seen 2 hours ago",
689
+ "is_contact": true,
690
+ "is_premium": false,
691
+ "is_verified": false
692
+ }
693
+ ```
694
+
695
+ **Use Case 2: Get user by username**
696
+ ```bash
697
+ # Input
698
+ {"user": "@johndoe"}
699
+ ```
700
+
701
+ ---
702
+
703
+ ## 7. getContacts
704
+
705
+ **Description:** Get contacts - either list all contacts or search by name/username. When `query` is provided, searches contacts; otherwise returns all contacts.
706
+
707
+ ### Input Schema
708
+ ```json
709
+ {
710
+ "type": "object",
711
+ "properties": {
712
+ "query": {
713
+ "type": "string",
714
+ "description": "Optional: Search query to filter contacts"
715
+ },
716
+ "limit": {
717
+ "type": "number",
718
+ "description": "Max results when searching (default: 50, max: 200)"
719
+ }
720
+ }
721
+ }
722
+ ```
723
+
724
+ ### Output Schema
725
+ ```typescript
726
+ {
727
+ contacts: Array<{
728
+ id: number;
729
+ name: string;
730
+ username?: string;
731
+ phone?: string;
732
+ status: string;
733
+ }>;
734
+ total_count: number;
735
+ query?: string; // Only present when searching
736
+ }
737
+ ```
738
+
739
+ ### Use Cases
740
+
741
+ **Use Case 1: List all contacts**
742
+ ```bash
743
+ # Input
744
+ {}
745
+
746
+ # Output
747
+ {
748
+ "contacts": [
749
+ {
750
+ "id": 555666777,
751
+ "name": "John Doe",
752
+ "phone": "+1234567890",
753
+ "status": "last seen 2 hours ago"
754
+ },
755
+ {
756
+ "id": 123456789,
757
+ "name": "John Doe",
758
+ "username": "johndoe",
759
+ "status": "online"
760
+ }
761
+ ],
762
+ "total_count": 2
763
+ }
764
+ ```
765
+
766
+ **Use Case 2: Search contacts**
767
+ ```bash
768
+ # Input
769
+ {"query": "John", "limit": 10}
770
+
771
+ # Output
772
+ {
773
+ "contacts": [
774
+ {
775
+ "id": 555666777,
776
+ "name": "John Doe",
777
+ "phone": "+1234567890",
778
+ "status": "last seen 2 hours ago"
779
+ }
780
+ ],
781
+ "total_count": 1,
782
+ "query": "John"
783
+ }
784
+ ```
785
+
786
+ ---
787
+
788
+ ## 8. getFile
789
+
790
+ **Description:** Get file metadata (size, remote ID). Note: Download is not supported in stateless mode since session files are cleaned up after each request.
791
+
792
+ ### Input Schema
793
+ ```json
794
+ {
795
+ "type": "object",
796
+ "properties": {
797
+ "file_id": {
798
+ "type": "number",
799
+ "description": "Identifier of the file to get metadata for"
800
+ }
801
+ },
802
+ "required": ["file_id"]
803
+ }
804
+ ```
805
+
806
+ ### Output Schema
807
+ ```typescript
808
+ {
809
+ id: number;
810
+ size: string; // Human-readable (e.g., "1.5 MB")
811
+ size_bytes: number;
812
+ remote_id?: string; // Remote file identifier
813
+ }
814
+ ```
815
+
816
+ ### Use Cases
817
+
818
+ **Use Case 1: Get file metadata**
819
+ ```bash
820
+ # Input
821
+ {"file_id": 33}
822
+
823
+ # Output
824
+ {
825
+ "id": 33,
826
+ "size": "1.00 MB",
827
+ "size_bytes": 1024000,
828
+ "remote_id": "AgACAgEAAxk..."
829
+ }
830
+ ```
831
+
832
+ **Use Case 2: Get file info from a message**
833
+ ```bash
834
+ # First, get messages to find a file_id
835
+ {"chat": "John Doe", "mode": "history", "limit": 5}
836
+ # Response includes file_id in messages with media
837
+
838
+ # Then get file metadata
839
+ {"file_id": 45}
840
+ ```
841
+
842
+ ---
843
+
844
+ ## 9. getGroup
845
+
846
+ **Description:** Get information about a group (basic group, supergroup, or channel). Use `type="auto"` to detect automatically, or specify `type="supergroup"` or `type="basic_group"` explicitly.
847
+
848
+ ### Input Schema
849
+ ```json
850
+ {
851
+ "type": "object",
852
+ "properties": {
853
+ "group": {
854
+ "type": ["number", "string"],
855
+ "description": "Group identifier: name or numeric ID"
856
+ },
857
+ "type": {
858
+ "type": "string",
859
+ "enum": ["auto", "supergroup", "basic_group"],
860
+ "description": "Group type (default: 'auto')"
861
+ }
862
+ },
863
+ "required": ["group"]
864
+ }
865
+ ```
866
+
867
+ ### Output Schema
868
+ ```typescript
869
+ {
870
+ id: number;
871
+ name: string;
872
+ type: "basic_group" | "supergroup" | "channel";
873
+ member_count: number;
874
+ is_verified?: boolean; // supergroups only
875
+ is_scam?: boolean; // supergroups only
876
+ join_date?: string;
877
+ }
878
+ ```
879
+
880
+ ### Use Cases
881
+
882
+ **Use Case 1: Get group with auto-detection**
883
+ ```bash
884
+ # Input
885
+ {"group": "Project Team"}
886
+
887
+ # Output
888
+ {
889
+ "id": 1234567890,
890
+ "name": "Project Team",
891
+ "type": "supergroup",
892
+ "member_count": 15,
893
+ "is_verified": false,
894
+ "is_scam": false
895
+ }
896
+ ```
897
+
898
+ **Use Case 2: Get basic group explicitly**
899
+ ```bash
900
+ # Input
901
+ {"group": "Family Group", "type": "basic_group"}
902
+
903
+ # Output
904
+ {
905
+ "id": 9876543210,
906
+ "name": "Family Group",
907
+ "type": "basic_group",
908
+ "member_count": 5
909
+ }
910
+ ```
911
+
912
+ **Use Case 3: Get supergroup by ID**
913
+ ```bash
914
+ # Input
915
+ {"group": 1234567890, "type": "supergroup"}
916
+ ```
917
+
918
+ ---
919
+
920
+ ## 10. getChatMembers
921
+
922
+ **Description:** Get members of a chat with filtering options. Supports filtering by role (administrators, banned, bots) or searching by name.
923
+
924
+ ### Input Schema
925
+ ```json
926
+ {
927
+ "type": "object",
928
+ "properties": {
929
+ "chat": {
930
+ "type": ["number", "string"],
931
+ "description": "Chat identifier: name/title or numeric ID"
932
+ },
933
+ "filter": {
934
+ "type": "string",
935
+ "enum": ["recent", "administrators", "banned", "bots", "search"],
936
+ "description": "Filter type (default: 'recent')"
937
+ },
938
+ "query": {
939
+ "type": "string",
940
+ "description": "Search query (for 'search' and 'banned' filters)"
941
+ },
942
+ "offset": {
943
+ "type": "number",
944
+ "description": "Pagination offset"
945
+ },
946
+ "limit": {
947
+ "type": "number",
948
+ "description": "Max members to return (default: 200, max: 200)"
949
+ }
950
+ },
951
+ "required": ["chat"]
952
+ }
953
+ ```
954
+
955
+ ### Output Schema
956
+ ```typescript
957
+ {
958
+ members: Array<{
959
+ user_id: number;
960
+ name: string;
961
+ username?: string;
962
+ status: string;
963
+ role: string; // "owner", "administrator", "member", etc.
964
+ joined_date?: string;
965
+ }>;
966
+ total_count: number;
967
+ chat_title?: string;
968
+ }
969
+ ```
970
+
971
+ ### Use Cases
972
+
973
+ **Use Case 1: Get recent members**
974
+ ```bash
975
+ # Input
976
+ {"chat": "Project Team", "limit": 10}
977
+
978
+ # Output
979
+ {
980
+ "members": [
981
+ {
982
+ "user_id": 111222333,
983
+ "name": "John Doe",
984
+ "status": "member",
985
+ "role": "creator"
986
+ },
987
+ {
988
+ "user_id": 123456789,
989
+ "name": "John Doe",
990
+ "username": "johndoe",
991
+ "status": "member",
992
+ "role": "member"
993
+ }
994
+ ],
995
+ "total_count": 15,
996
+ "chat_title": "Project Team"
997
+ }
998
+ ```
999
+
1000
+ **Use Case 2: Get only administrators**
1001
+ ```bash
1002
+ # Input
1003
+ {"chat": "Project Team", "filter": "administrators"}
1004
+
1005
+ # Output
1006
+ {
1007
+ "members": [
1008
+ {
1009
+ "user_id": 111222333,
1010
+ "name": "John Doe",
1011
+ "status": "administrator",
1012
+ "role": "owner"
1013
+ }
1014
+ ],
1015
+ "total_count": 1,
1016
+ "chat_title": "Project Team"
1017
+ }
1018
+ ```
1019
+
1020
+ **Use Case 3: Search members by name**
1021
+ ```bash
1022
+ # Input
1023
+ {"chat": "Project Team", "filter": "search", "query": "john"}
1024
+ ```
1025
+
1026
+ **Use Case 4: Get bot members**
1027
+ ```bash
1028
+ # Input
1029
+ {"chat": "Project Team", "filter": "bots"}
1030
+ ```
1031
+