bstraehle commited on
Commit
eb26e42
·
verified ·
1 Parent(s): 934ce3a

Update agents/tools/mcp_tools.py

Browse files
Files changed (1) hide show
  1. agents/tools/mcp_tools.py +17 -2
agents/tools/mcp_tools.py CHANGED
@@ -32,12 +32,27 @@ class MCPTools():
32
  try:
33
  mcp_url = os.getenv("MCP_SSE_URL", MCP_SSE_URL_CHESS_POSITION_EVALUATION)
34
 
35
- result = call_mcp_tool(
36
  mcp_url=mcp_url,
37
  tool_name=MCP_TOOL_CHESS_POSITION_EVALUATION,
38
  arguments={"fen": fen}
39
  )
40
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  print(f"🛠️ MCPTools: best_move_tool: result={result}")
42
 
43
  return result
 
32
  try:
33
  mcp_url = os.getenv("MCP_SSE_URL", MCP_SSE_URL_CHESS_POSITION_EVALUATION)
34
 
35
+ raw_result = call_mcp_tool(
36
  mcp_url=mcp_url,
37
  tool_name=MCP_TOOL_CHESS_POSITION_EVALUATION,
38
  arguments={"fen": fen}
39
  )
40
+
41
+ result = raw_result
42
+
43
+ if isinstance(raw_result, tuple) and len(raw_result) > 0:
44
+ raw_result = raw_result[0]
45
+
46
+ if isinstance(raw_result, dict) and "continuation" in raw_result:
47
+ result = raw_result["continuation"]
48
+ elif isinstance(raw_result, str):
49
+ try:
50
+ parsed = json.loads(raw_result)
51
+ if isinstance(parsed, dict) and "continuation" in parsed:
52
+ result = parsed["continuation"]
53
+ except (json.JSONDecodeError, KeyError):
54
+ pass
55
+
56
  print(f"🛠️ MCPTools: best_move_tool: result={result}")
57
 
58
  return result