Skip to main content
Glama

delete_variable

Remove a specific variable from Prefect's workflow automation platform by providing its name to maintain clean and organized workflow configurations.

Instructions

Delete a variable by name.

Args: name: The variable name

Returns: Confirmation message

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes

Implementation Reference

  • The handler function for the 'delete_variable' tool. It checks if the variable exists, deletes it using the Prefect client if it does, and returns appropriate success or error messages in MCP TextContent format. The @mcp.tool decorator registers this function as an MCP tool.
    @mcp.tool
    async def delete_variable(
        name: str,
    ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
        """
        Delete a variable by name.
        
        Args:
            name: The variable name
            
        Returns:
            Confirmation message or error
        """
        try:
            async with get_client() as client:
                # Check if variable exists first
                existing_variable = await client.read_variable_by_name(name)
                if existing_variable is None:
                    return [types.TextContent(type="text", text=json.dumps({"error": f"Variable '{name}' not found"}, indent=2))]
                
                await client.delete_variable_by_name(name)
                
                return [types.TextContent(type="text", text=json.dumps({
                    "message": f"Variable '{name}' deleted successfully"
                }, indent=2))]
        except ObjectNotFound:
            return [types.TextContent(type="text", text=json.dumps({
                "error": f"Variable '{name}' not found"
            }, indent=2))]
        except Exception as e:
            return [types.TextContent(type="text", text=json.dumps({"error": str(e)}, indent=2))]
  • Creation of the FastMCP server instance 'mcp' to which tools are registered via decorators.
    mcp = FastMCP(f"MCP Prefect {__version__}")
  • Import of the variable module which triggers the registration of variable-related tools (including delete_variable) via their @mcp.tool decorators.
    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