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
Pydantic AI comes with two ways to connect to MCP servers:
16
+
Pydantic AI comes with three ways to connect to MCP servers:
17
17
18
18
-[`MCPServerStreamableHTTP`][pydantic_ai.mcp.MCPServerStreamableHTTP] which connects to an MCP server using the [Streamable HTTP](https://modelcontextprotocol.io/introduction#streamable-http) transport
19
19
-[`MCPServerSSE`][pydantic_ai.mcp.MCPServerSSE] which connects to an MCP server using the [HTTP SSE](https://spec.modelcontextprotocol.io/specification/2024-11-05/basic/transports/#http-with-sse) transport
@@ -72,14 +72,14 @@ _(This example is complete, it can be run "as is" — you'll need to add `asynci
72
72
73
73
**What's happening here?**
74
74
75
-
- The model is receiving the prompt "how many days between 2000-01-01 and 2025-03-18?"
76
-
- The model decides "Oh, I've got this `run_python_code` tool, that will be a good way to answer this question", and writes some python code to calculate the answer.
75
+
- The model receives the prompt "What is 7 plus 5?"
76
+
- The model decides "Oh, I've got this `add` tool, that will be a good way to answer this question"
77
77
- The model returns a tool call
78
-
- Pydantic AI sends the tool call to the MCP server using the SSE transport
79
-
- The model is called again with the return value of running the code
78
+
- Pydantic AI sends the tool call to the MCP server using the Streamable HTTP transport
79
+
- The model is called again with the return value of running the `add` tool (12)
80
80
- The model returns the final answer
81
81
82
-
You can visualise this clearly, and even see the code that's run by adding three lines of code to instrument the example with [logfire](https://logfire.pydantic.dev/docs):
82
+
You can visualise this clearly, and even see the tool call, by adding three lines of code to instrument the example with [logfire](https://logfire.pydantic.dev/docs):

94
-
95
91
### SSE Client
96
92
97
93
[`MCPServerSSE`][pydantic_ai.mcp.MCPServerSSE] 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.
0 commit comments