Client Transports
Understand the different ways FastMCP Clients can connect to servers.
New in version: 2.0.0
The FastMCP Client
relies on a ClientTransport
object to handle the specifics of connecting to and communicating with an MCP server. FastMCP provides several built-in transport implementations for common connection methods.
While the Client
often infers the correct transport automatically (see Client Overview), you can also instantiate transports explicitly for more control.
Network Transports
These transports connect to servers running over a network, typically long-running services accessible via URLs.
Streamable HTTP
New in version: 2.3.0
- Class:
fastmcp.client.transports.StreamableHttpTransport
- Inferred From:
http://
orhttps://
URLs (default for HTTP URLs as of v2.3.0) - Use Case: Connecting to persistent MCP servers exposed over HTTP/S using FastMCP’s
mcp.run(transport="streamable-http")
mode.
Streamable HTTP is the recommended transport for web-based deployments, providing efficient bidirectional communication over HTTP.
SSE (Server-Sent Events)
- Class:
fastmcp.client.transports.SSETransport
- Inferred From: Not automatically inferred for most HTTP URLs (as of v2.3.0)
- Use Case: Connecting to MCP servers using Server-Sent Events, often using FastMCP’s
mcp.run(transport="sse")
mode.
While SSE is still supported, Streamable HTTP is the recommended transport for new web-based deployments.
Stdio Transports
These transports manage an MCP server running as a subprocess, communicating with it via standard input (stdin) and standard output (stdout). This is the standard mechanism used by clients like Claude Desktop.
Python Stdio
- Class:
fastmcp.client.transports.PythonStdioTransport
- Inferred From: Paths to
.py
files. - Use Case: Running a Python-based MCP server script (like one using FastMCP or the base
mcp
library) in a subprocess.
This is the most common way to interact with local FastMCP servers during development or when integrating with tools that expect to launch a server script.
The server script (my_mcp_server.py
in the example) must include logic to start the MCP server and listen on stdio, typically via mcp.run()
or fastmcp.server.run()
. The Client
only launches the script; it doesn’t inject the server logic.
Node.js Stdio
- Class:
fastmcp.client.transports.NodeStdioTransport
- Inferred From: Paths to
.js
files. - Use Case: Running a Node.js-based MCP server script in a subprocess.
Similar to the Python transport, but for JavaScript servers.
UVX Stdio (Experimental)
- Class:
fastmcp.client.transports.UvxStdioTransport
- Inferred From: Not automatically inferred. Must be instantiated explicitly.
- Use Case: Running an MCP server packaged as a Python tool using
uvx
(part of theuv
toolchain). This allows running tools without explicitly installing them into the current environment.
This is useful for executing MCP servers distributed as command-line tools or packages.
NPX Stdio (Experimental)
- Class:
fastmcp.client.transports.NpxStdioTransport
- Inferred From: Not automatically inferred. Must be instantiated explicitly.
- Use Case: Running an MCP server packaged as an NPM package using
npx
.
Similar to UvxStdioTransport
, but for the Node.js ecosystem.
In-Memory Transports
FastMCP Transport
- Class:
fastmcp.client.transports.FastMCPTransport
- Inferred From: An instance of
fastmcp.server.FastMCP
. - Use Case: Connecting directly to a
FastMCP
server instance running in the same Python process.
This is extremely useful for:
- Testing: Writing unit or integration tests for your FastMCP server without needing subprocesses or network connections.
- Embedding: Using an MCP server as a component within a larger application.
Communication happens through efficient in-memory queues, making it very fast.
Choosing a Transport
- Local Development/Testing: Use
PythonStdioTransport
(inferred from.py
files) orFastMCPTransport
(for same-process testing). - Connecting to Remote/Persistent Servers: Use
StreamableHttpTransport
(recommended, default for HTTP URLs) orSSETransport
(legacy option). - Running Packaged Tools: Use
UvxStdioTransport
(Python/uv) orNpxStdioTransport
(Node/npm) if you need to run MCP servers without local installation. - Integrating with Claude Desktop (or similar): These tools typically expect to run a Python script, so your server should be runnable via
python your_server.py
, makingPythonStdioTransport
the relevant mechanism on the client side.