list_variables
Retrieve and display all variables stored in Apache Airflow deployments, with options to limit, offset, and order results for efficient management.
Instructions
List all variables
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| offset | No | ||
| order_by | No |
Input Schema (JSON Schema)
{
"properties": {
"limit": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Limit"
},
"offset": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Offset"
},
"order_by": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Order By"
}
},
"type": "object"
}
Implementation Reference
- src/airflow/variable.py:22-37 (handler)The handler function for the list_variables tool. It accepts optional parameters limit, offset, and order_by, calls the Airflow VariableApi.get_variables, and returns the response as MCP TextContent.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-19 (registration)Local registration of the list_variables tool within the get_all_functions() which returns tuples used for MCP tool registration.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:18-18 (registration)Imports the get_all_functions from variable.py for inclusion in global tool registration.from src.airflow.variable import get_all_functions as get_variable_functions
- src/main.py:78-92 (registration)Global registration loop in main() that calls get_variable_functions() (among others) and registers each tool with the MCP app using app.add_tool.for api in apis: logging.debug(f"Adding API: {api}") 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)