Skip to content

fix(mcp): paginate tools/resources/prompts discovery via nextCursor#1256

Open
Liu-Vince wants to merge 2 commits intoHmbown:mainfrom
Liu-Vince:fix/mcp-discovery-pagination
Open

fix(mcp): paginate tools/resources/prompts discovery via nextCursor#1256
Liu-Vince wants to merge 2 commits intoHmbown:mainfrom
Liu-Vince:fix/mcp-discovery-pagination

Conversation

@Liu-Vince
Copy link
Copy Markdown
Contributor

Problem

MCP servers are allowed by spec to paginate tools/list, resources/list, resources/templates/list, and prompts/list responses. When a server paginates at N items per page (e.g. gbrain paginates at 5), the previous implementation would silently stop after the first page, making it appear as if only those N tools existed.

This caused the symptom reported in #1250: only the first 5 alphabetically-sorted tools were loaded, regardless of how many the server actually exposed.

Fix

All four discovery methods now follow nextCursor until the server signals no more pages, accumulating results across all pages before completing.

The non-paginating path (servers that return all results in one response with no nextCursor) is unchanged in behavior.

Testing

  • Servers that don't paginate: unaffected — they return no nextCursor, the loop exits after the first response exactly as before.
  • Servers that paginate: all pages are now fetched and merged.

Fixes #1250

MCP servers may return paginated results from list endpoints. The
previous implementation made a single request and stopped, silently
dropping any subsequent pages. Servers that paginate at fewer items
than their total tool count (e.g. 5 per page) would appear to expose
only those first few tools.

Follow nextCursor across all four discovery methods (tools, resources,
resource templates, prompts) until the server signals no more pages.

Fixes Hmbown#1250
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@Hmbown Hmbown mentioned this pull request May 9, 2026
4 tasks
LiangJianJi pushed a commit to LiangJianJi/DeepSeek-TUI that referenced this pull request May 9, 2026
…mbown#1250, Hmbown#1256)

MCP servers are allowed by spec to paginate list responses. The old
implementation made a single request and stopped, silently dropping
subsequent pages. Servers that paginate at fewer items than their
total tool count (e.g. gbrain at 5 per page) would appear to expose
only those first few tools.

All four discovery methods now follow nextCursor until the server
signals no more pages, accumulating results across all pages:
  - discover_tools
  - discover_resources
  - discover_resource_templates
  - discover_prompts

Thanks to Liu-Vince for the original diagnosis and fix (PR Hmbown#1256).
LiangJianJi pushed a commit to LiangJianJi/DeepSeek-TUI that referenced this pull request May 9, 2026
Version bump: 0.8.23 → 0.8.24 in workspace Cargo.toml.

CHANGELOG entries for:
  - Workspace-local slash commands (Hmbown#1259)
  - @-completion for gitignored dot-dirs
  - MCP paginated discovery via nextCursor (Hmbown#1250, Hmbown#1256, credit Liu-Vince)
  - Snapshot disk-space cap at 500 MB (Hmbown#1112, credit Giggitycountless)
  - /clear resets Todos sidebar (Hmbown#1258)
  - Language directive strengthened against project-context bias
  - Known issue: Windows flicker (Hmbown#1260, Hmbown#1251) — viewport-reset escape
    sequence on Windows conhost, investigation in progress
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] MCP client truncates tools at 5 (alphabetical) / MCP 客户端工具截断为5个

1 participant