Skip to content

Conversation

@tradeqvest
Copy link
Contributor

@tradeqvest tradeqvest commented Jul 25, 2025

This PR resolves a TypeError that occurs when using MCPServerSSE and other HTTP-based MCP servers. The issue stemmed from the _MCPServerHTTP class constructor, which was not calling the __post_init__ method from the MCPServer base class. This led to _enter_lock not being correctly initialized as an asyncio.Lock.

The fix ensures __post_init__ is called within the _MCPServerHTTP constructor, correcting the initialization sequence.

Fixes #2318

@tradeqvest tradeqvest changed the title fix: initialize MCP server post-construction by invoking __post_init__ method (#2318) Fix: TypeError in MCPServerSSE due to improper initialization Jul 25, 2025
@itayB
Copy link
Contributor

itayB commented Jul 27, 2025

We're experiencing the same issue, and this PR resolves the error

@DouweM DouweM self-assigned this Jul 28, 2025
@DouweM DouweM merged commit 806d56d into pydantic:main Jul 28, 2025
18 checks passed
@DouweM
Copy link
Collaborator

DouweM commented Jul 28, 2025

@tradeqvest Thank you Niko! I'll get a release out in a few hours.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeError with MCPServerSSE in pydantic-ai 0.4.7

3 participants