Skip to main content
Glama

get_variable

Retrieve specific variable details from Prefect's workflow automation platform by providing the variable name, enabling access to stored workflow configuration data.

Instructions

Get a variable by name.

Args: name: The variable name

Returns: Variable details

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes

Implementation Reference

  • The core handler function for the 'get_variable' MCP tool. It uses the Prefect client to read the variable by name and returns its details as JSON text content or an error message.
    @mcp.tool
    async def get_variable(
        name: str,
    ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
        """
        Get a variable by name.
        
        Args:
            name: The variable name
            
        Returns:
            Variable details or error message if not found
        """
        try:
            async with get_client() as client:
                variable = await client.read_variable_by_name(name)
                
                if variable is None:
                    return [types.TextContent(type="text", text=json.dumps({"error": f"Variable '{name}' not found"}, indent=2))]
                
                return [types.TextContent(type="text", text=json.dumps(variable.model_dump(), indent=2, default=str))]
        except Exception as e:
            return [types.TextContent(type="text", text=json.dumps({"error": str(e)}, indent=2))]
  • The import statement that loads the variable.py module, triggering registration of the get_variable tool via its @mcp.tool decorator.
    if APIType.VARIABLE.value in apis:
        info("Loading Variable API...")
        from . import variable
  • Docstring describing the input schema (name: str) and output (list of TextContent with JSON). The actual schema is inferred from the function signature by FastMCP.
    """
    Get a variable by name.
    
    Args:
        name: The variable name
        
    Returns:
        Variable details or error message if not found
    """

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