get_connection
Retrieve a specific connection by its ID using the MCP Server for Apache Airflow. Facilitates direct access to connection details for streamlined DAG and API operations.
Instructions
Get a connection by ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| conn_id | Yes |
Implementation Reference
- src/airflow/connection.py:72-74 (handler)The core handler function for the 'get_connection' tool. It takes a conn_id, calls the Airflow ConnectionApi to retrieve the connection, and returns the response as a TextContent object.async def get_connection(conn_id: str) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]: response = connection_api.get_connection(connection_id=conn_id) return [types.TextContent(type="text", text=str(response.to_dict()))]
- src/airflow/connection.py:11-20 (registration)Registers the 'get_connection' tool (line 16) along with other connection tools by returning a tuple (function, name, description, read_only) used by the main app.def get_all_functions() -> list[tuple[Callable, str, str, bool]]: """Return list of (function, name, description, is_read_only) tuples for registration.""" return [ (list_connections, "list_connections", "List all connections", True), (create_connection, "create_connection", "Create a connection", False), (get_connection, "get_connection", "Get a connection by ID", True), (update_connection, "update_connection", "Update a connection by ID", False), (delete_connection, "delete_connection", "Delete a connection by ID", False), (test_connection, "test_connection", "Test a connection", True), ]
- src/main.py:26-26 (registration)Maps APIType.CONNECTION to get_connection_functions (imported from src.airflow.connection), which provides the tool list including 'get_connection'.APIType.CONNECTION: get_connection_functions,
- src/main.py:95-96 (registration)Generic loop that registers all tools from get_all_functions() calls, including 'get_connection'.for func, name, description, *_ in functions: app.add_tool(Tool.from_function(func, name=name, description=description))
- src/airflow/connection.py:8-8 (helper)Initializes the ConnectionApi client instance used by get_connection handler.connection_api = ConnectionApi(api_client)