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.
Connection management for MCP implementations.
This module provides an abstract base class for different types of connection
managers used in MCP connectors.
ConnectionManager
from mcp_use.client.task_managers.base import ConnectionManager
method init
Initialize a new connection manager.Signaturemethod get_streams
Get the current connection streams.Returns
returns
mcp_use.client.task_managers.base.T | None
The current connection (typically a tuple of read_stream, write_stream) or None if not connected.
Signaturemethod start
Start the connection manager and establish a connection.Returns
returns
mcp_use.client.task_managers.base.T
The established connection.
Signaturemethod stop
Stop the connection manager and close the connection.This method ensures graceful shutdown by waiting for the connection task
to complete and cleanup to finish. If operations exceed the timeout,
forced cleanup is performed to prevent resource leaks.Note:
This method does not raise exceptions and guarantees graceful shutdown
even if cleanup times out.Parameters
timeout
float | None
default:"30.0"
Maximum time to wait for cleanup in seconds (default: 30.0).
Signaturedef stop(timeout: float | None = 30.0):