create_variable
Create and store variables in Apache Airflow for use in workflows, enabling configuration management and secure data handling across deployments.
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-52 (handler)The asynchronous function implementing the create_variable tool. It creates a new Airflow variable using the VariableApi by posting a request with key, value, and optional description.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:11-19 (registration)Module-level function that defines and returns the list of variable-related tools, including the create_variable tool, for registration into the main 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 [ (list_variables, "list_variables", "List all variables", True), (create_variable, "create_variable", "Create a variable", False), (get_variable, "get_variable", "Get a variable by key", True), (update_variable, "update_variable", "Update a variable by key", False), (delete_variable, "delete_variable", "Delete a variable by key", False), ]
- src/main.py:80-91 (registration)The code in the main function that retrieves the list of functions (including create_variable via get_variable_functions) and registers them as MCP tools using app.add_tool.get_function = APITYPE_TO_FUNCTIONS[APIType(api)] try: functions = get_function() except NotImplementedError: continue # Filter functions for read-only mode if requested if read_only: functions = filter_functions_for_read_only(functions) for func, name, description, *_ in functions: app.add_tool(func, name=name, description=description)