agentleFS
astronomerastronomer/agents/astro-airflow-mcp/AGENTS.md

agents / astro-airflow-mcp

AGENTS.md448 starsChanged 59 days agoApache-2.0View on GitHub

Guidelines for AI coding assistants contributing to this repository. MCP server for Apache Airflow with adapter pattern for version compatibility: Use httpx, not requests. All HTTP calls should use httpx.Client and pass self._verify for SSL configuration: All Airflow API calls go through adapters. Never call Airflow API directly from MCP tools: When adding new API endpoints: 1. Add abstract method to adapters/base.py 2. Implement in both airflow_v2.py and airflow_v3.py 3. Handle API differences (field names, paths, availability) Tools need descriptive…

The file

We split this AGENTS.md into the rules it gives an agent

4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use httpx, not requests. All HTTP calls should use httpx.Client and pass self._verify for SSL configuration:

    line 50
  2. Distinctive:

    All Airflow API calls go through adapters.

    line 63
  3. Distinctive:

    When adding new API endpoints:

    line 74
  4. Very specific:

    Add abstract method to adapters/base.py

    line 75

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md
<!-- START doctoc generated TOC please keep comment here to allow auto update --><!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

Table of Contents generated with DocToc

  • Agent Guidelines for astro-airflow-mcp
    • Architecture
    • Code Conventions
      • HTTP Client
      • Adapter Pattern
      • MCP Tools
      • Error Handling
    • Airflow Version Differences
    • Testing
    • Files to Know
<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Agent Guidelines for astro-airflow-mcp

Guidelines for AI coding assistants contributing to this repository.

Architecture

MCP server for Apache Airflow with adapter pattern for version compatibility:

src/astro_airflow_mcp/
├── server.py          # Core infrastructure: config, auth, adapter management (FastMCP)
├── tools/             # MCP tool implementations (grouped by domain)
│   ├── dag.py         # DAG management (get, list, source, stats, pause, unpause)
│   ├── task.py        # Task management (get, list, instance, logs, clear)
│   ├── dag_run.py     # DAG run management (list, get, trigger, trigger_and_wait, delete, clear)
│   ├── asset.py       # Asset/dataset tools (list, events, upstream events)
│   ├── admin.py       # Admin tools (connections, variables, pools, plugins, providers, config, version)
│   └── diagnostic.py  # Diagnostic tools (warnings, errors, explore, diagnose, health)
├── resources.py       # MCP resources (read-only endpoints)
├── prompts.py         # MCP prompts (guided workflows)
├── adapters/
│   ├── base.py        # Abstract adapter interface
│   ├── airflow_v2.py  # Airflow 2.x API (/api/v1)
│   └── airflow_v3.py  # Airflow 3.x API (/api/v2)
├── models.py          # Pydantic models (documentation/type reference)
└── plugin.py          # Airflow 3.x plugin integration

Code Conventions

HTTP Client

Use httpx, not requests. All HTTP calls should use httpx.Client and pass self._verify for SSL configuration:

# Good
with httpx.Client(timeout=30.0, verify=self._verify) as client:
    response = client.get(url, headers=headers)

# Bad
response = requests.get(url, headers=headers)

Adapter Pattern

All Airflow API calls go through adapters. Never call Airflow API directly from MCP tools:

# Good - use adapter
adapter = _get_adapter()
data = adapter.list_dags(limit=100)

# Bad - direct API call
response = httpx.get(f"{url}/api/v2/dags")

When adding new API endpoints:

  1. Add abstract method to adapters/base.py
  2. Implement in both airflow_v2.py and airflow_v3.py
  3. Handle API differences (field names, paths, availability)

MCP Tools

Tools need descriptive docstrings for AI discovery:

@mcp.tool()
def get_dag_details(dag_id: str) -> str:
    """Get detailed information about a specific DAG.

    Use this tool when the user asks about:
    - "Show me details for DAG X"
    - "What's the schedule for DAG Y?"

    Args:
        dag_id: The ID of the DAG

    Returns:
        JSON with DAG metadata
    """

Error Handling

Adapters handle missing endpoints gracefully:

try:
    return self._call("newEndpoint")
except NotFoundError:
    return self._handle_not_found(
        "newEndpoint",
        alternative="Use alternativeEndpoint instead"
    )

Airflow Version Differences

FeatureAirflow 2.xAirflow 3.x
API path/api/v1/api/v2
AuthBasic authOAuth2/JWT
Assetsdatasetsassets
DAG runsexecution_datelogical_date

Testing

  • Mock adapters, not HTTP libraries
  • Unit tests: tests/
  • Integration tests: tests/integration/ (require running Airflow)
# Good - mock adapter (patch in the tool module that imports it)
mock_adapter = mocker.Mock()
mock_adapter.list_dags.return_value = {"dags": [...]}
mocker.patch("astro_airflow_mcp.tools.dag._get_adapter", return_value=mock_adapter)

# Bad - mock HTTP library
mocker.patch("httpx.Client")

Files to Know

  • server.py: All MCP tools defined here
  • adapters/base.py: Interface contract for both versions
  • models.py: Type reference (not used for validation currently)
  • docker-compose.test.yml: Test against real Airflow instances

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.