Skip to content

Add read-only exposed tools mode - #136

Merged
chigwell merged 1 commit into
chigwell:mainfrom
iqdoctor:feat/exposed-tools-read-only
May 27, 2026
Merged

Add read-only exposed tools mode#136
chigwell merged 1 commit into
chigwell:mainfrom
iqdoctor:feat/exposed-tools-read-only

Conversation

@iqdoctor

Copy link
Copy Markdown
Contributor

Summary

  • Add TELEGRAM_EXPOSED_TOOLS=read-only to expose only tools annotated with readOnlyHint=True.
  • Keep the default/unset behavior as all so existing users continue seeing every registered tool.
  • Document the env var in README and .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-only to expose only tools annotated with readOnlyHint=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 pytest
  • uv run black --check .
  • git diff --check
  • Local smoke check: with registered real tools, read-only mode removed 65 of 114 tools and all remaining tools had readOnlyHint=True.
  • Local invalid-env smoke check: TELEGRAM_EXPOSED_TOOLS=banana exits with Invalid 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.

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
chigwell merged commit c64cece into chigwell:main May 27, 2026
4 checks passed
KiaroSama pushed a commit to KiaroSama/telegram-mcp that referenced this pull request Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants