Skip to content

fix(mcp): bound catalog pagination - #116845

Merged
steipete merged 8 commits into
mainfrom
codex/autoqa-mcp-pagination-shared-20260731
Jul 31, 2026
Merged

steipete merged 8 commits into
mainfrom
codex/autoqa-mcp-pagination-shared-20260731

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where an MCP server could keep node-host or agent-session catalog loading alive indefinitely with repeated or endless pagination cursors, multiply the configured timeout per page, grow retained results without bound, or silently lose later pages when the valid opaque cursor was an empty string.

Why This Change Was Made

One shared MCP pagination owner now governs node-host tools and session-bundle tools, resources, and prompts. It preserves opaque cursors, detects cursor cycles, caps pages/items/serialized bytes, applies one absolute deadline with remaining per-page budgets, composes caller cancellation, and rechecks cancellation/deadline after synchronous final-page processing. Each runtime keeps its existing filtering and ordering behavior and isolates only the offending MCP server.

User Impact

A malformed or unresponsive MCP server can no longer hang catalog startup or utility listing indefinitely, starve healthy sibling servers, or force unbounded catalog accumulation. Normal multi-page servers continue to return complete ordered results within their configured budget.

Evidence

  • Exact-head Testbox proof passed 116/116 focused tests across the shared paginator, node-host manager, and real session-bundle MCP runtime on tbx_01kyw39g39ng77pbnpvdmr1b4g, run 30631751241.
  • The complete changed gate passed on the same exact head, including core/core-test typechecks, lint, formatting, Knip, Plugin SDK/API boundaries, database-first, sidecar, cycle, webhook, and pairing guards.
  • Direct pinned @modelcontextprotocol/sdk 1.30.0 source/types confirm that cursors are arbitrary strings (including empty), nextCursor is optional, and request timeout/maxTotalTimeout are per SDK request; OpenClaw therefore owns the multi-page deadline.
  • Tests cover normal multi-page tool/resource/prompt results, empty cursors, repeated and cyclic cursors, endless unique cursors, page/item/byte caps, remaining absolute deadlines, caller abort, runtime disposal, final-page synchronous deadline crossing, synchronous abort with a resolved page, healthy sibling survival, and global node descriptor ordering.
  • Final autoreview was clean at 0.96. Independent final review was clean at 0.99 after confirming the empty-cursor, aggregate-deadline, and post-final-page timing findings were resolved.

No protocol, configuration, dependency, persisted-state, or MCP output-shape changes.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: L maintainer Maintainer-authored PR labels Jul 31, 2026
@steipete steipete self-assigned this Jul 31, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Jul 31, 2026
@clawsweeper

clawsweeper Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 31, 2026, 9:25 AM ET / 13:25 UTC.

ClawSweeper review

What this changes

This PR replaces separate MCP catalog pagination loops with a shared collector that preserves opaque cursors while bounding pages, items, bytes, deadline, and cancellation for node-host tools and agent-session tools, resources, and prompts.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

The bounded shared paginator looks like a focused response to a real MCP catalog availability problem, with prior review findings addressed and detailed exact-head Testbox evidence in the PR body. Keep this PR open for maintainer review because it intentionally changes timeout and failure behavior for existing multi-page MCP servers, its branch is behind current main, and the required checks/merged result are not yet complete.

Priority: P2
Reviewed head: 80861c936ad9bbc1e46c7593d5847bc7a624a2a3
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is focused and backed by strong focused proof, with merge readiness gated by the explicit compatibility decision plus refreshed merged-head checks.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body provides an exact-head Testbox run and comprehensive after-fix runtime-focused test coverage for shared pagination, node-host listing, and agent-session MCP catalogs; no browser, network, or security-only diagnostic proof is required here.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body provides an exact-head Testbox run and comprehensive after-fix runtime-focused test coverage for shared pagination, node-host listing, and agent-session MCP catalogs; no browser, network, or security-only diagnostic proof is required here.
Evidence reviewed 5 items Shared boundary and coverage: The branch adds collectMcpPaginatedItems and routes both node-host tool listing and agent-session tool, resource, and prompt listing through it; the supplied diff also adds focused tests for empty cursors, cycles, limits, aggregate deadlines, aborts, sibling survival, and ordering.
Compatibility-relevant behavior change: The node-host caller changes from per-page list calls to a bounded aggregate collector, adding page and retained-item caps while applying the configured catalog timeout as one lifecycle budget. That can intentionally reject a multi-page server that previously completed only because each page received a fresh full timeout.
Prior review continuity: The prior completed ClawSweeper cycle reviewed 7fe1681f4f31131962201463603c3884abe3208d with no findings; the final commit is described in supplied PR history as stabilizing pagination deadline ownership after the earlier final-page deadline finding.
Findings None None.
Security None None.

How this fits together

OpenClaw queries configured MCP servers for paginated capability catalogs, then turns those results into node-host tool descriptors and agent-session tools, resources, and prompts. This change inserts one shared guardrail layer between MCP list responses and the runtime-specific filtering, ordering, and publication paths.

flowchart LR
  A[Configured MCP server] --> B[Paginated catalog response]
  C[Timeout and cancellation] --> D[Shared bounded paginator]
  B --> D
  D --> E[Cursor and size limits]
  E --> F[Node-host tool descriptors]
  E --> G[Agent-session tools resources prompts]
  F --> H[Published capabilities]
  G --> H
Loading

Decision needed

Question Recommendation
Should OpenClaw treat the existing MCP catalog timeout as one aggregate catalog deadline and enforce the new page/item/byte caps, even when a slow or unusually large existing multi-page server would now be rejected rather than receiving a fresh full timeout for every page? Accept bounded aggregate loading: Merge after a refreshed merged-head run confirms normal multi-page servers still complete within the aggregate budget and the intended server-isolation diagnostics are preserved.

Why: This is a compatibility and availability tradeoff rather than a mechanical correctness question: the patch deliberately changes the operating contract for existing MCP catalog loading.

Before merge

  • Resolve merge risk (P1) - The aggregate deadline and fixed catalog caps intentionally alter existing behavior: unusually slow or very large but otherwise valid multi-page MCP servers may now fail listing and be isolated instead of eventually completing.
  • Resolve merge risk (P1) - The branch is behind current main; refresh the three-way merge result and wait for the in-progress required checks before relying on the supplied exact-head proof.
Agent review details

Security

None.

PR surface

Source +187, Tests +591. Total +778 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 260 73 +187
Tests 3 599 8 +591
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 859 81 +778

Review metrics

Metric Value Why it matters
Catalog guardrails 1 shared collector; 4 list surfaces routed through it A single owner reduces divergence between node-host tools and agent-session tools, resources, and prompts, but concentrates the timeout and cap contract into one merge-sensitive boundary.

Stored data model

Persistent data-model change detected: serialized state: src/agents/agent-bundle-mcp-runtime.test.ts, serialized state: src/agents/mcp-pagination.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Refresh and prove aggregate timeout behavior (recommended)
    Rebase or refresh the merge result, then retain the aggregate deadline only if merged-head proof shows normal multi-page catalogs complete while malformed servers fail without blocking siblings.
  2. Accept the stricter catalog contract
    Maintainers may intentionally accept the new caps and aggregate timeout as a safety contract for MCP server discovery.
  3. Pause for limit policy
    Pause this change if the current caps or aggregate deadline need product-level calibration for large existing MCP installations.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Refresh the merge result and complete exact merged-head proof for normal multi-page MCP catalogs plus malformed-server isolation before merge.

Technical review

Best possible solution:

Retain one shared bounded paginator, but land it only after maintainers accept the aggregate-timeout and cap policy for existing MCP servers, the branch is refreshed onto current main, and exact merged-head checks confirm both normal multi-page completion and bounded failure isolation.

Do we have a high-confidence way to reproduce the issue?

Yes, from source and supplied focused tests: a list response with an empty, repeated, cyclic, or endless cursor, or a sequence exceeding the aggregate deadline, follows the reported unsafe pagination path. The supplied Testbox report states these cases were exercised on the branch, though this read-only review could not independently execute them.

Is this the best way to solve the issue?

Yes, conditionally: centralizing the invariant in one collector is more maintainable than separately patching node-host and each agent-session list loop. The remaining question is whether the aggregate deadline and fixed caps are the intended compatibility contract for existing servers.

AGENTS.md: unclear because the file could not be read completely.

Codex review notes: model internal, reasoning high; reviewed against aaab981ab097.

Labels

Label justifications:

  • P2: Malformed MCP pagination can degrade catalog startup and tool availability, but the proposed isolation limits the expected blast radius.
  • merge-risk: 🚨 compatibility: Existing multi-page MCP servers now share one aggregate deadline and can hit new page, item, or byte limits that did not previously apply across the full catalog.
  • merge-risk: 🚨 availability: The change directly controls whether an MCP catalog remains available or is failed and isolated when pagination is slow, cyclic, or oversized.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides an exact-head Testbox run and comprehensive after-fix runtime-focused test coverage for shared pagination, node-host listing, and agent-session MCP catalogs; no browser, network, or security-only diagnostic proof is required here.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides an exact-head Testbox run and comprehensive after-fix runtime-focused test coverage for shared pagination, node-host listing, and agent-session MCP catalogs; no browser, network, or security-only diagnostic proof is required here.

Evidence

What I checked:

  • Shared boundary and coverage: The branch adds collectMcpPaginatedItems and routes both node-host tool listing and agent-session tool, resource, and prompt listing through it; the supplied diff also adds focused tests for empty cursors, cycles, limits, aggregate deadlines, aborts, sibling survival, and ordering. (src/agents/mcp-pagination.ts:1, 80861c936ad9)
  • Compatibility-relevant behavior change: The node-host caller changes from per-page list calls to a bounded aggregate collector, adding page and retained-item caps while applying the configured catalog timeout as one lifecycle budget. That can intentionally reject a multi-page server that previously completed only because each page received a fresh full timeout. (src/node-host/mcp.ts:29, 80861c936ad9)
  • Prior review continuity: The prior completed ClawSweeper cycle reviewed 7fe1681f4f31131962201463603c3884abe3208d with no findings; the final commit is described in supplied PR history as stabilizing pagination deadline ownership after the earlier final-page deadline finding. (src/agents/mcp-pagination.ts:1, 80861c936ad9)
  • After-fix proof supplied: The PR body reports an exact-head Testbox run with 116 focused tests across the shared paginator, node-host manager, and agent-session MCP runtime, plus a complete changed gate on the same head. The PR also has the proof: sufficient label. (src/agents/mcp-pagination.test.ts:1, 80861c936ad9)
  • Current merge state: GitHub context reports this branch as cleanly mergeable but behind main, with build, lint, compact checks, and QA smoke checks still in progress; the merge result needs a refresh before landing. (aaab981ab097)

Likely related people:

  • steipete: The supplied commit history attributes all eight commits in this bounded-pagination series to steipete, including the final deadline-ownership revision; the PR is also assigned to this person. (role: recent MCP pagination contributor; confidence: medium; commits: cbaed0f50a3b, b842885500b8, 7fe1681f4f31; files: src/agents/mcp-pagination.ts, src/node-host/mcp.ts, src/agents/agent-bundle-mcp-runtime.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Refresh the branch against current main and let the pending required checks complete.
  • Have the responsible maintainer explicitly accept the aggregate timeout and cap contract for existing MCP servers.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-07-31T12:59:54.864Z sha 7fe1681 :: needs maintainer review before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

Maintainer decision on the final reviewed head 80861c936ad9bbc1e46c7593d5847bc7a624a2a3:

  • I accept one configured catalog timeout as the aggregate MCP listing deadline and the fixed page, retained-item, and serialized-byte caps as the intended reliability contract. A server that cannot enumerate within those bounds should be isolated instead of extending startup work indefinitely.
  • Exact-head hosted CI run 30634087201 is green, including the previously failing agents-core shard. Focused proof is 117/117, and the timer-race regression passed 5/5 stress runs.
  • I am not rebasing solely to erase the BEHIND marker: fetched current main b2b62b2e1e0f65615cc836044bc1154f1838af30 has no changes in the six PR files. The repo-native merge verifier will validate the actual three-way result and refuse relevant drift before merge.

This completes the current ClawSweeper rank-up moves without introducing needless commit churn.

@steipete
steipete merged commit e051a7b into main Jul 31, 2026
120 checks passed
@steipete
steipete deleted the codex/autoqa-mcp-pagination-shared-20260731 branch July 31, 2026 13:41
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 1, 2026
* fix(node-host): bound MCP tool pagination

* fix(node-host): bound MCP catalog duration

* style(node-host): format MCP pagination test

* fix(mcp): share bounded pagination

* fix(mcp): keep pagination types private

* test(mcp): normalize abort rejection

* fix(mcp): enforce pagination deadline after loading

* fix(mcp): stabilize pagination deadline ownership
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant