运行OK
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"math": {
|
||||
"command": "python",
|
||||
"args": [
|
||||
"/home/kexsh/src/knightutils/test/mcp/math_server.py"
|
||||
],
|
||||
"transport": "stdio"
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
|
||||
16
src/mcp/server/math_server.py
Normal file
16
src/mcp/server/math_server.py
Normal file
@@ -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")
|
||||
Reference in New Issue
Block a user