Skip to main content
Glama
Michaelzag

Migadu MCP Server

by Michaelzag

list_rewrites

Read-onlyIdempotent

View pattern-based email rewrite rules for a domain to manage email routing and filtering with statistics and examples.

Instructions

List pattern-based rewrite rules for domain. Returns summary with statistics and samples.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
domainNo

Implementation Reference

  • The primary handler function for the 'list_rewrites' tool, decorated with @mcp.tool(). It handles optional domain parameter (defaults from config), logging, service factory retrieval, API call via service, result processing with count, and comprehensive error handling.
    @mcp.tool(
        annotations={
            "readOnlyHint": True,
            "idempotentHint": True,
            "openWorldHint": True,
        },
    )
    @with_context_protection(max_tokens=2000)
    async def list_rewrites(ctx: Context, domain: str | None = None) -> Dict[str, Any]:
        """List pattern-based rewrite rules for domain. Returns summary with statistics and samples."""
        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 log_operation_start(ctx, "Listing rewrite rules", domain)
        try:
            service = get_service_factory().rewrite_service()
            result = await service.list_rewrites(domain)
            count = len(result.get("rewrites", []))
            await log_operation_success(ctx, "Listed rewrite rules", domain, count)
            return result
        except Exception as e:
            await log_operation_error(ctx, "List rewrites", domain, str(e))
            raise
  • Registration call to register_rewrite_tools(mcp), which defines and registers the list_rewrites tool using FastMCP's @mcp.tool decorator.
    register_rewrite_tools(mcp)
  • Core service helper method that performs the actual API request to list rewrites for the given domain via MigaduClient.
    async def list_rewrites(self, domain: str) -> Dict[str, Any]:
        """List all rewrites for a domain"""
        return await self.client.request("GET", f"/domains/{domain}/rewrites")
  • MCP resource 'rewrites://{domain}' that provides list_rewrites functionality as a resource endpoint, directly calling the service.list_rewrites method.
    @mcp.resource("rewrites://{domain}")
    async def domain_rewrites(domain: str) -> Dict[str, Any]:
        """Resource providing all pattern-based rewrite rules configured for a domain. Shows wildcard
        patterns, destination addresses, processing order, and rule configuration for dynamic email
        routing. Use this resource to audit pattern-based forwarding systems, verify rule precedence,
        and manage complex email routing scenarios that require wildcard matching.
    
        URI Format: rewrites://example.org
        """
        factory = get_service_factory()
        service = factory.rewrite_service()
        return await service.list_rewrites(domain)
  • The register_rewrite_tools function that contains the @mcp.tool decorator for list_rewrites and other rewrite tools, invoked from main.py.
    def register_rewrite_tools(mcp: FastMCP):
        """Register rewrite tools using List[Dict] + iterator pattern"""
Behavior3/5

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

Annotations provide readOnlyHint=true (safe), openWorldHint=true (may return partial data), and idempotentHint=true (repeatable). The description adds that it returns a 'summary with statistics and samples', which gives context on output format beyond annotations. However, it doesn't detail pagination, error conditions, or rate limits, leaving some behavioral aspects unclear.

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?

Two concise sentences that are front-loaded with the core purpose and return value. No wasted words or redundant information, making it efficient and easy to parse.

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 1 parameter with 0% schema coverage, no output schema, and annotations covering safety and idempotency, the description is minimally adequate. It explains what the tool does and returns, but lacks details on parameter usage, output structure, or error handling, which could be important for a list operation with domain filtering.

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

Parameters3/5

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

Schema description coverage is 0%, so the schema only shows a 'domain' parameter with string/null types. The description mentions 'for domain', implying the parameter filters rules by domain, but doesn't specify format (e.g., domain name), default behavior when null, or if it lists all domains. This adds some meaning but doesn't fully compensate for the low coverage.

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 action ('List') and resource ('pattern-based rewrite rules for domain'), and mentions what it returns ('summary with statistics and samples'). It distinguishes from siblings like 'get_rewrite' (singular) and 'create/update/delete_rewrite' (mutations), but doesn't explicitly contrast with 'list_aliases' or 'list_mailboxes' which have similar list functions for different resources.

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 explicit guidance on when to use this tool versus alternatives like 'get_rewrite' (for a specific rule) or other list tools. The description implies usage for viewing rules with statistics, but lacks context on prerequisites, domain filtering, or when not to use it.

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