Skip to main content
Glama

dag_code

Retrieve the source code for a specific Apache Airflow DAG by providing its DAG ID, enabling developers to inspect and manage workflows directly within the MCP-Airflow-API environment.

Instructions

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

Args: dag_id: The DAG ID to get source code for

Returns: DAG source code: dag_id, file_token, source_code

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dag_idYes

Implementation Reference

  • The main handler function for the 'dag_code' tool. It fetches the source code of a specified DAG using the Airflow API endpoint /dagSources/{dag_id}.
    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 of common tools (including dag_code) for Airflow API v1 by calling register_common_tools.
    common_tools.register_common_tools(mcp)
  • Registration of common tools (including dag_code) for Airflow API v2 by calling register_common_tools.
    common_tools.register_common_tools(mcp)
  • Calls v1_tools.register_tools which registers dag_code for v1 API.
    from mcp_airflow_api.tools import v1_tools v1_tools.register_tools(mcp)
  • Calls v2_tools.register_tools which registers dag_code for v2 API.
    logger.info("Loading Airflow API v2 tools (Airflow 3.0+)") from mcp_airflow_api.tools import v2_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