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

Transport & HTTP

These control how the server listens when running with an HTTP transport.

Error Handling

Client

CLI & Display

Telemetry

Tasks (Docket)

Task settings (the FASTMCP_DOCKET_ variables) moved to the optional fastmcp-tasks package. See server tasks for configuration.

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 and the IP blocklist entirely and makes a single request to the hostname URL, explicitly routed 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 is a deliberate trust shift: the IP blocklist cannot be enforced through a proxy (the proxy does its own DNS, so an address FastMCP resolved is not the one the proxy dials). Only enable it when the proxy itself is trusted to mediate egress.FastMCP reads the proxy URL from the environment and passes it to the HTTP client explicitly, with the client’s own environment-based proxy routing turned off — so the request either goes through that exact proxy or fails outright, with no routing decision left for the client to make on its own. One consequence: NO_PROXY is not honored in this mode. A host that NO_PROXY would otherwise exclude is still routed through the configured proxy rather than fetched direct with the IP blocklist disabled — the safer of the two options, since the blocklist cannot apply to a direct fetch here anyway. If you set FASTMCP_SSRF_TRUST_PROXY=true but neither HTTPS_PROXY nor ALL_PROXY is present in the server process’s environment (an HTTP_PROXY alone never routes these HTTPS-only fetches), the request would otherwise go out direct with the IP blocklist disabled — no SSRF protection at all. Rather than send it, FastMCP refuses the fetch and raises SSRFError with an actionable message. The contract is crisp: proxy-trust mode delegates SSRF protection to the proxy, and with no proxy configured the fetch cannot proceed. Enable this setting only together with an active proxy that routes your auth endpoints.

Advanced