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.
View the source code for this module on GitHub: https://github.com/mcp-use/mcp-use/blob/main/libraries/python/mcp_use/client/connectors/base.py
BaseConnector
from mcp_use.client.connectors.base import BaseConnector
method init
Initialize base connector with common attributes.ParametersSignatureOptional callback to handle sampling requests from servers.Optional callback to handle elicitation requests from servers.Optional callback to handle messages from servers.Optional callback to handle log messages from servers.Optional list of middleware to apply to requests.Optional initial list of roots to advertise to the server.Optional custom callback to handle roots/list requests.
def __init__(sampling_callback: mcp.client.session.SamplingFnT | None = None, elicitation_callback: mcp.client.session.ElicitationFnT | None = None, message_handler: mcp.client.session.MessageHandlerFnT | None = None, logging_callback: mcp.client.session.LoggingFnT | None = None, middleware: list[mcp_use.client.middleware.middleware.Middleware] | None = None, roots: list[mcp.types.Root] | None = None, list_roots_callback: mcp.client.session.ListRootsFnT | None = None):
method call_tool
Call an MCP tool with automatic reconnection handling.ParametersReturnsThe name of the tool to call.The arguments to pass to the tool.timeout seconds when calling tool
SignatureThe result of the tool call.
def call_tool(
name: str,
arguments: dict[str,
Any],
read_timeout_seconds: datetime.timedelta | None = None
):
property prompts
Get the list of available prompts... deprecated::
This property is deprecated because it may return stale data when the server
sends list change notifications. Use `await list_prompts()’ instead to ensure
you always get the latest data.ReturnsSignature
def prompts():
property resources
Get the list of available resources... deprecated::
This property is deprecated because it may return stale data when the server
sends list change notifications. Use await list_resources() instead to ensure
you always get the latest data.ReturnsSignature
def resources():
method set_roots
Set the roots and notify the server if connected.Roots represent directories or files that the client has access to.Example:await connector.set_roots([
Root(uri="file:///home/user/project", name="My Project"),
Root(uri="file:///home/user/data"),
])
SignatureArray of Root objects withuri(must start with “file://”) and optionalname.
def set_roots(roots: list[mcp.types.Root]):
property tools
Get the list of available tools... deprecated::
This property is deprecated because it may return stale data when the server
sends list change notifications. Use await list_tools() instead to ensure
you always get the latest data.ReturnsSignature
def tools():