Skip widget JSON for Claude Code clients#235
Conversation
Claude Code doesn't render MCP App widgets, so the widget JSON blob in the tool response just wastes context. Detect the client using two approaches: 1. MCP Apps UI capability — check experimental["io.modelcontextprotocol/ui"] (spec-recommended, but not yet advertised by any client) 2. Name-based fallback — denylist "claude-code" based on clientInfo.name sent during initialization (to be removed once clients adopt the cap) Also adds log_client_info() helper that logs client name, version, and capability flags on every tool call for observability. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@claude code review |
|
Claude finished @RafaelPo's task in 1m 17s —— View job Code Review: Skip widget JSON for Claude Code clients
Overall this is a clean, well-scoped change. The 1. Docstring says "allowlist" but the implementation is a denylist
2. Inconsistent defaults for unknown clients
If the intent is fail-safe (include widgets when unsure), line 102 should also return if not cp:
return True # Unknown client — default to including widgets3. No tests for the new behavior The existing test suite covers
4. Minor:
Summary: The core logic is sound and the |
- Switch client_supports_widgets from denylist to whitelist approach: unknown clients default to no widget (saves context tokens) - Whitelist verified client names: Claude.ai and Claude Desktop both report "Anthropic/ClaudeAI" (same identity, single entry covers both) - Add log_client_info to all tools except everyrow_progress - Update result_store comment to reflect whitelist approach Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
client_supports_widgets()detection using two approaches:experimental["io.modelcontextprotocol/ui"](spec-recommended, not yet advertised by any client)"claude-code"based onclientInfo.name(to be removed once clients adopt the capability)log_client_info()helper that logs client name, version, and capability flags on tool calls for observability.Test plan
🤖 Generated with Claude Code