Skip to content

Commit 94fb24e

Browse files
committed
Reference toolkit from tools
1 parent f6be96f commit 94fb24e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/langchain_mcp/toolkit.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ async def get_tools(self) -> list[BaseTool]: # type: ignore[override]
3232

3333
return [
3434
MCPTool(
35-
session=self.session,
35+
toolkit=self,
3636
name=tool.name,
3737
description=tool.description or "",
3838
args_schema=create_schema_model(tool.inputSchema),
@@ -67,7 +67,7 @@ class MCPTool(BaseTool):
6767
MCP server tool
6868
"""
6969

70-
session: ClientSession
70+
toolkit: MCPToolkit
7171
handle_tool_error: bool | str | Callable[[ToolException], str] | None = True
7272

7373
@t.override
@@ -79,7 +79,7 @@ def _run(self, *args: t.Any, **kwargs: t.Any) -> t.Any:
7979

8080
@t.override
8181
async def _arun(self, *args: t.Any, **kwargs: t.Any) -> t.Any:
82-
result = await self.session.call_tool(self.name, arguments=kwargs)
82+
result = await self.toolkit.session.call_tool(self.name, arguments=kwargs)
8383
content = pydantic_core.to_json(result.content).decode()
8484
if result.isError:
8585
raise ToolException(content)

0 commit comments

Comments
 (0)