Skip to main content
New in version 2.0.0 Transports handle the underlying connection between your client and MCP servers. While the client can automatically select a transport based on what you pass to it, instantiating transports explicitly gives you full control over configuration.

STDIO Transport

STDIO transport communicates with MCP servers through subprocess pipes. When using STDIO, your client launches and manages the server process, controlling its lifecycle and environment.
STDIO servers inherit only a small allowlist of environment variables — just enough to locate an interpreter and a home directory. Anything else in your shell, including API keys and other credentials, does not reach the server unless you pass it through env explicitly.The allowlist is platform-specific. On POSIX systems it is HOME, LOGNAME, PATH, SHELL, TERM, and USER; on Windows it is APPDATA, HOMEDRIVE, HOMEPATH, LOCALAPPDATA, PATH, PATHEXT, PROCESSOR_ARCHITECTURE, SYSTEMDRIVE, SYSTEMROOT, TEMP, USERNAME, and USERPROFILE.
For convenience, the client can infer STDIO transport from file paths, though this limits configuration options. Pass a Path: inferring a subprocess from a bare string like Client("my_server.py") is deprecated as of 4.0 — it warns, and in FastMCP 5 a string will only ever mean a URL:
Transport inference treats its input as trusted configuration. A string naming an existing .py or .js file starts that file as a subprocess, and a configuration dictionary can run any command with any arguments. An application that accepts server locations from users should validate them at its own boundary and construct the transport explicitly, for example StreamableHttpTransport(url=...) for a URL, rather than passing the raw value to Client.

Environment Variables

Values you pass through env are merged on top of the inherited allowlist, so you add configuration rather than replacing the base environment. Anything your server needs beyond the allowlist has to be listed explicitly. Selective forwarding passes only the variables your server needs:
Loading from .env files keeps configuration separate from code:

Session Persistence

STDIO transports maintain sessions across multiple client contexts by default (keep_alive=True). This reuses the same subprocess for multiple connections, improving performance.
A kept-alive session is reused when the transport options and request timeout match. Connecting with a different Client(timeout=...) restarts an idle subprocess. If another client is still connected, the new client shares its session and that session’s timeout, and FastMCP logs a warning; use separate transports when concurrent clients need different defaults. Per-call timeout overrides do not restart the session. For complete isolation between connections, disable session persistence:
A persisted session belongs to the event loop that created it, so reuse from a different loop transparently starts a fresh subprocess instead. Sharing one transport between loops still works, but only reuses the subprocess within a single loop — and it raises if two loops try to hold overlapping sessions on the same transport, which needs one transport per loop. The old subprocess is shut down on the loop that started it, so that loop must still be running or already closed: if it is stopped but still open (as after loop.run_until_complete(...)), reuse from another loop raises until you close the client on the original loop.

HTTP Transport

New in version 2.3.0 HTTP transport connects to MCP servers running as web services. This is the recommended transport for production deployments. Incoming SSE events are limited to 1 MiB by default. If a server returns larger tool results or resources, set max_sse_event_size on StreamableHttpTransport to a byte limit that accommodates them, or use None to disable the limit:
The same field is available as max_sse_event_size on an MCP config’s remote server entry, which forwards it when building the transport. A client created from a bare URL (Client("https://api.example.com/mcp")) keeps the 1 MiB default; pass an explicit StreamableHttpTransport as above to raise or disable it.
FastMCP also provides authentication helpers:

SSL Verification

By default, HTTPS connections verify the server’s SSL certificate using the operating system’s trust store through HTTPX2. You can customize this behavior with the verify parameter; see HTTPX2’s SSL guide. Keep the trust store used by your deployment current. Updating certifi does not update the operating system’s CA store or a custom bundle selected by SSL_CERT_FILE, SSL_CERT_DIR, or verify. Custom client factories configure their own TLS verification. Rebuild containers and restart processes after updating trust stores. This also matters for servers making outbound HTTPS requests to OAuth providers, JWKS endpoints, and upstream APIs. For the October 2026 eMudhra CA incident, follow the FastMCP security notice. A FastMCP package upgrade alone does not remediate every trust store. The verify parameter on Client accepts a boolean, a CA bundle path, or an ssl.SSLContext:
The verify parameter is also available directly on StreamableHttpTransport and SSETransport:

Custom HTTP Client

For anything beyond SSL settings — proxies, mTLS, event hooks — pass an httpx_client_factory. The factory receives headers, auth, and follow_redirects, plus timeout when the client has one configured (for example Client(transport, timeout=60)). Accept **kwargs so the factory stays forward-compatible. When no client timeout is configured, the factory owns the timeout: none is passed, and an httpx2.AsyncClient built without one uses httpx’s 5 second default, which is too short for many MCP tool calls. Set a default with setdefault, so an explicit client timeout still wins:
These 30s connect / 300s read values match the defaults FastMCP applies when no factory is used.

SSE Transport

Server-Sent Events transport is maintained for backward compatibility. Use Streamable HTTP for new deployments unless you have specific infrastructure requirements.

In-Memory Transport

In-memory transport connects directly to a FastMCP server instance within the same Python process. This eliminates both subprocess management and network overhead, making it ideal for testing.
Unlike STDIO transports, in-memory servers share the same memory space and environment variables as your client code.

Multi-Server Configuration

New in version 2.4.0 Connect to multiple servers defined in a configuration dictionary:

Per-server Timeouts

Set timeout on a server entry to limit how long its requests can wait. Entry timeouts use milliseconds, apply to HTTP, SSE, and STDIO servers, and take precedence over the timeout passed to Client. An omitted or null entry timeout uses the client timeout; 0 disables the timeout for that backend session. For example, give the weather server 5 seconds and use a 30-second client timeout for entries without their own limit:
With multiple servers, the client timeout also limits the entire routed request, so a backend timeout cannot extend that outer limit. Composite clients and configurations with tool transformations or tag filters use backend proxy sessions: a per-call timeout cannot extend those sessions’ configured limits. sse_read_timeout remains a separate setting for the SSE connection.

Tool Transformations

FastMCP supports tool transformations within the configuration. You can change names, descriptions, tags, and arguments for tools from a server. Key each transformation by the tool’s name on that server, before any server-name prefix is added.
To filter tools by tag, use include_tags or exclude_tags at the server level:
Omit include_tags to leave inclusion unrestricted. An empty include_tags list includes no tools, while an empty exclude_tags list excludes none. These filters apply to each server in both single-server and multi-server configurations.