Update agents/tools/mcp_tools.py
Browse files
agents/tools/mcp_tools.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
|
| 3 |
# https://docs.crewai.com/introduction
|
| 4 |
|
| 5 |
-
import
|
| 6 |
from agents.mcp.mcp_client import (
|
| 7 |
call_mcp_tool,
|
| 8 |
MCP_SSE_URL_CHESS_POSITION_EVALUATION,
|
|
@@ -40,13 +40,16 @@ class MCPTools():
|
|
| 40 |
|
| 41 |
result = raw_result
|
| 42 |
|
|
|
|
|
|
|
|
|
|
| 43 |
if isinstance(raw_result, str):
|
| 44 |
try:
|
| 45 |
-
parsed =
|
| 46 |
|
| 47 |
if isinstance(parsed, dict) and "continuation" in parsed:
|
| 48 |
result = parsed["continuation"]
|
| 49 |
-
except (
|
| 50 |
pass
|
| 51 |
|
| 52 |
print(f"🛠️ MCPTools: best_move_tool: result={result}")
|
|
|
|
| 2 |
|
| 3 |
# https://docs.crewai.com/introduction
|
| 4 |
|
| 5 |
+
import json, os
|
| 6 |
from agents.mcp.mcp_client import (
|
| 7 |
call_mcp_tool,
|
| 8 |
MCP_SSE_URL_CHESS_POSITION_EVALUATION,
|
|
|
|
| 40 |
|
| 41 |
result = raw_result
|
| 42 |
|
| 43 |
+
#if isinstance(raw_result, dict) and 'continuation' in raw_result:
|
| 44 |
+
# result = raw_result['continuation']
|
| 45 |
+
#elif isinstance(raw_result, str):
|
| 46 |
if isinstance(raw_result, str):
|
| 47 |
try:
|
| 48 |
+
parsed = json.loads(raw_result)
|
| 49 |
|
| 50 |
if isinstance(parsed, dict) and "continuation" in parsed:
|
| 51 |
result = parsed["continuation"]
|
| 52 |
+
except (json.JSONDecodeError, KeyError):
|
| 53 |
pass
|
| 54 |
|
| 55 |
print(f"🛠️ MCPTools: best_move_tool: result={result}")
|