get_variable
Retrieve configuration values from Apache Airflow using a specific key to access stored variables for workflow automation.
Instructions
Get a variable by key
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | Yes |
Implementation Reference
- src/airflow/variable.py:54-56 (handler)The core handler function for the 'get_variable' tool. It calls the Airflow VariableApi to retrieve the variable by key and formats the response as MCP TextContent.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)Registration of the 'get_variable' tool within the list of functions returned by get_all_functions(), which is used by main.py to add the tools to the 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:38-38 (registration)Mapping of APIType.VARIABLE to get_variable_functions (alias for get_all_functions from variable.py), enabling dynamic tool registration for variables.APIType.VARIABLE: get_variable_functions,
- src/main.py:95-96 (registration)The dynamic registration loop where tools, including 'get_variable', are added to the MCP app using Tool.from_function.for func, name, description, *_ in functions: app.add_tool(Tool.from_function(func, name=name, description=description))
- src/airflow/variable.py:8-8 (helper)Initialization of the variable_api client used by the get_variable handler.variable_api = VariableApi(api_client)