Skip to main content
Glama

update_label

Modify an existing label in a GitLab project to change its name, color, description, or priority.

Instructions

Update an existing label in a GitLab project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes
nameYes
new_nameNo
colorNo
descriptionNo
priorityNo

Implementation Reference

  • The implementation of the updateLabel function which handles the GitLab API request for updating an existing label.
    export async function updateLabel(
      projectId: string,
      name: string,
      options: {
        new_name?: string;
        color?: string;
        description?: string;
        priority?: number;
      }
    ): Promise<GitLabLabelResponse> {
      if (!projectId?.trim()) {
        throw new Error("Project ID is required");
      }
      if (!name?.trim()) {
        throw new Error("Label name is required");
      }
      if (options.color && !options.color.match(/^#[0-9a-fA-F]{6}$/)) {
        throw new Error("Label color must be a valid hex color (e.g., #ff0000)");
      }
    
      const encodedName = encodeURIComponent(name);
      const endpoint = `/projects/${encodeProjectId(projectId)}/labels/${encodedName}`;
    
      const label = await gitlabPut<GitLabLabelResponse>(endpoint, {
        new_name: options.new_name,
        color: options.color,
        description: options.description,
        priority: options.priority
      });
    
      return GitLabLabelSchema.parse(label);
    }
  • Zod schema for validating the input arguments of the update_label tool.
    export const UpdateLabelSchema = z.object({
      project_id: z.string(),
      name: z.string(), // Current name (identifier)
      new_name: z.string().optional(),
      color: z.string().optional(),
      description: z.string().optional(),
      priority: z.number().optional()
    });
  • src/server.ts:312-317 (registration)
    Tool registration and handler execution logic for update_label in the MCP server.
    case "update_label": {
      const args = UpdateLabelSchema.parse(request.params.arguments);
      const { project_id, name, ...options } = args;
      const label = await api.updateLabel(project_id, name, options);
      return { content: [{ type: "text", text: JSON.stringify(label, null, 2) }] };
    }

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/TheRealChrisThomas/gitlab-mcp-server'

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