Commit graph

60 commits

Author SHA1 Message Date
smixs
1206cf81d6 style: format code with black 2026-01-27 14:59:35 +05:00
smixs
b733d32467 feat(folders): add 7 tools for Telegram folder management
Add new MCP tools to manage Telegram dialog folders (filters):
- list_folders: get all folders with IDs, names, emoji
- get_folder: get folder details including all included chats
- create_folder: create new folder with filters and chat list
- add_chat_to_folder: add chat to existing folder (idempotent)
- remove_chat_from_folder: remove chat from folder (idempotent)
- delete_folder: delete folder (chats preserved)
- reorder_folders: change folder order

Handles Telegram API specifics:
- TextWithEntities for folder titles
- Max 10 folders limit
- System folder protection (ID < 2)
- title_noanimate and color attributes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 13:55:55 +05:00
Eugene Evstafev
d65fb8b74c
Merge pull request #48 from BayramAnnakov/feat/message-engagement-metrics
feat: add engagement metrics to message output
2026-01-11 20:02:05 +00:00
Eugene Evstafev
ff8d19b59c
Merge pull request #46 from BayramAnnakov/fix/unread-mark-detection
fix: detect manually marked unread chats in list_chats
2025-12-26 22:51:54 +00:00
Bayram Annakov
6a05d7a661 feat: add engagement metrics (views, forwards, reactions) to message output
Adds views, forwards, and reaction counts to message output for channel posts.
These metrics are available in Telegram's API for channel content.

Changes:
- get_messages: Include engagement info in output
- list_messages: Include engagement info in output

Example output: 'views:1234, forwards:56, reactions:78'

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 14:09:48 -08:00
Bayram Annakov
11bfca7083 style: apply black formatting to match project standards 2025-12-26 13:51:20 -08:00
Bayram Annakov
aabe9d8bc0 fix: correct syntax error from suggestion application
The individual line suggestions created invalid Python when applied
separately. Combined the ternary expression properly.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 13:48:36 -08:00
Bayram Annakov
182e3684dd
Update main.py
Co-authored-by: Eugene Evstafev <36392751+chigwell@users.noreply.github.com>
2025-12-26 13:47:11 -08:00
Bayram Annakov
d504e5fa45
Update main.py
Co-authored-by: Eugene Evstafev <36392751+chigwell@users.noreply.github.com>
2025-12-26 13:47:05 -08:00
Bayram Annakov
700c01b2d3
Update main.py
Co-authored-by: Eugene Evstafev <36392751+chigwell@users.noreply.github.com>
2025-12-26 13:46:59 -08:00
Bayram Annakov
fe8dcb3797
Update main.py
Co-authored-by: Eugene Evstafev <36392751+chigwell@users.noreply.github.com>
2025-12-26 13:46:53 -08:00
Bayram Annakov
adc6ef4c7c
Update main.py
Co-authored-by: Eugene Evstafev <36392751+chigwell@users.noreply.github.com>
2025-12-26 13:46:46 -08:00
Bayram Annakov
041bf0dbec
Update main.py
Co-authored-by: Eugene Evstafev <36392751+chigwell@users.noreply.github.com>
2025-12-26 13:46:38 -08:00
Bayram Annakov
78a21ef2d0
Update main.py
Co-authored-by: Eugene Evstafev <36392751+chigwell@users.noreply.github.com>
2025-12-26 13:46:31 -08:00
Bayram Annakov
943f66a67c
Apply suggestions from code review
Co-authored-by: Eugene Evstafev <36392751+chigwell@users.noreply.github.com>
2025-12-26 13:45:28 -08:00
Bayram Annakov
6b1f4cda85 fix: detect manually marked unread chats in list_chats
Previously list_chats only checked dialog.unread_count, missing chats
that were manually marked as unread via Telegram's "mark as unread" feature.

Now also checks dialog.dialog.unread_mark flag:
- unread_count > 0: shows "Unread: N"
- unread_mark = True: shows "Unread: marked"

This matches the behavior of Telegram's "Unread" folder filter.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 19:17:22 -08:00
Bayram Annakov
37269e11ea feat: add draft management tools (save_draft, get_drafts, clear_draft)
Add three new tools for managing Telegram drafts:
- save_draft: Save a draft message to any chat/channel
- get_drafts: List all drafts across all chats
- clear_draft: Clear a draft from a specific chat

Uses Telethon's SaveDraftRequest and GetAllDraftsRequest APIs.
Drafts appear in Telegram's input field for review before sending.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 19:04:32 -08:00
Dmitrii Zolotukhin
7a9ee58c71 feat: add message reactions support
Add three new MCP tools for handling Telegram message reactions:
- send_reaction: Send emoji reaction to a message
- remove_reaction: Remove your reaction from a message
- get_message_reactions: Get list of reactions on a message

All tools include proper ToolAnnotations and follow existing code patterns.
2025-12-23 19:55:54 +03:00
triepod-ai
49d70795f0 feat: Add title annotations to all 78 tools for improved LLM display
Add human-readable title annotations to all MCP tools to help clients
display tool names in a user-friendly format.

Changes:
- Added title annotation to all 78 tools (e.g., "Get Chats", "Send Message")
- Formatted with Black for code style consistency

This improves the user experience when MCP clients display tool lists.

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-23 07:55:43 -06:00
Yurii Karabas
92a0dc31b5 fix lint errors 2025-12-18 23:47:12 +01:00
Yurii Karabas
603119073a Add scripts entrypoint to run telegram-mcp using uvx 2025-11-22 14:22:13 +01:00
Valeriy_Pavlovich
be12812c62 black: reformatted main.py 2025-11-14 01:08:37 +03:00
Valeriy_Pavlovich
1c71806082 feat: add comprehensive ToolAnnotations to all MCP tools
- Add openWorldHint=True to all 63+ @mcp.tool decorators
- Add readOnlyHint=True to read-only operations (get/list/search/export functions)
- Add destructiveHint=True to state-changing operations (send/create/delete/edit functions)
- Add idempotentHint=True to safely repeatable operations (block/unblock/pin/unpin/ban/unban/etc.)
- Fix syntax errors: openWorldHint(True) → openWorldHint=True
- Remove incorrect idempotentHint from non-idempotent operations (send_file, press_inline_button, import_contacts)

These annotations help MCP clients understand tool behavior:
- readOnlyHint: tool doesn't modify environment
- destructiveHint: tool performs destructive updates
- idempotentHint: repeated calls with same args have no additional effect
- openWorldHint: tool interacts with external entities (Telegram API)

Improves tool discoverability and helps AI agents make better decisions about tool usage.
2025-11-14 00:26:35 +03:00
latand
b5ac2c0445 Format main.py with black 2025-11-05 12:17:21 +02:00
latand
c3594795cd Add inline button helpers and channel subscription tool 2025-11-04 20:56:04 +02:00
Korzhavin Ivan
62a3fd68be fix: undefined variable _id in unarchive_chat function
Fixed undefined variable '_id' in unarchive_chat function by
changing it to 'chat_id' which is the correct parameter name.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-21 09:34:48 +02:00
Korzhavin Ivan
994a49faba style: format code with black 2025-10-20 01:06:06 +02:00
Korzhavin Ivan
80245bcdc9 fix: resolve stash conflict 2025-10-20 01:01:13 +02:00
Korzhavin Ivan
f8a8b581f4 fix: merge conflict 2025-10-20 01:00:55 +02:00
Eugene Evstafev
97884fd1c1
Merge pull request #24 from korjavin/main
Refactor error logging in main.py to structured JSON format with backward compatibility
2025-10-19 17:16:57 +01:00
Korzhavin Ivan
cbe429b474 Merge branch 'main' of https://github.com/chigwell/telegram-mcp into feature/id-validation-decorator
Resolved conflict in log_and_format_error function by:
- Combining ErrorCategory enum (from main) with user_message parameter (from feature branch)
- Supporting both ErrorCategory and string prefixes (for validation errors)
- Keeping validation decorator functionality intact

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-19 15:23:15 +02:00
Korzhavin Ivan
2a7134be39 fix: Apply Black formatting to pass CI checks
Applied Black code formatting to main.py to resolve linting
failures in GitHub Actions for PR #24.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-19 15:19:34 +02:00
Korzhavin Ivan
6bbeae8c98 fix: Apply Black formatting to pass CI checks
Applied Black code formatting to main.py and test_validation.py
to resolve linting failures in GitHub Actions.

Changes include:
- Proper line breaking for long lines
- Consistent quote style (single to double quotes)
- Better formatting of return statements

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-19 15:18:05 +02:00
Mathias L. Baumann
7f078dd1e7 feat: add poll creation functionality
- Implement create_poll tool using Telethon's native poll API
- Support for multiple choice, quiz mode, public votes, and close dates
2025-10-17 17:32:14 +02:00
Valeriy Pavlovich
aa6d2761ce feat: Add forum topics support with list_topics tool
Add new list_topics() MCP tool to retrieve forum topics from Telegram
supergroups with forum feature enabled.

Features:
- Validates chat is a supergroup with forum enabled
- Supports pagination via offset_topic parameter
- Supports search filtering via search_query parameter
- Returns comprehensive topic metadata:
  * Topic ID and title
  * Total messages and unread count
  * Status flags (closed, hidden)
  * Last activity timestamp
- Proper error handling and logging

Documentation:
- Added list_topics to README Messaging tools list
- Added complete code example with implementation
- Added example output showing typical usage

Uses Telethon's GetForumTopicsRequest API for reliable forum topic
retrieval from supergroups.
2025-10-14 15:39:00 +03:00
Valeriy Pavlovich
f08667c47a Format main.py with Black 2025-10-13 21:20:24 +03:00
Valeriy Pavlovich
553125cd76 Make list_messages predictable and efficient for date ranges and search: avoid over-fetch, apply limit after filtering, and separate search from date offsets #27
- stream search results via `client.iter_messages()` and apply date bounds in-code so we collect up to `limit` matches
- use server-side iteration for date-only queries with inclusive upper bounds to avoid over-fetching
- keep the existing `get_messages()` fast path when no filters are provided
2025-10-12 07:14:25 +03:00
google-labs-jules[bot]
50b01ca494 feat: implement structured JSON error logging
- Add python-json-logger dependency.
- Configure file handler to use JsonFormatter for structured logging.
- Keep console handler with the existing text format.
- Refactor log_and_format_error to log a dictionary with structured error data.
2025-09-01 14:39:30 +00:00
google-labs-jules[bot]
34bdd58905 feat: Implement input validation decorator for chat/user IDs
Adds a new `@validate_id` decorator to validate `chat_id` and `user_id` parameters in `main.py`.

This decorator ensures that all IDs passed to functions are in a valid format before making RPC calls to the Telegram API. It handles:
- Integer IDs (positive and negative)
- String representations of integer IDs
- Usernames (e.g., "@username")
- Lists of IDs

Key changes:
- Created a `validate_id` decorator in `main.py`.
- Applied the decorator to all functions that accept `chat_id`, `user_id`, or similar parameters.
- Updated the central `log_and_format_error` function to handle custom validation error messages and a specific `VALIDATION-001` error code for logging.
- Added a new test suite (`test_validation.py`) with comprehensive tests for the decorator.
- Updated `README.md` and `session_string_generator.py` with documentation about the new validation.
2025-08-29 23:16:13 +02:00
google-labs-jules[bot]
59fb2dcd10 refactor: Replace hardcoded error prefixes with an Enum 2025-08-29 23:13:59 +02:00
Tim
78a99b06f2 refactor: clean up whitespace and improve code formatting using black . 2025-08-06 21:07:59 +03:00
TimTProd
2dc8454a4f
Merge branch 'main' into add_replies 2025-08-06 20:19:38 +03:00
Tim
103ce35594 feat: enhance message display with reply information
Updated message formatting in various functions to include details about replies. When a message is a reply, it now shows the ID of the original message and the sender's name, improving context for users.
2025-08-06 19:37:30 +03:00
Tim
f0072801cb feat: add get_sender_name function to enhance message formatting
Introduced a new helper function, get_sender_name, to retrieve the sender's name from messages. Updated various message display functions to include the sender's name in the output, improving clarity and context for users
2025-07-24 17:28:42 +03:00
anonim
214bd6c6e5 style: improve code formatting and consistency in main.py
Refactored several sections of main.py to enhance readability by adjusting line breaks and indentation. This includes formatting changes in error handling and function calls across various asynchronous functions.
2025-04-22 18:39:58 +03:00
anonim
b46f9a4e34 Merge branch 'main' of https://github.com/l1v0n1/telegram-mcp-server 2025-04-22 18:35:06 +03:00
anonim
d562cf61fb refactor: Remove file handling functions from main.py and update README.md
Removed several functions that required direct file path access, including `send_file`, `download_media`, `set_profile_photo`, `edit_chat_photo`, `send_voice`, `send_sticker`, and `upload_file`, due to limitations in the current MCP environment. Updated the README to reflect these changes and added a section on removed functionality.
2025-04-22 18:24:46 +03:00
Eugene Evstafev
eca9fb48cf refactor: update formatting 2025-04-18 14:25:24 +01:00
anonim
0833e51f48 refactor: Consolidate and clean up imports in main.py 2025-04-18 15:03:46 +03:00
anonim
492dd15b42
Update main.py
Co-authored-by: Eugene Evstafev <36392751+chigwell@users.noreply.github.com>
2025-04-17 19:42:54 +03:00