Skip to main content
Glama

delete_message

Permanently remove unwanted emails from Gmail by specifying the message ID to delete messages and free up storage space.

Instructions

Immediately and permanently delete a message

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe ID of the message to delete

Implementation Reference

  • src/index.ts:548-558 (registration)
    Registration of the 'delete_message' MCP tool, including schema definition and inline handler function that deletes a Gmail message by ID using the Gmail API.
    server.tool("delete_message",
      "Immediately and permanently delete a message",
      {
        id: z.string().describe("The ID of the message to delete")
      },
      async (params) => {
        return handleTool(config, async (gmail: gmail_v1.Gmail) => {
          const { data } = await gmail.users.messages.delete({ userId: 'me', id: params.id })
          return formatResponse(data)
        })
      }
  • Handler function for the delete_message tool. It invokes handleTool with the Gmail client to call users.messages.delete API endpoint.
    async (params) => {
      return handleTool(config, async (gmail: gmail_v1.Gmail) => {
        const { data } = await gmail.users.messages.delete({ userId: 'me', id: params.id })
        return formatResponse(data)
      })
    }
  • Input schema for delete_message tool: requires 'id' parameter as a string representing the Gmail message ID.
    {
      id: z.string().describe("The ID of the message to delete")
    },
  • Shared helper function handleTool used by delete_message (and other tools) to manage OAuth2 authentication, create Gmail client, and execute the API call.
    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}`
      }
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively communicates that this is a destructive operation ('permanently delete') with immediate effect, which is crucial context. However, it doesn't mention error conditions, permissions required, or what happens if the message doesn't exist - leaving some behavioral gaps.

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 a single, efficient sentence that front-loads the most critical information ('immediately and permanently delete'). Every word earns its place, with no wasted verbiage or redundant information.

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

Completeness3/5

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

For a destructive operation with no annotations and no output schema, the description provides adequate but incomplete context. It clearly communicates the irreversible nature of the action, which is the most critical information, but lacks details about error handling, return values, or permissions - leaving the agent with some uncertainty about how to handle edge cases.

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?

The schema has 100% description coverage, with the single parameter 'id' clearly documented in the schema. The description doesn't add any additional parameter context beyond what's already in the schema, so it meets the baseline of 3 for high schema coverage without adding extra value.

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

Purpose5/5

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

The description clearly states the specific action ('delete'), resource ('message'), and key behavioral traits ('immediately and permanently'). It distinguishes from sibling tools like 'trash_message' (which likely moves to trash) and 'batch_delete_messages' (which handles multiple messages).

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?

The description provides no guidance on when to use this tool versus alternatives like 'trash_message' or 'batch_delete_messages'. It doesn't mention prerequisites, permissions needed, or any context for choosing this specific deletion method over other options available in the sibling tool list.

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