Skip to main content
Glama

delete_thread

Remove email threads from your Gmail account by specifying the thread ID to permanently delete conversations and manage your inbox.

Instructions

Delete a thread

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe ID of the thread to delete

Implementation Reference

  • src/index.ts:716-727 (registration)
    Registration of the 'delete_thread' tool, including inline handler and input schema (thread ID). Uses shared handleTool for auth and Gmail API call to delete the thread.
    server.tool("delete_thread",
      "Delete a thread",
      {
        id: z.string().describe("The ID of the thread to delete")
      },
      async (params) => {
        return handleTool(config, async (gmail: gmail_v1.Gmail) => {
          const { data } = await gmail.users.threads.delete({ userId: 'me', id: params.id })
          return formatResponse(data)
        })
      }
    )
  • The handler function for delete_thread executes handleTool with Gmail API call to users.threads.delete using the provided thread ID.
    async (params) => {
      return handleTool(config, async (gmail: gmail_v1.Gmail) => {
        const { data } = await gmail.users.threads.delete({ userId: 'me', id: params.id })
        return formatResponse(data)
      })
    }
  • Zod input schema for delete_thread tool requiring a single 'id' parameter (string, thread ID).
    {
      id: z.string().describe("The ID of the thread to delete")
    },
  • Shared helper function handleTool manages OAuth2 authentication, credential validation, Gmail client creation, and error handling (including auth-specific errors) for all Gmail API tool calls.
    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) {
        // Check for specific authentication errors
        if (
          error.message?.includes("invalid_grant") ||
          error.message?.includes("refresh_token") ||
          error.message?.includes("invalid_client") ||
          error.message?.includes("unauthorized_client") ||
          error.code === 401 ||
          error.code === 403
        ) {
          return formatResponse({
            error: `Authentication failed: ${error.message}. Please re-authenticate by running: npx @shinzolabs/gmail-mcp auth`,
          });
        }
    
        return formatResponse({ error: `Tool execution failed: ${error.message}` });
      }
    }
  • Shared helper formatResponse wraps tool results or errors in MCP-compatible content format (JSON stringified).
    const formatResponse = (response: any) => ({ content: [{ type: "text", text: JSON.stringify(response) }] })
Behavior1/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. 'Delete a thread' implies a destructive operation, but it doesn't specify whether this is permanent, requires special permissions, has confirmation prompts, affects related messages, or what happens on success/failure. For a destructive tool with zero annotation coverage, this is critically inadequate.

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 at just three words, with zero wasted language. It's front-loaded with the core action, though this brevity comes at the cost of completeness. Every word earns its place by stating the essential function.

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?

Given this is a destructive operation with no annotations and no output schema, the description is incomplete. It doesn't address critical context like permanence, side effects, error conditions, or return values. The agent lacks sufficient information to use this tool safely and effectively.

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%, with the single parameter 'id' clearly documented in the schema as 'The ID of the thread to delete'. The description adds no additional parameter information beyond what the schema provides, so it meets the baseline score of 3 for adequate schema coverage.

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

Purpose2/5

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

The description 'Delete a thread' is a tautology that merely restates the tool name without adding specificity. It doesn't clarify what type of thread (email thread, chat thread, etc.) or what system this operates on, though sibling tools suggest it's likely for email threads. This provides minimal value beyond the tool name itself.

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 about when to use this tool versus alternatives. With sibling tools like 'trash_thread' and 'untrash_thread' available, the description doesn't explain whether deletion is permanent versus reversible, or when to choose deletion over trashing. The agent must infer usage from context alone.

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/faithk7/gmail-mcp'

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