Skip to main content
Glama
YimingYAN

gmail-labels-mcp-server

by YimingYAN

Gmail Labels MCP Server

An MCP server for Gmail label management. Fills the gap in the official Gmail MCP connector, which lacks label/tag operations.

Handles OAuth2 automatically — authenticate once, and the server refreshes tokens forever.

Tools

Tool

Description

gmail_list_labels

List all labels with IDs, names, and message counts

gmail_create_label

Create a new label (supports nesting with /)

gmail_delete_label

Delete a user-created label

gmail_get_message_labels

Get current labels on a specific message

gmail_modify_message_labels

Add/remove labels on a specific message

gmail_modify_thread_labels

Add/remove labels on an entire thread

gmail_bulk_label_by_search

Search messages and bulk apply label changes

Related MCP server: Gmail MCP Server

Setup

1. Create a Google Cloud project and enable the Gmail API

  1. Go to the Google Cloud Console

  2. Create a new project (or select an existing one)

  3. Navigate to APIs & Services > Library

  4. Search for Gmail API and click Enable

2. Create OAuth2 credentials

  1. Go to APIs & Services > Credentials

  2. Click Create Credentials > OAuth Client ID

  3. If prompted, configure the OAuth consent screen first:

    • Choose External user type (or Internal if using Google Workspace)

    • Fill in the app name (e.g. "Gmail Labels MCP") and your email

    • Add the scope https://mail.google.com/

    • Add your email as a test user

    • Save and go back to creating credentials

  4. Select Desktop app as the application type

  5. Give it a name (e.g. "Gmail Labels MCP")

  6. Click Create and copy the Client ID and Client Secret

3. Install and authenticate

Option A: Install from npm (recommended)

npm install -g gmail-labels-mcp-server
GOOGLE_CLIENT_ID=your_client_id GOOGLE_CLIENT_SECRET=your_client_secret gmail-labels-mcp-server --auth

Option B: Clone and build from source

git clone https://github.com/YimingYAN/gmail-labels-mcp-server.git
cd gmail-labels-mcp-server
npm install && npm run build
GOOGLE_CLIENT_ID=your_client_id GOOGLE_CLIENT_SECRET=your_client_secret npm run auth

This opens a browser for Google consent. Approve Gmail access, and credentials are saved to ~/.gmail-labels-mcp/credentials.json. You only need to do this once.

4. Configure your client

Claude Code

claude mcp add gmail-labels -- npx gmail-labels-mcp-server

Or if installed from source:

claude mcp add gmail-labels -- node /path/to/gmail-labels-mcp-server/dist/index.js

Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "gmail-labels": {
      "command": "npx",
      "args": ["gmail-labels-mcp-server"]
    }
  }
}

No env vars needed — the server reads credentials from ~/.gmail-labels-mcp/credentials.json and auto-refreshes tokens.

Example Usage

  • "List all my Gmail labels"

  • "Create a label called 'Crypto/Compliance'"

  • "Tag message [id] with the Finance label"

  • "Mark message [id] as read" (removes UNREAD label)

  • "Archive all emails from newsletter@example.com"

  • "Star message [id]" (adds STARRED label)

  • "What labels does message [id] currently have?"

Notes

  • System label IDs: INBOX, SENT, TRASH, SPAM, STARRED, IMPORTANT, UNREAD

  • User label IDs follow the format Label_XXXXXXXXXX

  • Use gmail_list_labels first to discover label IDs before modifying messages

  • "Mark as read" = remove UNREAD label; "Mark as unread" = add UNREAD label

  • To re-authenticate: delete ~/.gmail-labels-mcp/credentials.json and re-run the auth step

License

MIT

Available Tools

7 tools
gmail_create_labelCreate Gmail LabelA

Create a new user label (tag) in Gmail.

Args:

  • name (string): Label name. Supports nesting with "/" (e.g., "Finance/Invoices")

Returns: The created label with its ID, name, and visibility settings.

Examples:

  • Use when: "Create a label called 'Compliance'"

  • Use when: "Add a new Gmail tag 'Projects/Alpha'"

ParametersJSON Schema
NameRequiredDescriptionDefault
nameYesLabel name, supports nesting with '/' (e.g. 'Finance/Invoices')

TDQS

A4/5.0
Behavior3/5

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

Annotations already indicate a non-read-only, non-idempotent operation. The description adds the return value (ID, name, visibility settings) and nesting behavior, but does not disclose potential duplicate handling or error cases. This adds some context but is not extensive.

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 compact and well-structured with distinct sections for Args, Returns, and Examples. Every line serves a purpose and there is no redundant content.

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

Completeness4/5

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

For a simple one-parameter creation tool, the description is sufficiently complete: it explains what it does, when to use it, the return value, and includes examples. No significant gaps are apparent.

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 already covers the single 'name' parameter with the same nesting description (100% coverage). The description's Args section repeats this information without adding new semantics such as uniqueness constraints or format details.

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 uses the specific verb 'Create' and identifies the resource as 'a new user label (tag) in Gmail'. This clearly distinguishes it from sibling tools like gmail_list_labels and gmail_delete_label. Examples reinforce the purpose.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides two 'Use when' examples that clearly indicate when to invoke this tool. However, it does not explicitly mention alternatives or exclusions, relying on sibling tool names for that context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

gmail_delete_labelDelete Gmail LabelA
DestructiveIdempotent

Delete a user-created label from Gmail. System labels cannot be deleted.

Args:

  • label_id (string): The label ID to delete (use gmail_list_labels to find IDs)

Note: Deleting a label removes it from all messages but does not delete the messages.

Examples:

  • Use when: "Delete the label with ID Label_123"

  • Use when: "Remove the 'OldProject' label"

ParametersJSON Schema
NameRequiredDescriptionDefault
label_idYesThe label ID to delete (e.g. 'Label_123')

TDQS

A4.5/5.0
Behavior4/5

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

Beyond the annotations (destructiveHint=true, idempotentHint=true), the description adds valuable behavioral context: deleting a label removes it from all messages but does not delete the messages. This is important side-effect information not covered by the annotations.

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 compact and well-structured: it leads with the purpose, then explains the parameter, notes a critical caveat, and provides two clear usage examples. Every sentence adds value with no redundancy.

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

Completeness5/5

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

For a simple single-parameter mutation tool, the description is complete. It covers what the tool does, how to get the parameter, key behavioral caveats, and example usage. The annotations and full schema coverage fill in the remaining safety details.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema already fully describes the single parameter ('label_id') with 100% coverage. The description adds extra value by instructing users to use gmail_list_labels to find IDs, which is helpful usage guidance beyond the schema.

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 tool deletes a user-created label from Gmail, using a specific verb+resource. It distinguishes itself from siblings by explicitly saying system labels cannot be deleted and by focusing on deletion rather than listing, creating, or modifying labels.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear usage context: it explains when to use the tool with two practical examples. It also notes a key constraint (system labels cannot be deleted) which helps decide when not to use it, though it doesn't explicitly mention alternative tools for non-deletion operations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

gmail_get_message_labelsGet Current Labels on a Gmail MessageA
Read-onlyIdempotent

Retrieve the current labels on a specific Gmail message.

Args:

  • message_id (string): The Gmail message ID

Returns: Message metadata including subject, snippet, and current label IDs.

Examples:

  • Use when: "What labels does message abc123 have?"

  • Use when: "Is message abc123 starred?"

ParametersJSON Schema
NameRequiredDescriptionDefault
message_idYesGmail message ID

TDQS

A4.3/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true and idempotentHint=true, establishing the safety profile. The description adds return details (subject, snippet, label IDs) and example queries, providing extra behavioral context without contradicting annotations.

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 compact and well-structured: purpose, args, returns, and examples in a few lines. Every sentence adds value, with no redundancy or filler.

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

Completeness5/5

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

For a simple single-parameter read-only retrieval tool, the description is complete. Annotations cover safety, schema covers the parameter, and the description provides return type and use cases. No output schema exists, but the return description compensates sufficiently.

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% and the parameter message_id is self-explanatory. The description repeats the parameter but does not add new semantic meaning, so the baseline score of 3 applies.

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 uses a specific verb 'Retrieve' with a clear resource 'labels on a specific Gmail message.' The examples further clarify the scope, distinguishing this from sibling tools like gmail_list_labels (all labels) and gmail_modify_message_labels (changing labels).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Two concrete 'Use when' examples provide clear scenarios for invocation. However, it lacks explicit 'when not to use' guidance or alternative tool mentions, such as when to use gmail_list_labels for global label listing.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

gmail_list_labelsList Gmail LabelsA
Read-onlyIdempotent

List all labels (tags) in the Gmail account.

Returns both system labels (INBOX, SENT, TRASH, etc.) and user-created labels. Use this to find label IDs needed for add/remove operations.

Returns: List of labels with their IDs, names, types, and message counts.

Examples:

  • Use when: "Show me all my Gmail labels"

  • Use when: "What label ID does 'Finance' have?"

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A4.5/5.0
Behavior4/5

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

Annotations already declare the operation read-only, idempotent, and non-destructive. The description adds that both system and user-created labels are returned, along with their IDs, names, types, and message counts, giving a clearer picture of the response without contradicting annotations.

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?

Four sections—purpose, scope, return details, and two concrete usage examples—are packed into a compact description with no filler. Every line adds value.

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

Completeness5/5

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

For a zero-parameter read-only tool, the description fully specifies its output, clarifies its use cases, and implies the broader label-management workflow via sibling tools. No output schema exists, but the return list is described in sufficient detail.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool accepts zero parameters, so the schema fully covers all inputs. The description mentions the return fields (IDs, names, etc.), which is useful context but not required for parameter understanding.

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 opens with 'List all labels (tags) in the Gmail account', clearly identifying the action and resource. It distinguishes itself from sibling write tools by noting its role in finding label IDs for 'add/remove operations'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides explicit 'Use when' examples for common queries and mentions 'Use this to find label IDs needed for add/remove operations', indicating when it should be chosen over mutation tools. Sibling tools for creating/deleting/modifying labels make the context unambiguous, though no direct 'when not to use' statement is included.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

gmail_modify_message_labelsModify Labels on a Gmail MessageA

Add or remove labels (tags) on a specific Gmail message.

Args:

  • message_id (string): The Gmail message ID

  • add_label_ids (string[]): List of label IDs to add (optional)

  • remove_label_ids (string[]): List of label IDs to remove (optional)

Use gmail_list_labels to find label IDs. Common system label IDs:

  • INBOX, STARRED, IMPORTANT, SENT, TRASH, SPAM, UNREAD, READ

Returns: Updated message with its current label IDs.

Examples:

  • Use when: "Tag message abc123 with label Label_456"

  • Use when: "Remove INBOX label from message abc123 (archive it)"

  • Use when: "Star message abc123" -> add_label_ids: ["STARRED"]

ParametersJSON Schema
NameRequiredDescriptionDefault
message_idYesGmail message ID
add_label_idsNoLabel IDs to add (e.g. ['Label_123', 'STARRED'])
remove_label_idsNoLabel IDs to remove (e.g. ['INBOX'])

TDQS

A4.5/5.0
Behavior4/5

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

The description discloses the return behavior ('Updated message with its current label IDs') and notes that removing the INBOX label archives the message. Annotations already indicate this is a mutating operation (readOnlyHint: false), so the added context is useful and does not contradict any annotation.

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 well-structured with Args, Returns, and Examples sections, making it easy to scan. However, the Args section partially duplicates the schema, adding some redundancy. Overall, it is focused and every sentence carries useful information.

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

Completeness5/5

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

The description is complete for a tool of this complexity: it covers purpose, parameters, return value, and common use cases. With no output schema or explicit prerequisites, the description still gives enough detail for an agent to invoke the tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Despite 100% schema description coverage, the description adds significant value by providing common system label IDs (INBOX, STARRED, etc.) and concrete examples for each parameter (e.g., 'Star message abc123' -> add_label_ids: ['STARRED']). This goes beyond the schema's basic parameter descriptions.

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 'Add or remove labels (tags) on a specific Gmail message', which is a specific verb+resource+scope. It distinguishes from sibling tools like gmail_modify_thread_labels (modifies a thread) and gmail_bulk_label_by_search (bulk operation) by emphasizing 'specific Gmail message'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides concrete usage context with 'Use gmail_list_labels to find label IDs' and multiple 'Use when' examples. It does not explicitly exclude alternatives like thread-level or bulk operations, but the examples make it clear this is for single-message label modifications.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

gmail_modify_thread_labelsModify Labels on a Gmail ThreadA

Add or remove labels on all messages in a Gmail thread at once.

Args:

  • thread_id (string): The Gmail thread ID

  • add_label_ids (string[]): Label IDs to add to all messages in the thread

  • remove_label_ids (string[]): Label IDs to remove from all messages in the thread

Returns: Updated thread with message count and affected message IDs.

Examples:

  • Use when: "Label this entire conversation as 'Compliance'"

  • Use when: "Archive this thread" -> remove_label_ids: ["INBOX"]

ParametersJSON Schema
NameRequiredDescriptionDefault
thread_idYesGmail thread ID
add_label_idsNoLabel IDs to add to all messages in the thread
remove_label_idsNoLabel IDs to remove from all messages in the thread

TDQS

A4.5/5.0
Behavior4/5

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

The description discloses the scope ('all messages in a Gmail thread at once'), the return format ('Updated thread with message count and affected message IDs'), and implies a mutation operation. Annotations already declare readOnlyHint=false, idempotentHint=false, and destructiveHint=false, and the description adds context without contradicting them. It does not cover edge cases, but overall adds useful behavioral detail.

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 concise and well-structured with sections for the summary, Args, Returns, and Examples. It is front-loaded with the core purpose and avoids unnecessary verbiage. Every sentence earns its place.

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

Completeness5/5

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

For a 3-parameter mutation tool with annotations and no output schema, the description covers purpose, parameters, return value, and usage examples. It is complete enough for an agent to select and invoke the tool correctly. The lack of edge-case details is acceptable given the simplicity and the provided structured data.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, and the description repeats the parameter meanings. The added example for remove_label_ids ('Archive this thread') gives practical semantics beyond the schema's bare definitions, making the tool more intuitive. Baseline is 3, and the example raises it to 4.

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 tool's function: 'Add or remove labels on all messages in a Gmail thread at once.' The verb 'Add or remove' and specific resource 'labels on all messages in a Gmail thread' is explicit. The title and description distinguish this from sibling tools like gmail_modify_message_labels by emphasizing the thread-level scope.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides concrete 'Use when' examples, such as 'Label this entire conversation as Compliance' and 'Archive this thread' with remove_label_ids: ['INBOX']. This offers clear context for when to use the tool, but it does not explicitly mention alternatives or state 'when not to use', leaving a slight gap.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 7 tool updatesv1.0.0
    • First observedgmail_bulk_label_by_search
    • First observedgmail_create_label
    • First observedgmail_delete_label
    • First observedgmail_get_message_labels
    • First observedgmail_list_labels
    • First observedgmail_modify_message_labels
    • First observedgmail_modify_thread_labels

TDQS

A4.4/5.0

Scored across 7 tools

Disambiguation5/5

Each tool targets a distinct resource and action: label CRUD, message label operations, thread label operations, and bulk search modifications. There is no overlap between tools; even the three modifying tools differ by scope (single message, single thread, bulk search).

Naming Consistency5/5

All tool names follow a consistent gmail_ prefix with a verb_noun pattern (e.g., list_labels, create_label, modify_message_labels). Even 'bulk_label_by_search' uses a clear action-object-modifier structure. The naming is uniform and predictable.

Tool Count5/5

Seven tools is well-scoped for a Gmail label management server. It covers label administration and all common ways to apply/remove labels without excess overlap or missing essentials. The set feels neither sparse nor bloated.

Completeness4/5

The tool set provides label CRUD (list, create, delete) and comprehensive label modification via message, thread, and bulk search. The only notable gap is the lack of an update/rename label operation, which is a minor omission that agents can work around by creating a new label and migrating.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    C
    quality
    D
    maintenance
    Enables comprehensive Gmail management through the Gmail API, including sending/receiving emails, organizing labels and threads, managing drafts, and configuring account settings with secure OAuth2 authentication.
    64
    627
    1
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI assistants to manage Gmail through natural language, supporting operations like sending, searching, and reading emails. It includes comprehensive label management, batch processing, and a streamlined OAuth2 auto-authentication flow.
    MIT