Skip to main content
Glama
madamak

Apache Airflow MCP Server

by madamak

airflow_get_task_instance_logs

Retrieve and filter Apache Airflow task execution logs by error level, context lines, or tail length, with automatic handling for large files and multi-host output.

Instructions

Fetch task instance logs with optional filtering and truncation.

Large log handling: Logs >100MB automatically tail to last 10,000 lines (sets auto_tailed=true). Host-segmented responses are flattened into a single string using headers of the form --- [worker] ---, ensuring agents can reason about multi-host output. The tool requires an explicit try_number; callers should first retrieve it via airflow_get_task_instance.

Filter order of operations:

  1. Auto-tail: If log >100MB, take last 10,000 lines

  2. tail_lines: Extract last N lines from log

  3. filter_level: Find matching lines by level (content filter)

  4. context_lines: Add surrounding lines around matches (symmetric: N before + N after)

  5. max_bytes: Hard cap on total output (UTF-8 safe truncation)

Parameters

  • instance: Instance key (optional, mutually exclusive with ui_url)

  • ui_url: Airflow UI URL to resolve identifiers (optional)

  • dag_id, dag_run_id, task_id, try_number: Task instance identifiers (required)

  • filter_level: "error" | "warning" | "info" (optional) - Show only lines matching level

    • "error": ERROR, CRITICAL, FATAL, Exception, Traceback

    • "warning": WARN, WARNING + error patterns

    • "info": INFO + warning + error patterns

  • context_lines: N lines before/after each match (optional, clamped to [0, 1000]; accepts int/float/str, coerced to non-negative int, fractional values truncated)

  • tail_lines: Extract last N lines before filtering (optional, clamped to [0, 100000]; accepts int/float/str, coerced to non-negative int, fractional values truncated)

  • max_bytes: Maximum response size in bytes (default: 100KB ≈ 25K tokens, clamped to reasonable limit)

Returns

  • Response dict with fields:

    • log: Normalized/filtered log text (host headers inserted when needed)

    • truncated: true if output exceeded max_bytes

    • auto_tailed: true if original log >100MB triggered auto-tail

    • bytes_returned: Actual byte size of returned log

    • original_lines: Line count before any filtering

    • returned_lines: Line count after all filtering/truncation

    • match_count: Number of lines matching filter_level (before context expansion)

    • meta.try_number: Attempt number for this task instance

    • meta.filters: Echo of effective filters applied (shows clamped values)

    • ui_url: Direct link to log view in Airflow UI

    • request_id: Correlates with server logs

  • Raises: ToolError with compact JSON payload (code, message, request_id, optional context)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
instanceNo
ui_urlNo
dag_idNo
dag_run_idNo
task_idNo
try_numberNo
filter_levelNo
context_linesNo
tail_linesNo
max_bytesNo

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/madamak/apache-airflow-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server