bstraehle commited on
Commit
5b01595
·
verified ·
1 Parent(s): 33dd1d7

Create mcp_tools.py

Browse files
Files changed (1) hide show
  1. agents/tools/mcp_tools.py +37 -0
agents/tools/mcp_tools.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from agents.mcp.mcp_client import (
3
+ call_mcp_tool,
4
+ MCP_SSE_URL_CHESS_EVALUATION,
5
+ MCP_TOOL_CHESS_EVALUATION
6
+ )
7
+ from crewai.tools import tool
8
+
9
+ class ChessTools():
10
+ @tool("Get Best Move Tool")
11
+ def get_best_move_tool(fen: str) -> str:
12
+ """Get best move for chess position.
13
+
14
+ Args:
15
+ fen (str): Chess position in FEN
16
+
17
+ Returns:
18
+ str: FEN and chess position evaluation
19
+
20
+ Raises:
21
+ RuntimeError: If processing fails
22
+
23
+ """
24
+ try:
25
+ mcp_url = os.getenv("MCP_SSE_URL", MCP_SSE_URL_CHESS_EVALUATION)
26
+
27
+ evaluation = call_mcp_tool(
28
+ mcp_url=mcp_url,
29
+ tool_name=MCP_TOOL_CHESS_EVALUATION,
30
+ arguments={"fen": fen}
31
+ )
32
+
33
+ print(f"🤖 Evaluation: {evaluation}")
34
+
35
+ return evaluation
36
+ except Exception as e:
37
+ raise RuntimeError(f"Processing failed: {str(e)}")