Documentation Index
Fetch the complete documentation index at: https://docs.mcp-use.com/llms.txt
Use this file to discover all available pages before exploring further.
Session manager for MCP connections.
This module provides a session manager for MCP connections,
which handles authentication, initialization, and tool discovery.
MCPSession
from mcp_use.client.session import MCPSession
method init
Initialize a new MCP session.Parameters
connector
mcp_use.client.connectors.base.BaseConnector
required
The connector to use for communicating with the MCP implementation.
Whether to automatically connect to the MCP implementation.
Signaturedef __init__(connector: mcp_use.client.connectors.base.BaseConnector, auto_connect: bool = True):
Call an MCP tool.Parameters
The name of the tool to call.
The arguments to pass to the tool.
read_timeout_seconds
datetime.timedelta | None
default:"None"
Optional timeout for the tool call.
Returns
The result of the tool call.
Signaturedef call_tool(
name: str,
arguments: dict[str,
Any],
read_timeout_seconds: datetime.timedelta | None = None
):
method connect
Connect to the MCP implementation.Signaturemethod disconnect
Disconnect from the MCP implementation.Signaturemethod get_prompt
Get a prompt by name.Parameters
The name of the prompt to get.
arguments
dict[str, typing.Any] | None
default:"None"
Optional arguments for the prompt.
Returns
returns
mcp.types.GetPromptResult
The prompt result with messages.
Signaturedef get_prompt(name: str, arguments: dict[str, typing.Any] | None = None):
method initialize
Initialize the MCP session and discover available tools.Returns
The session information returned by the MCP implementation.
Signatureproperty is_connected
Check if the connector is connected.Returns
Signaturemethod list_prompts
List all available prompts from the MCP server.Returns
List of available prompts.
Signaturemethod list_resources
List all available resources from the MCP server.Returns
List of available resources.
SignatureList all available tools from the MCP server.Returns
Signature method read_resource
Read a resource by URI.Parameters
uri
pydantic.networks.AnyUrl
required
The URI of the resource to read.
Returns
returns
mcp.types.ReadResourceResult
The resource content.
Signaturedef read_resource(uri: pydantic.networks.AnyUrl):