Skip to content

[Bug] MCP list_tasks can make opaque pagination cursors unusable on large responses #803

Closed

Description

@cmt-t

Summary

First, thank you for the work on Paca and on the MCP integration. The pagination improvements are very useful for working with larger projects.

I noticed a reproducible edge case in the MCP list_tasks tool when a page contains enough tasks and full task descriptions to produce a large textual response.

The Paca API generates a valid opaque next_cursor, but the MCP response can become large enough that the cursor is abbreviated in the returned tool text (for example, eyJjYS...jIn0=). Once abbreviated, the value cannot be passed back to list_tasks, so I cannot safely enumerate the complete task collection.

I am sharing this report because it may be especially important for AI clients: a partial task list can look complete unless the continuation metadata is preserved reliably.

Environment

  • Paca instance: self-hosted Paca
  • MCP package: @paca-ai/[email protected]
  • MCP transport: stdio through Hermes Agent
  • Client host: Linux
  • Repository inspected: Paca-AI/paca
  • Affected tool: list_tasks
  • Test data: a private project containing more than 300 tasks and long Markdown descriptions

Steps to reproduce

  1. Connect an MCP client to Paca using @paca-ai/[email protected].

  2. Select a project with many tasks and long descriptions.

  3. Call list_tasks with a larger page size, such as 100 or 200.

  4. Observe a response similar to:

    Tasks (100 returned, more available)

  5. Inspect the continuation instruction at the end of the response.

  6. In this scenario, the cursor may be abbreviated with an ellipsis instead of being returned byte-for-byte.

  7. Passing the abbreviated cursor to the next list_tasks call cannot continue pagination.

Observed behavior

With pageSize=100, the response was large and the cursor was returned in abbreviated form. The same occurred with pageSize=25.

With pageSize=10, the response remained small enough and the full cursor was returned. Using the full cursor then allowed the next page to be requested.

The API also exposed a useful total_count value that the MCP client did not preserve, so I could not reconcile the complete collection using the normal MCP response alone.

Expected behavior

I would expect list_tasks to always return a usable, exact continuation token and enough structured metadata to enumerate the collection safely, regardless of page size or task-description length.

At minimum, the response could preserve something equivalent to:

{
  "items": [],
  "page_size": 10,
  "returned_count": 10,
  "total_count": 370,
  "next_cursor": "<exact opaque cursor or null>"
}

The cursor should not be summarized, shortened, normalized, or embedded after a large Markdown block that may be subject to a response-size limit.

Investigation and code references

I inspected the current Paca source and found:

  1. The API handler returns next_cursor and total_count separately in services/api/internal/transport/http/handler/task_handler.go in ListTasks.
  2. services/api/internal/domain/task/cursor.go encodes the cursor as a complete URL-safe Base64 token.
  3. In apps/mcp/src/api/client.ts, listTasks currently returns only items and nextCursor; total_count is not retained in the MCP result type.
  4. In apps/mcp/src/tools/task-tools.ts, list_tasks formats every task with formatTask, including full descriptions, and interpolates the cursor at the end of one large text response.
  5. The MCP package contains shared pagination helpers, while list_tasks uses a custom text formatter instead of returning compact structured pagination metadata.

Based on this, I suspect the issue is in the MCP presentation/serialization path or in the response-size handling around that path, rather than in the backend cursor encoder.

Possible solution

I would appreciate consideration of the following improvements:

1. Preserve pagination metadata

Extend the MCP client result type to retain total_count/total when the API provides it.

2. Return compact structured output

Return pagination metadata separately from task content, so the continuation token is not placed after a potentially large Markdown block.

3. Make list output compact by default

list_tasks could return task summaries by default, without full descriptions, with an explicit option for descriptions or a recommendation to use get_task for full content.

4. Centralize pagination formatting

Use the shared pagination helper consistently, or return JSON-compatible structured content for paginated tools.

5. Encode cursor query parameters defensively

When sending a continuation token back to the API, use encodeURIComponent for the cursor query value. This is not the primary symptom I observed, but it would help protect opaque-token handling.

6. Add regression tests

I suggest tests covering:

  • a page with long task descriptions;
  • pageSize=100 or the maximum supported page size;
  • exact equality of the returned cursor before and after MCP serialization;
  • a second-page request using that cursor;
  • preservation of total_count;
  • a final page with next_cursor: null;
  • both compact and detailed task output modes.

Current workaround

Until this is addressed, I can use a small page size, such as pageSize=10, and reject any cursor containing an ellipsis. This works, but it increases the number of round trips and leaves the MCP client without a reliable total count.

Impact

This can lead to incomplete project audits, inaccurate task counts, missed dependencies, and uncertainty about whether a collection was fully inspected. It is particularly relevant for AI clients because opaque continuation tokens must be preserved literally.

Thank you again for maintaining Paca and for considering this report. I hope the details above make the behavior straightforward to reproduce and help improve the pagination experience for large projects.

Activity

  1. pullfrog commented on Nov 20, 2026

    @pullfrog
    Contributor
  2. added
    bug
    good first issue
    on Nov 20, 2026
  3. added a commit that references this issue on Nov 20, 2026
    eacce85
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions