Skip to content

fix: tolerate extra kwargs in _make_httpx_client_factory#5748

Closed
Oxygen56 wants to merge 1 commit into
pydantic:mainfrom
Oxygen56:fix/issue-5688
Closed

fix: tolerate extra kwargs in _make_httpx_client_factory#5748
Oxygen56 wants to merge 1 commit into
pydantic:mainfrom
Oxygen56:fix/issue-5688

Conversation

@Oxygen56
Copy link
Copy Markdown

@Oxygen56 Oxygen56 commented Jun 1, 2026

Summary

  • Adds **_kwargs: Any to the closure returned by _make_httpx_client_factory so it tolerates extra keyword arguments (e.g. follow_redirects) that FastMCP transports may pass.
  • This is a one-line, backwards-compatible fix.

Root Cause

When http_client= is passed to MCPToolset, the _make_httpx_client_factory function returns a closure with the signature factory(headers=None, timeout=None, auth=None) — no **kwargs. FastMCP's StreamableHttpTransport and SSETransport call this factory with follow_redirects=True, which raises a TypeError.

Fixes #5688

Test Plan

  • Added test_http_client_factory_tolerates_extra_kwargs — verifies the factory accepts follow_redirects=True and still returns the user-supplied client.
  • All 23 existing TestMCPToolsetConstruction tests pass.

FastMCP transports pass extra keyword arguments (e.g. follow_redirects)
to the httpx_client_factory callback. The factory returned by
_make_httpx_client_factory did not accept **kwargs, causing a TypeError
when MCPToolset was constructed with an explicit http_client=.

Fixes pydantic#5688

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions github-actions Bot added the size: S Small PR (≤100 weighted lines) label Jun 1, 2026
@github-actions github-actions Bot closed this Jun 1, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

Thanks for your interest in this issue! However, there are already open PRs addressing issue #5688: #5694.

To avoid duplicate efforts, this PR has been closed. If you'd like to contribute, you can review the existing PRs or share your thoughts on issue #5688.

If you believe the existing PRs are inactive, please comment on the issue and a maintainer can reassess.

@github-actions github-actions Bot added the bug Report that something isn't working, or PR implementing a fix label Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Report that something isn't working, or PR implementing a fix size: S Small PR (≤100 weighted lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCPToolset(url, http_client=...) crashes: factory missing follow_redirects kwarg passed by FastMCP

1 participant