get_latest_email
Retrieve the most recent full email from a temporary inbox to access verification codes and confirmation links without manual intervention.
Instructions
Read and return the latest full email in an inbox.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| inbox_id | Yes | ||
| mark_as_read | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The core logic for the get_latest_email tool, which fetches and reads the latest email from an inbox.
async def run( api: ApiClient, inbox_id: str, mark_as_read: bool = False, ) -> dict[str, Any]: if not inbox_id: return tool_error("validation_error", 400, "inbox_id is required") try: messages = await api.list_messages(inbox_id, limit=1, offset=0) except ApiClientError as exc: return exc.to_dict() if not messages: return tool_error("no_messages", 404, "No messages found for inbox") latest = messages[0] message_id = str(latest.get("id") or "") if not message_id: return tool_error("invalid_response", 502, "Missing message id in API response") try: full_message = await api.read_message(inbox_id, message_id) except ApiClientError as exc: return exc.to_dict() return { "message_id": str(full_message.get("id") or message_id), "subject": full_message.get("subject"), "from_address": full_message.get("from_address"), "received_at": full_message.get("received_at"), "body_text": full_message.get("body_text"), "body_html": full_message.get("body_html"), "has_attachments": bool(full_message.get("attachments")), # API read_message marks messages as read; this side effect is always true. "marked_as_read": True, "mark_as_read_requested": mark_as_read, } - src/uncorreotemporal_mcp/server.py:158-170 (registration)The registration of the get_latest_email tool in the MCP server, which wraps the execution logic.
@mcp.tool(description="Read and return the latest full email in an inbox.") async def get_latest_email( inbox_id: str, mark_as_read: bool = False, ) -> dict[str, Any]: api_key = _get_api_key() if not api_key: return _unauthorized() try: async with ApiClient(api_key=api_key) as api: return await get_latest_email_tool.run( api=api, inbox_id=inbox_id,