update_identity
Modify identity settings for mailboxes in Migadu email hosting. Specify parameters like domain, name, may_send, and may_receive to update mailbox configurations.
Instructions
Update identity settings. List of dicts with: target, mailbox (required), domain, name, may_send, may_receive (optional).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| updates | Yes |
Input Schema (JSON Schema)
{
"properties": {
"updates": {
"items": {
"additionalProperties": true,
"type": "object"
},
"title": "Updates",
"type": "array"
}
},
"required": [
"updates"
],
"type": "object"
}
Implementation Reference
- The primary handler function for the 'update_identity' MCP tool. It processes a list of updates using the bulk processor and logs the operation.@mcp.tool( annotations={ "readOnlyHint": False, "destructiveHint": False, "idempotentHint": True, "openWorldHint": True, }, ) async def update_identity( updates: List[Dict[str, Any]], ctx: Context ) -> Dict[str, Any]: """Update identity settings. List of dicts with: target, mailbox (required), domain, name, may_send, may_receive (optional).""" count = len(list(ensure_iterable(updates))) await log_bulk_operation_start(ctx, "Updating", count, "identity") result = await process_update_identity(updates, ctx) await log_bulk_operation_result(ctx, "Identity update", result, "identity") return result
- Helper function that processes individual identity updates after schema validation, calls the identity service, and handles logging.@bulk_processor_with_schema(IdentityUpdateRequest) async def process_update_identity( validated_item: IdentityUpdateRequest, ctx: Context ) -> Dict[str, Any]: """Process a single identity update""" # Get domain if not provided domain = validated_item.domain 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") email_address = format_email_address(domain, validated_item.target) await log_operation_start(ctx, "Updating identity", email_address) service = get_service_factory().identity_service() result = await service.update_identity( domain, validated_item.mailbox, validated_item.target, validated_item.name, validated_item.may_send, validated_item.may_receive, ) await log_operation_success(ctx, "Updated identity", email_address) return {"identity": result, "email_address": email_address, "success": True}
- migadu_mcp/utils/schemas.py:199-222 (schema)Pydantic schema used for validating input parameters to the update_identity tool via the bulk_processor_with_schema decorator.class IdentityUpdateRequest(BaseModel): """Request schema for updating an identity""" target: str = Field(..., description="Local part of identity address") mailbox: str = Field(..., description="Username of mailbox that owns this identity") domain: Optional[str] = Field(None, description="Domain name") name: Optional[str] = Field(None, description="Update display name") may_send: Optional[bool] = Field( None, description="Allow/deny sending from identity" ) may_receive: Optional[bool] = Field( None, description="Allow/deny receiving to identity" ) may_access_imap: Optional[bool] = Field(None, description="Allow/deny IMAP access") may_access_pop3: Optional[bool] = Field(None, description="Allow/deny POP3 access") may_access_managesieve: Optional[bool] = Field( None, description="Allow/deny ManageSieve access" ) footer_active: Optional[bool] = Field(None, description="Enable/disable footer") footer_plain_body: Optional[str] = Field( None, description="Plain text footer content" ) footer_html_body: Optional[str] = Field(None, description="HTML footer content")
- migadu_mcp/main.py:22-22 (registration)Registration of all identity tools, including 'update_identity', by calling the register_identity_tools function during MCP server initialization.register_identity_tools(mcp)
- Underlying service method that makes the actual Migadu API PUT request to update the identity settings.async def update_identity( self, domain: str, mailbox: str, identity: str, name: Optional[str] = None, may_send: Optional[bool] = None, may_receive: Optional[bool] = None, ) -> Dict[str, Any]: """Update identity settings""" data: Dict[str, Any] = {} if name is not None: data["name"] = name if may_send is not None: data["may_send"] = may_send if may_receive is not None: data["may_receive"] = may_receive return await self.client.request( "PUT", f"/domains/{domain}/mailboxes/{mailbox}/identities/{identity}", json=data, )