Skip to main content
Glama

list_drafts

List email drafts from your Gmail mailbox using optional search queries, spam/trash filters, and result limits.

Instructions

List drafts in the user's mailbox

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
maxResultsNoMaximum number of drafts to return. Accepts values between 1-500
qNoOnly return drafts matching the specified query. Supports the same query format as the Gmail search box
includeSpamTrashNoInclude drafts from SPAM and TRASH in the results
includeBodyHtmlNoWhether to include the parsed HTML in the return for each body, excluded by default because they can be excessively large

Implementation Reference

  • src/index.ts:333-369 (registration)
    Registration of the 'list_drafts' tool via server.tool() with Zod schema for input parameters (maxResults, q, includeSpamTrash, includeBodyHtml). The handler calls Gmail API's users.drafts.list, paginates through all results, and optionally processes message parts.
    server.tool("list_drafts",
      "List drafts in the user's mailbox",
      {
        maxResults: z.number().optional().describe("Maximum number of drafts to return. Accepts values between 1-500"),
        q: z.string().optional().describe("Only return drafts matching the specified query. Supports the same query format as the Gmail search box"),
        includeSpamTrash: z.boolean().optional().describe("Include drafts from SPAM and TRASH in the results"),
        includeBodyHtml: z.boolean().optional().describe("Whether to include the parsed HTML in the return for each body, excluded by default because they can be excessively large"),
      },
      async (params) => {
        return handleTool(config, async (gmail: gmail_v1.Gmail) => {
          let drafts: Draft[] = []
    
          const { data } = await gmail.users.drafts.list({ userId: 'me', ...params })
    
          drafts.push(...data.drafts || [])
    
          while (data.nextPageToken) {
            const { data: nextData } = await gmail.users.drafts.list({ userId: 'me', ...params, pageToken: data.nextPageToken })
            drafts.push(...nextData.drafts || [])
          }
    
          if (drafts) {
            drafts = drafts.map(draft => {
              if (draft.message?.payload) {
                draft.message.payload = processMessagePart(
                  draft.message.payload,
                  params.includeBodyHtml
                )
              }
              return draft
            })
          }
    
          return formatResponse(drafts)
        })
      }
    )
  • Handler function that executes the list_drafts logic: calls Gmail API, paginates through drafts, optionally processes message parts, and returns formatted response.
      async (params) => {
        return handleTool(config, async (gmail: gmail_v1.Gmail) => {
          let drafts: Draft[] = []
    
          const { data } = await gmail.users.drafts.list({ userId: 'me', ...params })
    
          drafts.push(...data.drafts || [])
    
          while (data.nextPageToken) {
            const { data: nextData } = await gmail.users.drafts.list({ userId: 'me', ...params, pageToken: data.nextPageToken })
            drafts.push(...nextData.drafts || [])
          }
    
          if (drafts) {
            drafts = drafts.map(draft => {
              if (draft.message?.payload) {
                draft.message.payload = processMessagePart(
                  draft.message.payload,
                  params.includeBodyHtml
                )
              }
              return draft
            })
          }
    
          return formatResponse(drafts)
        })
      }
    )
  • Zod schema defining the input parameters for the list_drafts tool.
    {
      maxResults: z.number().optional().describe("Maximum number of drafts to return. Accepts values between 1-500"),
      q: z.string().optional().describe("Only return drafts matching the specified query. Supports the same query format as the Gmail search box"),
      includeSpamTrash: z.boolean().optional().describe("Include drafts from SPAM and TRASH in the results"),
      includeBodyHtml: z.boolean().optional().describe("Whether to include the parsed HTML in the return for each body, excluded by default because they can be excessively large"),
    },
Behavior2/5

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

No annotations are present, so the description must bear the full burden. It fails to disclose any behavioral traits (e.g., read-only nature, response structure, pagination). The agent cannot infer safety or side effects.

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

Conciseness4/5

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

The description is a single sentence that efficiently communicates the tool's purpose. It is front-loaded and contains no unnecessary information, though it could benefit from additional context.

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?

With 4 optional parameters, no output schema, and no annotations, the description is incomplete. It does not explain how to effectively use parameters like 'q' or 'includeBodyHtml', nor the expected return format.

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 input schema has 100% description coverage for all 4 parameters, so the baseline is 3. The tool description adds no additional meaning beyond what the schema already provides.

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 'List drafts in the user's mailbox' with a specific verb and resource. It distinguishes from sibling tools like list_messages by targeting drafts, though it could be more explicit about scope.

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 on when to use this tool versus alternatives (e.g., get_draft, list_messages). No exclusions or context provided, leaving the agent without decision support.

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

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