Skip to main content
Glama

patch_label

Update Gmail label properties like name, visibility, or color settings using partial modifications for better email organization.

Instructions

Patch an existing label (partial update)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe ID of the label to patch
nameNoThe display name of the label
messageListVisibilityNoThe visibility of messages with this label in the message list
labelListVisibilityNoThe visibility of the label in the label list
colorNoThe color settings for the label

Implementation Reference

  • src/index.ts:492-511 (registration)
    Registration of the 'patch_label' MCP tool, including input schema (using Zod) and the handler function that destructures params, calls the shared handleTool helper, which invokes Gmail API's users.labels.patch to partially update the label, and formats the response.
    server.tool("patch_label",
      "Patch an existing label (partial update)",
      {
        id: z.string().describe("The ID of the label to patch"),
        name: z.string().optional().describe("The display name of the label"),
        messageListVisibility: z.enum(['show', 'hide']).optional().describe("The visibility of messages with this label in the message list"),
        labelListVisibility: z.enum(['labelShow', 'labelShowIfUnread', 'labelHide']).optional().describe("The visibility of the label in the label list"),
        color: z.object({
          textColor: z.string().describe("The text color of the label as hex string"),
          backgroundColor: z.string().describe("The background color of the label as hex string")
        }).optional().describe("The color settings for the label")
      },
      async (params) => {
        const { id, ...labelData } = params
        return handleTool(config, async (gmail: gmail_v1.Gmail) => {
          const { data } = await gmail.users.labels.patch({ userId: 'me', id, requestBody: labelData })
          return formatResponse(data)
        })
      }
    )
  • The handler function for 'patch_label' tool: extracts id and labelData from params, uses handleTool to authenticate and call Gmail API patch on labels with the provided data.
    async (params) => {
      const { id, ...labelData } = params
      return handleTool(config, async (gmail: gmail_v1.Gmail) => {
        const { data } = await gmail.users.labels.patch({ userId: 'me', id, requestBody: labelData })
        return formatResponse(data)
      })
    }
  • Zod schema for 'patch_label' tool inputs: required id, optional name, visibilities, and color object.
    id: z.string().describe("The ID of the label to patch"),
    name: z.string().optional().describe("The display name of the label"),
    messageListVisibility: z.enum(['show', 'hide']).optional().describe("The visibility of messages with this label in the message list"),
    labelListVisibility: z.enum(['labelShow', 'labelShowIfUnread', 'labelHide']).optional().describe("The visibility of the label in the label list"),
    color: z.object({
      textColor: z.string().describe("The text color of the label as hex string"),
      backgroundColor: z.string().describe("The background color of the label as hex string")
    }).optional().describe("The color settings for the label")
  • Shared 'handleTool' helper function used by 'patch_label' and all other tools: handles OAuth2 client creation/validation, Gmail client setup, executes the provided API callback, and manages auth errors with formatted responses.
    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}` });
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states 'patch' and 'partial update', implying a mutation operation, but doesn't disclose behavioral traits like required permissions, whether changes are reversible, error handling, or rate limits. For a mutation tool with zero annotation coverage, this is a significant gap in safety and operational context.

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 with zero waste. It's front-loaded with the core action and resource, and 'partial update' adds necessary clarification without redundancy. Every word earns its place, making it easy to parse quickly.

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 complexity (5 parameters with nested objects, mutation operation) and no annotations or output schema, the description is incomplete. It lacks behavioral context (e.g., permissions, side effects), usage guidelines versus siblings, and any mention of return values or errors. For a patch tool in a rich API context, this leaves critical gaps for an agent.

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 detailed descriptions for all parameters including enums and nested objects. The description adds no parameter semantics beyond what the schema provides—it doesn't explain relationships between parameters or usage examples. Baseline 3 is appropriate as the schema does the heavy lifting, but no extra value is added.

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 ('Patch') and resource ('an existing label'), with 'partial update' clarifying it's not a full replacement. It distinguishes from 'update_label' (likely full update) and 'create_label' among siblings, though not explicitly. However, it doesn't specify what fields can be patched, leaving some ambiguity.

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 like 'update_label' (which appears in siblings) or 'create_label'. The description implies it's for partial updates, but doesn't state prerequisites (e.g., needing label ID) or exclusions. Usage is inferred from the name and context, not explicitly defined.

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