Skip to main content
Glama

gitlab_close_issue

Close a GitLab issue by specifying the project path and issue internal ID. This tool helps manage issue resolution within GitLab projects.

Instructions

Closes a GitLab issue.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectPathYesThe path of the GitLab project.
issueIidYesThe internal ID of the issue.

Implementation Reference

  • src/index.ts:926-942 (registration)
    Tool registration and input schema definition for 'gitlab_close_issue'
    {
      name: 'gitlab_close_issue',
      description: 'Closes a GitLab issue.',
      inputSchema: {
        type: 'object',
        properties: {
          projectPath: {
            type: 'string',
            description: 'The path of the GitLab project.',
          },
          issueIid: {
            type: 'number',
            description: 'The internal ID of the issue.',
          },
        },
        required: ['projectPath', 'issueIid'],
      },
  • MCP tool handler that dispatches the call to GitLabService.closeIssue
    case 'gitlab_close_issue': {
      if (!gitlabService) {
        throw new Error('GitLab service is not initialized.');
      }
      const { projectPath, issueIid } = args as { projectPath: string; issueIid: number };
      const result = await gitlabService.closeIssue(projectPath, issueIid);
      return {
        content: [
          {
            type: 'text',
            text: `Issue closed successfully: ${JSON.stringify(result, null, 2)}`,
          },
        ],
      };
    }
  • GitLabService.closeIssue method implementing the core tool logic by calling updateIssue
    // New tool: Close Issue
    async closeIssue(projectPath: string, issueIid: number): Promise<any> {
      return this.updateIssue(projectPath, issueIid, { state: 'close' });
    }
  • Generic updateIssue helper method that sends PUT request to GitLab API, used by closeIssue to set state_event to 'close'
    async updateIssue(projectPath: string, issueIid: number, updates: {
      title?: string;
      description?: string;
      labels?: string[];
      assigneeIds?: number[];
      state?: 'close' | 'reopen';
    }): Promise<any> {
      const encodedProjectPath = encodeURIComponent(projectPath);
      const body: any = {};
      
      if (updates.title) body.title = updates.title;
      if (updates.description) body.description = updates.description;
      if (updates.labels) body.labels = updates.labels.join(',');
      if (updates.assigneeIds) body.assignee_ids = updates.assigneeIds;
      if (updates.state) body.state_event = updates.state;
      
      return this.callGitLabApi<any>(
        `projects/${encodedProjectPath}/issues/${issueIid}`,
        'PUT',
        body,
      );

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