Skip to main content
Glama

get_variables

Retrieve Prefect workflow variables with optional filtering by name, limit, or offset to manage configuration data in your automation platform.

Instructions

Get a list of variables with optional filtering.

Args: limit: Maximum number of variables to return offset: Number of variables to skip name: Filter by name pattern

Returns: A list of variables with their details

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
nameNo
offsetNo

Implementation Reference

  • The main handler function for the 'get_variables' tool. It uses Prefect client to read variables with client-side filtering for name and offset, returning JSON-formatted results or error messages.
    @mcp.tool async def get_variables( limit: Optional[int] = None, offset: Optional[int] = None, name: Optional[str] = None, ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]: """ Get a list of variables with optional filtering. Args: limit: Maximum number of variables to return offset: Number of variables to skip (not supported in current Prefect version) name: Filter by name pattern (client-side filtering since API doesn't support it) Returns: A list of variables with their details """ try: async with get_client() as client: # Get all variables and filter client-side since the API doesn't support filtering variables = await client.read_variables(limit=limit) # Apply client-side filtering for name if name: variables = [var for var in variables if name.lower() in var.name.lower()] # Apply offset client-side if offset: variables = variables[offset:] variables_result = { "variables": [variable.model_dump() for variable in variables] } return [types.TextContent(type="text", text=json.dumps(variables_result, indent=2, default=str))] except Exception as e: return [types.TextContent(type="text", text=json.dumps({"error": str(e)}, indent=2))]
  • Conditional import of the 'variable.py' module when VARIABLE API is enabled, which triggers registration of all variable-related tools (including 'get_variables') via their @mcp.tool decorators.
    if APIType.VARIABLE.value in apis: info("Loading Variable API...") from . import variable

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/allen-munsch/mcp-prefect'

If you have feedback or need assistance with the MCP directory API, please join our Discord server