Skip to main content

fastmcp.client.transports.config

Classes

MCPConfigTransport

Transport for connecting to one or more MCP servers defined in an MCPConfig. This transport provides a unified interface to multiple MCP servers defined in an MCPConfig object or dictionary matching the MCPConfig schema. It supports two key scenarios:
  1. If the MCPConfig contains exactly one server, it creates a direct transport to that server.
  2. If the MCPConfig contains multiple servers, it creates a composite client by mounting all servers on a single FastMCP instance, with each server’s name, by default, used as its mounting prefix.
In the multiserver case, tools are accessible with the prefix pattern {server_name}_{tool_name} and resources with the pattern protocol://{server_name}/path/to/resource. This is particularly useful for creating clients that need to interact with multiple specialized MCP servers through a single interface, simplifying client code. Examples:
Methods:

connect_session

close