Skip to main content
Glama

create_merge_request

Create a new merge request in a GitLab project to propose code changes from a source branch to a target branch for review and integration.

Instructions

Create a new merge request in a GitLab project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYesProject ID or URL-encoded path
titleYesMerge request title
descriptionNoMerge request description
source_branchYesBranch containing changes
target_branchYesBranch to merge into
draftNoCreate as draft merge request
allow_collaborationNoAllow commits from upstream members

Implementation Reference

  • The actual implementation of the 'createMergeRequest' function that interacts with the GitLab API.
    export async function createMergeRequest(projectId: string, options: CreateMergeRequestOptions): Promise<GitLabMergeRequest> {
      if (!projectId?.trim()) {
        throw new Error("Project ID is required");
      }
      if (!options?.title?.trim()) {
        throw new Error("Merge request title is required");
      }
      if (!options?.source_branch?.trim()) {
        throw new Error("Source branch is required");
      }
      if (!options?.target_branch?.trim()) {
        throw new Error("Target branch is required");
      }
    
      const endpoint = `/projects/${encodeProjectId(projectId)}/merge_requests`;
    
      const mergeRequest = await gitlabPost<GitLabMergeRequest>(endpoint, {
        title: options.title,
        description: options.description,
        source_branch: options.source_branch,
        target_branch: options.target_branch,
        allow_collaboration: options.allow_collaboration,
        draft: options.draft
      });
    
      return GitLabMergeRequestSchema.parse(mergeRequest);
    }
  • Input schema validation for the create_merge_request tool.
    export const CreateMergeRequestSchema = ProjectParamsSchema.extend({
      title: z.string().describe("Merge request title"),
      description: z.string().optional().describe("Merge request description"),
      source_branch: z.string().describe("Branch containing changes"),
      target_branch: z.string().describe("Branch to merge into"),
      draft: z.boolean().optional().describe("Create as draft merge request"),
      allow_collaboration: z.boolean().optional().describe("Allow commits from upstream members")
    });
    
    export const ForkRepositorySchema = ProjectParamsSchema.extend({
      namespace: z.string().optional().describe("Namespace to fork to (full path)")
    });
  • src/server.ts:292-303 (registration)
    Tool handler registration for 'create_merge_request' in the server loop.
    case "create_merge_request": {
      const args = CreateMergeRequestSchema.parse(request.params.arguments);
      const { project_id, ...options } = args;
      const mergeRequest = await api.createMergeRequest(project_id, options);
      return { content: [{ type: "text", text: JSON.stringify(mergeRequest, null, 2) }] };
    }
    
    // Label tools
    case "list_labels": {
      const args = ListLabelsSchema.parse(request.params.arguments);
      const labels = await api.listLabels(args.project_id, args.page, args.per_page);
      return { content: [{ type: "text", text: JSON.stringify(labels, null, 2) }] };
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. While 'Create' implies a write operation, it doesn't specify required permissions, whether the operation is idempotent, potential side effects (e.g., notifications sent), or error conditions. This leaves significant gaps in understanding how the tool behaves beyond basic creation.

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 efficiently communicates the core purpose without unnecessary words. It's front-loaded with the essential action and resource, making it easy 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?

For a creation tool with no annotations and no output schema, the description is insufficient. It doesn't explain what happens upon success (e.g., returns merge request ID), error handling, or important behavioral aspects like permissions or side effects. Given the complexity of creating a merge request in GitLab, more context is needed for effective use.

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 schema description coverage is 100%, so all parameters are documented in the schema. The description adds no additional parameter information beyond what's in the schema, such as explaining relationships between parameters (e.g., source_branch must exist) or providing examples. This meets the baseline for high schema coverage.

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 a new merge request') and the resource ('in a GitLab project'), making the purpose immediately understandable. However, it doesn't differentiate this tool from sibling tools like 'update_merge_request' or 'merge_merge_request', which would require more specific context about when to use each.

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 'update_merge_request' or 'merge_merge_request'. It also doesn't mention prerequisites (e.g., needing appropriate permissions or existing branches) or contextual constraints, leaving the agent to infer usage from the tool name alone.

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

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