Skip to main content
Glama

dag_code

Retrieve source code for Apache Airflow DAGs to inspect workflow definitions and troubleshoot pipeline logic within MCP-Airflow-API.

Instructions

[Tool Role]: Retrieves the source code for the specified DAG.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dag_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler function for the 'dag_code' tool. Fetches the source code of the specified DAG by making a GET request to the Airflow API endpoint '/dagSources/{dag_id}' and returns the JSON response.
    @mcp.tool()
    async def dag_code(dag_id: str) -> Dict[str, Any]:
        """[Tool Role]: Retrieves the source code for the specified DAG."""
        if not dag_id:
            raise ValueError("dag_id must not be empty")
        resp = await airflow_request("GET", f"/dagSources/{dag_id}")
        resp.raise_for_status()
        return resp.json()
  • Registration for Airflow v1 API tools, which sets the v1-specific airflow_request function and calls register_common_tools(mcp) to register 'dag_code' among other common tools.
    def register_tools(mcp):
        """Register v1 tools by importing common tools with v1 request function."""
        
        logger.info("Initializing MCP server for Airflow API v1")
        logger.info("Loading Airflow API v1 tools (Airflow 2.x)")
        
        # 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)
        
        # V1 has no exclusive tools - all tools are shared with v2
        
        logger.info("Registered all Airflow API v1 tools (56 tools: 43 core + 13 management tools)")
  • Registration for Airflow v2 API tools, which sets the v2-specific airflow_request function and calls register_common_tools(mcp) to register 'dag_code' among other common tools.
    def register_tools(mcp):
        """Register v2 tools: common tools + v2-exclusive asset tools."""
        
        logger.info("Initializing MCP server for Airflow API v2")
        logger.info("Loading Airflow API v2 tools (Airflow 3.0+)")
        
        # 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)
  • Global airflow_request function pointer used by dag_code handler, set during registration to v1 or v2 specific implementation.
    # Global variable to hold the version-specific airflow_request function
    # This will be set by v1_tools.py or v2_tools.py during registration
    airflow_request = None
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves source code, implying a read-only operation, but doesn't mention any behavioral traits such as permissions needed, rate limits, error handling, or what the output contains (e.g., code format, size limits). This is a significant gap for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise with a single sentence that directly states the tool's role. It's front-loaded and wastes no words, making it easy to parse quickly without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (retrieving source code), no annotations, and an output schema present (which likely covers return values), the description is minimally adequate. It states the purpose but lacks usage guidelines, behavioral details, and parameter semantics, leaving gaps that the agent must infer from context or structured data.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0% description coverage, with one parameter 'dag_id' documented only by title. The description adds minimal value by implying 'dag_id' specifies which DAG's source code to retrieve, but doesn't clarify semantics like format, constraints, or examples. Since schema coverage is low, the description doesn't fully compensate, but it provides basic context.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('Retrieves') and resource ('source code for the specified DAG'), making it immediately understandable. However, it doesn't explicitly differentiate from siblings like 'get_dag' or 'dag_graph', which might also retrieve DAG-related information, leaving some ambiguity about uniqueness.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With many sibling tools like 'get_dag', 'dag_graph', and 'list_dags', there's no indication of specific use cases, prerequisites, or exclusions, leaving the agent to infer usage from the name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/call518/MCP-Airflow-API'

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