Skip to main content
Glama

batch_delete_messages

Delete multiple Gmail messages at once by specifying their IDs to manage your inbox efficiently.

Instructions

Delete multiple messages

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idsYesThe IDs of the messages to delete

Implementation Reference

  • The handler function that executes the batch deletion of multiple Gmail messages by calling the Gmail API's batchDelete method with the provided message IDs.
    async (params) => {
      return handleTool(config, async (gmail: gmail_v1.Gmail) => {
        const { data } = await gmail.users.messages.batchDelete({ userId: 'me', requestBody: { ids: params.ids } })
        return formatResponse(data)
      })
    }
  • Input schema validation using Zod for the tool, requiring an array of string message IDs.
    {
      ids: z.array(z.string()).describe("The IDs of the messages to delete")
    },
  • src/index.ts:520-531 (registration)
    MCP server tool registration for 'batch_delete_messages', including description, input schema, and inline handler function.
    server.tool("batch_delete_messages",
      "Delete multiple messages",
      {
        ids: z.array(z.string()).describe("The IDs of the messages to delete")
      },
      async (params) => {
        return handleTool(config, async (gmail: gmail_v1.Gmail) => {
          const { data } = await gmail.users.messages.batchDelete({ userId: 'me', requestBody: { ids: params.ids } })
          return formatResponse(data)
        })
      }
    )
  • Shared helper function used by all Gmail tools to handle OAuth2 authentication, client creation, and execution of the API call with error handling.
    const handleTool = async (queryConfig: Record<string, any> | undefined, apiCall: (gmail: gmail_v1.Gmail) => Promise<any>) => {
      try {
        const oauth2Client = queryConfig ? createOAuth2Client(queryConfig) : defaultOAuth2Client
        if (!oauth2Client) throw new Error('OAuth2 client could not be created, please check your credentials')
    
        const credentialsAreValid = await validateCredentials(oauth2Client)
        if (!credentialsAreValid) throw new Error('OAuth2 credentials are invalid, please re-authenticate')
    
        const gmailClient = queryConfig ? google.gmail({ version: 'v1', auth: oauth2Client }) : defaultGmailClient
        if (!gmailClient) throw new Error('Gmail client could not be created, please check your credentials')
    
        const result = await apiCall(gmailClient)
        return result
      } catch (error: any) {
        return `Tool execution failed: ${error.message}`
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only states the action without behavioral details. It does not disclose if deletion is permanent or reversible, permission requirements, rate limits, error handling, or what happens to associated data. This is inadequate for a destructive operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise with just three words, front-loading the key action and target. There is no wasted language, making it efficient for quick understanding, though this brevity contributes to gaps in other dimensions.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive tool with no annotations and no output schema, the description is incomplete. It lacks critical context such as the permanence of deletion, success/failure indicators, or how it differs from sibling tools like 'trash_message'. This leaves significant gaps for safe and effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents the 'ids' parameter. The description adds no additional meaning beyond implying multiple IDs are needed, which is already clear from the schema. Baseline score of 3 is appropriate as the schema handles parameter documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Delete') and target ('multiple messages'), which is specific and unambiguous. However, it does not explicitly differentiate from its sibling 'delete_message' (singular deletion), missing an opportunity to clarify the batch nature versus individual deletion.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like 'delete_message' or 'trash_message'. The description lacks context about prerequisites, such as needing message IDs, or when batch deletion is preferred over other methods.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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