fix: the parsing of list type returned by MCP

This commit is contained in:
Novice
2025-07-10 10:25:29 +08:00
parent 762f85fd46
commit fe3a41194e

View File

@ -56,7 +56,14 @@ class MCPTool(Tool):
if isinstance(content, TextContent):
yield self.create_text_message(content.text)
try:
yield self.create_json_message(json.loads(content.text))
content_json = json.loads(content.text)
if isinstance(content_json, dict):
yield self.create_json_message(content_json)
elif isinstance(content_json, list):
for item in content_json:
yield self.create_json_message(item)
else:
pass
except json.JSONDecodeError:
pass