Skip to main content
Glama
Michaelzag

Migadu MCP Server

by Michaelzag

delete_rewrite

DestructiveIdempotent

Remove email rewrite rules from Migadu hosting services. This destructive action permanently deletes specified rules and cannot be undone.

Instructions

Delete rewrite rules. DESTRUCTIVE: Cannot be undone. List of dicts with: name (required), domain (optional).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
targetsYes

Implementation Reference

  • The primary handler function for the 'delete_rewrite' MCP tool. It handles bulk deletion requests by logging the operation, issuing warnings, and delegating to the process_delete_rewrite helper.
    @mcp.tool(
        annotations={
            "readOnlyHint": False,
            "destructiveHint": True,
            "idempotentHint": True,
            "openWorldHint": True,
        },
    )
    async def delete_rewrite(
        targets: List[Dict[str, Any]], ctx: Context
    ) -> Dict[str, Any]:
        """Delete rewrite rules. DESTRUCTIVE: Cannot be undone. List of dicts with: name (required), domain (optional)."""
        count = len(list(ensure_iterable(targets)))
        await log_bulk_operation_start(ctx, "Deleting", count, "rewrite rule")
        await ctx.warning("🗑️ DESTRUCTIVE: This operation cannot be undone!")
    
        result = await process_delete_rewrite(targets, ctx)
        await log_bulk_operation_result(
            ctx, "Rewrite rule deletion", result, "rewrite rule"
        )
        return result
  • Helper function for processing individual delete operations, including validation via RewriteDeleteRequest schema and calling the service layer.
    @bulk_processor_with_schema(RewriteDeleteRequest)
    async def process_delete_rewrite(
        validated_item: RewriteDeleteRequest, ctx: Context
    ) -> Dict[str, Any]:
        """Process a single rewrite rule deletion with Pydantic validation"""
        # Use validated Pydantic model directly - all validation already done
        name = validated_item.name
        domain = validated_item.domain
    
        # Get domain if not provided
        if domain is None:
            from migadu_mcp.config import get_config
    
            config = get_config()
            domain = config.get_default_domain()
            if not domain:
                raise ValueError("No domain provided and MIGADU_DOMAIN not configured")
    
        await ctx.warning(f"🗑️ DESTRUCTIVE: Deleting rewrite rule {name}@{domain}")
    
        service = get_service_factory().rewrite_service()
        await service.delete_rewrite(domain, name)
    
        await log_operation_success(ctx, "Deleted rewrite rule", f"{name}@{domain}")
        return {"deleted": f"{name}@{domain}", "success": True}
  • Pydantic model defining the input schema for delete_rewrite requests, with required 'name' and optional 'domain' fields.
    class RewriteDeleteRequest(BaseModel):
        """Request schema for deleting a rewrite rule"""
    
        name: str = Field(..., description="Identifier/slug of the rule to delete")
        domain: Optional[str] = Field(None, description="Domain name")
  • The registration call in the main MCP server initialization that includes the delete_rewrite tool via register_rewrite_tools.
    register_rewrite_tools(mcp)
  • Service layer implementation that performs the actual HTTP DELETE request to the Migadu API to remove the rewrite rule.
    async def delete_rewrite(self, domain: str, name: str) -> Dict[str, Any]:
        """Delete a rewrite rule"""
        return await self.client.request("DELETE", f"/domains/{domain}/rewrites/{name}")
Behavior4/5

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

Annotations already indicate destructiveHint=true, readOnlyHint=false, openWorldHint=true, and idempotentHint=true. The description adds valuable context by explicitly warning 'Cannot be undone', reinforcing the destructive nature. It also provides structural details about the input format ('List of dicts with: name (required), domain (optional)'), which complements the annotations without contradiction.

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

Conciseness5/5

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

The description is highly concise and front-loaded, with only two sentences that each earn their place. The first sentence states the purpose, the second provides critical warnings and parameter details, with zero wasted words.

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

Completeness4/5

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

Given the tool's destructive nature (annotations cover this), no output schema, and 0% schema coverage, the description does well by explaining parameters and adding a strong warning. However, it could improve by mentioning potential side effects or confirming idempotency (implied by annotations but not stated in description).

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

Parameters5/5

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

Schema description coverage is 0%, so the description carries full burden. It effectively explains the parameter 'targets' as a 'List of dicts' and specifies the required 'name' and optional 'domain' fields, adding crucial semantic meaning beyond the generic schema. This fully compensates for the lack of schema descriptions.

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

Purpose5/5

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

The description clearly states the verb ('Delete') and resource ('rewrite rules'), making the purpose specific and unambiguous. It distinguishes this tool from siblings like 'delete_alias', 'delete_mailbox', and 'delete_identity' by specifying the exact resource type.

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

Usage Guidelines3/5

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

The description implies usage context through the 'DESTRUCTIVE' warning, suggesting caution. However, it doesn't explicitly state when to use this tool versus alternatives like 'update_rewrite' or 'get_rewrite', nor does it mention prerequisites or exclusions beyond the destructive nature.

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/Michaelzag/migadu-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server