diff --git a/src/agent/my_graph.py b/src/agent/my_graph.py index b9a2689..650db16 100644 --- a/src/agent/my_graph.py +++ b/src/agent/my_graph.py @@ -41,6 +41,7 @@ async def make_graph() -> CompiledStateGraph[Any, Any, Any, Any]: client = get_client() mcp_tools = await client.get_tools() + # mcp_tools = [] tools = [get_wheather] tools.extend(mcp_tools) @@ -51,7 +52,7 @@ async def make_graph() -> CompiledStateGraph[Any, Any, Any, Any]: graph_builder.add_node("chatbot", chatbot) - tool_node = ToolNode(tools=[tool]) + tool_node = ToolNode(tools=tools) graph_builder.add_node("tools", tool_node) graph_builder.add_conditional_edges( diff --git a/mcp_servers.json b/src/mcp/config/mcp_servers.json similarity index 59% rename from mcp_servers.json rename to src/mcp/config/mcp_servers.json index fe2eb83..54ca22a 100644 --- a/mcp_servers.json +++ b/src/mcp/config/mcp_servers.json @@ -2,7 +2,7 @@ "math": { "command": "python", "args": [ - "/home/kexsh/src/knightutils/test/mcp/math_server.py" + "./src/mcp/server/math_server.py" ], "transport": "stdio" } diff --git a/src/mcp/mcp_servers.json b/src/mcp/mcp_servers.json deleted file mode 100644 index fe2eb83..0000000 --- a/src/mcp/mcp_servers.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "math": { - "command": "python", - "args": [ - "/home/kexsh/src/knightutils/test/mcp/math_server.py" - ], - "transport": "stdio" - } -} \ No newline at end of file diff --git a/src/mcp/mcp_tools.py b/src/mcp/mcp_tools.py index df0c07a..9fe710b 100644 --- a/src/mcp/mcp_tools.py +++ b/src/mcp/mcp_tools.py @@ -2,7 +2,7 @@ from langchain_mcp_adapters.client import MultiServerMCPClient import json def get_client() -> MultiServerMCPClient: - mcp_tools = json.load(open("mcp_servers.json")) + mcp_tools = json.load(open("src/mcp/config/mcp_servers.json")) client = MultiServerMCPClient(mcp_tools) diff --git a/src/mcp/server/math_server.py b/src/mcp/server/math_server.py new file mode 100644 index 0000000..7ae36be --- /dev/null +++ b/src/mcp/server/math_server.py @@ -0,0 +1,16 @@ +from mcp.server.fastmcp import FastMCP + +mcp = FastMCP("Math") + +@mcp.tool() +def add(a: int, b: int) -> int: + """Add two numbers""" + return a + b + +@mcp.tool() +def multiply(a: int, b: int) -> int: + """Multiply two numbers""" + return a * b + +if __name__ == "__main__": + mcp.run(transport="stdio") \ No newline at end of file