fix: use camelCase structuredContent attr, prefer structured over text
- The MCP SDK Pydantic model uses camelCase (structuredContent), not snake_case (structured_content). The original getattr was a silent no-op. - When structuredContent is present, return it AS the result instead of alongside text — the structured payload is the machine-readable data. - Move test file to tests/tools/ and fix fake class to use camelCase. - Patch _run_on_mcp_loop in tests so the handler actually executes.
This commit is contained in:
@@ -1255,13 +1255,10 @@ def _make_tool_handler(server_name: str, tool_name: str, tool_timeout: float):
|
||||
parts.append(block.text)
|
||||
text_result = "\n".join(parts) if parts else ""
|
||||
|
||||
# Preserve structured_content (structuredContent) if present
|
||||
structured = getattr(result, "structured_content", None)
|
||||
# Prefer structuredContent (machine-readable JSON) over plain text
|
||||
structured = getattr(result, "structuredContent", None)
|
||||
if structured is not None:
|
||||
return json.dumps({
|
||||
"result": text_result,
|
||||
"structuredContent": structured,
|
||||
})
|
||||
return json.dumps({"result": structured})
|
||||
return json.dumps({"result": text_result})
|
||||
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user