list_variables
Retrieve and manage Airflow variables by listing them with optional filters like limit, offset, and order_by. Simplifies access to key-value pairs within your Airflow environment.
Instructions
List all variables
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| offset | No | ||
| order_by | No |
Implementation Reference
- src/airflow/variable.py:22-38 (handler)The main handler function for the 'list_variables' tool. It accepts optional parameters limit, offset, and order_by, calls the Airflow VariableApi to list variables, and returns the response as a TextContent object.async def list_variables( limit: Optional[int] = None, offset: Optional[int] = None, order_by: Optional[str] = None, ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]: # Build parameters dictionary kwargs: Dict[str, Any] = {} if limit is not None: kwargs["limit"] = limit if offset is not None: kwargs["offset"] = offset if order_by is not None: kwargs["order_by"] = order_by response = variable_api.get_variables(**kwargs) return [types.TextContent(type="text", text=str(response.to_dict()))]
- src/airflow/variable.py:11-20 (registration)The get_all_functions() returns the registration tuple for 'list_variables' among other variable tools, which is used by main.py to register the tools with 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:95-97 (registration)The generic registration loop in main.py that adds all tools (including list_variables) to the MCP app using Tool.from_function, after fetching from get_all_functions.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 VariableApi instance used by the list_variables handler.variable_api = VariableApi(api_client)