Skip to main content

fastmcp.client.transports.base

Classes

SessionKwargs

Keyword arguments for the MCP ClientSession constructor.

ClientTransport

Abstract base class for different MCP client transport mechanisms. A Transport is responsible for establishing and managing connections to an MCP server, and providing a ClientSession within an async context. Methods:

connect_session

Establishes a connection and yields an active ClientSession. The ClientSession is not expected to be initialized in this context manager. The session is guaranteed to be valid only within the scope of the async context manager. Connection setup and teardown are handled within this context. Args:
  • **session_kwargs: Keyword arguments to pass to the ClientSession constructor (e.g., callbacks, timeouts).

close

Close the transport.

get_session_id

Get the session ID for this transport, if available.