Skip to main content
Glama
Michaelzag

Migadu MCP Server

by Michaelzag

delete_rewrite

DestructiveIdempotent

Delete rewrite rules using name and optional domain. Permanently removes selected rules from email configuration.

Instructions

Delete rewrite rule(s). DESTRUCTIVE. List of dicts with: name, domain (optional).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
itemsYes

Implementation Reference

  • Tool handler function for delete_rewrite. Decorated with @migadu_bulk_tool, accepts a RewriteDeleteRequest, resolves domain, calls the service layer, and returns success.
    @migadu_bulk_tool(mcp, RewriteDeleteRequest, entity="rewrite", destructive=True)
    async def delete_rewrite(
        item: RewriteDeleteRequest, ctx: Context
    ) -> dict[str, Any]:
        """Delete rewrite rule(s). DESTRUCTIVE. List of dicts with: name, domain (optional)."""
        domain = item.domain or resolve_domain(None)
        await ctx.warning(f"🗑️ Deleting rewrite {item.name}")
        await get_service_factory().rewrite_service().delete_rewrite(domain, item.name)
        return {"deleted": item.name, "success": True}
  • Service-layer implementation that sends the actual HTTP DELETE request to the Migadu API endpoint /domains/{domain}/rewrites/{name}
    async def delete_rewrite(self, domain: str, name: str) -> None:
        await self.client.delete(f"/domains/{domain}/rewrites/{name}")
  • Pydantic schema defining the input validation for delete_rewrite: requires 'name' (str), optional 'domain' (str)
    class RewriteDeleteRequest(BaseModel):
        name: str
        domain: str | None = None
  • Registration of rewrite tools in the initialize_server function of main.py, which calls register_rewrite_tools(mcp)
    register_rewrite_tools(mcp)
  • The register_rewrite_tools function that registers all rewrite tools including delete_rewrite with FastMCP via the @migadu_bulk_tool decorator
    def register_rewrite_tools(mcp: FastMCP) -> None:
        @migadu_tool(mcp, read_only=True, summarize_response=True)
        async def list_rewrites(ctx: Context, domain: str | None = None) -> dict[str, Any]:
            """List rewrite rules for a domain."""
            resolved = resolve_domain(domain)
            await ctx.info(f"📋 Listing rewrites for {resolved}")
            return await get_service_factory().rewrite_service().list_rewrites(resolved)
    
        @migadu_tool(mcp, read_only=True)
        async def get_rewrite(
            name: str, ctx: Context, domain: str | None = None
        ) -> dict[str, Any]:
            """Get rewrite rule details by slug/name."""
            resolved = resolve_domain(domain)
            await ctx.info(f"📋 Getting rewrite {name} for {resolved}")
            return await get_service_factory().rewrite_service().get_rewrite(resolved, name)
    
        @migadu_bulk_tool(mcp, RewriteCreateRequest, entity="rewrite", idempotent=False)
        async def create_rewrite(
            item: RewriteCreateRequest, ctx: Context
        ) -> dict[str, Any]:
            """Create rewrite rule(s). List of dicts with: name, local_part_rule (pattern), destinations, domain (optional), order_num (optional)."""
            domain = item.domain or resolve_domain(None)
            destinations = [str(d) for d in item.destinations]
            await ctx.info(f"📋 Creating rewrite {item.name} on {domain}")
            result = (
                await get_service_factory()
                .rewrite_service()
                .create_rewrite(
                    domain, item.name, item.local_part_rule, destinations, item.order_num
                )
            )
            return {"rewrite": result, "success": True}
    
        @migadu_bulk_tool(mcp, RewriteUpdateRequest, entity="rewrite")
        async def update_rewrite(
            item: RewriteUpdateRequest, ctx: Context
        ) -> dict[str, Any]:
            """Update rewrite rule(s). List of dicts with: name (required), and any of: new_name, local_part_rule, destinations, order_num, domain."""
            domain = item.domain or resolve_domain(None)
            destinations = (
                [str(d) for d in item.destinations] if item.destinations else None
            )
            await ctx.info(f"📋 Updating rewrite {item.name} on {domain}")
            result = (
                await get_service_factory()
                .rewrite_service()
                .update_rewrite(
                    domain,
                    item.name,
                    item.new_name,
                    item.local_part_rule,
                    destinations,
                    item.order_num,
                )
            )
            return {"rewrite": result, "success": True}
    
        @migadu_bulk_tool(mcp, RewriteDeleteRequest, entity="rewrite", destructive=True)
        async def delete_rewrite(
            item: RewriteDeleteRequest, ctx: Context
        ) -> dict[str, Any]:
            """Delete rewrite rule(s). DESTRUCTIVE. List of dicts with: name, domain (optional)."""
            domain = item.domain or resolve_domain(None)
            await ctx.warning(f"🗑️ Deleting rewrite {item.name}")
            await get_service_factory().rewrite_service().delete_rewrite(domain, item.name)
            return {"deleted": item.name, "success": True}
    
        _ = (list_rewrites, get_rewrite, create_rewrite, update_rewrite, delete_rewrite)
Behavior3/5

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

Annotations already indicate destructive and idempotent hints; the description adds the 'DESTRUCTIVE' warning which aligns, but provides little extra beyond parameter format details.

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?

A single sentence conveys the purpose, destructiveness, and parameter format concisely with no 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?

For a simple deletion tool with no output schema, the description covers the essential aspects; it could mention return status but is otherwise complete.

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?

With 0% schema description coverage, the description fully compensates by specifying that items are a list of dicts with name and optional domain, adding critical meaning beyond the bare schema.

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 action ('Delete rewrite rule(s)') and resource, distinguishing it from sibling tools like create_rewrite or update_rewrite.

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 flags the tool as destructive but lacks explicit guidance on when to use it compared to alternatives, such as update_rewrite for modifying rules.

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