Skip to content

fix(pull_request_read): expose 'after' cursor parameter in input schema#2489

Merged
SamMorrowDrums merged 2 commits into
github:mainfrom
jluocsa:fix/pull-request-read-after-param-2122
May 19, 2026
Merged

fix(pull_request_read): expose 'after' cursor parameter in input schema#2489
SamMorrowDrums merged 2 commits into
github:mainfrom
jluocsa:fix/pull-request-read-after-param-2122

Conversation

@jluocsa

@jluocsa jluocsa commented May 17, 2026

Copy link
Copy Markdown
Contributor

What

The pull_request_read tool advertises in both its description and the documentation that the get_review_comments method uses cursor-based pagination (perPage, after), and the handler does plumb after through to the GraphQL query. But the tool's inputSchema only declared page and perPage (via WithPagination) — after was never exposed.

As a result, MCP clients had no way to request the after cursor, leaving cursor pagination effectively broken:

This PR is a small, surgical fix for the schema bug.

Changes

  • pkg/github/pullrequests.go: After the existing WithPagination(schema) call in PullRequestRead, add an after property (string, optional) to the schema with a description making clear it only applies to get_review_comments. All other methods continue to ignore it. No handler behavior is changed.
  • pkg/github/__toolsnaps__/pull_request_read.snap: Regenerated via UPDATE_TOOLSNAPS=true go test ./pkg/github.
  • README.md: Regenerated via go run ./cmd/github-mcp-server generate-docs.
  • pkg/github/pullrequests_test.go: Augment the schema-verification block in Test_GetPullRequestComments to assert after is present (regression guard) and add a new table-driven case "after cursor is forwarded to GraphQL query" that verifies the cursor flows from requestArgs["after"] into the GraphQL variables.

Validation

$ go build ./...
$ go test ./...
ok  github.com/github/github-mcp-server/pkg/github           2.615s
ok  github.com/github/github-mcp-server/internal/githubv4mock 13.371s
... (all packages pass)
$ go vet ./...
(clean)
$ go run ./cmd/github-mcp-server generate-docs
Successfully updated README.md with automated documentation
Successfully updated docs/remote-server.md with automated documentation
Successfully updated docs/tool-renaming.md with automated documentation

golangci-lint is not installed locally; CI will run script/lint.

The new test case provides explicit coverage: the GraphQL mock matcher expects "after": githubv4.String("cursor-page-2") and the test passes "after": "cursor-page-2" in requestArgs, so a regression that drops after from the schema or handler wiring would fail this test.

Scope note

This PR only addresses the missing-after portion of #2122. The remaining concerns in that issue — unbounded payloads from get, get_diff, and get_reviews — involve more invasive API surface choices (field-selection parameters, truncation, etc.) and are better handled in a follow-up after design discussion. Happy to take that on as a separate PR if maintainers prefer a particular approach.

Fixes #2122 (partial)

The `pull_request_read` tool description tells clients that
`get_review_comments` uses cursor-based pagination (`perPage`, `after`),
and the handler does plumb `after` through to the GraphQL query, but the
input schema only declared `page` and `perPage` (via `WithPagination`).
Because `after` was not advertised in `inputSchema`, MCP clients had
no way to request it, leaving cursor pagination effectively broken:
`perPage: 1` returned only the first thread with no way to advance, and
`page` was silently ignored by the GraphQL path.

This change adds `after` to the schema (string, optional) with a
description making clear it only applies to `get_review_comments`. All
other methods continue to ignore it. No handler behavior is changed.

- Add `after` schema property after `WithPagination` in `PullRequestRead`
- Regenerate `__toolsnaps__/pull_request_read.snap` and update README
- Add a regression test asserting `after` is in the schema and a new
  table-driven case verifying the cursor is forwarded to the GraphQL query

Fixes github#2122 (for the `get_review_comments` pagination part). The
remaining concerns in github#2122 about unbounded response sizes for `get`,
`get_diff`, and `get_reviews` are deferred to follow-up design.
@jluocsa jluocsa requested a review from a team as a code owner May 17, 2026 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants