kaxil opened a new pull request, #69006:
URL: https://github.com/apache/airflow/pull/69006
pydantic-ai deprecated `MCPServerStdio`, `MCPServerSSE`, and
`MCPServerStreamableHTTP` in favor of a unified `MCPToolset`, and removes all
three in pydantic-ai v2. The common.ai `MCPHook` constructed all three
directly, so it emits `DeprecationWarning`s today and would break on the v2
upgrade.
This migrates `MCPHook.get_conn()` to build an `MCPToolset` over the
matching FastMCP transport.
## What changed
| Transport | Before | After |
|---|---|---|
| `http` | `MCPServerStreamableHTTP(host, headers=…, tool_prefix=…)` |
`MCPToolset(StreamableHttpTransport(host, headers=…))` |
| `sse` | `MCPServerSSE(host, headers=…, tool_prefix=…)` |
`MCPToolset(SSETransport(host, headers=…))` |
| `stdio` | `MCPServerStdio(cmd, args=…, timeout=…, tool_prefix=…)` |
`MCPToolset(StdioTransport(command=cmd, args=…), init_timeout=…)` |
| prefix | `tool_prefix=` constructor arg | `.prefixed(prefix)` |
## Design rationale
- **Explicit transports instead of URL inference.** `MCPToolset` can infer a
transport from a bare URL, but FastMCP only picks SSE when the URL ends in
`/sse`. The connection has an explicit `transport` field, so the hook builds
the transport explicitly to honor that choice regardless of URL shape, and to
keep attaching the `Authorization` header.
- **`StdioTransport` for stdio.** The connection supplies an arbitrary
`command` + `args`, which is the case pydantic-ai's deprecation message
prescribes `StdioTransport(...)` for; the `MCPToolset("script.py")` shorthand
only covers literal script paths.
- **`.prefixed()` for `tool_prefix`.** `MCPToolset` has no `tool_prefix`
argument. `.prefixed(prefix)` produces the same `<prefix>_<tool>` names as
before and matches pydantic-ai's own `load_mcp_toolsets`. It returns a
`PrefixedToolset` that proxies the async-context-manager protocol, so the
connection-backed `MCPToolset` wrapper keeps working unchanged.
- **`init_timeout` is the successor to the old stdio `timeout`;** the hook
keeps its default of 10s.
## Tradeoffs / notes
- Behavior-preserving: tool names, auth headers, caching defaults, and the
no-auth path are unchanged.
- `fastmcp.client.transports` is the canonical public import path.
`pydantic_ai.mcp` imports from it, and pydantic-ai's own deprecation message
recommends `MCPToolset(fastmcp.client.transports.StdioTransport(...))`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]