bstraehle commited on
Commit
b35329e
·
verified ·
1 Parent(s): 65a0c52

Update agents/tools/mcp_tools.py

Browse files
Files changed (1) hide show
  1. agents/tools/mcp_tools.py +23 -2
agents/tools/mcp_tools.py CHANGED
@@ -21,7 +21,7 @@ class MCPTools():
21
  fen (str): Chess position in FEN
22
 
23
  Returns:
24
- str: Best move with continuation in UCI notation
25
 
26
  Raises:
27
  RuntimeError: If processing fails
@@ -32,12 +32,33 @@ 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
 
21
  fen (str): Chess position in FEN
22
 
23
  Returns:
24
+ str: Best move with continuation in UCI notation (e.g., 'f8f3 e5e6 f3f1')
25
 
26
  Raises:
27
  RuntimeError: If processing fails
 
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
+ raw_result = call_mcp_tool(
42
  mcp_url=mcp_url,
43
  tool_name=MCP_TOOL_CHESS_POSITION_EVALUATION,
44
  arguments={"fen": fen}
45
  )
46
 
47
+ result = raw_result
48
+
49
+ print(f"🤖 MCPTools: best_move_tool: raw_result={raw_result}")
50
+
51
+ if isinstance(raw_result, str) and "continuation" in raw_result:
52
+ try:
53
+ import ast
54
+ parsed = ast.literal_eval(raw_result)
55
+ if isinstance(parsed, tuple) and len(parsed) > 0:
56
+ data = parsed[0]
57
+ if isinstance(data, dict) and 'continuation' in data:
58
+ result = data['continuation']
59
+ except:
60
+ pass
61
+
62
  print(f"🤖 MCPTools: best_move_tool: result={result}")
63
 
64
  return result