get_rewrite
Retrieve detailed configuration of rewrite rules for email domains using the rule name/slug. Essential for managing email routing and automation in Migadu MCP Server.
Instructions
Get detailed rewrite rule configuration. Requires rule name/slug.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domain | No | ||
| name | Yes |
Implementation Reference
- migadu_mcp/tools/rewrite_tools.py:67-92 (handler)The primary handler function implementing the logic for the 'get_rewrite' MCP tool, including parameter handling, logging, service delegation, and error management.async def get_rewrite( name: str, ctx: Context, domain: str | None = None ) -> Dict[str, Any]: """Get detailed rewrite rule configuration. Requires rule name/slug.""" 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") try: await log_operation_start( ctx, "Retrieving rewrite rule details", f"{name}@{domain}" ) service = get_service_factory().rewrite_service() result = await service.get_rewrite(domain, name) await log_operation_success( ctx, "Retrieved rewrite rule details", f"{name}@{domain}" ) return result except Exception as e: await log_operation_error(ctx, "Get rewrite", f"{name}@{domain}", str(e)) raise
- migadu_mcp/main.py:24-24 (registration)The call to register_rewrite_tools which registers the 'get_rewrite' tool (and other rewrite tools) with the FastMCP instance.register_rewrite_tools(mcp)
- Helper service method that performs the actual Migadu API request to fetch the rewrite rule details.async def get_rewrite(self, domain: str, name: str) -> Dict[str, Any]: """Get details of a specific rewrite""" return await self.client.request("GET", f"/domains/{domain}/rewrites/{name}")
- migadu_mcp/tools/rewrite_tools.py:60-66 (registration)The @mcp.tool decorator that registers the get_rewrite function as an MCP tool.@mcp.tool( annotations={ "readOnlyHint": True, "idempotentHint": True, "openWorldHint": True, }, )
- The specific call to the rewrite service's get_rewrite method within the tool handler.service = get_service_factory().rewrite_service() result = await service.get_rewrite(domain, name) await log_operation_success( ctx, "Retrieved rewrite rule details", f"{name}@{domain}" ) return result except Exception as e: await log_operation_error(ctx, "Get rewrite", f"{name}@{domain}", str(e)) raise