Skip to main content
Glama
Alosies

GitLab MCP Server

by Alosies

mark_mr_as_draft

Mark a GitLab merge request as draft to indicate it's a work in progress and not ready for review.

Instructions

Mark a merge request as draft (work in progress, not ready for review)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYesProject ID or path
merge_request_iidYesMerge request internal ID

Implementation Reference

  • Core implementation of the mark_mr_as_draft tool: fetches the MR details, checks if already marked as draft (Draft: or WIP: prefix), and if not, updates the title by prefixing 'Draft: '.
    async markMRAsDraft(args: MarkMRAsDraftParams) {
      // First get the current MR to check its title
      const mr = (await this.client.get(
        `/projects/${encodeURIComponent(args.project_id)}/merge_requests/${
          args.merge_request_iid
        }`
      )) as GitLabMergeRequest;
    
      // Check if already a draft
      if (mr.title.startsWith("Draft: ") || mr.title.startsWith("WIP: ")) {
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                { message: "Merge request is already marked as draft", ...mr },
                null,
                2
              ),
            },
          ],
        };
      }
    
      // Update the title to add Draft: prefix
      const data = await this.client.put(
        `/projects/${encodeURIComponent(args.project_id)}/merge_requests/${
          args.merge_request_iid
        }`,
        { title: `Draft: ${mr.title}` }
      );
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(data, null, 2),
          },
        ],
      };
    }
  • Tool registration: defines the MCP tool object with name 'mark_mr_as_draft', description, and input JSON schema. Included in mergeRequestTools array imported for server tool listing.
    {
      name: 'mark_mr_as_draft',
      description:
        'Mark a merge request as draft (work in progress, not ready for review)',
      inputSchema: {
        type: 'object',
        properties: {
          project_id: {
            type: 'string',
            description: 'Project ID or path',
          },
          merge_request_iid: {
            type: 'number',
            description: 'Merge request internal ID',
          },
        },
        required: ['project_id', 'merge_request_iid'],
      },
    },
  • src/server.ts:247-250 (registration)
    Server dispatch: switch case in CallToolRequestSchema handler that routes calls to the tool to MergeRequestHandlers.markMRAsDraft method.
    case "mark_mr_as_draft":
      return await this.mergeRequestHandlers.markMRAsDraft(
        args as unknown as MarkMRAsDraftParams
      );
  • TypeScript type definition for the input parameters used by the handler and referenced in server dispatch.
    export interface MarkMRAsDraftParams {
      project_id: string;
      merge_request_iid: number;
    }

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

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