Skip to content

fix: discover all pages of MCP tool resource and prompt catalogs - #302

Merged
Eigenwise merged 4 commits into
Eigenwise:mainfrom
liangzhechen655:fix/mcp-paginated-discovery
Oct 10, 2026
Merged

Eigenwise merged 4 commits into
Eigenwise:mainfrom
liangzhechen655:fix/mcp-paginated-discovery

Conversation

@liangzhechen655

@liangzhechen655 liangzhechen655 commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

MCP discovery currently reads only the first page of tools, resources, resource templates and prompts. A paginated server therefore exposes an incomplete catalog to generated agents.

Follow each opaque nextCursor, keeping the first request free of cursor arguments and preserving discovery order and definition conversion. Unsupported resource-template fallback applies only to the initial request: once a server has returned a page, continuation failures propagate instead of discarding the partial catalog.

The pagination helper uses constrained MCP SDK response and item types plus typed item accessors. Its return and callback boundaries retain the concrete SDK types.

Validation on Windows / Python 3.13:

  • Six original pagination regressions fail on the original base.
  • The new later-page METHOD_NOT_FOUND regression fails on the previous PR head; the accompanying internal-error case verifies propagation by error identity.
  • Full core suite: 408 passed, 3 credential-gated integration tests skipped, 93% coverage.
  • Repository-wide Black and Flake8 pass. GitHub's Code Quality & Tests passed on 99969e2.
  • Targeted mypy comparison reports the same six pre-existing diagnostics before and after the follow-up (SSE tuple unpacking and resource URI conversion); no pagination-helper diagnostics remain.

@Eigenwise Eigenwise left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Source review of 6e52126a1bfdbd350a59312ed66f8109e1696500: the pagination fix is useful, but mcp_definition_service.py:267-272 applies the unsupported-template fallback to every page. If the first call returns a template and nextCursor, then the continuation raises METHOD_NOT_FOUND, the error is swallowed and the collected templates are discarded. Keep the fallback for the initial request and propagate continuation errors. Please add that later-page regression alongside the existing first-call fallback test.

The new _fetch_all_pages helper also introduces Callable[..., Awaitable[Any]] and List[Any]. Preserve the known SDK response and item types with a concrete or constrained generic boundary.

These are source findings. I haven't run this head's tests or measured its per-function coverage.

@Eigenwise Eigenwise left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked 99969e2c279be706e3f6d57c7fa783a22833856a. The unsupported-template fallback is limited to the initial request, and continuation errors propagate unchanged. Both new error-identity cases and the six pagination cases passed in normal CI. The helper now preserves the SDK response/item types, ordering and session ownership. Full CI: 408 passed, 3 MiniMax integration skips, with formatting and lint passing. Both earlier findings are resolved.

@Eigenwise
Eigenwise merged commit e77c4e7 into Eigenwise:main Oct 10, 2026
1 check passed
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.

2 participants