fix(tools): trim raw GitHub payloads from write-tool responses#279
Merged
Conversation
Seven write tools returned the raw GitHub API response verbatim (1.5-3KB of user objects, reactions, _links and *_url fields per call), while their CommentData/IssueData annotations advertised a compact schema that was never honoured at runtime - FastMCP does no schema-based key stripping. Trim add_pr_comments, add_inline_pr_comment, create_issue, update_issue, update_reviews, update_assignees and create_release to compact results via three small helpers (_pick, _comment_result, _issue_result), completing the pattern already used by get_pr_content, create_pr and list_open_issues_prs. update_assignees now returns one unified status shape instead of embedding the full raw issue. Wire responses shrink ~85-90% (create_issue: ~2.5-3KB to ~0.3KB) and structured content now matches the declared output schemas. Tests: exact-equality coverage for all seven tools against realistic bloated payloads; merge_pr, update_pr_branch and create_tag are untouched (GitHub already returns small payloads there).
Up to standards ✅🟢 Issues
|
| Category | Results |
|---|---|
| Documentation | 1 minor |
🟢 Metrics 15 complexity
Metric Results Complexity 15
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Dependency ReviewThe following issues were found:
License Issuesuv.lock
OpenSSF ScorecardScorecard details
Scanned Files
|
- fastmcp-slim 3.4.2 -> 3.4.4, redis 8.0.0 -> 8.0.1 (mcp 1.28.1 transitively) - dev: pyright 1.1.411, pytest 9.1.1, ruff 0.15.21, uv 0.11.28 - drop removed ANN101/ANN102 codes from the ruff ignore list All patch-level with no code changes. ruff and pyright clean, 64 tests pass, server boots and registers all 24 tools.
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.
What
Seven write tools shipped the raw GitHub API response straight to the LLM client - 1.5-3KB per call of user objects, reactions,
_linksand dozens of*_urlfields. TheCommentData/IssueDatareturn annotations promised a compact shape, but FastMCP does no schema-based key stripping (verified in fastmcp-slim 3.4.2convert_result, which serialises the raw return value), so the wire response never matched the advertised output schema.This trims the seven offenders to the compact contracts the codebase already uses in
get_pr_content,create_prandlist_open_issues_prs:add_pr_comments,add_inline_pr_comment->{id, body, author, html_url, created_at}create_issue,update_issue->{number, title, body, state, author, labels: string[], html_url, created_at, updated_at}update_reviews->{id, state, body, html_url, submitted_at}create_release->{id, tag_name, name, html_url, draft, prerelease, body}(body kept - it carries generated release notes)update_assignees-> one unified{status, assignees_requested, assignees_applied, issue_url}shape; previously the partial branch embedded the entire raw issueThree small module-level helpers (
_pick,_comment_result,_issue_result) do the trimming.Why
create_issuewire response drops from 1,085 bytes (mocked payload - real ones are 2-3x larger) to 219 bytes.tools/listadvertises is what the tool returns.Not changed
merge_pr,update_pr_branchandcreate_tag- GitHub already returns small payloads for these, andmerge_prhas passthrough tests.get_pr_diffis untouched; the diff is the product.Testing
update_assigneesbranches)ruff check .clean (also fixes two pre-existing violations in the test file),pyright0 errorstools/listthat all 24 tools register and the regenerated output schemas show the new shapes