View the source code for this module on GitHub: https://github.com/mcp-use/mcp-use/blob/main/libraries/python/mcp_use/client/session.py
MCPSession
from mcp_use.client.session import MCPSession
method init
Initialize a new MCP session.ParametersSignatureThe connector to use for communicating with the MCP implementation.Whether to automatically connect to the MCP implementation.
def __init__(connector: mcp_use.client.connectors.base.BaseConnector, auto_connect: bool = True):
method call_tool
Call an MCP tool.ParametersReturnsThe name of the tool to call.The arguments to pass to the tool.Optional timeout for the tool call.
SignatureThe result of the tool call.
def call_tool(
name: str,
arguments: dict[str,
Any],
read_timeout_seconds: datetime.timedelta | None = None
):
method get_prompt
Get a prompt by name.ParametersReturnsThe name of the prompt to get.Optional arguments for the prompt.
SignatureThe prompt result with messages.
def get_prompt(name: str, arguments: dict[str, typing.Any] | None = None):