PrefectHQ/fastmcp · warning · UserWarning

Both 'httpx_client_factory' and 'verify' were provided. The

Error message

Both 'httpx_client_factory' and 'verify' were provided. The 'verify' parameter will be ignored because 'httpx_client_factory' takes precedence. Configure SSL verification directly in your httpx_client_factory instead.

What it means

`HttpTransport` accepts both an `httpx_client_factory` and a `verify` SSL setting. When both are supplied the factory fully determines the client, so `verify` would be silently dead — FastMCP raises a `UserWarning` and ignores `verify`.

Source

Thrown at fastmcp_slim/fastmcp/client/transports/http.py:74

                enabled). Ignored when httpx_client_factory is provided.
        """
        if isinstance(url, AnyUrl):
            url = str(url)
        if not isinstance(url, str) or not url.startswith("http"):
            raise ValueError("Invalid HTTP/S URL provided for Streamable HTTP.")

        # Don't modify the URL path - respect the exact URL provided by the user
        # Some servers are strict about trailing slashes (e.g., PayPal MCP)

        self.url: str = url
        self.headers = headers or {}
        self.httpx_client_factory = httpx_client_factory
        self.verify: ssl.SSLContext | bool | str | None = verify

        if httpx_client_factory is not None and verify is not None:
            import warnings

            warnings.warn(
                "Both 'httpx_client_factory' and 'verify' were provided. "
                "The 'verify' parameter will be ignored because "
                "'httpx_client_factory' takes precedence. Configure SSL "
                "verification directly in your httpx_client_factory instead.",
                UserWarning,
                stacklevel=2,
            )

        self._set_auth(auth)

        # SDK v2's streamable_http_client no longer exposes a get_session_id
        # callback. We recover the session id ourselves by capturing the
        # `mcp-session-id` response header via an httpx event hook on the
        # client we own (see connect_session / _capture_session_id).
        self._session_id: str | None = None

    async def _capture_session_id(self, response: httpx2.Response) -> None:
        """httpx response event hook: record the server's `mcp-session-id`.

View on GitHub (pinned to 1f02114297)

Solutions

  1. Remove `verify=` and configure SSL inside the factory: `lambda **kw: httpx.AsyncClient(verify=False, **kw)`.
  2. Or drop the custom `httpx_client_factory` if you only need to control `verify`.
  3. Suppress deliberately only if the factory already handles the same verification value.
  4. Extract shared factory/verify config into one place to prevent the conflict recurring.

Example fix

// before
transport = HttpTransport(url, verify=False, httpx_client_factory=lambda **kw: httpx.AsyncClient(**kw))
// after
def factory(**kw):
    return httpx.AsyncClient(verify=False, **kw)
transport = HttpTransport(url, httpx_client_factory=factory)
Defensive patterns

Strategy: validation

Validate before calling

assert not (httpx_client_factory is not None and verify is not None), "Configure SSL in the httpx_client_factory instead of passing verify"

Try / catch

import warnings
with warnings.catch_warnings(record=True) as caught:
    warnings.simplefilter("always")
    t = HttpTransport(url, verify=verify, httpx_client_factory=factory)
if any("'verify' parameter will be ignored" in str(w.message) for w in caught):
    logging.warning("verify ignored; ensure factory applies SSL settings")

Prevention

When it happens

Trigger: `HttpTransport(url, verify=False, httpx_client_factory=my_factory)` — any non-None combination of the two.

Common situations: Hardening TLS config while also having a custom client factory from older code; copy-pasting transport configs where a default factory was later added.

Understand the failure class

Related errors


AI-assisted analysis of PrefectHQ/fastmcp@1f02114297 (2026-08-29). Data as JSON: /api/errors/0f6776f0e8ef1cf1. Report an issue: GitHub.