Skip to content

fix(mcp): return compact summaries from list_recent_events by default - #79

Merged
DominikPinsel merged 1 commit into
mainfrom
fix/mcp-recent-events-summary
Aug 10, 2026
Merged

fix(mcp): return compact summaries from list_recent_events by default#79
DominikPinsel merged 1 commit into
mainfrom
fix/mcp-recent-events-summary

Conversation

@DominikPinsel

Copy link
Copy Markdown
Owner

Closes #75

Problem

list_recent_events shipped the complete raw webhook payload for every event — ~30–40 KB each, with the body duplicated under raw. Even count=1 was ~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:

  • drops raw entirely and trims headers to identifying ones (*-Event, *-Delivery, Content-Type, X-Request-Id)
  • replaces data with a compact summary of well-known fields: action, ref, repository (full_name), sender login, issue / pull_request number+title, commitCount
  • records the original payload size as payloadBytes
  • derives the canonical event type into type (same -Event header scan the hub uses)
  • adds an opt-in full: bool parameter (default false) returning the untouched raw payload for the rare case it is actually needed

Acceptance criteria

  • defaults return well under ~10 KB (each event now ~200–300 bytes)
  • no duplicated payload (raw gone unless full=true)
  • full payload still retrievable via explicit opt-in

Tests

New unit tests cover: summarization strips raw/sensitive headers and keeps identity fields, full=true passthrough, and non-object payloads. go build, go test ./internal/tools/, golangci-lint run all pass.

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
@DominikPinsel
DominikPinsel merged commit 438d5ef into main Aug 10, 2026
3 checks passed
@DominikPinsel
DominikPinsel deleted the fix/mcp-recent-events-summary branch August 10, 2026 21:52
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.

MCP: list_recent_events returns full raw webhook payloads — blows up agent context

1 participant