list_event_logs
Retrieve and filter event log entries from Apache Airflow clusters. Supports filtering by DAG ID, task ID, run ID, and pagination with limit and offset parameters.
Instructions
[Tool Role]: Lists event log entries with optional filtering.
Args: dag_id: Filter by DAG ID (optional) task_id: Filter by task ID (optional) run_id: Filter by run ID (optional) limit: Maximum number of log entries to return (default: 20, increased from 20 for better coverage) offset: Number of entries to skip (default: 0)
Returns: List of event logs: event_logs, total_entries, limit, offset, pagination metadata
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dag_id | No | ||
| limit | No | ||
| offset | No | ||
| run_id | No | ||
| task_id | No |
Implementation Reference
- The core handler function implementing the list_event_logs tool. It constructs a query for the Airflow /eventLogs API endpoint with optional dag_id filtering and pagination parameters (limit/offset), makes the HTTP request using the shared airflow_request function, and returns the JSON response.@mcp.tool() async def list_event_logs(dag_id: Optional[str] = None, limit: int = 20, offset: int = 0) -> Dict[str, Any]: """[Tool Role]: Lists event logs from Airflow.""" params = {'limit': limit, 'offset': offset} if dag_id: params['dag_id'] = dag_id query_string = "&".join([f"{k}={v}" for k, v in params.items()]) resp = await airflow_request("GET", f"/eventLogs?{query_string}") resp.raise_for_status() return resp.json()
- src/mcp_airflow_api/tools/v1_tools.py:19-23 (registration)Registration point for v1 API: sets the v1-specific airflow_request function and calls register_common_tools which defines and registers list_event_logs among other common tools.# Set the global request function to v1 common_tools.airflow_request = airflow_request_v1 # Register all 56 common tools (includes management tools) common_tools.register_common_tools(mcp)
- src/mcp_airflow_api/tools/v2_tools.py:20-24 (registration)Registration point for v2 API: sets the v2-specific airflow_request function and calls register_common_tools which defines and registers list_event_logs among other common tools.# Set the global request function to v2 common_tools.airflow_request = airflow_request_v2 # Register all 43 common tools common_tools.register_common_tools(mcp)
- The register_common_tools function that contains the @mcp.tool() decorator and definition for list_event_logs (located at lines 359-369 within this large function). This is called from both v1_tools and v2_tools.def register_common_tools(mcp): """Register all 43 common tools that work with both v1 and v2 APIs.""" if airflow_request is None: raise RuntimeError("airflow_request function must be set before registering common tools") logger.info("Registering common tools shared between v1 and v2")