read_email
Retrieve complete email content from your Gmail inbox by providing the message ID, enabling you to access and review full messages through Claude Desktop.
Instructions
Read the full content of an email
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| messageId | Yes | Email message ID |
Implementation Reference
- src/tools.ts:73-78 (handler)The handler function in handleToolCall that processes the read_email tool call, validates input, fetches the email via GmailService, and formats the response.case "read_email": { const v = validated as z.infer<typeof schemas.read_email>; const email = await gmailService.readEmail(v.messageId); return { content: [{ type: "text", text: `Subject: ${email.subject}\nFrom: ${email.from}\nTo: ${email.to}\nDate: ${email.date}\nThread ID: ${email.threadId}\nGmail URL: ${gmailService.getEmailUrl(v.messageId)}\n\nContent:\n${email.body}` }] }; }
- src/gmail-service.ts:56-70 (helper)Core GmailService method that fetches and parses the full email details using the Gmail API.async readEmail(messageId: string): Promise<EmailDetails> { const { data } = await this.gmail.users.messages.get({ userId: 'me', id: messageId, format: 'full' }); const h = data.payload?.headers || []; const findHeader = (name: string) => h.find(x => x.name?.toLowerCase() === name.toLowerCase())?.value || ''; return { id: messageId, threadId: data.threadId || '', subject: findHeader('subject'), from: findHeader('from'), to: findHeader('to'), date: findHeader('date'), body: this.extractBody(data.payload) }; }
- src/tools.ts:10-10 (schema)Zod schema defining the input for the read_email tool: requires a messageId string.read_email: z.object({ messageId: z.string().describe("Email message ID") }),
- src/tools.ts:50-55 (registration)Function that generates tool definitions for all tools including read_email, used for MCP registration.export const getToolDefinitions = () => Object.entries(schemas).map(([name, schema]) => ({ name, description: toolDescriptions[name], inputSchema: zodToJsonSchema(schema) }));