[BUG] structuredContent is not included in UserMessage with `tool_result`

Resolved 💬 3 comments Opened Jul 26, 2025 by rushilpatel0 Closed Aug 19, 2025

Environment

  • Platform (select one):
  • [ x ] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: <!-- output of claude --version --> 1.0.61
  • Operating System: <!-- e.g. macOS 14.3, Windows 11, Ubuntu 22.04 --> MacOS Sequoia 15.5, Darwin Kernel Version 24.5.0
  • Terminal: <!-- e.g. iTerm2, Terminal App --> Iterm2

Bug Description

<!-- A clear and concise description of the bug -->

Steps to Reproduce

  1. <!-- First step -->
Setup Claude code with an MCP tool that returns text content and in addition structured content. In my case I have a fastmcp server with a tool return like so: `` return ToolResult( content=content, structured_content=structured_content, ) ``
  1. <!-- Second step -->
Connect claude code to the MCP server, and run a prompt that invokes the MCP Tool returning structured content. Run the command claude --debug --output-format stream-json --print --verbose "your prompt here"
  1. <!-- And so on... -->
Observe that in the debug logs, the tool result message includes the structuredContent fields, however the user message json that is printed does not include it.

Expected Behavior

<!-- What you expected to happen -->
I'm expecting the structuredContent to be included in the json output for the tool result.

Actual Behavior

<!-- What actually happened -->
structuredContent is not included in the tool result in the user message json that is output by the CLI

Additional Context

<!-- Add any other context about the problem here, such as screenshots, logs, etc. -->
Here is an example of the logs from my own setup.

[DEBUG] executePreToolHooks called for tool: mcp__codegen_tools__sql_query
[DEBUG] Executing hooks for PreToolUse:mcp__codegen_tools__sql_query
[DEBUG] Getting matching hook commands for PreToolUse with query: mcp__codegen_tools__sql_query
[DEBUG] Found 0 hook matchers in settings
[DEBUG] Matched 0 unique hooks for query "mcp__codegen_tools__sql_query" (0 before deduplication)
[DEBUG] Found 0 hook commands to execute
[DEBUG] MCP server "codegen_tools": Calling MCP tool: sql_query
[DEBUG] MCP server "codegen_tools": No token data found
[DEBUG] MCP server "codegen_tools": Tool call succeeded:

{"content":[{"type":"text","text":"SQL Query Executed on Database: Test db\nQuery: select 1\nPage: 1 of 1\nRows on this page: 1\nTotal rows: 1\nHas more pages: False\n🛡️ Static IP Proxy: postgresql_proxy (None)\n\nResults (CSV format):\n?column?\n1"}],"structuredContent":{"status":"success","error":null,"query":"select 1","row_count":1,"results":[{"?column?":1}],"database_name":"Test db"},"isError":false}

{"type":"user","message":{"role":"user","content":[{"tool_use_id":"toolu_01Uf6cugSEpSNpH3mLRVvujd","type":"tool_result","content":[{"type":"text","text":"SQL Query Executed on Database: Test db\nQuery: select 1\nPage: 1 of 1\nRows on this page: 1\nTotal rows: 1\nHas more pages: False\n🛡️ Static IP Proxy: postgresql_proxy (None)\n\nResults (CSV format):\n?column?\n1"}]}]},"parent_tool_use_id":null,"session_id":"b75c4370-59ff-4ff7-928b-10b471b0db1d"}

[DEBUG] Executing hooks for PostToolUse:mcp__codegen_tools__sql_query
[DEBUG] Getting matching hook commands for PostToolUse with query: mcp__codegen_tools__sql_query
[DEBUG] Found 0 hook matchers in settings
[DEBUG] Matched 0 unique hooks for query "mcp__codegen_tools__sql_query" (0 before deduplication)
[DEBUG] Found 0 hook commands to execute
[DEBUG] Stream started - received first chunk

{"type":"assistant","message":{"id":"msg_01Px6a63DuwPU13GZBbRCru6","type":"message","role":"assistant","model":"claude-sonnet-4-20250514","content":[{"type":"text","text":"The test query executed successfully and returned `1` as expected."}],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":7,"cache_creation_input_tokens":379,"cache_read_input_tokens":19272,"output_tokens":16,"service_tier":"standard"}},"parent_tool_use_id":null,"session_id":"b75c4370-59ff-4ff7-928b-10b471b0db1d"}

[DEBUG] Executing hooks for Stop
[DEBUG] Getting matching hook commands for Stop with query: undefined
[DEBUG] Found 0 hook matchers in settings
[DEBUG] Matched 0 unique hooks for query "no match query" (0 before deduplication)
[DEBUG] Found 0 hook commands to execute

{"type":"result","subtype":"success","is_error":false,"duration_ms":27324,"duration_api_ms":5794,"num_turns":4,"result":"The test query executed successfully and returned `1` as expected.","session_id":"b75c4370-59ff-4ff7-928b-10b471b0db1d","total_cost_usd":0.01463065,"usage":{"input_tokens":11,"cache_creation_input_tokens":379,"cache_read_input_tokens":38544,"output_tokens":98,"server_tool_use":{"web_search_requests":0},"service_tier":"standard"}}
[DEBUG] Cleaned up session snapshot: /Users/rushil/.claude/shell-snapshots/snapshot-zsh-1753544572562-grzyqg.sh
[DEBUG] Metrics opt-out API response: enabled=true
[DEBUG] BigQuery metrics exported successfully
[DEBUG] "API Response: {\n  \"accepted_count\": 10,\n  \"rejected_count\": 0\n}"
[DEBUG] BigQuery metrics exporter flush complete
[DEBUG] BigQuery metrics exporter flush complete
[DEBUG] BigQuery metrics exporter shutdown complete

Notice that the debug log following [DEBUG] MCP server "codegen_tools": Tool call succeeded: includes the structuredContent property, hoewever the following message which is the printed user message does not have it.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗