You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PydanticAI comes with two ways to connect to MCP servers:
20
20
21
-
-[`MCPServerHTTP`][pydantic_ai.mcp.MCPServerHTTP] which connects to an MCP server using the [HTTP SSE](https://spec.modelcontextprotocol.io/specification/2024-11-05/basic/transports/#http-with-sse) transport
21
+
-[`MCPServerHTTP`][pydantic_ai.mcp.MCPServerHTTP] which connects to an MCP server using the [Streamable HTTP transport](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http) transport
22
22
-[`MCPServerStdio`][pydantic_ai.mcp.MCPServerStdio] which runs the server as a subprocess and connects to it using the [stdio](https://spec.modelcontextprotocol.io/specification/2024-11-05/basic/transports/#stdio) transport
23
23
24
24
Examples of both are shown below; [mcp-run-python](run-python.md) is used as the MCP server in both examples.
25
25
26
-
### SSE Client
26
+
### HTTP Client
27
27
28
-
[`MCPServerHTTP`][pydantic_ai.mcp.MCPServerHTTP] connects over HTTP using the [HTTP + Server Sent Events transport](https://spec.modelcontextprotocol.io/specification/2024-11-05/basic/transports/#http-with-sse) to a server.
28
+
[`MCPServerHTTP`][pydantic_ai.mcp.MCPServerHTTP] connects over HTTP using the [Streamable HTTP transport](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http) to a server.
29
29
30
30
!!! note
31
31
[`MCPServerHTTP`][pydantic_ai.mcp.MCPServerHTTP] requires an MCP server to be running and accepting HTTP connections before calling [`agent.run_mcp_servers()`][pydantic_ai.Agent.run_mcp_servers]. Running the server is not managed by PydanticAI.
32
32
33
-
The name "HTTP" is used since this implemented will be adapted in future to use the new
34
-
[Streamable HTTP](https://github.com/modelcontextprotocol/specification/pull/206) currently in development.
33
+
The StreamableHTTP Transport is able to connect to both stateless HTTP and older Server Sent Events (SSE) servers.
35
34
36
-
Before creating the SSE client, we need to run the server (docs [here](run-python.md)):
35
+
Before creating the HTTP client, we need to run the server (docs [here](run-python.md)):
0 commit comments