You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "kaxil (via GitHub)" <gi...@apache.org> on 2026/06/26 01:12:11 UTC

[PR] Replace deprecated pydantic-ai MCP classes with MCPToolset in common.ai [airflow]

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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Replace deprecated `pydantic-ai` MCP classes with `MCPToolset` in `common.ai` [airflow]

Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil merged PR #69006:
URL: https://github.com/apache/airflow/pull/69006


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Replace deprecated `pydantic-ai` MCP classes with `MCPToolset` in `common.ai` [airflow]

Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil commented on PR #69006:
URL: https://github.com/apache/airflow/pull/69006#issuecomment-4817365482

   Thanks @gopidesupavan! Good call -- done in 42c8b27. All the `@patch` decorators (and the `mask_secret` patch) now use `autospec=True`.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org