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
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes |
Implementation Reference
- src/mcp_prefect/variable.py:160-190 (handler)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))]
- src/mcp_prefect/server.py:6-6 (registration)Creation of the FastMCP server instance 'mcp' to which tools are registered via decorators.mcp = FastMCP(f"MCP Prefect {__version__}")
- src/mcp_prefect/main.py:72-72 (registration)Import of the variable module which triggers the registration of variable-related tools (including delete_variable) via their @mcp.tool decorators.from . import variable