Skip to main content
Glama
Michaelzag

Migadu MCP Server

by Michaelzag

create_rewrite

Create email rewrite rules by specifying local part patterns, destination addresses, and optional domain and order number to redirect incoming messages.

Instructions

Create rewrite rule(s). List of dicts with: name, local_part_rule (pattern), destinations, domain (optional), order_num (optional).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
itemsYes

Implementation Reference

  • The MCP tool handler for 'create_rewrite'. Decorated with @migadu_bulk_tool, accepts a RewriteCreateRequest (validated via Pydantic), resolves domain, converts destinations to strings, and delegates to the RewriteService.create_rewrite method. Returns {'rewrite': result, 'success': True}.
    @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}
  • The service-level implementation of create_rewrite. Constructs request data (name, local_part_rule, destinations as CSV, optional order_num) and POSTs to /domains/{domain}/rewrites via the MigaduClient.
    async def create_rewrite(
        self,
        domain: str,
        name: str,
        local_part_rule: str,
        destinations: list[str],
        order_num: int | None = None,
    ) -> dict[str, Any]:
        data: dict[str, Any] = {
            "name": name,
            "local_part_rule": local_part_rule,
            "destinations": ",".join(destinations),
        }
        if order_num is not None:
            data["order_num"] = order_num
        return await self.client.post(f"/domains/{domain}/rewrites", json=data)
  • Pydantic schema RewriteCreateRequest used to validate input to the create_rewrite tool. Fields: name, local_part_rule, destinations (coerced from CSV string to list[EmailStr]), domain (optional), order_num (optional).
    class RewriteCreateRequest(BaseModel):
        name: str = Field(..., description="Unique identifier/slug for the rule")
        local_part_rule: str = Field(
            ..., description="Pattern to match (e.g., 'demo-*', 'support-*')"
        )
        destinations: list[EmailStr]
        domain: str | None = None
        order_num: int | None = None
    
        @field_validator("destinations", mode="before")
        @classmethod
        def _coerce(cls, v: Union[list[str], str]) -> list[str]:
            coerced = _coerce_destinations(v)
            if not coerced:
                raise ValueError("destinations must be a non-empty list or CSV string")
            return coerced
  • Import of register_rewrite_tools from rewrite_tools module.
    from migadu_mcp.tools.rewrite_tools import register_rewrite_tools
  • Registration call: register_rewrite_tools(mcp) which registers all rewrite tools including create_rewrite.
    register_rewrite_tools(mcp)
Behavior2/5

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

Annotations indicate readOnlyHint false (modifies state) and destructiveHint false (not destructive). The description adds no behavioral details beyond 'create'. It does not disclose if rules are merged, overwritten, or validated, nor does it mention side effects or permissions. The description provides minimal transparency beyond the annotation hints.

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

Conciseness4/5

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

The description is a single sentence that efficiently states the action and lists the fields. It is front-loaded with the purpose and then details the structure. No superfluous words. However, it could be slightly improved by specifying that 'items' is an array parameter.

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

Completeness3/5

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

Given the complexity of creating rewrite rules (multiple fields with optional parameters) and the lack of schema details, the description provides a basic field list but omits field types, constraints (e.g., required vs optional), and formatting. Without an output schema, the agent may wonder about return values. The description is adequate but leaves gaps.

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

Parameters4/5

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

Schema coverage is 0%, with only an array of objects property defined. The description lists the expected dictionary keys (name, local_part_rule, destinations, domain, order_num), adding critical semantic meaning that the schema lacks. This effectively compensates for the empty schema, though it could be more detailed (e.g., specifying types or constraints).

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

Purpose4/5

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

The description clearly states the purpose: 'Create rewrite rule(s)' with a list of dictionaries. The verb 'create' and resource 'rewrite rule' are specific. However, it does not distinguish this tool from other creation tools like create_alias or create_forwarding, which are siblings. The listing of fields adds clarity but misses differentiation.

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

Usage Guidelines2/5

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

No guidance on when to use this tool versus alternatives (e.g., create_alias, create_forwarding). There is no mention of prerequisites, when not to use, or context about rewrite rules. The description is purely functional without usage context.

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