Repository navigation
fix(mcp): preserve App pagination cursor bytes - #164368
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 3, 2026, 7:26 PM ET / 23:26 UTC (Revision 3). ClawSweeper reviewWhat this changesThe PR preserves empty and whitespace-bearing MCP App pagination cursors through the UI bridge and Gateway, with regressions for exact token forwarding and returned pages. Merge readiness✅ Ready for maintainer review The repair remains necessary on current main. The new transport evidence resolves the previous proof blocker, and inspection found no introduced correctness defect. Priority: P2 Review scores
Verification
How this fits togetherMCP Apps are server-provided interactive views hosted by OpenClaw. Their tool and resource requests pass through the UI bridge and authenticated Gateway to the selected MCP server, then return filtered results to the App. flowchart LR
A[App pagination request] --> B[UI protocol bridge]
B --> C[Authenticated Gateway]
C --> D[Current view authorization]
D --> E[Exact cursor forwarding]
E --> F[Selected MCP server]
F --> G[Filtered page and next cursor]
G --> A
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +8, Tests +140. Total +148 across 5 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep one App forwarding path that preserves every present string cursor exactly while retaining current authorization, filtering, and resource aggregation. Do we have a high-confidence way to reproduce the issue? Yes: current-main source deterministically drops empty tokens and trims padded tokens on the App list path; the supplied before/after Gateway traces corroborate the failure. This reviewer did not execute a reproduction. Is this the best way to solve the issue? Yes: preserving the existing optional string parameter through all forwarding adapters is the narrow repair, and the shared catalog paginator serves a different aggregation contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9b16ed050a69. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
@clawsweeper re-review: exact head ff311f7 now has built-Gateway real WebSocket-to-stdio-MCP before/after cursor traces, unchanged aggregation/discovery controls, failing-before/passing-after installed regressions with standalone single-worker timings, and one real provider smoke. Evidence and explicit browser-proof limit are in the updated PR body. |
|
🦞👀 Re-review progress:
|
Fixes openclaw#164365. MCP Apps received the first or wrong tools or resource-template page when a server returned an empty or whitespace-bearing continuation cursor, because the UI bridge and the Gateway trimmed or dropped it. Present string cursors now pass through the bridge, the Gateway parser and MCP app operations unchanged. The wire shape (an optional string cursor) is unchanged, with no gateway-protocol schema change. Absent and normal cursors, resource aggregation and catalog discovery are unchanged. Proof: a built Gateway over authenticated WS, with a local stdio MCP App that paginates using `""` and padded cursors, dropped or trimmed them on base and returned the wrong page. With this change the exact bytes reached the server and the correct pages came back. The Gateway and installed AppBridge regression tests fail on base and pass here. A live gpt-5-mini smoke call passed. Co-authored-by: Ayaan Zaidi <[email protected]>
|
Thanks for adding the built Gateway-to-MCP cursor traces and the confirmation fixture. The before/after calls and unchanged discovery controls make the forwarding behavior much easier to verify. I appreciate the extra validation and landing work. |
Closes #164365
What Problem This Solves
MCP Apps can receive the first or wrong tools/resource-template page when a server returns an empty or whitespace-bearing continuation cursor. The UI bridge and App operation adapters dropped empty strings, and the Gateway parser trimmed opaque tokens.
User Impact
Apps can request the intended page using the server's exact token, including
""and" page 2 ". Absent cursors still request the first page; normal cursors, catalog discovery, resource aggregation, authorization and tool visibility filtering retain their behavior.Why This Change Was Made
Preserve present string cursors in the existing forwarding path rather than introduce another paginator. The MCP pagination contract defines opaque string tokens without a nonempty requirement.
No dependency, configuration, permission, persistence or protocol-schema change. No
packages/gateway-protocolfiles change. RPC method names and the optional stringcursorwire shape are unchanged; only normalization/omission is removed.Original report and fix by @ooiuuii. Contributor commits are preserved. Integrated main's intervening MCP authority and file-confirmation changes and supplied the current confirmation callback in the UI regression fixture. No overlap with Pash/Sarah changes.
Evidence
Built Gateway → real WebSocket → local stdio MCP server
Observed on baseline main
67ab6f3104fd5d5016c6fc8f6e1ff3edcb5e078fand candidateff311f77ed36caa405abf91688a718f0898bc2e8, in an isolated Linux ARM64 Node 24.16.0 container. Built withpnpm build:docker; the candidate runtime rebuild reused unchanged declarations. The actualnode openclaw.mjs --profile <isolated-profile> gateway runCLI started each Gateway. Its database-ownership command confirmed task-owned state before startup.An authenticated WS client created isolated sessions, called
mcp.app.discoverandmcp.app.launch, then called the samemcp.app.listToolsandmcp.app.listResourceTemplatesRPCs used by the UI bridge. No Gateway handler, runtime, catalog, view lease or MCP transport was mocked or manually inserted. A local stdio MCP server advertised an App and four pages; it logged every received JSON-RPC request. Unknown/altered tokens return the first page.Results apply to both list methods:
firstfirst""first(wrong)""empty" page 2 ""page 2"first(wrong)" page 2 "padded"normal""normal"normal"normal"normalExact candidate upstream trace excerpt, after App launch:
{"method":"tools/list","params":{"cursor":""}} {"method":"resources/templates/list","params":{"cursor":""}} {"method":"tools/list","params":{"cursor":" page 2 "}} {"method":"resources/templates/list","params":{"cursor":" page 2 "}}Candidate returned
nextCursor: " page 2 "with pageempty, andnextCursor: "normal"with pagepadded. Baseline omitted empty request cursors and transmitted"page 2"for padded requests, returning pagefirstin both cases.Controls compared from retained output: discovery returned the identical four App entrypoints on both versions;
mcp.app.listResourcesreturned both aggregated upstream resources and no next cursor. All 16 before/after page observations and both equality controls passed an independent check of the recorded output.Regression RED → GREEN and standalone file cost
Each command used
pnpm test <file> --maxWorkers=1, with isolated test state and real installed dependencies:src/gateway/server-methods/mcp-app.test.tsui/src/components/mcp-app-bridge.cursor.test.ts{}Gateway Vitest durations: 19.17 s → 15.57 s; UI: 1.27 s → 0.949 s. These are standalone commands, not comparable performance benchmarks; Gateway compilation was cold for both. The UI test uses the installed App/AppBridge in-memory transport, not a mocked SDK.
Earlier contributor-head hosted evidence: CI run 37132655143, Gateway targeted shard 24.23 s; UI shard 170.56 s (includes 545 files, not this test's isolated cost). Fresh CI is required for the integrated head above; no CI jobs have been rerun.
Live smoke
Candidate made one real
gpt-5-miniResponses request through a passive, one-call-capped proxy:reasoning.effort: "low",max_output_tokens: 4096, streamed response, HTTP 200, CLI exit 0, nonempty final model response. The response followed the fresh workspace onboarding prompt rather than the requested literal marker; this is a provider transport smoke, not an exact-text assertion. Proxy and task-only credential were removed afterward.Limits
The complete real transport proof starts at the Gateway WS method used by the UI bridge; Chromium/iframe rendering was not exercised. The separate installed AppBridge regression covers browser-adapter cursor forwarding. Full local lint/typecheck and project-wide suites were not run; hosted CI owns those gates. Initial fixture startup/admission errors were corrected before the successful before/after proof and are not counted as reproductions.