mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
fix(mcp): preserve structured_content in tool call results
MCP CallToolResult may include structured_content (a JSON object) alongside content blocks. The tool handler previously only forwarded concatenated text from content blocks, silently dropping the structured payload. This breaks MCP tools that return a minimal human text in content while putting the actual machine-usable payload in structured_content. Now, when structured_content is present, it is included in the returned JSON under the 'structuredContent' key. Fixes NousResearch/hermes-agent#5874
This commit is contained in:
parent
cbf1f15cfe
commit
2ad7694874
1 changed files with 10 additions and 1 deletions
|
|
@ -1253,7 +1253,16 @@ def _make_tool_handler(server_name: str, tool_name: str, tool_timeout: float):
|
|||
for block in (result.content or []):
|
||||
if hasattr(block, "text"):
|
||||
parts.append(block.text)
|
||||
return json.dumps({"result": "\n".join(parts) if parts else ""})
|
||||
text_result = "\n".join(parts) if parts else ""
|
||||
|
||||
# Preserve structured_content (structuredContent) if present
|
||||
structured = getattr(result, "structured_content", None)
|
||||
if structured is not None:
|
||||
return json.dumps({
|
||||
"result": text_result,
|
||||
"structuredContent": structured,
|
||||
})
|
||||
return json.dumps({"result": text_result})
|
||||
|
||||
try:
|
||||
return _run_on_mcp_loop(_call(), timeout=tool_timeout)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue