Update agents/tools/mcp_tools.py
Browse files
agents/tools/mcp_tools.py
CHANGED
|
@@ -38,29 +38,33 @@ class MCPTools():
|
|
| 38 |
arguments={"fen": fen}
|
| 39 |
)
|
| 40 |
|
| 41 |
-
print("111", raw_result)
|
| 42 |
|
| 43 |
# Extract from tuple if needed
|
| 44 |
if isinstance(raw_result, tuple) and len(raw_result) > 0:
|
| 45 |
raw_result = raw_result[0]
|
| 46 |
-
print("222", raw_result)
|
| 47 |
|
| 48 |
# Extract continuation from dict
|
|
|
|
| 49 |
if isinstance(raw_result, dict) and "continuation" in raw_result:
|
| 50 |
result = raw_result["continuation"]
|
| 51 |
-
print("333", result)
|
| 52 |
elif isinstance(raw_result, str):
|
| 53 |
try:
|
| 54 |
parsed = json.loads(raw_result)
|
| 55 |
if isinstance(parsed, dict) and "continuation" in parsed:
|
| 56 |
result = parsed["continuation"]
|
| 57 |
-
print("444", result)
|
| 58 |
else:
|
| 59 |
result = raw_result
|
|
|
|
| 60 |
except (json.JSONDecodeError, KeyError):
|
| 61 |
result = raw_result
|
|
|
|
| 62 |
else:
|
| 63 |
result = raw_result
|
|
|
|
| 64 |
|
| 65 |
print(f"🛠️ MCPTools: best_move_tool: result={result}")
|
| 66 |
|
|
|
|
| 38 |
arguments={"fen": fen}
|
| 39 |
)
|
| 40 |
|
| 41 |
+
print("111 raw_result:", raw_result)
|
| 42 |
|
| 43 |
# Extract from tuple if needed
|
| 44 |
if isinstance(raw_result, tuple) and len(raw_result) > 0:
|
| 45 |
raw_result = raw_result[0]
|
| 46 |
+
print("222 after tuple extraction:", raw_result)
|
| 47 |
|
| 48 |
# Extract continuation from dict
|
| 49 |
+
result = None
|
| 50 |
if isinstance(raw_result, dict) and "continuation" in raw_result:
|
| 51 |
result = raw_result["continuation"]
|
| 52 |
+
print("333 extracted continuation:", result)
|
| 53 |
elif isinstance(raw_result, str):
|
| 54 |
try:
|
| 55 |
parsed = json.loads(raw_result)
|
| 56 |
if isinstance(parsed, dict) and "continuation" in parsed:
|
| 57 |
result = parsed["continuation"]
|
| 58 |
+
print("444 parsed continuation:", result)
|
| 59 |
else:
|
| 60 |
result = raw_result
|
| 61 |
+
print("555 using raw string:", result)
|
| 62 |
except (json.JSONDecodeError, KeyError):
|
| 63 |
result = raw_result
|
| 64 |
+
print("666 json error, using raw:", result)
|
| 65 |
else:
|
| 66 |
result = raw_result
|
| 67 |
+
print("777 fallback to raw_result:", result)
|
| 68 |
|
| 69 |
print(f"🛠️ MCPTools: best_move_tool: result={result}")
|
| 70 |
|