read_email
Retrieve the content of a specific email using its message ID. Optionally specify an inbox ID to narrow the search.
Instructions
Read a specific email message. If inbox_id is omitted, uses the default inbox.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| inbox_id | No | Inbox ID (optional, uses default inbox) | |
| message_id | Yes | Message ID |
Implementation Reference
- mcp/index.js:229-237 (handler)The handler function that executes the read_email tool logic: resolves the inbox (default if omitted), then calls the API GET endpoint to fetch a specific email message by message_id.
async ({ inbox_id, message_id }) => { if (!inbox_id) { const inbox = await getOrCreateDefaultInbox(); if (inbox.error) return { content: [{ type: 'text', text: JSON.stringify(inbox, null, 2) }] }; inbox_id = inboxId(inbox); } const result = await api('GET', `/v1/inboxes/${inbox_id}/messages/${message_id}`); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; } - mcp/index.js:222-238 (registration)Registration of the 'read_email' tool on the MCP server via server.tool(), including its description and parameter schema.
server.tool( 'read_email', 'Read a specific email message. If inbox_id is omitted, uses the default inbox.', { inbox_id: idSchema.optional().describe('Inbox ID (optional, uses default inbox)'), message_id: idSchema.describe('Message ID') }, async ({ inbox_id, message_id }) => { if (!inbox_id) { const inbox = await getOrCreateDefaultInbox(); if (inbox.error) return { content: [{ type: 'text', text: JSON.stringify(inbox, null, 2) }] }; inbox_id = inboxId(inbox); } const result = await api('GET', `/v1/inboxes/${inbox_id}/messages/${message_id}`); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; } ); - mcp/index.js:26-33 (schema)The idSchema used for inbox_id and message_id parameters in read_email. Accepts numbers or numeric strings.
const idSchema = z.union([ z.number(), z.string().transform((v) => { const n = Number(v); if (isNaN(n)) throw new Error(`Invalid ID: ${v}`); return n; }) ]).describe('ID (number or numeric string)'); - mcp/index.js:140-142 (helper)Helper function used by the read_email handler to extract the inbox ID from an inbox object.
function inboxId(inbox) { return inbox?.id || inbox?.inbox_id; } - mcp/index.js:128-138 (helper)Helper function used by the read_email handler to get or prompt creation of a default inbox when inbox_id is not provided.
async function getOrCreateDefaultInbox() { const inbox = await getDefaultInbox(); if (inbox) return inbox; if (inbox?.error) return inbox; return { error: 'NO_INBOX', message: 'You don\'t have an email inbox yet! Let\'s set one up first.', action: 'Ask the user what name they want for their email address, then call my_email(preferred_name: "theirname") to create it. For example: jarvis@clawaimail.com, assistant@clawaimail.com, etc.', hint: 'The user can choose any name — if it\'s taken, a similar alternative will be suggested.' }; }