fix(mcp): return compact summaries from list_recent_events by default - #79
Merged
Conversation
list_recent_events shipped the complete raw webhook payload for every event (~30-40 KB each, with the body duplicated under "raw"), so even count=1 responses were ~30 KB and the default 20-event listing close to 900 KB — unusable for LLM agents with limited context. Post-process the hub response before returning: - drop the duplicate "raw" field and all non-identifying headers (only *-Event, *-Delivery, Content-Type, X-Request-Id are kept) - replace "data" with a compact summary of well-known fields (action, ref, repository, sender, issue/pull_request number+title, commit count) and record the original size as payloadBytes - derive the canonical event type into "type" Add an opt-in "full" boolean parameter (default false) that returns the untouched raw payload for the rare case it is actually needed. Closes #75
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.
Closes #75
Problem
list_recent_eventsshipped the complete raw webhook payload for every event — ~30–40 KB each, with the body duplicated underraw. Evencount=1was ~30 KB; the default 20-event listing ~900 KB. This floods agent context windows and makes the tool unusable.Changes (MCP server,
services/mcp/internal/tools/events.go)Post-processes the hub response before returning:
rawentirely and trimsheadersto identifying ones (*-Event,*-Delivery,Content-Type,X-Request-Id)datawith a compact summary of well-known fields:action,ref,repository(full_name),senderlogin,issue/pull_requestnumber+title,commitCountpayloadBytestype(same-Eventheader scan the hub uses)full: boolparameter (defaultfalse) returning the untouched raw payload for the rare case it is actually neededAcceptance criteria
rawgone unlessfull=true)Tests
New unit tests cover: summarization strips
raw/sensitive headers and keeps identity fields,full=truepassthrough, and non-object payloads.go build,go test ./internal/tools/,golangci-lint runall pass.