Skip to main content
Glama

list_labels

Retrieve all Gmail labels to organize and categorize emails for better inbox management and filtering.

Instructions

List all Gmail labels

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Executes the list_labels tool by calling GmailService.listLabels(), filtering labels into system and user categories, and formatting a structured text response.
    case "list_labels": { const labels = await gmailService.listLabels(); const system = labels.filter(l => l.type === 'system'); const user = labels.filter(l => l.type === 'user'); return { content: [{ type: "text", text: labels.length ? `System Labels (${system.length}):\n${system.map(l => ` - ${l.name} (${l.id})`).join('\n')}\n\nUser Labels (${user.length}):\n${user.map(l => ` - ${l.name} (${l.id})`).join('\n')}` : "No labels found." }] }; }
  • Zod input schema for the list_labels tool, which accepts no parameters.
    list_labels: z.object({}),
  • src/tools.ts:50-55 (registration)
    Generates MCP tool definitions including name, description, and input schema for list_labels and other tools, used in ListTools handler.
    export const getToolDefinitions = () => Object.entries(schemas).map(([name, schema]) => ({ name, description: toolDescriptions[name], inputSchema: zodToJsonSchema(schema) }));
  • Core implementation that fetches all Gmail labels via the Google Gmail API v1.
    async listLabels(): Promise<Label[]> { const { data } = await this.gmail.users.labels.list({ userId: 'me' }); return (data.labels || []) as Label[]; }
  • TypeScript interface defining the structure of Label objects returned by listLabels.
    export interface Label { id?: string | null; name?: string | null; type?: string | null; }

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/muammar-yacoob/GMail-Manager-MCP'

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