Skip to main content
Glama
yangkyeongmo

MCP Server for Apache Airflow

by yangkyeongmo

get_dag_source

Retrieve DAG source code from Apache Airflow using a file token to access and review workflow definitions.

Instructions

Get a source code

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_tokenYes

Implementation Reference

  • The handler function for the 'get_dag_source' tool. It takes a file_token, calls the Airflow DAG API to retrieve the DAG source, converts the response to a dictionary string, and returns it as MCP TextContent.
    async def get_dag_source(file_token: str) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
        response = dag_api.get_dag_source(file_token=file_token)
        return [types.TextContent(type="text", text=str(response.to_dict()))]
  • Registers the 'get_dag_source' tool (4th entry) along with other DAG-related tools. This function is imported into src/main.py and its output used to add tools to the MCP server.
    def get_all_functions() -> list[tuple[Callable, str, str, bool]]:
        """Return list of (function, name, description, is_read_only) tuples for registration."""
        return [
            (get_dags, "fetch_dags", "Fetch all DAGs", True),
            (get_dag, "get_dag", "Get a DAG by ID", True),
            (get_dag_details, "get_dag_details", "Get a simplified representation of DAG", True),
            (get_dag_source, "get_dag_source", "Get a source code", True),
            (pause_dag, "pause_dag", "Pause a DAG by ID", False),
            (unpause_dag, "unpause_dag", "Unpause a DAG by ID", False),
            (get_dag_tasks, "get_dag_tasks", "Get tasks for DAG", True),
            (get_task, "get_task", "Get a task by ID", True),
            (get_tasks, "get_tasks", "Get tasks for DAG", True),
            (patch_dag, "patch_dag", "Update a DAG", False),
            (patch_dags, "patch_dags", "Update multiple DAGs", False),
            (delete_dag, "delete_dag", "Delete a DAG", False),
            (clear_task_instances, "clear_task_instances", "Clear a set of task instances", False),
            (set_task_instances_state, "set_task_instances_state", "Set a state of task instances", False),
            (reparse_dag_file, "reparse_dag_file", "Request re-parsing of a DAG file", False),
        ]
  • src/main.py:95-96 (registration)
    The loop in main() that adds all tools from module get_all_functions, including get_dag_source from dag.py, to the MCP app using Tool.from_function.
    for func, name, description, *_ in functions:
        app.add_tool(Tool.from_function(func, name=name, description=description))
  • src/main.py:8-8 (registration)
    Imports the get_all_functions from dag.py, which includes the get_dag_source registration.
    from src.airflow.dag import get_all_functions as get_dag_functions
Behavior1/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 only states 'Get a source code', which implies a read operation but doesn't cover aspects like authentication needs, rate limits, error handling, or what 'source code' entails (e.g., file content, metadata). This is inadequate for a tool with no annotation support.

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

Conciseness4/5

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

The description is extremely concise ('Get a source code'), which is efficient and front-loaded. However, it's under-specified rather than optimally concise, as it lacks necessary details. It earns a 4 because it's brief and to the point, but the brevity comes at the cost of clarity.

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

Completeness1/5

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

Given the complexity (1 required parameter, no annotations, no output schema, and many sibling tools), the description is incomplete. It doesn't explain what 'source code' refers to, how to use the 'file_token', or what the tool returns, making it insufficient for effective agent use in this context.

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

Parameters1/5

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

The input schema has 1 parameter ('file_token') with 0% description coverage, and the tool description provides no information about parameters. The description does not add any meaning beyond the schema, failing to compensate for the lack of schema documentation, which is critical for a required parameter.

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

Purpose2/5

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

The description 'Get a source code' states a vague action ('Get') and resource ('source code'), but it doesn't specify what type of source code (e.g., DAG source code) or from where. It's slightly better than a tautology but lacks specificity compared to siblings like 'get_dag' or 'get_dag_details', which clearly indicate their scope.

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

Usage Guidelines1/5

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

No guidance is provided on when to use this tool versus alternatives. With siblings like 'get_dag', 'get_dag_details', and 'get_import_error' that might relate to DAGs or code, the description offers no context for differentiation, leaving the agent to guess based on the tool 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/yangkyeongmo/mcp-server-apache-airflow'

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