Fix: Render MCP tool output identically to built-in tools - #2
Open
Meldrey wants to merge 1 commit into
Open
Conversation
Two gates prevented MCP tool results from displaying to users: 1. toolExecution.ts: isMcpTool() guard routed MCP tools through a separate code path that skipped addToolResult(), the function that stores results for UI rendering. Built-in tools called it; MCP tools didn't. Removed the guard so all tools use the same rendering path. Also removed the duplicate MCP-only addToolResult() call that would have double-rendered. 2. MCPTool.ts: outputSchema was z.string(), but MCP tool results arrive as content arrays (objects), not strings. UserToolSuccessMessage validates results against outputSchema before rendering — string validation on an array silently returns null, killing the render. Changed to z.any(). The Anthropic dev left a guilty TODO on gate IIIIQIIII#1: 'TOOD(hackyon): refactor so we don't have different experiences for MCP tools' Now they don't. Co-Authored-By: J5 <mod+ai_dev@arktechnwa.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
MCP tool results are invisible to users. When Claude calls an MCP tool, the model receives the response, but users see no output block. Built-in tools (Bash, Edit, Read) display output normally.
This affects all MCP servers — plugins, project
.mcp.json, everything.Root Cause
Two gates in the rendering pipeline prevent MCP tool output from reaching users:
Gate 1:
toolExecution.ts— separate code pathsaddToolResult()stores tool results for UI rendering. It was only called for built-in tools. MCP tools were routed through a separate path that calledaddToolResult()later, without the pre-mapped block. The upstream dev left a typo'd TODO acknowledging this.Gate 2:
MCPTool.ts— outputSchema type mismatchMCP tool results arrive as content arrays (objects), not strings.
UserToolSuccessMessagevalidates results againstoutputSchemabefore rendering —z.string().safeParse()on an array fails silently, returningnull. The renderer never fires.Fix
toolExecution.ts: Remove the
isMcpToolguard. All tools calladdToolResult()through the same path. Remove the duplicate MCP-onlyaddToolResult()call downstream.MCPTool.ts: Change
outputSchemafromz.string()toz.any()so validation accepts whatever the MCP server returns.Result
MCP tool output renders in the same result block as built-in tools. Same component (
OutputLine), same pipeline, same user experience.Net change: +3 lines, -9 lines.