Skip to main content
Connection management for MCP implementations. This module provides an abstract base class for different types of connection managers used in MCP connectors.

ConnectionManager

method init

Initialize a new connection manager.Signature

method get_streams

Get the current connection streams.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.
Signature

method start

Start the connection manager and establish a connection.Returns
mcp_use.client.task_managers.base.T
The established connection.
Signature

method 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
float | None
default:"30.0"
Maximum time to wait for cleanup in seconds (default: 30.0).
Signature