fix: the parsing of list type returned by MCP

pull/20716/head
Novice 11 months ago
parent 762f85fd46
commit fe3a41194e

@ -56,7 +56,14 @@ class MCPTool(Tool):
if isinstance(content, TextContent): if isinstance(content, TextContent):
yield self.create_text_message(content.text) yield self.create_text_message(content.text)
try: 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: except json.JSONDecodeError:
pass pass

Loading…
Cancel
Save