Commit graph

38 commits

Author SHA1 Message Date
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
anonim
9cfc9d547e
Update main.py
Co-authored-by: Eugene Evstafev <36392751+chigwell@users.noreply.github.com>
2025-04-17 19:42:48 +03:00
anonim
dd9a5cf81a
Update main.py
Co-authored-by: Eugene Evstafev <36392751+chigwell@users.noreply.github.com>
2025-04-17 19:42:42 +03:00
anonim
861a1281d5
Update main.py
Co-authored-by: Eugene Evstafev <36392751+chigwell@users.noreply.github.com>
2025-04-17 19:42:36 +03:00
anonim
e297416e54 feat: refine logging and error handling in main.py, update .env.example and README
- Enhanced logging setup in main.py for better error tracking and console output.
- Improved error handling in group and user management functions.
- Updated .env.example to include a sample session string and removed outdated test configurations.
- Expanded README.md with new tool examples and usage instructions for better clarity.
- Removed the test.py file as it is no longer needed for testing.
2025-04-17 17:56:42 +03:00
anonim
fec185075b feat: update .env.example and README for enhanced testing configuration
- Expanded .env.example to include detailed test configuration options for chat and user IDs.
- Updated README.md to reflect new testing instructions and configuration details.
- Improved documentation on error handling and robustness of the Telegram MCP server.
2025-04-17 16:52:31 +03:00
anonim
710b9fd05c feat: enhance error handling and logging in main.py
- Added logging setup to capture errors in mcp_errors.log.
- Improved error handling in get_chats, get_messages, send_message, and other functions to provide clearer feedback.
- Added file existence and readability checks for file-related functions.
- Updated documentation for function arguments to clarify requirements.
2025-04-15 16:47:06 +03:00
anonim
84de77230b feat: major update to Telegram MCP server with new features and enhancements
- Bumped version to 2.0.0 in pyproject.toml and updated dependencies.
- Expanded README.md to reflect new features, including comprehensive tools for chat, group, and contact management.
- Added new functionalities for managing contacts, messages, and user profiles.
- Updated .gitignore to include .DS_Store files.
- Improved error handling and messaging in main.py.
- Enhanced overall documentation and usage examples for better user guidance.
2025-04-15 16:30:32 +03:00
anonim
4b5c23faf6 refactor: improve error message formatting in main.py and clean up test imports
- Reformatted the error message for database lock detection in main.py for better readability.
- Removed unnecessary imports from test_basic.py to streamline the test file.
2025-03-31 18:56:30 +03:00
anonim
726fef23f3 feat: enhance Telegram MCP server with new features and configuration updates
- Updated .env.example with new Telegram API credentials and session string options.
- Expanded .gitignore to exclude session files and configuration.
- Refactored main.py to support string session authentication and added new functions for contact and message management.
- Updated README.md to reflect new features, installation instructions, and usage examples.
- Added python-dotenv as a dependency in pyproject.toml for environment variable management.
2025-03-31 18:45:36 +03:00
Eugene Evstafev
1f7474aa5c feat: init commit 2025-03-20 15:49:27 +00:00