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
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool returns 'a list of variables with their details,' which implies a read-only operation, but doesn't clarify permissions, rate limits, pagination behavior, or error handling. For a list tool with zero annotation coverage, this leaves significant gaps in understanding how it behaves.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, starting with the core purpose followed by structured parameter and return explanations. Each sentence adds value without redundancy. However, the formatting with 'Args:' and 'Returns:' sections is slightly verbose but still efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (list operation with filtering), no annotations, no output schema, and 3 parameters, the description is minimally adequate. It covers the purpose and parameters well but lacks behavioral details like pagination, error cases, or sibling differentiation. It's complete enough for basic use but has clear gaps for robust agent understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds meaningful context beyond the input schema, which has 0% description coverage. It explains that 'limit' is the 'Maximum number of variables to return,' 'offset' is the 'Number of variables to skip,' and 'name' is for 'Filter by name pattern.' This compensates well for the schema's lack of descriptions, providing clear semantics for all three parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get a list of variables with optional filtering.' It specifies the verb ('Get') and resource ('variables'), making the action clear. However, it doesn't explicitly differentiate from sibling tools like 'get_variable' (singular) or 'create_variable', leaving room for ambiguity in sibling context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'get_variable' (for single variable) or 'create_variable', nor does it specify prerequisites or exclusions. Usage is implied through the action but lacks explicit context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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