Add read-only exposed tools mode - #136
Merged
Merged
Conversation
Use existing FastMCP ToolAnnotations as the source of truth so operators can narrow the client-visible surface without maintaining a separate tool allowlist. Constraint: TELEGRAM_EXPOSED_TOOLS must default to all and accept only all or read-only. Rejected: Hardcoded read-only tool-name allowlist | It would duplicate MCP annotations and drift from registered tool metadata. Confidence: high Scope-risk: narrow Directive: Keep this as an MCP exposure filter; do not represent it as lowering Telegram session authority. Tested: uv run pytest; uv run black --check .; git diff --check; smoke check confirmed read-only mode kept only readOnlyHint=True tools. Not-tested: Live Telegram network behavior or mutation calls, by design.
chigwell
approved these changes
May 27, 2026
KiaroSama
pushed a commit
to KiaroSama/telegram-mcp
that referenced
this pull request
Aug 25, 2026
…-only Add read-only exposed tools mode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TELEGRAM_EXPOSED_TOOLS=read-onlyto expose only tools annotated withreadOnlyHint=True.allso existing users continue seeing every registered tool..env.example, with focused unit coverage for default/all, read-only pruning, and invalid values.Rationale
If you want to prevent MCP clients from sending messages or performing chat/account mutations, set
TELEGRAM_EXPOSED_TOOLS=read-onlyto expose only tools annotated withreadOnlyHint=True.This is an MCP tool-surface restriction, not a Telegram session sandbox or reduced Telegram account permission. The Telegram session string still has normal authority inside the process; the guarantee is that mutating tools are not registered/exposed through MCP when the option is enabled.
Test Plan
uv run pytestuv run black --check .git diff --checkreadOnlyHint=True.TELEGRAM_EXPOSED_TOOLS=bananaexits withInvalid TELEGRAM_EXPOSED_TOOLS 'banana'. Expected one of: all, read-only.Safety note
This restricts which MCP tools are exposed to clients. It does not lower the Telegram account/session authority available to the server process itself.