Configure how FastMCP Clients connect to and communicate with servers.
New in version: 2.0.0
The FastMCP Client
communicates with MCP servers through transport objects that handle the underlying connection mechanics. While the client can automatically select a transport based on what you pass to it, instantiating transports explicitly gives you full control over configuration—environment variables, authentication, session management, and more.
Think of transports as configurable adapters between your client code and MCP servers. Each transport type handles a different communication pattern: subprocesses with pipes, HTTP connections, or direct in-memory calls.
env
parameter:
keep_alive=True
). This improves performance by reusing the same subprocess for multiple connections, but can be controlled when you need isolation.
By default, the subprocess persists between connections:
keep_alive=False
when you need complete isolation (e.g., in test suites) or when server state could cause issues between connections.
StdioTransport
with pre-configured commands:
PythonStdioTransport
- Uses python
command for .py
filesNodeStdioTransport
- Uses node
command for .js
filesUvStdioTransport
- Uses uv
for Python packages (uses env_vars
parameter)UvxStdioTransport
- Uses uvx
for Python packages (uses env_vars
parameter)NpxStdioTransport
- Uses npx
for Node packages (uses env_vars
parameter)StdioTransport
directly with your desired command. These specialized transports are primarily useful for client inference shortcuts.
New in version: 2.3.0
Streamable HTTP is the recommended transport for production deployments, providing efficient bidirectional streaming over HTTP connections.
StreamableHttpTransport
mcp run --transport http
SSETransport
mcp run --transport sse
FastMCPTransport
New in version: 2.4.0
This transport supports the emerging MCP JSON configuration standard for defining multiple servers:
MCPConfigTransport
weather_get_forecast
tool to only retrieve the weather for Miami
and hiding the city
argument from the client.
tags
to the tools on the server. In the following example, we’re allowlisting only tools marked with the forecast
tag, all other tools will be unavailable to the client.