Skip to content

Feat: Add ALLOWED_TOOLS filter and fix forum mark_as_read#82

Open
nhomar wants to merge 1 commit intochigwell:mainfrom
nhomar:fix-forum-mark-read
Open

Feat: Add ALLOWED_TOOLS filter and fix forum mark_as_read#82
nhomar wants to merge 1 commit intochigwell:mainfrom
nhomar:fix-forum-mark-read

Conversation

@nhomar
Copy link
Copy Markdown

@nhomar nhomar commented Mar 31, 2026

Description

This PR introduces two major fixes:

  1. ALLOWED_TOOLS Filtering (Antigravity Context Optimization)
    Implemented an ALLOWED_TOOLS environment variable that dynamically filters the number of tools registered with FastMCP. This is crucial for downstream AI clients like Antigravity, which suffer from context overflows when 100+ generic or unused tools are loaded simultaneously into the LLM context.

  2. mark_as_read Forum Topic Support
    The original mark_as_read implementation only cleared the general chat history using send_read_acknowledge(entity). It did not clear unread badges for forums (supergroups with topics enabled).

    • Added a specific loop to check if the group supports forum topics using GetForumTopicsRequest.
    • Iterated over active topics and checked for unread counts (unread_count > 0 or unread_mentions_count > 0).
    • Fired ReadDiscussionRequest directly against the specific topic msg_id to reliably clear the notification badge for that individual thread.
    • Encapsulated topic handling inside a try/except block to gracefully ignore standard groups.

- Implemented an `ALLOWED_TOOLS` environment variable to filter the number of tools registered with FastMCP. This is crucial to prevent token limits and context overflows in downstream AI clients (e.g. Antigravity) that cannot handle 100+ tools.
- Improved `mark_as_read` by adding support for forum topics properly utilizing `GetForumTopicsRequest` and `ReadDiscussionRequest`.
@nhomar nhomar force-pushed the fix-forum-mark-read branch from eb7d7e4 to 28f4adf Compare March 31, 2026 01:05
@nhomar nhomar changed the title Fix: Support marking forum topics as read Feat: Add ALLOWED_TOOLS filter and fix forum mark_as_read Mar 31, 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.

1 participant