Repository navigation
fix(mcp): keep list_tasks pagination cursor intact on large pages - #805
Conversation
Return a compact task summary by default (descriptions behind the new includeDescription flag), put next_cursor and total before the task list, preserve total_count from the API and URL-encode the cursor. Fixes #803
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
There was a problem hiding this comment.
ℹ️ No blocking issues — a few small suggestions inline.
Approach: sound — shrink the page by defaulting to a description-free summary and move the cursor ahead of the list, so a host that abbreviates oversized tool output can no longer eat the continuation token.
Reviewed changes
- Cursor-first layout —
list_tasksnow emitsTasks (N returned, T total, more available):and anext_cursor:line before the task list, replacing the old end-of-response note. - Compact output by default — new
includeDescriptionflag (defaultfalse) selects a newformatTaskSummaryinstead offormatTask; full descriptions remain available via the flag orget_task. total_countpreserved —PacaAPIClient.listTaskskeepstotal_count(falling back tototal) astotal, and the handler surfaces it asN total.- Cursor encoding — the cursor query value is now
encodeURIComponent'd. - Regression tests — long-description page at
pageSize=100, cursor ordering, total preservation, last page without cursor, compact vs detailed output, and cursor encoding.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
| const total = response.total_count ?? response.total; | ||
| return { | ||
| items: response.items || response.tasks || response.data || [], | ||
| nextCursor: response.next_cursor ?? null, | ||
| ...(typeof total === "number" ? { total } : {}), | ||
| }; |
There was a problem hiding this comment.
This re-implements toPage, which is already imported into this file (line 25) and used by listSprints / listDocuments. Delegating keeps total_count mapping in one place and lets listTasks return the shared Page<Task> type (its shape is already identical).
Technical details
# Use the shared page reader
## Affected sites
- `apps/mcp/src/api/client.ts:212-217` — hand-rolled `items` / `next_cursor` / `total_count` extraction
- `apps/mcp/src/api/paginate.ts:56` — `toPage<T>` does the same mapping (`items ?? data`, `next_cursor`, `total_count ?? total`)
## Required outcome
- `listTasks` returns `Page<Task>` and delegates to `toPage<Task>(response)`.
- The `response.tasks` fallback can go: the API `ListTasks` handler returns `items`.
## Open questions for the human (optional)
- `withPaging` would also remove the manual `encodeURIComponent`, but it owns the whole query string; adopting it here means building the filters after the paging params, so it can stay out of this PR.| const total = response.total_count ?? response.total; | |
| return { | |
| items: response.items || response.tasks || response.data || [], | |
| nextCursor: response.next_cursor ?? null, | |
| ...(typeof total === "number" ? { total } : {}), | |
| }; | |
| return toPage<Task>(response); |
| function formatTaskSummary(task: Task): string { | ||
| const assignees = | ||
| task.assignee_ids && task.assignee_ids.length > 0 | ||
| ? task.assignee_ids.join(", ") | ||
| : "Unassigned"; | ||
| return `Task #${task.task_number}: ${task.title} | ||
| ID: ${task.id} | ||
| Status: ${task.status_id || "None"} | ||
| Type: ${task.task_type_id || "None"} | ||
| Sprint: ${task.sprint_id || "None"} | ||
| Assignees: ${assignees} | ||
| Parent Task: ${task.parent_task_id || "None"} | ||
| Importance: ${task.importance} | ||
| Story Points: ${task.story_points ?? "None"} | ||
| Tags: ${task.tags && task.tags.length > 0 ? task.tags.join(", ") : "None"} | ||
| Due Date: ${task.due_date || "None"}`; |
There was a problem hiding this comment.
formatTaskSummary isn't formatTask minus the description: it also drops Start Date, Created and Updated, which are cheap fields and not what makes the page large. That's a second, unannounced change to list_tasks output. Consider giving formatTask a description option (or moving the summary beside it in utils/formatters.ts) so the two views can't drift on the fields the compact output is supposed to keep.
Technical details
# Keep compact and full task views in sync
## Affected sites
- `apps/mcp/src/tools/task-tools.ts:73-88` — `formatTaskSummary` (no `start_date`, `created_at`, `updated_at`)
- `apps/mcp/src/utils/formatters.ts:87-109` — `formatTask` (all fields plus description)
- `apps/mcp/src/tools/task-tools.ts:399-402` — selects between the two formatters
## Required outcome
- The compact list keeps the small fields `formatTask` shows and omits only the description, so `list_tasks` output differs from the previous format in exactly the way the PR body describes.
- One field list, one place to update.
## Suggested approach (optional)
- `formatTask(task, { includeDescription = true })` rendering `Description:` only when asked, and drop the local duplicate.| includeDescription: { | ||
| type: "boolean", | ||
| description: | ||
| "Include full task descriptions (default false). The default compact summary keeps responses small so the pagination cursor is never truncated; use get_task for a task's full content.", | ||
| }, |
There was a problem hiding this comment.
This changes the default shape of a widely used tool and isn't recorded anywhere outside the schema: this repo logs behavioural changes in CHANGELOG.md under [Unreleased], and README.md:262 still tells readers that paged list replies end with the cursor line (no longer true for list_tasks). A short changelog bullet under Changed and a README tweak (list_tasks returns compact summaries and puts next_cursor before the list) would keep the docs honest.
pikann
left a comment
There was a problem hiding this comment.
LGTM! Thank you for the contribution! 🚀

Fixes #803
Changes
list_tasksnow returns a compact summary per task by default; full descriptions are opt-in viaincludeDescription: true(useget_taskfor full content).next_cursorand the total count are emitted in the header, before the task list, so a response-size limit can't truncate the cursor.PacaAPIClient.listTaskspreservestotal_count(astotal) and URL-encodes the cursor.Tests
Added tests for long descriptions at pageSize=100 (exact cursor, placed before the list), total preservation, last page without cursor, compact vs detailed output, and cursor encoding. Targeted vitest suites pass,
tsc --noEmitis clean and biome is clean on the changed files.