Skip to main content
FastMCP uses pydantic-settings for configuration. Every setting is available as an environment variable with a FASTMCP_ prefix. Settings are loaded from environment variables and from a .env file.
You can change which .env file is loaded by setting the FASTMCP_ENV_FILE environment variable (defaults to .env). Because this controls which file is loaded, it must be set as an environment variable — it cannot be set inside a .env file itself.

Logging

To turn on debug logging from your own entry point, for example behind a --debug flag, pass log_level to run() instead of reconfiguring logging yourself. It applies to every transport for as long as the server runs:

Transport & HTTP

These control how the server listens when running with an HTTP transport. MCP SDK 2.2 also limits concurrent stateful HTTP sessions to 10,000. Keeping the default idle timeout lets abandoned sessions expire and frees capacity for new connections. Disabling it means clients must explicitly close their sessions to release that capacity. Stateless HTTP does not use the session pool.

Error Handling

Client

CLI & Display

Telemetry

Tasks (Docket)

Task settings (the FASTMCP_DOCKET_ and FASTMCP_TASKS_ variables) live in the optional fastmcp-tasks package. See server tasks for configuration, including FASTMCP_TASKS_ENCRYPTION_KEY for encrypting task snapshots at rest.

Security

These control FastMCP’s SSRF protection for the outbound fetches it makes during authentication (OAuth client metadata and JWKS). By default, FastMCP protects its OAuth and JWKS fetches against SSRF by resolving the target hostname, rejecting any address that maps to a private, loopback, link-local, or reserved IP, and then pinning the connection to that validated IP. This breaks when a corporate CONNECT proxy is the only egress path: the container often cannot resolve external DNS at all (only the proxy can), and even when it can, pinning to the IP makes TLS verification fail because public certificates list hostnames, not IP addresses. Set FASTMCP_SSRF_TRUST_PROXY=true when a trusted proxy is your mandated egress. FastMCP then skips DNS resolution, the IP blocklist, and connection pinning, and makes a single request to the hostname URL through the proxy named by the standard HTTPS_PROXY / ALL_PROXY environment variables (checked in that order). The HTTPS-only and hostname checks still apply.
This setting shifts SSRF protection to the proxy. The IP blocklist cannot be enforced through a proxy, because the proxy does its own DNS, and FastMCP verifies that a proxy is configured but not what its policy allows. Enable it only when the proxy enforces equivalent destination restrictions.FastMCP passes the proxy URL to the HTTP client explicitly, so the request goes through that proxy or fails. NO_PROXY is not honored in this mode: a host it would exclude still goes through the proxy instead of direct with no blocklist. If neither HTTPS_PROXY nor ALL_PROXY is set in the server process’s environment (HTTP_PROXY alone never routes these HTTPS-only fetches), FastMCP refuses the fetch and raises SSRFError.

Advanced