get_variable
Retrieve specific configuration variables from Apache Airflow deployments using their unique keys to access runtime parameters and settings.
Instructions
Get a variable by key
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes |
Input Schema (JSON Schema)
{
"properties": {
"key": {
"title": "Key",
"type": "string"
}
},
"required": [
"key"
],
"type": "object"
}
Implementation Reference
- src/airflow/variable.py:54-56 (handler)The handler function implementing the 'get_variable' tool. It calls the Airflow VariableApi to fetch the variable by key and returns the response as a text content list.async def get_variable(key: str) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]: response = variable_api.get_variable(variable_key=key) return [types.TextContent(type="text", text=str(response.to_dict()))]
- src/airflow/variable.py:11-19 (registration)The get_all_functions helper that provides the registration tuple for the 'get_variable' tool among others.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:36-36 (registration)Mapping of APIType.VARIABLE to the get_variable_functions (alias for get_all_functions from variable.py) for tool registration.APIType.VARIABLE: get_variable_functions,
- src/main.py:90-91 (registration)The loop that registers each tool, including 'get_variable', by calling app.add_tool.for func, name, description, *_ in functions: app.add_tool(func, name=name, description=description)
- src/main.py:18-18 (helper)Import of the get_all_functions from variable.py, aliased for use in main.py registration.from src.airflow.variable import get_all_functions as get_variable_functions