mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 10:12:51 +00:00
fix: MCP node execution failed (#3528)
This commit is contained in:
parent
b9aa36ed1e
commit
693ed6004a
|
|
@ -4,6 +4,7 @@ import json
|
|||
from typing import List
|
||||
|
||||
from langchain_mcp_adapters.client import MultiServerMCPClient
|
||||
from langchain_mcp_adapters.sessions import create_session
|
||||
|
||||
from application.flow.i_step_node import NodeResult
|
||||
from application.flow.step_node.mcp_node.i_mcp_node import IMcpNode
|
||||
|
|
@ -22,12 +23,12 @@ class BaseMcpNode(IMcpNode):
|
|||
params = json.loads(json.dumps(tool_params))
|
||||
params = self.handle_variables(params)
|
||||
|
||||
async def call_tool(s, session, t, a):
|
||||
async with MultiServerMCPClient(s) as client:
|
||||
s = await client.sessions[session].call_tool(t, a)
|
||||
return s
|
||||
async def call_tool(t, a):
|
||||
client = MultiServerMCPClient(servers)
|
||||
async with create_session(client.connections[mcp_server]) as s:
|
||||
return await s.call_tool(t, a)
|
||||
|
||||
res = asyncio.run(call_tool(servers, mcp_server, mcp_tool, params))
|
||||
res = asyncio.run(call_tool(mcp_tool, params))
|
||||
return NodeResult(
|
||||
{'result': [content.text for content in res.content], 'tool_params': params, 'mcp_tool': mcp_tool}, {})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue