create_toolkit(session, *, use_mcp_tools=True, use_mcp_resources=True, resource_download_folder=None)
Create a toolkit from the MCP client session.
PARAMETER | DESCRIPTION |
session | TYPE: ClientSession |
use_mcp_tools | Whether to include MCP tools in the toolkit. TYPE: bool DEFAULT: True |
use_mcp_resources | Whether to include MCP resources in the toolkit. TYPE: bool DEFAULT: True |
resource_download_folder | The folder to download files to. TYPE: Optional[Union[Path, str]] DEFAULT: None |
Returns: Toolkit: The toolkit containing the converted tools.
Source code in autogen/mcp/mcp_client.py
| @export_module("autogen.mcp")
async def create_toolkit(
session: "ClientSession",
*,
use_mcp_tools: bool = True,
use_mcp_resources: bool = True,
resource_download_folder: Optional[Union[Path, str]] = None,
) -> Toolkit: # type: ignore[no-any-unimported]
"""Create a toolkit from the MCP client session.
Args:
session (ClientSession): The MCP client session.
use_mcp_tools (bool): Whether to include MCP tools in the toolkit.
use_mcp_resources (bool): Whether to include MCP resources in the toolkit.
resource_download_folder (Optional[Union[Path, str]]): The folder to download files to.
Returns:
Toolkit: The toolkit containing the converted tools.
"""
if resource_download_folder:
if isinstance(resource_download_folder, str):
resource_download_folder = Path(resource_download_folder)
await anyio.to_thread.run_sync(lambda: resource_download_folder.mkdir(parents=True, exist_ok=True))
return await MCPClient.load_mcp_toolkit(
session=session,
use_mcp_tools=use_mcp_tools,
use_mcp_resources=use_mcp_resources,
resource_download_folder=resource_download_folder,
)
|