Skip to main content
Glama

create_label

Create a new Gmail label to organize emails by specifying name, visibility settings, and color customization for improved inbox management.

Instructions

Create a new label

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesThe 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:403-420 (registration)
    Registration of the 'create_label' tool on the MCP server, including schema definition and handler function.
    server.tool("create_label",
      "Create a new label",
      {
        name: z.string().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) => {
        return handleTool(config, async (gmail: gmail_v1.Gmail) => {
          const { data } = await gmail.users.labels.create({ userId: 'me', requestBody: params })
          return formatResponse(data)
        })
      }
    )
  • Handler function that invokes the Gmail API to create a new label using the provided parameters, wrapped in handleTool for authentication.
    async (params) => {
      return handleTool(config, async (gmail: gmail_v1.Gmail) => {
        const { data } = await gmail.users.labels.create({ userId: 'me', requestBody: params })
        return formatResponse(data)
      })
    }
  • Input schema for the create_label tool using Zod validation for parameters like name, visibilities, and optional color.
      name: z.string().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")
    },
  • Helper function handleTool that manages OAuth2 authentication, validates credentials, creates Gmail client, and executes 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}`
      }
    }
  • Helper function to format API responses into MCP content structure.
    const formatResponse = (response: any) => ({ content: [{ type: "text", text: JSON.stringify(response) }] })
Behavior2/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. 'Create a new label' implies a write operation but provides no information about permissions required, rate limits, error conditions, or what happens on success (e.g., returns the created label object). This is inadequate for a mutation tool with zero annotation coverage.

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 - just three words that directly state the tool's purpose. There's no wasted language or unnecessary elaboration, making it perfectly front-loaded and efficient.

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 mutation tool with no annotations and no output schema, the description is insufficient. It doesn't explain what the tool returns, what permissions are needed, or how it differs from similar tools. The 100% schema coverage helps with parameters, but overall context is lacking.

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 description coverage is 100%, so the schema already fully documents all 4 parameters. The description adds no parameter information beyond what's in the schema, so it meets the baseline expectation but doesn't provide additional value.

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 ('Create') and resource ('a new label'), making the purpose immediately understandable. However, it doesn't differentiate this tool from sibling tools like 'patch_label' or 'update_label', which also modify labels, so it doesn't reach the highest clarity level.

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. There are sibling tools like 'patch_label' and 'update_label' that also modify labels, but the description doesn't explain when creation is appropriate versus updating existing labels.

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

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