fix(docs): use lowercase MCP tool id and surface MCP errors (#82702)#82704
Conversation
|
Codex review: needs maintainer review before merge. Summary Reproducibility: yes. Current main passes the uppercase selector to mcporter, and live MCP calls show that selector returns Real behavior proof Next step before merge Security Review detailsBest possible solution: Land the focused docs CLI fix after required checks are green, then close the linked bug through the PR’s closing reference. Do we have a high-confidence way to reproduce the issue? Yes. Current main passes the uppercase selector to mcporter, and live MCP calls show that selector returns Is this the best way to solve the issue? Yes. Updating the fixed selector and surfacing MCP error text before parsing is the narrow maintainable fix, and the PR keeps code, docs, and regression tests aligned. What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 6a1213448927. |
8f05faa to
475f7b4
Compare
…#82702) - Rename SEARCH_TOOL to https://docs.openclaw.ai/mcp.search_open_claw to match the actual tool name advertised by the docs MCP server. - Detect "MCP error -<code>" responses on stdout/stderr when mcporter exits 0 and propagate them as a hard CLI failure so misconfigured tool ids stop silently returning "No results." - Add docs.test.ts covering both regressions.
475f7b4 to
257ba5d
Compare
Fixes #82702.
Problem
openclaw docs <query>always printsNo results.and exits 0 even for valid queries, because the CLI is calling the docs MCP server with the wrong tool id. Per the issue and permcporter list https://docs.openclaw.ai/mcp, the actual tool is namedsearch_open_claw, but the CLI was sendingSearchOpenClaw. The server replies withMCP error -32602: Tool SearchOpenClaw not found, butmcporter call ... --output textstill exits 0, so the CLI happily parses an empty stdout into zero results.Fix
src/commands/docs.ts:SEARCH_TOOLfromhttps://docs.openclaw.ai/mcp.SearchOpenClawtohttps://docs.openclaw.ai/mcp.search_open_claw.MCP_ERROR_PATTERN = /MCP error\s+-?\d+/iguard. Aftermcporterreturns exit code 0, scan combined stdout+stderr for an MCP JSON-RPC error envelope and surface it as a hard CLI failure (runtime.error(...)+runtime.exit(1)) instead of silently returningNo results..docs/cli/docs.md: update the public CLI reference to the lowercase selector (addresses ClawSweeper P3 review finding — docs were still pointing users at the broken uppercase URL).src/commands/docs.test.ts(new): three vitest cases covering selector value, MCP error surfacing as exit 1, and healthy payload still rendering.Real behavior proof
Behavior or issue addressed:
openclaw docs <query>silently returnsNo results.because the CLI calls the wrong MCP tool id (SearchOpenClawvs. server-advertisedsearch_open_claw); the server'sMCP error -32602is swallowed by mcporter's exit-0 envelope.Real environment tested: Linux x86_64 (Ubuntu 24.04), Node v22.16, against the live public docs MCP endpoint at
https://docs.openclaw.ai/mcpusingnpx -y mcporter@latest. Local checkout ofopenclaw/openclawat branchfix-docs-search-tool-name(headbeb9824e) rebased onorigin/main. The probe runsmcporter callexactly the waysrc/commands/docs.tsinvokes it.Exact steps or command run after this patch:
Evidence after fix: live stdout from the lowercase selector returns real Title/Link/Content blocks — exactly the shape
parseSearchOutputexpects to render:For comparison, the unpatched uppercase selector reproducibly returns the error this PR now surfaces in the CLI:
Observed result after fix: the lowercase selector returns six real docs hits and the patched CLI parses them via
parseSearchOutputinto ranked results. When the server emitsMCP error -<code>, the newMCP_ERROR_PATTERNbranch routes throughruntime.error(...)+runtime.exit(1)instead of swallowing it. Net behavior change:openclaw docs "browser existing-session"now renders the four+ hits above instead ofNo results..What was not tested: I did not exercise the rich-terminal renderer path (
isRich()) on a real TTY; the vitest case for that branch covers the rendering call sites but not real ANSI output. Source-checkout end-to-end inside a packaged install was not run because the change is confined to a constant + a regex guard and does not interact with the launcher's respawn logic.