update_variable
Modify existing variables in Apache Airflow deployments by specifying a key to update its value or description.
Instructions
Update a variable by key
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| description | No | ||
| key | Yes | ||
| value | No |
Input Schema (JSON Schema)
{
"properties": {
"description": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Description"
},
"key": {
"title": "Key",
"type": "string"
},
"value": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Value"
}
},
"required": [
"key"
],
"type": "object"
}
Implementation Reference
- src/airflow/variable.py:59-71 (handler)The asynchronous handler function that executes the update_variable tool, patching the variable using Airflow's VariableApi.async def update_variable( key: str, value: Optional[str] = None, description: Optional[str] = None ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]: update_request = {} if value is not None: update_request["value"] = value if description is not None: update_request["description"] = description response = variable_api.patch_variable( variable_key=key, update_mask=list(update_request.keys()), variable_request=update_request ) return [types.TextContent(type="text", text=str(response.to_dict()))]
- src/airflow/variable.py:11-19 (registration)Function that returns the registration tuple for the update_variable tool (and others), including name, description, and read-only flag.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), ]