Skip to content

Commit e2ff79c

Browse files
committed
cache client/tools for mcp
1 parent b103913 commit e2ff79c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

template_langgraph/tools/mcp_tool.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def __init__(
3131
if settings is None:
3232
settings = get_mcp_settings()
3333
self.settings = settings
34+
self.client = None
3435

3536
def get_tools(self) -> list[BaseTool]:
3637
if self.settings.mcp_config_path == "":
@@ -39,6 +40,6 @@ def get_tools(self) -> list[BaseTool]:
3940
config = json.load(f)
4041
for _, value in config["servers"].items():
4142
value["transport"] = "stdio"
42-
client = MultiServerMCPClient(config["servers"])
43-
tools = asyncio.run(client.get_tools())
44-
return tools
43+
self.client = MultiServerMCPClient(config["servers"])
44+
self.tools = asyncio.run(self.client.get_tools())
45+
return self.tools

0 commit comments

Comments
 (0)