Skip to main content
Glama

gitlab_assign_reviewers_to_merge_request

Assign reviewers to GitLab merge requests by specifying user IDs and MR URL for code review workflow automation.

Instructions

Assigns reviewers to a GitLab Merge Request.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
mrUrlYesThe URL of the GitLab Merge Request.
reviewerIdsYesAn array of GitLab user IDs to assign as reviewers.

Implementation Reference

  • The core handler functions that parse the merge request URL, extract project path and MR IID, encode the project path, and execute the PUT request to the GitLab API endpoint to assign the specified reviewer IDs to the merge request.
    async assignReviewersToMergeRequest(
      projectPath: string,
      mrIid: number,
      reviewerIds: number[],
    ): Promise<any> {
      const encodedProjectPath = encodeURIComponent(projectPath);
      return this.callGitLabApi(
        `projects/${encodedProjectPath}/merge_requests/${mrIid}`,
        'PUT',
        { reviewer_ids: reviewerIds },
      );
    }
    
    // Convenience method to assign reviewers from MR URL
    async assignReviewersToMergeRequestFromUrl(
      mrUrl: string,
      reviewerIds: number[],
    ): Promise<any> {
      const { projectPath, mrIid } = this.parseMrUrl(mrUrl, this.config.url);
      return this.assignReviewersToMergeRequest(projectPath, mrIid, reviewerIds);
    }
  • src/index.ts:164-182 (registration)
    MCP tool registration including the tool name, description, and input schema definition.
    name: 'gitlab_assign_reviewers_to_merge_request',
    description: 'Assigns reviewers to a GitLab Merge Request.',
    inputSchema: {
      type: 'object',
      properties: {
        mrUrl: {
          type: 'string',
          description: 'The URL of the GitLab Merge Request.',
        },
        reviewerIds: {
          type: 'array',
          items: {
            type: 'number',
          },
          description: 'An array of GitLab user IDs to assign as reviewers.',
        },
      },
      required: ['mrUrl', 'reviewerIds'],
    },
  • The MCP server request handler (switch case) that validates the GitLab service availability, extracts input arguments, calls the GitLabService handler method, and formats the success response.
    case 'gitlab_assign_reviewers_to_merge_request': {
      if (!gitlabService) {
        throw new Error('GitLab service is not initialized.');
      }
      const { mrUrl, reviewerIds } = args as {
        mrUrl: string;
        reviewerIds: number[];
      };
      const result =
        await gitlabService.assignReviewersToMergeRequestFromUrl(
          mrUrl,
          reviewerIds,
        );
      return {
        content: [
          {
            type: 'text',
            text: `Reviewers assigned successfully: ${JSON.stringify(
              result,
            )}`,
          },
        ],
      };
  • Helper utility function to parse a GitLab merge request URL into project path and MR IID, with validation against the configured GitLab base URL.
    private parseMrUrl(
      mrUrl: string,
      gitlabBaseUrl: string,
    ): { projectPath: string; mrIid: number } {
      try {
        const url = new URL(mrUrl);
        const baseUrl = new URL(gitlabBaseUrl);
    
        // Ensure the URL is from the same GitLab instance
        if (url.origin !== baseUrl.origin) {
          throw new Error(
            `MR URL is not from the configured GitLab instance: ${gitlabBaseUrl}`,
          );
        }
    
        // Parse the path: /{namespace}/{project}/-/merge_requests/{iid}
        const pathMatch = url.pathname.match(/^\/(.+)\/-\/merge_requests\/(\d+)/);
        if (!pathMatch) {
          throw new Error(`Invalid GitLab MR URL format: ${mrUrl}`);
        }
    
        const projectPath = pathMatch[1];
        const mrIid = parseInt(pathMatch[2], 10);
    
        return { projectPath, mrIid };
      } catch (error) {
        throw new Error(
          `Failed to parse GitLab MR URL: ${error instanceof Error ? error.message : String(error)}`,
        );
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. While 'Assigns' implies a mutation operation, the description lacks details on permissions required, whether assignments are additive or replace existing reviewers, error handling (e.g., invalid user IDs), or side effects. This is inadequate for a mutation tool with zero annotation coverage.

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, efficient sentence with zero waste—it directly states the tool's purpose without fluff or redundancy. It's appropriately sized and front-loaded, 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?

Given the tool's complexity (a mutation operation with 2 required parameters), lack of annotations, and no output schema, the description is incomplete. It fails to address behavioral aspects like permissions, idempotency, or response format, leaving significant gaps for an agent to operate safely and effectively.

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?

Schema description coverage is 100%, with both parameters ('mrUrl' and 'reviewerIds') clearly documented in the schema. The description adds no additional meaning beyond what the schema provides (e.g., format examples, sourcing of IDs). Baseline 3 is appropriate when the schema does the heavy lifting, though no extra value is added.

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 ('Assigns reviewers') and target resource ('to a GitLab Merge Request'), providing a specific verb+resource combination. However, it doesn't differentiate from sibling tools like 'gitlab_update_issue' or 'gitlab_get_merge_request_details' which might also involve merge request operations, leaving room for ambiguity about when this specific assignment tool is appropriate versus alternatives.

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. It doesn't mention prerequisites (e.g., needing merge request access), exclusions (e.g., not for unassigned reviewers), or comparisons to siblings like 'gitlab_list_project_members' for finding user IDs. Without this context, an agent must 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/HainanZhao/mcp-gitlab-jira'

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