create_variable
Define and store configuration values as variables in Apache Airflow for use across workflows and tasks.
Instructions
Create a variable
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes | ||
| value | Yes | ||
| description | No |
Implementation Reference
- src/airflow/variable.py:40-51 (handler)The main handler function for the 'create_variable' tool. It constructs a variable request with key, value, and optional description, then calls the Airflow VariableApi to create the variable and returns the response.async def create_variable( key: str, value: str, description: Optional[str] = None ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]: variable_request = { "key": key, "value": value, } if description is not None: variable_request["description"] = description response = variable_api.post_variables(variable_request=variable_request) return [types.TextContent(type="text", text=str(response.to_dict()))]
- src/airflow/variable.py:15-15 (registration)Registration tuple for the create_variable tool within the module's get_all_functions().(create_variable, "create_variable", "Create a variable", False),
- src/main.py:19-19 (registration)Imports the get_all_functions from the variable module for top-level tool registration.from src.airflow.variable import get_all_functions as get_variable_functions
- src/main.py:38-38 (registration)Maps APIType.VARIABLE to the variable functions getter.APIType.VARIABLE: get_variable_functions,
- src/main.py:95-96 (registration)Loop that registers all tools (including create_variable) by calling app.add_tool.for func, name, description, *_ in functions: app.add_tool(Tool.from_function(func, name=name, description=description))