test_connection
Verify connectivity by testing Airflow database and external system connections using specified parameters such as host, port, login, and password.
Instructions
Test a connection
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| conn_type | Yes | ||
| extra | No | ||
| host | No | ||
| login | No | ||
| password | No | ||
| port | No | ||
| schema | No |
Implementation Reference
- src/airflow/connection.py:114-140 (handler)The async handler function for the 'test_connection' tool. It constructs a connection request from the input parameters and calls the Airflow ConnectionApi.test_connection method to perform the test, returning the response as text content.async def test_connection( conn_type: str, host: Optional[str] = None, port: Optional[int] = None, login: Optional[str] = None, password: Optional[str] = None, schema: Optional[str] = None, extra: Optional[str] = None, ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]: connection_request = { "conn_type": conn_type, } if host is not None: connection_request["host"] = host if port is not None: connection_request["port"] = port if login is not None: connection_request["login"] = login if password is not None: connection_request["password"] = password if schema is not None: connection_request["schema"] = schema if extra is not None: connection_request["extra"] = extra response = connection_api.test_connection(connection_request=connection_request) return [types.TextContent(type="text", text=str(response.to_dict()))]
- src/airflow/connection.py:11-20 (registration)The get_all_functions() returns a list of tuples for tool registration, including the entry for 'test_connection' with its handler, name, description, and read-only status.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), ]