Skip to content

Reduce context usage for list_issues#2098

Open
kerobbi wants to merge 2 commits intomainfrom
kerobbi/reduce-context-list-issues
Open

Reduce context usage for list_issues#2098
kerobbi wants to merge 2 commits intomainfrom
kerobbi/reduce-context-list-issues

Conversation

@kerobbi
Copy link
Contributor

@kerobbi kerobbi commented Feb 25, 2026

Summary

Reduces context usage for list_issues by converting GraphQL fragments directly to MinimalIssue, and introducing a typed MinimalIssuesResponse for the paginated response (following the MinimalReviewThreadsResponse pattern). Also removes the intermediate fragmentToIssue conversion.

Token reduction is modest since the GraphQL fragment was already sparse, the main wins are labels flattened to name strings and id dropped.

Fields preserved

number, title, body, state, user (login), labels (name strings), comments, created_at, updated_at

Fields dropped

id, Label's node_id and description (labels flattened to []string)

Single Item Payload Diff

Before
{
	"id": 3985464387,
	"number": 2082,
	"state": "OPEN",
	"title": "Duplicate CodeQL",
	"body": "### Describe the bug\n\nA clear and concise description of what the bug is.\n\n### Affected version\n\nPlease run ` docker run -i --rm ghcr.io/github/github-mcp-server ./github-mcp-server --version` and paste the output below\n\n### Steps to reproduce the behavior\n\n1. Type this \u0026#39;...\u0026#39;\n2. View the output \u0026#39;....\u0026#39;\n3. See error\n\n### Expected vs actual behavior\n\nA clear and concise description of what you expected to happen and what actually happened.\n\n### Logs\n\nPaste any available logs. Redact if needed.\n",
	"user": { "login": "kdehl16-web" },
	"labels": [
		{ "name": "bug", "description": "Something isn't working", "node_id": "LA_kwDOODGMVM8AAAAB6zaIbw" },
		{ "name": "request ai review", "description": "", "node_id": "LA_kwDOODGMVM8AAAACVGXp_w" }
	],
	"comments": 0,
	"created_at": "2026-02-24T19:32:40Z",
	"updated_at": "2026-02-24T19:32:51Z"
}
After
{
	"number": 2082,
	"title": "Duplicate CodeQL",
	"body": "### Describe the bug\n\nA clear and concise description of what the bug is.\n\n### Affected version\n\nPlease run ` docker run -i --rm ghcr.io/github/github-mcp-server ./github-mcp-server --version` and paste the output below\n\n### Steps to reproduce the behavior\n\n1. Type this \u0026#39;...\u0026#39;\n2. View the output \u0026#39;....\u0026#39;\n3. See error\n\n### Expected vs actual behavior\n\nA clear and concise description of what you expected to happen and what actually happened.\n\n### Logs\n\nPaste any available logs. Redact if needed.\n",
	"state": "OPEN",
	"user": { "login": "kdehl16-web" },
	"labels": ["bug", "request ai review"],
	"created_at": "2026-02-24T19:32:40Z",
	"updated_at": "2026-02-24T19:32:51Z"
}

Token Reduction

Measured using a script that makes use of OAI's tiktoken library (o200k_base) at 2 and 100 items. The web version can be found here.

Items Baseline Optimised Reduction
2 790 687 13.0%
100 71,035 66,236 6.8%

Why

list_issues was converting GraphQL fragments to raw *github.Issue objects (via fragmentToIssue), then serialising those with full Label objects and hand built pagination info. This replaces both with typed minimal types.

What changed

  • Added MinimalIssuesResponse struct and convertToMinimalIssuesResponse function (which follows MinimalReviewThreadsResponse pattern)
  • Added fragmentToMinimalIssue which converts GraphQL fragment directly to MinimalIssue, skipping the intermediate *github.Issue
  • Aligned MinimalPageInfo and response wrapper structs to camelCase tags (pageInfo, totalCount, hasNextPage, etc.) consistent with how all tools handlers return pagination metadata. This affects MinimalReviewThreadsResponse which was the only outlier using snake_case
  • Added omitempty to MinimalIssue.HTMLURL (not populated by the GraphQL fragment)
  • Updated relevant tests

MCP impact

  • No tool or API changes
  • Tool schema or behavior changed
  • New tool added

Prompts tested (tool changes only)

  • List the last 2 issues in github/github-mcp-server
  • List the last 100 issues in github/github-mcp-server

Security / limits

  • No security or limits impact
  • Auth / permissions considered
  • Data exposure, filtering, or token/size limits considered

Tool renaming

  • I am renaming tools as part of this PR (e.g. a part of a consolidation effort)
    • I have added the new tool aliases in deprecated_tool_aliases.go
  • I am not renaming tools as part of this PR

Note: if you're renaming tools, you must add the tool aliases. For more information on how to do so, please refer to the official docs.

Lint & tests

  • Linted locally with ./script/lint
  • Tested locally with ./script/test

Docs

  • Not needed
  • Updated (README / docs / examples)

Copilot AI review requested due to automatic review settings February 25, 2026 18:49
@kerobbi kerobbi requested a review from a team as a code owner February 25, 2026 18:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces list_issues response verbosity by converting GraphQL issue fragments directly into MinimalIssue and returning a typed, paginated MinimalIssuesResponse, avoiding intermediate *github.Issue objects.

Changes:

  • Added MinimalIssuesResponse and conversion helpers to produce a minimal, typed paginated response for issues.
  • Switched list_issues to marshal the new minimal response instead of raw GitHub issue objects + hand-built pagination map.
  • Updated MinimalIssue JSON tags (html_url now omitempty) and adjusted Test_ListIssues to unmarshal the new response type.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
pkg/github/minimal_types.go Introduces MinimalIssuesResponse plus fragment-to-minimal conversion to reduce output size and flatten labels.
pkg/github/issues.go Removes fragmentToIssue and updates list_issues to return MinimalIssuesResponse via MarshalledTextResult.
pkg/github/issues_test.go Updates Test_ListIssues to unmarshal MinimalIssuesResponse and validates basic issue fields.

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.

2 participants