Reduce token usage in MCP tools by avoiding unnecessary data fetching#229
Open
Reduce token usage in MCP tools by avoiding unnecessary data fetching#229
Conversation
- get_updates: Use @include directives so replies and assets are only fetched from the API when requested (previously always fetched and discarded in JS). Drop redundant HTML body field — text_body is sufficient for LLM consumption and roughly halves update content size. - get_board_activity: Add opt-in includeData parameter (default false) with @include directive. The raw data field contains full before/after JSON state of every change and was unconditionally fetched for up to 1000 entries, producing massive payloads. - list_users_and_teams: Fix listUsersOnly query which was identical to listUsersWithTeams — it fetched team membership data for every user (up to 1000) despite being the "users only" code path. Made-with: Cursor
damian-rakus
approved these changes
Mar 12, 2026
Collaborator
damian-rakus
left a comment
There was a problem hiding this comment.
Before merging let's make sure all relevant subgraphs support the @include
Collaborator
Author
Yeah I sent them a message, I think you are in that channel as well |
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
Three targeted optimizations to reduce response payload sizes in platform API tools, cutting unnecessary token consumption:
1.
get_updates— Conditional fetching + dropped HTML bodyProblem: The GraphQL queries always fetched
repliesandassetsfrom the monday.com API, even whenincludeRepliesandincludeAssetswerefalse. The tool discarded them in JavaScript after they'd already been transferred. Additionally, every update returned bothbody(HTML markup) andtext_body(plain text) — the HTML is unnecessary for LLM consumption and roughly doubles each update's content size.Fix:
@include(if: $includeReplies)and@include(if: $includeAssets)directives to bothGetItemUpdatesandGetBoardUpdatesGraphQL queries, so the API itself skips these fields when not requested.body(HTML) field from queries and response mapping —text_bodyis sufficient for LLM tools.2.
get_board_activity— NewincludeDataoption (defaultfalse)Problem: Each activity log entry has a
datafield containing the full raw JSON of before/after column state for every change. With the default limit of 1000 entries, this produces massive payloads — often 100k+ tokens of raw JSON that the LLM rarely needs.Fix:
includeDatainput parameter (boolean, defaultfalse) with a descriptive schema.@include(if: $includeData)directive to thedatafield in the GraphQL query so it's not even fetched when not needed.3.
list_users_and_teams— FixedlistUsersOnlyqueryProblem: The
listUsersOnlyGraphQL query was identical tolistUsersWithTeams— both fetchedteams { ...UserTeamMembership }for every user. WithDEFAULT_USER_LIMIT = 1000, this meant team membership data for up to 1000 users was being fetched and serialized for no reason on the "users only" code path.Fix: Removed the
teamsfragment fromlistUsersOnlyso it actually matches its semantic intent.Test plan
get-updates-tooltests pass (including updated assertions for newincludeReplies/includeAssetsvariables)list-users-and-teams-tooltests passMade with Cursor