Skip to content

Commit de042c0

Browse files
committed
refactor: share cursor pagination metadata
1 parent 97ca3cb commit de042c0

11 files changed

Lines changed: 28 additions & 32 deletions

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ The following sets of tools are available:
717717
- **list_dependabot_alerts** - List dependabot alerts
718718
- **Required OAuth Scopes**: `security_events`
719719
- **Accepted OAuth Scopes**: `repo`, `security_events`
720-
- `after`: Omit for the first page. For subsequent pages, use pageInfo.nextCursor from the previous response. (string, optional)
720+
- `after`: Cursor for pagination. Use the cursor from the previous response. (string, optional)
721721
- `owner`: The owner of the repository. (string, required)
722722
- `perPage`: Results per page for pagination (min 1, max 100) (number, optional)
723723
- `repo`: The name of the repository. (string, required)
@@ -755,7 +755,7 @@ The following sets of tools are available:
755755

756756
- **get_discussion_comments** - Get discussion comments
757757
- **Required OAuth Scopes**: `repo`
758-
- `after`: Cursor for pagination. Use the endCursor from the previous page's PageInfo for GraphQL APIs. (string, optional)
758+
- `after`: Cursor for pagination. Use the cursor from the previous response. (string, optional)
759759
- `discussionNumber`: Discussion Number (number, required)
760760
- `includeReplies`: When true, each top-level comment will include its replies nested within it (up to 100 replies per comment, which is the GitHub API maximum). Defaults to false. (boolean, optional)
761761
- `owner`: Repository owner (string, required)
@@ -769,7 +769,7 @@ The following sets of tools are available:
769769

770770
- **list_discussions** - List discussions
771771
- **Required OAuth Scopes**: `repo`
772-
- `after`: Cursor for pagination. Use the endCursor from the previous page's PageInfo for GraphQL APIs. (string, optional)
772+
- `after`: Cursor for pagination. Use the cursor from the previous response. (string, optional)
773773
- `category`: Optional filter by discussion category ID. If provided, only discussions with this category are listed. (string, optional)
774774
- `direction`: Order direction. (string, optional)
775775
- `orderBy`: Order discussions by field. If provided, the 'direction' also needs to be provided. (string, optional)
@@ -881,7 +881,7 @@ The following sets of tools are available:
881881

882882
- **list_issues** - List issues
883883
- **Required OAuth Scopes**: `repo`
884-
- `after`: Cursor for pagination. Use the endCursor from the previous page's PageInfo for GraphQL APIs. (string, optional)
884+
- `after`: Cursor for pagination. Use the cursor from the previous response. (string, optional)
885885
- `direction`: Order direction. If provided, the 'orderBy' also needs to be provided. (string, optional)
886886
- `labels`: Filter by labels (string[], optional)
887887
- `orderBy`: Order issues by field. If provided, the 'direction' also needs to be provided. (string, optional)

docs/feature-flags.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ runtime behavior (such as output formatting) won't appear here.
102102

103103
- **list_issues** - List issues
104104
- **Required OAuth Scopes**: `repo`
105-
- `after`: Cursor for pagination. Use the endCursor from the previous page's PageInfo for GraphQL APIs. (string, optional)
105+
- `after`: Cursor for pagination. Use the cursor from the previous response. (string, optional)
106106
- `direction`: Order direction. If provided, the 'orderBy' also needs to be provided. (string, optional)
107107
- `field_filters`: Filter by custom issue field values. Each entry takes a field_name and a value; the server looks up the field and coerces the value to its type (single-select option name, text, number, or YYYY-MM-DD date). (object[], optional)
108108
- `labels`: Filter by labels (string[], optional)

docs/insiders-features.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ The list below is generated from the Go source. It covers tool **inventory and s
9696

9797
- **list_issues** - List issues
9898
- **Required OAuth Scopes**: `repo`
99-
- `after`: Cursor for pagination. Use the endCursor from the previous page's PageInfo for GraphQL APIs. (string, optional)
99+
- `after`: Cursor for pagination. Use the cursor from the previous response. (string, optional)
100100
- `direction`: Order direction. If provided, the 'orderBy' also needs to be provided. (string, optional)
101101
- `field_filters`: Filter by custom issue field values. Each entry takes a field_name and a value; the server looks up the field and coerces the value to its type (single-select option name, text, number, or YYYY-MM-DD date). (object[], optional)
102102
- `labels`: Filter by labels (string[], optional)

pkg/github/__toolsnaps__/get_discussion_comments.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"inputSchema": {
88
"properties": {
99
"after": {
10-
"description": "Cursor for pagination. Use the endCursor from the previous page's PageInfo for GraphQL APIs.",
10+
"description": "Cursor for pagination. Use the cursor from the previous response.",
1111
"type": "string"
1212
},
1313
"discussionNumber": {

pkg/github/__toolsnaps__/list_dependabot_alerts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"inputSchema": {
88
"properties": {
99
"after": {
10-
"description": "Omit for the first page. For subsequent pages, use pageInfo.nextCursor from the previous response.",
10+
"description": "Cursor for pagination. Use the cursor from the previous response.",
1111
"type": "string"
1212
},
1313
"owner": {

pkg/github/__toolsnaps__/list_discussions.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"inputSchema": {
88
"properties": {
99
"after": {
10-
"description": "Cursor for pagination. Use the endCursor from the previous page's PageInfo for GraphQL APIs.",
10+
"description": "Cursor for pagination. Use the cursor from the previous response.",
1111
"type": "string"
1212
},
1313
"category": {

pkg/github/__toolsnaps__/list_issues.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"inputSchema": {
88
"properties": {
99
"after": {
10-
"description": "Cursor for pagination. Use the endCursor from the previous page's PageInfo for GraphQL APIs.",
10+
"description": "Cursor for pagination. Use the cursor from the previous response.",
1111
"type": "string"
1212
},
1313
"direction": {

pkg/github/__toolsnaps__/list_issues_ff_remote_mcp_issue_fields.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"inputSchema": {
88
"properties": {
99
"after": {
10-
"description": "Cursor for pagination. Use the endCursor from the previous page's PageInfo for GraphQL APIs.",
10+
"description": "Cursor for pagination. Use the cursor from the previous response.",
1111
"type": "string"
1212
},
1313
"direction": {

pkg/github/dependabot.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,6 @@ func ListDependabotAlerts(t translations.TranslationHelperFunc) inventory.Server
121121
Required: []string{"owner", "repo"},
122122
}
123123
WithCursorPagination(schema)
124-
// The Dependabot alerts REST endpoint uses cursor pagination via the response's
125-
// Link header (surfaced as pageInfo.nextCursor), not GraphQL. Override the shared
126-
// cursor description, which otherwise refers to a GraphQL PageInfo.
127-
schema.Properties["after"].Description = "Omit for the first page. For subsequent pages, use pageInfo.nextCursor from the previous response."
128124

129125
return NewTool(
130126
ToolsetMetadataDependabot,

pkg/github/params.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ func WithCursorPagination(schema *jsonschema.Schema) *jsonschema.Schema {
376376

377377
schema.Properties["after"] = &jsonschema.Schema{
378378
Type: "string",
379-
Description: "Cursor for pagination. Use the endCursor from the previous page's PageInfo for GraphQL APIs.",
379+
Description: "Cursor for pagination. Use the cursor from the previous response.",
380380
}
381381

382382
return schema
@@ -435,6 +435,22 @@ type CursorPaginationParams struct {
435435
After string
436436
}
437437

438+
type pageInfo struct {
439+
HasNextPage bool `json:"hasNextPage"`
440+
HasPreviousPage bool `json:"hasPreviousPage"`
441+
NextCursor string `json:"nextCursor,omitempty"`
442+
PrevCursor string `json:"prevCursor,omitempty"`
443+
}
444+
445+
func buildPageInfo(resp *github.Response) pageInfo {
446+
return pageInfo{
447+
HasNextPage: resp.After != "",
448+
HasPreviousPage: resp.Before != "",
449+
NextCursor: resp.After,
450+
PrevCursor: resp.Before,
451+
}
452+
}
453+
438454
// ToGraphQLParams converts cursor pagination parameters to GraphQL-specific parameters.
439455
func (p CursorPaginationParams) ToGraphQLParams() (*GraphQLPaginationParams, error) {
440456
if p.PerPage > 100 {

0 commit comments

Comments
 (0)