Skip to main content
Glama

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
NameRequiredDescriptionDefault
topicNameYesThe name of the Cloud Pub/Sub topic to publish notifications to
labelIdsNoLabel IDs to restrict notifications to
labelFilterActionNoWhether 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) }) } )
  • 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") },
  • 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) }) }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/nk900600/gmail-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server