Fix crash when parsing MCP server tool results#2
Merged
Conversation
MCP tools return tool_result content as an array of content blocks
([{"type":"text","text":"..."}]) while built-in tools return a plain
string. The ToolResult.Content field was typed as string, causing
json.Unmarshal to fail on any MCP tool result.
Change Content to json.RawMessage and add extractToolResultContent()
to handle both formats.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Closed
phiat
added a commit
that referenced
this pull request
Mar 20, 2026
…n output - Fix show_text default (false → true) — text output was hidden with no toggle - Add Text toggle (x key) in header - Add solo mode (s key) — isolate a session/agent in tree view - Remove destructive x/d delete — space toggle + solo covers filtering - Show tool name on output headers (e.g., "Bash result (1.2s)") - Fix dedup to key on (ToolID, Type) — input+output with same ID both kept - Rename "Auto" to "Scroll" in header - Update README keybindings Based on phiat/claude-esp-rs#2 by @rdmontgomery Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
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.
Summary
tool_result.contentas an array of content blocks ([{"type":"text","text":"..."}]), while built-in tools return a plain string. TheToolResult.Contentfield was typed asstring, causingjson.Unmarshalto fail on any MCP tool result — crashing the UI with a JSON parse error.Contenttojson.RawMessageand addedextractToolResultContent()to handle both string and array formats gracefully.Test plan
TestParseLine_MCPToolResult— single content block (MCP style)TestParseLine_MCPToolResultMultiBlock— multiple content blocks joined with newlinesclaude-espwhile Claude invokes an MCP server (e.g., Context7) and verify output displays correctly🤖 Generated with Claude Code