watch_mailbox
Monitor Gmail mailbox for new emails and changes, sending notifications to a specified Pub/Sub topic when updates occur.
Instructions
Watch for changes to the user's mailbox
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| topicName | Yes | The name of the Cloud Pub/Sub topic to publish notifications to | |
| labelIds | No | Label IDs to restrict notifications to | |
| labelFilterAction | No | Whether to include or exclude the specified labels |
Implementation Reference
- src/index.ts:1300-1313 (registration)Registration of the 'watch_mailbox' tool, including input schema and handler implementation. The handler uses the Gmail API's users.watch method to watch the mailbox for changes and publish notifications to a specified Cloud Pub/Sub topic.server.tool("watch_mailbox", "Watch for changes to the user's mailbox", { topicName: z.string().describe("The name of the Cloud Pub/Sub topic to publish notifications to"), labelIds: z.array(z.string()).optional().describe("Label IDs to restrict notifications to"), labelFilterAction: z.enum(['include', 'exclude']).optional().describe("Whether to include or exclude the specified labels") }, async (params) => { return handleTool(config, async (gmail: gmail_v1.Gmail) => { const { data } = await gmail.users.watch({ userId: 'me', requestBody: params }) return formatResponse(data) }) } )
- src/index.ts:1303-1306 (schema)Input schema for the watch_mailbox tool defining parameters for Pub/Sub topic and label filtering.topicName: z.string().describe("The name of the Cloud Pub/Sub topic to publish notifications to"), labelIds: z.array(z.string()).optional().describe("Label IDs to restrict notifications to"), labelFilterAction: z.enum(['include', 'exclude']).optional().describe("Whether to include or exclude the specified labels") },
- src/index.ts:1307-1312 (handler)Handler function for watch_mailbox tool that authenticates via handleTool and calls Gmail API users.watch to set up mailbox watching.async (params) => { return handleTool(config, async (gmail: gmail_v1.Gmail) => { const { data } = await gmail.users.watch({ userId: 'me', requestBody: params }) return formatResponse(data) }) }