Skip to content

Conversation

mattdholloway
Copy link
Contributor

@mattdholloway mattdholloway commented Aug 27, 2025

This aims to reduce the output from the 'worst offending' MCP tools for response length. The main changes are the introduction of new minimal types for API responses, updates to CRUD handlers to use these minimal types, and enhancements to search and commit tools for more configurable output. These changes simplify responses and make the API easier to consume for clients that only need essential information.

Tools Modified

Search and Listing Tools (Added Parameters)

search_repositories - Added minimal_output parameter (default: true) to return minimal repository information instead of full GitHub API objects
get_commit - Added include_diff parameter (default: true) to optionally include file diffs and stats in the response

List Tools (Modified to Return Minimal Objects)

list_commits - Modified to return minimal commit objects with essential fields only
list_branches - Modified to return minimal branch objects (name, SHA, protected status)

CRUD Tools (Modified to Return URL-Only Response)

create_repository - Modified to return minimal response containing only the repository URL
fork_repository - Modified to return minimal response containing only the repository URL
create_pull_request - Modified to return minimal response containing only the pull request URL
update_pull_request - Modified to return minimal response containing only the pull request URL
create_issue - Modified to return minimal response containing only the issue URL
update_issue - Modified to return minimal response containing only the issue URL
create_gist - Modified to return minimal response containing only the gist URL
update_gist - Modified to return minimal response containing only the gist URL

@mattdholloway mattdholloway changed the title add comprehensive minimal response where appropriate Add comprehensive minimal response where appropriate Aug 27, 2025
@mattdholloway mattdholloway marked this pull request as ready for review August 27, 2025 14:42
@mattdholloway mattdholloway requested a review from a team as a code owner August 27, 2025 14:42
@Copilot Copilot AI review requested due to automatic review settings August 27, 2025 14:42
Copilot

This comment was marked as outdated.

@mattdholloway mattdholloway changed the title Add comprehensive minimal response where appropriate Add comprehensive minimal response to CRUD tools, repositories and search toolsets Aug 27, 2025
@mattdholloway mattdholloway changed the title Add comprehensive minimal response to CRUD tools, repositories and search toolsets Add minimal response to CRUD tools, repositories and search toolsets Aug 27, 2025
@tonytrg
Copy link
Contributor

tonytrg commented Aug 28, 2025

Great work! I have not been much involved in the recent discussions about the size of tool call responses,
so this is just some thinking out loud. Nothing that blocks this pr.

but do you think instead of selectively picking specific tools and downsizing their response we could do:

  • new param responsemode
    • optional
    • default minimal
    • values: minimal, full

Something reusable for every other tool where the api response is unnecessary long.

So kinda stays the same as this pr, only now they can fall back to the old/full response if they need to.

Copilot

This comment was marked as outdated.

mattdholloway and others added 5 commits August 29, 2025 10:33
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@LuluBeatson LuluBeatson linked an issue Sep 1, 2025 that may be closed by this pull request
Copy link
Contributor

@Copilot 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 adds minimal response options to various GitHub MCP tools to reduce output verbosity. The changes introduce optional parameters to return concise responses instead of full GitHub API objects, addressing the need for more efficient data transfer in MCP tools.

  • Added minimal_output parameter to search_repositories (default: true) and include_diff parameter to get_commit (default: true)
  • Modified list operations (list_commits, list_branches) to return minimal objects by default
  • Updated CRUD operations to return only URLs in minimal response format

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/github/server.go Added OptionalBoolParamWithDefault helper function
pkg/github/search.go Added minimal output option to repository search
pkg/github/repositories.go Updated commit and branch operations to use minimal responses
pkg/github/pullrequests.go Modified PR CRUD operations to return minimal responses
pkg/github/issues.go Updated issue CRUD operations to return minimal responses
pkg/github/gists.go Modified gist CRUD operations to return minimal responses
pkg/github/minimal_types.go Added new minimal response type definitions
Test files Updated tests to verify minimal response formats
Documentation Updated README and tool snapshots with new parameters

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

mattdholloway and others added 3 commits September 1, 2025 17:31
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@LuluBeatson
Copy link
Contributor

LuluBeatson commented Sep 1, 2025

Estimated output length savings

Token counts provided with OpenAI tokenizer for reference, but proporional savings will be similar across models.

List Commits (5.2x)

{
  "owner": "github",
  "repo": "github-mcp-server",
  "sha": "e72c1430debb8b0410cbaa9ba0a0cae33adae91a"
}
New: 7,673 tokens
[
  ...,
  {
      "sha": "586a0d6591a9b408890c39195e36dccccd3d7e40",
      "html_url": "https://github.com/github/github-mcp-server/commit/586a0d6591a9b408890c39195e36dccccd3d7e40",
      "commit": {
          "message": "Update pkg/github/repositories.go\n\nCo-authored-by: Copilot \u003c175728472+Copilot@users.noreply.github.com\u003e",
          "author": {
              "name": "Matt Holloway",
              "email": "mattdholloway@github.com",
              "date": "2025-09-01T16:31:51Z"
          },
          "committer": {
              "name": "GitHub",
              "email": "noreply@github.com",
              "date": "2025-09-01T16:31:51Z"
          }
      },
      "author": {
          "login": "mattdholloway",
          "id": 918573,
          "profile_url": "https://github.com/mattdholloway",
          "avatar_url": "https://avatars.githubusercontent.com/u/918573?v=4"
      },
      "committer": {
          "login": "web-flow",
          "id": 19864447,
          "profile_url": "https://github.com/web-flow",
          "avatar_url": "https://avatars.githubusercontent.com/u/19864447?v=4"
      }
  },
  ...
]
Old: 39,860 tokens
[
  ...
  {
      "node_id": "C_kwDOODGMVNoAKDU4NmEwZDY1OTFhOWI0MDg4OTBjMzkxOTVlMzZkY2NjY2QzZDdlNDA",
      "sha": "586a0d6591a9b408890c39195e36dccccd3d7e40",
      "commit": {
          "author": {
              "date": "2025-09-01T16:31:51Z",
              "name": "Matt Holloway",
              "email": "mattdholloway@github.com"
          },
          "committer": {
              "date": "2025-09-01T16:31:51Z",
              "name": "GitHub",
              "email": "noreply@github.com"
          },
          "message": "Update pkg/github/repositories.go\n\nCo-authored-by: Copilot \u003c175728472+Copilot@users.noreply.github.com\u003e",
          "tree": { "sha": "415f5817de2ecbafcaddc7bf709482b875cb6f45" },
          "url": "https://api.github.com/repos/github/github-mcp-server/git/commits/586a0d6591a9b408890c39195e36dccccd3d7e40",
          "verification": {
              "verified": true,
              "reason": "valid",
              "signature": "-----BEGIN PGP SIGNATURE-----\n\nwsFcBAABCAAQBQJotcp3CRC1aQ7uu5UhlAAAZ3UQAB5FlbZqLwFWX6kfDb7i10Gk\n6oIi1lXRUo1fhB3JbwzQXIXQJL8vVxCG7DzDl9z+PX+1yCrRR1pr/Yo3zd01MLoy\n4XWrrBxXhX4LUoniBDpckIG003+l2uvTl9p2gGuzV9R4awFpoDm47zVD4oj2wJzp\ngbiW7DTnsqQ9/EDxeMJe41HsC1VFvEUatv20y7mqne6xLDKYXRNLJ0ZJPn9B1x3E\n1R1XGxlTBXMgkdxM0D0lJuiZLolCnPKH8PuXAFQ0SHeaGmjfHdg6wj4uW2uK2Ri8\neATJfTWI48oCll78bZgcfwJlHE++pDt8wgZmBNNKdgqes/jJ2vsW+7qggrw8hA63\nZBYNG2Szlg0r2N9cO1oKz8gP3o/jMUknXf+9SQFYg7+oI2s+MIPfUGuKUds1EZHB\n664CKF8SPFXzY+9OxMkMfQNuRunkfgRRksEpPMdygeVD8FFIEk1fW16hRzIvDvW3\n6qiMiBJDJNzEG4hfKM3VpNqom18qSPupLlHU3BgBVWE0bcBCdxlgnJ4THX4bgDx6\ne7hF7Za9BgRvUhnyaZjozh65grl/HyKSD81JJNeDdSgKL9Yee9TLu3OsLbXMLEf2\nqqcqn3vFQCvK/AziQd+vj+9SLnmiDSKlIOlE6ywhZwp7dMDMaT8WlnExF7FlYh4I\nqKSQCxuMcJS/visAK9Fe\n=ZNXS\n-----END PGP SIGNATURE-----\n",
              "payload": "tree 415f5817de2ecbafcaddc7bf709482b875cb6f45\nparent cfeed3d5e3095f0de2de2e4916d867a7379f98fb\nauthor Matt Holloway \u003cmattdholloway@github.com\u003e 1756744311 +0100\ncommitter GitHub \u003cnoreply@github.com\u003e 1756744311 +0100\n\nUpdate pkg/github/repositories.go\n\nCo-authored-by: Copilot \u003c175728472+Copilot@users.noreply.github.com\u003e"
          },
          "comment_count": 0
      },
      "author": {
          "login": "mattdholloway",
          "id": 918573,
          "node_id": "MDQ6VXNlcjkxODU3Mw==",
          "avatar_url": "https://avatars.githubusercontent.com/u/918573?v=4",
          "html_url": "https://github.com/mattdholloway",
          "gravatar_id": "",
          "type": "User",
          "site_admin": true,
          "url": "https://api.github.com/users/mattdholloway",
          "events_url": "https://api.github.com/users/mattdholloway/events{/privacy}",
          "following_url": "https://api.github.com/users/mattdholloway/following{/other_user}",
          "followers_url": "https://api.github.com/users/mattdholloway/followers",
          "gists_url": "https://api.github.com/users/mattdholloway/gists{/gist_id}",
          "organizations_url": "https://api.github.com/users/mattdholloway/orgs",
          "received_events_url": "https://api.github.com/users/mattdholloway/received_events",
          "repos_url": "https://api.github.com/users/mattdholloway/repos",
          "starred_url": "https://api.github.com/users/mattdholloway/starred{/owner}{/repo}",
          "subscriptions_url": "https://api.github.com/users/mattdholloway/subscriptions"
      },
      "committer": {
          "login": "web-flow",
          "id": 19864447,
          "node_id": "MDQ6VXNlcjE5ODY0NDQ3",
          "avatar_url": "https://avatars.githubusercontent.com/u/19864447?v=4",
          "html_url": "https://github.com/web-flow",
          "gravatar_id": "",
          "type": "User",
          "site_admin": false,
          "url": "https://api.github.com/users/web-flow",
          "events_url": "https://api.github.com/users/web-flow/events{/privacy}",
          "following_url": "https://api.github.com/users/web-flow/following{/other_user}",
          "followers_url": "https://api.github.com/users/web-flow/followers",
          "gists_url": "https://api.github.com/users/web-flow/gists{/gist_id}",
          "organizations_url": "https://api.github.com/users/web-flow/orgs",
          "received_events_url": "https://api.github.com/users/web-flow/received_events",
          "repos_url": "https://api.github.com/users/web-flow/repos",
          "starred_url": "https://api.github.com/users/web-flow/starred{/owner}{/repo}",
          "subscriptions_url": "https://api.github.com/users/web-flow/subscriptions"
      },
      "parents": [
          {
              "sha": "cfeed3d5e3095f0de2de2e4916d867a7379f98fb",
              "html_url": "https://github.com/github/github-mcp-server/commit/cfeed3d5e3095f0de2de2e4916d867a7379f98fb",
              "url": "https://api.github.com/repos/github/github-mcp-server/commits/cfeed3d5e3095f0de2de2e4916d867a7379f98fb"
          }
      ],
      "html_url": "https://github.com/github/github-mcp-server/commit/586a0d6591a9b408890c39195e36dccccd3d7e40",
      "url": "https://api.github.com/repos/github/github-mcp-server/commits/586a0d6591a9b408890c39195e36dccccd3d7e40",
      "comments_url": "https://api.github.com/repos/github/github-mcp-server/commits/586a0d6591a9b408890c39195e36dccccd3d7e40/comments"
  },
  ...
]

List Branches (4.1x)

{
  "owner": "github",
  "repo": "github-mcp-server"
}
New: 1,373 tokens
[
  ...,
  {
      "name": "SamMorrowDrums-patch-1",
      "sha": "884c0e66eee260e1bbd58e1470311d66764a2bc5",
      "protected": true
  },
  ...
]
Old: 5,606 tokens
[
  ...,
  {
      "name": "SamMorrowDrums-patch-1",
      "commit": {
          "sha": "884c0e66eee260e1bbd58e1470311d66764a2bc5",
          "url": "https://api.github.com/repos/github/github-mcp-server/commits/884c0e66eee260e1bbd58e1470311d66764a2bc5"
      },
      "protected": true,
      "protection": {
          "required_status_checks": {
              "strict": false,
              "contexts": [],
              "checks": []
          },
          "required_pull_request_reviews": null,
          "enforce_admins": null,
          "restrictions": null,
          "required_linear_history": null,
          "allow_force_pushes": null,
          "allow_deletions": null,
          "required_conversation_resolution": null
      },
      "protection_url": "https://api.github.com/repos/github/github-mcp-server/branches/SamMorrowDrums-patch-1/protection"
  },
  ...

Create Issue (34.3x*)

* highly variable depending on issue body length

{
  "owner": "lulubeatson",
  "repo": "ghmcp-test",
  "title": "Add a pun to the README",
  "body": "## Description\nThe README could use some humor! Let's add a pun to make it more engaging and fun to read.\n\n## Acceptance Criteria\n- [ ] Add a clever pun related to the repository or its purpose\n- [ ] Ensure the pun fits naturally within the existing README content\n- [ ] Keep it appropriate and professional\n\n## Suggestions\nSome ideas for puns:\n- Something related to GitHub/Git (e.g., \"This repo is commit-ted to excellence!\")\n- Something about testing or development\n- A play on words related to the project name\n\n## Priority\nLow - this is a fun enhancement to improve the developer experience"
}
New: 20 tokens
{"url":"https://github.com/LuluBeatson/ghmcp-test/issues/28"}
Old: 685 tokens
{"id":3373361799,"number":27,"state":"open","locked":false,"title":"Add a pun to the README","body":"## Description\nThe README could use some humor! Let's add a pun to make it more engaging and fun to read.\n\n## Acceptance Criteria\n- [ ] Add a clever pun related to the repository or its purpose\n- [ ] Ensure the pun fits naturally within the existing README content\n- [ ] Keep it appropriate and professional\n\n## Suggestions\nSome ideas for puns:\n- Something related to GitHub/Git (e.g., \"This repo is commit-ted to excellence!\")\n- Something about testing or development\n- A play on words related to the project name\n\n## Priority\nLow - this is a fun enhancement to improve the developer experience","author_association":"OWNER","user":{"login":"LuluBeatson","id":59149422,"node_id":"MDQ6VXNlcjU5MTQ5NDIy","avatar_url":"https://avatars.githubusercontent.com/u/59149422?v=4","html_url":"https://github.com/LuluBeatson","gravatar_id":"","type":"User","site_admin":true,"url":"https://api.github.com/users/LuluBeatson","events_url":"https://api.github.com/users/LuluBeatson/events{/privacy}","following_url":"https://api.github.com/users/LuluBeatson/following{/other_user}","followers_url":"https://api.github.com/users/LuluBeatson/followers","gists_url":"https://api.github.com/users/LuluBeatson/gists{/gist_id}","organizations_url":"https://api.github.com/users/LuluBeatson/orgs","received_events_url":"https://api.github.com/users/LuluBeatson/received_events","repos_url":"https://api.github.com/users/LuluBeatson/repos","starred_url":"https://api.github.com/users/LuluBeatson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LuluBeatson/subscriptions"},"comments":0,"created_at":"2025-09-01T17:12:58Z","updated_at":"2025-09-01T17:12:58Z","url":"https://api.github.com/repos/LuluBeatson/ghmcp-test/issues/27","html_url":"https://github.com/LuluBeatson/ghmcp-test/issues/27","comments_url":"https://api.github.com/repos/LuluBeatson/ghmcp-test/issues/27/comments","events_url":"https://api.github.com/repos/LuluBeatson/ghmcp-test/issues/27/events","labels_url":"https://api.github.com/repos/LuluBeatson/ghmcp-test/issues/27/labels{/name}","repository_url":"https://api.github.com/repos/LuluBeatson/ghmcp-test","reactions":{"total_count":0,"+1":0,"-1":0,"laugh":0,"confused":0,"heart":0,"hooray":0,"rocket":0,"eyes":0,"url":"https://api.github.com/repos/LuluBeatson/ghmcp-test/issues/27/reactions"},"node_id":"I_kwDOPNjcb87JEWqH"}

@mattdholloway mattdholloway merged commit 358a415 into main Sep 1, 2025
16 checks passed
@mattdholloway mattdholloway deleted the reduce-output-fields branch September 1, 2025 17:13
LuluBeatson added a commit to ipapapa/github-mcp-server that referenced this pull request Sep 2, 2025
…ets (github#988)

* add comprehensive minimal response where appropriate

* remove unneeded comments

* remove incorrect diff param

* update docs

* rm comment

* Update pkg/github/repositories.go

Co-authored-by: Lulu <59149422+LuluBeatson@users.noreply.github.com>

* update toolsnaps and docs

* change minimal_output to use new OptionalBoolParamWithDefault

* Update pkg/github/repositories.go

Co-authored-by: Lulu <59149422+LuluBeatson@users.noreply.github.com>

* refactor minimal conversion funcs to minimal_types.go

* consolidate response structs and remove unneeded message field

* consolidate response further

* remove CloneURL field

* Update pkg/github/repositories.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update pkg/github/server.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix undefined

* change incorrect comment

* remove old err var declaration

* Update pkg/github/repositories.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix syntax issue

* update toolsnaps

---------

Co-authored-by: Lulu <59149422+LuluBeatson@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

Enable concise responses to API requests
3 participants