list_aliases
Retrieve and analyze email aliases for a specified domain, including summaries and statistics, using the Migadu MCP Server management tool.
Instructions
List email aliases for domain. Returns summary with statistics and samples.
Args: domain: Domain name. Uses MIGADU_DOMAIN if not provided.
Returns: JSON object with alias summary and statistics
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domain | No |
Input Schema (JSON Schema)
{
"properties": {
"domain": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Domain"
}
},
"type": "object"
}
Implementation Reference
- migadu_mcp/tools/alias_tools.py:32-66 (handler)The core handler function for the 'list_aliases' MCP tool. It handles the tool invocation, resolves the domain if not provided, calls the alias service, logs the operation, and returns the result.@mcp.tool( annotations={ "readOnlyHint": True, "idempotentHint": True, "openWorldHint": True, }, ) @with_context_protection(max_tokens=2000) async def list_aliases(ctx: Context, domain: str | None = None) -> Dict[str, Any]: """List email aliases for domain. Returns summary with statistics and samples. Args: domain: Domain name. Uses MIGADU_DOMAIN if not provided. Returns: JSON object with alias summary and statistics """ 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 aliases", domain) try: service = get_service_factory().alias_service() result = await service.list_aliases(domain) count = len(result.get("aliases", [])) await log_operation_success(ctx, "Listed aliases", domain, count) return result except Exception as e: await log_operation_error(ctx, "List aliases", domain, str(e)) raise
- migadu_mcp/main.py:9-23 (registration)Registration of the alias tools module, which includes the 'list_aliases' tool, called during server initialization.from migadu_mcp.tools.alias_tools import register_alias_tools from migadu_mcp.tools.rewrite_tools import register_rewrite_tools from migadu_mcp.tools.resource_tools import register_resources # Initialize FastMCP server mcp: FastMCP = FastMCP("Migadu Mailbox Manager") def initialize_server(): """Initialize the MCP server with all tools and resources""" # Register all tools register_mailbox_tools(mcp) register_identity_tools(mcp) register_alias_tools(mcp)
- Helper service method that performs the actual API call to list aliases for a given domain.async def list_aliases(self, domain: str) -> Dict[str, Any]: """List all aliases for a domain""" return await self.client.request("GET", f"/domains/{domain}/aliases")
- The registration function that defines and registers the list_aliases tool with the MCP server.def register_alias_tools(mcp: FastMCP): """Register alias tools using List[Dict] + iterator pattern""" @mcp.tool( annotations={ "readOnlyHint": True, "idempotentHint": True, "openWorldHint": True, }, ) @with_context_protection(max_tokens=2000) async def list_aliases(ctx: Context, domain: str | None = None) -> Dict[str, Any]: """List email aliases for domain. Returns summary with statistics and samples. Args: domain: Domain name. Uses MIGADU_DOMAIN if not provided. Returns: JSON object with alias summary and statistics """ 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 aliases", domain) try: service = get_service_factory().alias_service() result = await service.list_aliases(domain) count = len(result.get("aliases", [])) await log_operation_success(ctx, "Listed aliases", domain, count) return result except Exception as e: await log_operation_error(ctx, "List aliases", domain, str(e)) raise