Skip to main content
Glama

create_label

Create a new label in a GitLab project to organize issues and merge requests by specifying name, color, and optional description or priority.

Instructions

Create a new label in a GitLab project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYes
nameYes
colorYes
descriptionNo
priorityNo

Implementation Reference

  • The handler function that creates a label in a GitLab project.
    export async function createLabel(
      projectId: string,
      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 (!color?.trim()) {
        throw new Error("Label color is required");
      }
      if (!color.match(/^#[0-9a-fA-F]{6}$/)) {
        throw new Error("Label color must be a valid hex color (e.g., #ff0000)");
      }
    
      const endpoint = `/projects/${encodeProjectId(projectId)}/labels`;
    
      const label = await gitlabPost<GitLabLabelResponse>(endpoint, {
        name,
        color,
        description,
        priority
      });
    
      return GitLabLabelSchema.parse(label);
    }
  • The schema defining the input validation for the create_label tool.
    export const CreateLabelSchema = z.object({
      project_id: z.string(),
      name: z.string(),
      color: z.string(),
      description: z.string().optional(),
      priority: z.number().optional()
    });
  • src/server.ts:115-118 (registration)
    Tool registration for create_label.
      name: "create_label",
      description: "Create a new label in a GitLab project",
      inputSchema: zodToJsonSchema(CreateLabelSchema)
    },

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