airflow.providers.common.ai.hooks.mcp¶
Classes¶
Hook for connecting to MCP (Model Context Protocol) servers. |
Module Contents¶
- class airflow.providers.common.ai.hooks.mcp.MCPHook(mcp_conn_id=default_conn_name, tool_prefix=None, **kwargs)[source]¶
Bases:
airflow.providers.common.compat.sdk.BaseHookHook for connecting to MCP (Model Context Protocol) servers.
Manages connection configuration for MCP servers. Supports three transport types: HTTP (Streamable HTTP), SSE, and stdio.
- Connection fields:
host: Server URL for HTTP/SSE transports (e.g.
http://localhost:3001/mcp)password: Auth token (optional)
Extra.transport: Transport type —
http(default),sse, orstdioExtra.command: Command to run for stdio transport (e.g.
uvx)Extra.args: Command arguments for stdio transport (e.g.
["mcp-run-python"])Extra.timeout: Connection timeout in seconds for stdio (default: 10)
- Parameters:
- static get_ui_field_behaviour()[source]¶
Return custom field behaviour for the Airflow connection form.
- get_conn()[source]¶
Return a configured PydanticAI MCP server instance.
Creates the appropriate MCP server based on the transport type in the connection’s extra field:
http(default):MCPServerStreamableHTTPsse:MCPServerSSEstdio:MCPServerStdio
The result is cached for the lifetime of this hook instance.