qwen-code/packages/sdk-typescript/scripts
Shaojin Wen ef0c39cf96
feat(web-shell): browse MCP server resources in the /mcp dialog (#5879)
* feat(web-shell): browse MCP server resources in the /mcp dialog

Port the TUI's MCP resource browser (#5544/#5635) to the Web Shell. The
/mcp dialog now shows per-server resource and prompt counts plus an
expandable resource browser (URI, MIME type, size, description, and the
@server:uri chat reference), reaching parity with the terminal UI.

Resources and prompts were never serialized past the in-process core
registries, so this wires the data end to end: per-server resourceCount
and promptCount ride the existing /workspace/mcp status, and a new
qwen/status/workspace/mcp/resources ext-method (mirroring the tools
drill-down) carries the resource list through the daemon, SDK, and webui
hook into the Web Shell McpDialog. All additions are protocol-additive;
older daemons 404 the new route and the client degrades gracefully.

* fix(web-shell): make resourcesByServer optional and pluralize 1-byte size

Address review on #5879:
- SerializedMcpStatusMessage.resourcesByServer is now optional, matching
  its JSDoc ("older clients omit it") so TypeScript enforces the `?? {}`
  defensive read at every consumer.
- mcp.resource.bytes now pluralizes ("1 byte" vs "2 bytes"), consistent
  with the mcp.resourceCount / mcp.promptCount strings in this PR.

* fix(web-shell): address MCP resources review — remove non-functional @ref, harden fallbacks, add tests

Address review on #5879:
- [Critical] Remove the "@server:uri" chat-reference UI from the resource
  browser: the Web Shell submits prompts as a plain text block and the
  daemon forwards it verbatim (the TUI's atCommandProcessor resolution is
  TUI-client-side only), so the reference never injected resource content.
  The browser stays as read-only metadata; @-reference injection is a
  follow-up that needs the resolver wired into the Web Shell prompt path.
- [Critical] reloadServer now isolates the resource refetch in its own
  try/catch so a failed resource load can't report a successful
  reconnect/enable as failed.
- [Critical] resolveServerMcpResources/Prompts skip a throwing session in
  the pool-mode fallback so one degraded session can't blank the base
  /workspace/mcp status (which now carries the counts).
- [Suggestion] Resource section renders an "unavailable" state when a
  server advertises a count but the drill-down list is empty.
- [Suggestion] Add SDK client URL-encoding test (workspaceMcpResources),
  route-table matching test, and an unconfigured-server error-branch test.

---------

Co-authored-by: qwen-code-dev-bot <qwen-code-dev-bot@users.noreply.github.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-06-26 17:12:01 +00:00
..
build.js feat(web-shell): browse MCP server resources in the /mcp dialog (#5879) 2026-06-26 17:12:01 +00:00
bundle-cli-from-npm.js fix(sdk): Include CLI chunks in SDK package (#4541) 2026-05-26 16:40:49 +08:00
bundle-cli.js fix(sdk): Include CLI chunks in SDK package (#4541) 2026-05-26 16:40:49 +08:00
get-release-version.js refactor: extract shared release helper utilities (#3834) 2026-05-05 10:15:17 +08:00