get_email
Fetch a specific Gmail email by providing its message ID. Get full message content and metadata.
Instructions
Read one Gmail message by messageId.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| messageId | Yes | Gmail message id. |
Implementation Reference
- src/gmail.ts:113-122 (handler)Handler function that fetches a full Gmail message by ID using format 'full' and converts it to EmailDetail.
export async function getEmail(messageId: string): Promise<EmailDetail> { const gmail = await getGmailClient(); const response = await gmail.users.messages.get({ userId: USER_ID, id: messageId, format: "full", }); return toEmailDetail(response.data); } - src/gmail.ts:18-30 (schema)Schema/type definition for the EmailDetail return type of getEmail.
export type EmailDetail = EmailSummary & { cc?: string; bcc?: string; bodyText?: string; bodyHtml?: string; attachments: Array<{ filename: string; mimeType?: string | null; attachmentId?: string; size?: number | null; }>; internalDate?: string | null; }; - src/index.ts:36-43 (registration)Registration of the 'get_email' tool with the MCP server, including its Zod schema for messageId input.
server.tool( "get_email", "Read one Gmail message by messageId.", { messageId: z.string().min(1).describe("Gmail message id."), }, async ({ messageId }) => jsonResult(await getEmail(messageId)), );