Skip to content

feat: add Telegram chat tools - #2

Draft
tdakkota wants to merge 9 commits into
gotd:mainfrom
tdakkota:feat/more-tools
Draft

feat: add Telegram chat tools#2
tdakkota wants to merge 9 commits into
gotd:mainfrom
tdakkota:feat/more-tools

Conversation

@tdakkota

@tdakkota tdakkota commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add general chat list/history/search MCP tools
  • add send_message and TG_FILE_ROOT-restricted send_file tools
  • generalize dialog cache/storage for channels, groups, and private chats while preserving broadcast unread tools
  • expose limit metadata for capped responses

Tests

  • go test ./...

@tdakkota
tdakkota marked this pull request as draft July 6, 2026 09:29
tdakkota and others added 9 commits August 2, 2026 22:54
Co-authored-by: Codex <codex@openai.com>
Generalize mark-read to any dialog (mark_chat_read replaces
mark_channel_read) and namespace cache mutations by peer kind, so marking
a user or group read no longer misses the cache. Add a query filter to
list_chats.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Server-side peer search, so public chats absent from the dialog cache are
findable. Reuses the resolve_peer output shape, annotated with cached
dialog state.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Read paths dropped every *tg.MessageService, so pins, joins and screenshot
events were silently missing from history. They are now returned with
service=true and a snake_case action name derived from the TL type.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Let Telegram decide which peers accept the notification instead of
guessing from the TL schema comment.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
get_file gains inline mode, returning an image content block for
vision-capable clients. It picks the smallest photo variant reaching
1280px on the long edge, since smaller is unreadable and larger only
costs context, and caps the result at 5 MiB.

TG_ALLOW_SEND now defaults to off like the other rights, so a server
started with no configuration is read-only. Existing deployments relying
on the old default must set TG_ALLOW_SEND=true.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Adds OpenTelemetry traces, metrics and logs: a span per MCP request and per
MTProto call via gotd/contrib/oteltg, plus mcp.request.*, tg.rpc.* and
tg.flood_wait.count. The MCP receiving middleware replaces the per-tool logged()
wrapper, and injectLogger puts the zctx base logger on request contexts.

Exporters keep the SDK defaults (OTLP/gRPC to localhost:4317), so deployments
without a collector must set OTEL_*_EXPORTER=none. Binary grows 27 MB to 81 MB.
"tgmcp auth" stays outside app.Run to keep its interactive prompts.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
send_message and send_file accept parse_mode: plain (default, verbatim) or
markdown, parsed by gotd's telegram/message/markdown into Telegram entities.
Default stays plain so text containing "_" or "*" is not silently reformatted.

Mentions resolve the access hash from the dialog cache, since a user session
cannot mention by ID alone; unknown users fail instead of sending a broken
mention.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

1 participant