Skip to main content
Glama

create_merge_request

Generate a new merge request in a GitLab project by specifying source and target branches, title, description, and project details.

Instructions

Create a new merge request in a GitLab project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
allow_collaborationNo
descriptionNo
draftNo
project_idNo
source_branchNo
target_branchNo
titleNo

Implementation Reference

  • src/index.ts:144-148 (registration)
    Registration of the 'create_merge_request' tool in the ALL_TOOLS array, including name, description, input schema, and read-only flag.
    {
      name: "create_merge_request",
      description: "Create a new merge request in a GitLab project",
      inputSchema: createJsonSchema(CreateMergeRequestSchema),
      readOnly: false
  • MCP tool handler in the switch statement: parses arguments with CreateMergeRequestSchema, extracts project_id and options, calls gitlabApi.createMergeRequest, and returns JSON response.
    case "create_merge_request": {
      const args = CreateMergeRequestSchema.parse(request.params.arguments);
      const { project_id, ...options } = args;
      const mergeRequest = await gitlabApi.createMergeRequest(project_id, options);
      return { content: [{ type: "text", text: JSON.stringify(mergeRequest, null, 2) }] };
  • CreateMergeRequestSchema definition, which merges project_id with CreateMergeRequestOptionsSchema for input validation.
    export const CreateMergeRequestSchema = z.object({
      project_id: z.string()
    }).merge(CreateMergeRequestOptionsSchema);
  • CreateMergeRequestOptionsSchema defining input fields: title, description, source_branch, target_branch, allow_collaboration, draft.
    export const CreateMergeRequestOptionsSchema = z.object({
      title: z.string(),
      description: z.string().optional(),
      source_branch: z.string(),
      target_branch: z.string(),
      allow_collaboration: z.boolean().optional(),
      draft: z.boolean().optional()
    });
  • Core implementation of createMergeRequest in GitLabApi class: makes POST request to GitLab API to create merge request and parses response.
    async createMergeRequest(
      projectId: string,
      options: z.infer<typeof CreateMergeRequestOptionsSchema>
    ): Promise<GitLabMergeRequest> {
      const response = await fetch(
        `${this.apiUrl}/projects/${encodeURIComponent(projectId)}/merge_requests`,
        {
          method: "POST",
          headers: {
            "Authorization": `Bearer ${this.token}`,
            "Content-Type": "application/json"
          },
          body: JSON.stringify({
            title: options.title,
            description: options.description,
            source_branch: options.source_branch,
            target_branch: options.target_branch,
            allow_collaboration: options.allow_collaboration,
            draft: options.draft
          })
        }
      );
    
      if (!response.ok) {
        throw new McpError(
          ErrorCode.InternalError,
          `GitLab API error: ${response.statusText}`
        );
      }
    
      const responseData = await response.json() as Record<string, any>;
    
      return {
        id: responseData.id,
        iid: responseData.iid,
        project_id: responseData.project_id,
        title: responseData.title,
        description: responseData.description || null,
        state: responseData.state,
        merged: responseData.merged,
        author: responseData.author,
        assignees: responseData.assignees || [],
        source_branch: responseData.source_branch,
        target_branch: responseData.target_branch,
        diff_refs: responseData.diff_refs || null,
        web_url: responseData.web_url,
        created_at: responseData.created_at,
        updated_at: responseData.updated_at,
        merged_at: responseData.merged_at,
        closed_at: responseData.closed_at,
        merge_commit_sha: responseData.merge_commit_sha
      };
    }
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. It states the tool creates a merge request but does not mention any behavioral traits such as required permissions, whether it's idempotent, error handling, or rate limits. This leaves significant gaps for an agent to understand how to use it effectively.

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 a single, clear sentence that directly states the tool's purpose without unnecessary words. It is front-loaded and efficient, making it easy for an agent to parse quickly.

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?

Given the complexity of a merge request creation (7 parameters, no annotations, no output schema), the description is inadequate. It does not explain what a merge request entails in GitLab, what the expected output might be, or how to handle the parameters, leaving the agent with insufficient context for proper tool invocation.

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

Parameters2/5

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

The schema description coverage is 0%, meaning none of the 7 parameters are documented in the schema. The description adds no information about parameters like 'project_id', 'source_branch', or 'draft', failing to compensate for the lack of schema details. This leaves the agent with no semantic understanding of the inputs.

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 ('new merge request in a GitLab project'), making the purpose unambiguous. However, it does not differentiate from sibling tools like 'create_issue' or 'create_branch' beyond the resource name, which is why it scores 4 instead of 5.

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 like 'create_issue' or 'list_merge_requests'. It lacks context about prerequisites (e.g., needing an existing project) or exclusions, offering only a basic statement of function.

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

Related 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/yoda-digital/mcp-gitlab-server'

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