Skip to content

Commit e6f77c0

Browse files
committed
update pagination rules
1 parent 1235e58 commit e6f77c0

File tree

5 files changed

+49
-31
lines changed

5 files changed

+49
-31
lines changed

pkg/github/__toolsnaps__/list_project_fields.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
"inputSchema": {
88
"properties": {
99
"after": {
10-
"description": "Forward pagination cursor. Use when the previous response's pageInfo.hasNextPage=true. Supply pageInfo.nextCursor as 'after' and immediately request the next page. LOOP UNTIL pageInfo.hasNextPage=false (don't stop early). Keep per_page identical for every page.",
10+
"description": "Forward pagination cursor from previous pageInfo.nextCursor.",
1111
"type": "string"
1212
},
1313
"before": {
14-
"description": "Backward pagination cursor (rare): supply to move to the preceding page using pageInfo.prevCursor. Not needed for normal forward iteration.",
14+
"description": "Backward pagination cursor from previous pageInfo.prevCursor (rare).",
1515
"type": "string"
1616
},
1717
"owner": {
@@ -27,7 +27,7 @@
2727
"type": "string"
2828
},
2929
"per_page": {
30-
"description": "Results per page (max 50). Keep constant across paginated requests; changing mid-sequence can complicate page traversal.",
30+
"description": "Results per page (max 50)",
3131
"type": "number"
3232
},
3333
"project_number": {

pkg/github/__toolsnaps__/list_project_items.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
"inputSchema": {
88
"properties": {
99
"after": {
10-
"description": "Forward pagination cursor. Use when the previous response's pageInfo.hasNextPage=true. Supply pageInfo.nextCursor as 'after' and immediately request the next page. LOOP UNTIL pageInfo.hasNextPage=false (don't stop early). Keep query, fields, and per_page identical for every page.",
10+
"description": "Forward pagination cursor from previous pageInfo.nextCursor.",
1111
"type": "string"
1212
},
1313
"before": {
14-
"description": "Backward pagination cursor (rare): supply to move to the preceding page using pageInfo.prevCursor. Not needed for normal forward iteration.",
14+
"description": "Backward pagination cursor from previous pageInfo.prevCursor (rare).",
1515
"type": "string"
1616
},
1717
"fields": {
@@ -34,7 +34,7 @@
3434
"type": "string"
3535
},
3636
"per_page": {
37-
"description": "Results per page (max 50). Keep constant across paginated requests; changing mid-sequence can complicate page traversal.",
37+
"description": "Results per page (max 50)",
3838
"type": "number"
3939
},
4040
"project_number": {

pkg/github/__toolsnaps__/list_projects.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
"inputSchema": {
88
"properties": {
99
"after": {
10-
"description": "Forward pagination cursor. Use when the previous response's pageInfo.hasNextPage=true. Supply pageInfo.nextCursor as 'after' and immediately request the next page. LOOP UNTIL pageInfo.hasNextPage=false (don't stop early). Keep query and per_page identical for every page.",
10+
"description": "Forward pagination cursor from previous pageInfo.nextCursor.",
1111
"type": "string"
1212
},
1313
"before": {
14-
"description": "Backward pagination cursor (rare): supply to move to the preceding page using pageInfo.prevCursor. Not needed for normal forward iteration.",
14+
"description": "Backward pagination cursor from previous pageInfo.prevCursor (rare).",
1515
"type": "string"
1616
},
1717
"owner": {
@@ -27,7 +27,7 @@
2727
"type": "string"
2828
},
2929
"per_page": {
30-
"description": "Results per page (max 50). Keep constant across paginated requests; changing mid-sequence can complicate page traversal.",
30+
"description": "Results per page (max 50)",
3131
"type": "number"
3232
},
3333
"query": {

pkg/github/instructions.go

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,42 +65,60 @@ Use 'list_discussion_categories' to understand available categories before creat
6565
case "projects":
6666
return `## Projects
6767
68-
When using 'list_project_items', follow these guidelines:
69-
70-
Field usage:
68+
Read Tools:
69+
- list_projects
70+
- get_project
71+
- list_project_fields
72+
- get_project_field
73+
- list_project_items
74+
- get_project_item
75+
Write Tools:
76+
- add_project_item
77+
- update_project_item
78+
- delete_project_item
79+
80+
Field usage:
7181
- Call list_project_fields first to understand available fields and get IDs/types before filtering.
7282
- Use EXACT returned field names (case-insensitive match). Don't invent names or IDs.
7383
- Iteration synonyms (sprint/cycle/iteration) only if that field exists; map to the actual name (e.g. sprint:@current).
7484
- Only include filters for fields that exist and are relevant.
7585
76-
Pagination (mandatory):
77-
- Loop while pageInfo.hasNextPage=true using after=nextCursor. Keep query, fields, per_page IDENTICAL each page.
78-
79-
Fields parameter:
86+
Pagination (mandatory):
87+
Forward (normal) flow:
88+
- Loop while pageInfo.hasNextPage=true using after=pageInfo.nextCursor.
89+
- Keep query, fields, per_page IDENTICAL on every page.
90+
Backward (rare) flow:
91+
- Use before=pageInfo.prevCursor only when explicitly navigating to a previous page.
92+
Parameters:
93+
- per_page: results per page (max 50). Choose a stable value; do not change mid-sequence.
94+
- after: forward cursor from prior response (pageInfo.nextCursor).
95+
- before: backward cursor from prior response (pageInfo.prevCursor); seldom needed.
96+
97+
Fields parameter:
8098
- Include field IDs on EVERY paginated list_project_items call if you need values. Omit → title only.
8199
82-
Counting rules:
100+
Counting rules:
83101
- Count items array length after full pagination.
84102
- If multi-page: collect all pages, dedupe by item.id (fallback node_id) before totals.
85103
- Never count field objects, content, or nested arrays as separate items.
86104
- item.id = project item ID (for updates/deletes). item.content.id = underlying issue/PR ID.
87105
88-
Summary vs list:
106+
Summary vs list:
89107
- Summaries ONLY if user uses verbs: analyze | summarize | summary | report | overview | insights.
90-
- Listing verbs (list/show/get/fetch/display/enumerate) → just enumerate + total.
108+
- Listing verbs (list/show/get/fetch/display/enumerate) → enumerate + total.
91109
92-
Examples:
110+
Examples:
93111
- list_projects: "roadmap is:open"
94112
- list_project_items: state:open is:issue sprint:@current priority:high updated:>@today-7d
95113
96-
Self-check before returning:
114+
Self-check before returning:
97115
- Paginated fully
98116
- Dedupe by id/node_id
99117
- Correct IDs used
100118
- Field names valid
101119
- Summary only if requested.
102120
103-
Return COMPLETE data or state what's missing (e.g. pages skipped).`
121+
Return COMPLETE data or state what's missing (e.g. pages skipped).`
104122
default:
105123
return ""
106124
}

pkg/github/projects.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ Examples:
5151
- is:open feature planning`),
5252
),
5353
mcp.WithNumber("per_page",
54-
mcp.Description(fmt.Sprintf("Results per page (max %d). Keep constant across paginated requests; changing mid-sequence can complicate page traversal.", MaxProjectsPerPage)),
54+
mcp.Description(fmt.Sprintf("Results per page (max %d)", MaxProjectsPerPage)),
5555
),
5656
mcp.WithString("after",
57-
mcp.Description("Forward pagination cursor. Use when the previous response's pageInfo.hasNextPage=true. Supply pageInfo.nextCursor as 'after' and immediately request the next page. LOOP UNTIL pageInfo.hasNextPage=false (don't stop early). Keep query and per_page identical for every page."),
57+
mcp.Description("Forward pagination cursor from previous pageInfo.nextCursor."),
5858
),
5959
mcp.WithString("before",
60-
mcp.Description("Backward pagination cursor (rare): supply to move to the preceding page using pageInfo.prevCursor. Not needed for normal forward iteration."),
60+
mcp.Description("Backward pagination cursor from previous pageInfo.prevCursor (rare)."),
6161
),
6262
), func(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
6363
owner, err := RequiredParam[string](req, "owner")
@@ -228,13 +228,13 @@ func ListProjectFields(getClient GetClientFn, t translations.TranslationHelperFu
228228
mcp.Description("The project's number."),
229229
),
230230
mcp.WithNumber("per_page",
231-
mcp.Description(fmt.Sprintf("Results per page (max %d). Keep constant across paginated requests; changing mid-sequence can complicate page traversal.", MaxProjectsPerPage)),
231+
mcp.Description(fmt.Sprintf("Results per page (max %d)", MaxProjectsPerPage)),
232232
),
233233
mcp.WithString("after",
234-
mcp.Description("Forward pagination cursor. Use when the previous response's pageInfo.hasNextPage=true. Supply pageInfo.nextCursor as 'after' and immediately request the next page. LOOP UNTIL pageInfo.hasNextPage=false (don't stop early). Keep per_page identical for every page."),
234+
mcp.Description("Forward pagination cursor from previous pageInfo.nextCursor."),
235235
),
236236
mcp.WithString("before",
237-
mcp.Description("Backward pagination cursor (rare): supply to move to the preceding page using pageInfo.prevCursor. Not needed for normal forward iteration."),
237+
mcp.Description("Backward pagination cursor from previous pageInfo.prevCursor (rare)."),
238238
),
239239
), func(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
240240
owner, err := RequiredParam[string](req, "owner")
@@ -452,13 +452,13 @@ Never:
452452
- Drop 'fields' param on subsequent pages if field values are needed.`),
453453
),
454454
mcp.WithNumber("per_page",
455-
mcp.Description(fmt.Sprintf("Results per page (max %d). Keep constant across paginated requests; changing mid-sequence can complicate page traversal.", MaxProjectsPerPage)),
455+
mcp.Description(fmt.Sprintf("Results per page (max %d)", MaxProjectsPerPage)),
456456
),
457457
mcp.WithString("after",
458-
mcp.Description("Forward pagination cursor. Use when the previous response's pageInfo.hasNextPage=true. Supply pageInfo.nextCursor as 'after' and immediately request the next page. LOOP UNTIL pageInfo.hasNextPage=false (don't stop early). Keep query, fields, and per_page identical for every page."),
458+
mcp.Description("Forward pagination cursor from previous pageInfo.nextCursor."),
459459
),
460460
mcp.WithString("before",
461-
mcp.Description("Backward pagination cursor (rare): supply to move to the preceding page using pageInfo.prevCursor. Not needed for normal forward iteration."),
461+
mcp.Description("Backward pagination cursor from previous pageInfo.prevCursor (rare)."),
462462
),
463463
mcp.WithArray("fields",
464464
mcp.Description("Field IDs to include (e.g. [\"102589\", \"985201\"]). CRITICAL: Always provide to get field values. Without this, only titles returned. Get IDs from list_project_fields first."),

0 commit comments

Comments
 (0)