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
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes |
Implementation Reference
- src/mcp_prefect/variable.py:50-73 (handler)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))]
- src/mcp_prefect/main.py:70-72 (registration)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
- src/mcp_prefect/variable.py:54-62 (schema)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 """