Skip to main content
Glama
ttpears

GitLab MCP Server

by ttpears

Create Issue

create_issue

Create new issues in GitLab projects to track tasks, bugs, or feature requests. Requires write permissions and project path.

Instructions

Create a new issue in a GitLab project (requires user authentication with write permissions)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectPathYesFull path of the project (e.g., "group/project-name")
titleYesTitle of the issue
descriptionNoDescription of the issue
userCredentialsNoYour GitLab credentials (optional - uses shared token if not provided)

Implementation Reference

  • src/tools.ts:170-198 (registration)
    Tool definition and registration for create_issue - defines the tool name, description, input schema (with user credentials), and the handler that executes when the tool is called
    const createIssueTool: Tool = {
      name: 'create_issue',
      title: 'Create Issue',
      description: 'Create a new issue in a GitLab project (requires user authentication with write permissions)',
      requiresAuth: true,
      requiresWrite: true,
      annotations: {
        readOnlyHint: false,
        destructiveHint: false,
        idempotentHint: false,
      },
      inputSchema: withUserAuth(z.object({
        projectPath: z.string().describe('Full path of the project (e.g., "group/project-name")'),
        title: z.string().min(1).describe('Title of the issue'),
        description: z.string().optional().describe('Description of the issue'),
      })),
      handler: async (input, client, userConfig) => {
        const credentials = input.userCredentials ? validateUserConfig(input.userCredentials) : userConfig;
        if (!credentials) {
          throw new Error('User authentication is required for creating issues. Please provide your GitLab credentials.');
        }
        const result = await client.createIssue(input.projectPath, input.title, input.description, credentials);
        const payload = result.createIssue;
        if (payload.errors && payload.errors.length > 0) {
          throw new Error(`Failed to create issue: ${payload.errors.join(', ')}`);
        }
        return payload.issue;
      },
    };
  • Tool handler function that processes create_issue requests - validates user credentials, calls the client's createIssue method, and returns the created issue or throws an error
    handler: async (input, client, userConfig) => {
      const credentials = input.userCredentials ? validateUserConfig(input.userCredentials) : userConfig;
      if (!credentials) {
        throw new Error('User authentication is required for creating issues. Please provide your GitLab credentials.');
      }
      const result = await client.createIssue(input.projectPath, input.title, input.description, credentials);
      const payload = result.createIssue;
      if (payload.errors && payload.errors.length > 0) {
        throw new Error(`Failed to create issue: ${payload.errors.join(', ')}`);
      }
      return payload.issue;
    },
  • Client method that implements the actual create_issue logic using GraphQL mutation - introspects schema to determine the correct mutation field name and input type, builds the mutation query, and executes it
    async createIssue(projectPath: string, title: string, description?: string, userConfig?: UserConfig): Promise<any> {
      await this.introspectSchema(userConfig);
      const mutationType = this.schema?.getMutationType();
      const fields = mutationType ? mutationType.getFields() : {};
    
      const fieldName = fields['createIssue'] ? 'createIssue' : (fields['issueCreate'] ? 'issueCreate' : null);
      if (!fieldName) {
        throw new Error('Neither createIssue nor issueCreate mutation is available on this GitLab instance');
      }
    
      const hasCreateInput = !!this.schema.getType('CreateIssueInput');
      const hasLegacyInput = !!this.schema.getType('IssueCreateInput');
      const inputType = hasCreateInput ? 'CreateIssueInput' : (hasLegacyInput ? 'IssueCreateInput' : null);
      if (!inputType) {
        throw new Error('Neither CreateIssueInput nor IssueCreateInput input type is available on this GitLab instance');
      }
    
      const mutation = gql`
        mutation createIssue($input: ${inputType}!) {
          ${fieldName}(input: $input) {
            issue {
              id
              iid
              title
              description
              webUrl
              state
              createdAt
            }
            errors
          }
        }
      `;
    
      const input = {
        projectPath,
        title,
        description,
      };
    
      const result = await this.query(mutation, { input }, userConfig, true);
      // Normalize payload to { createIssue: ... }
      const payload = (result as any)[fieldName];
      return { createIssue: payload };
    }
  • Input schema definition for create_issue tool using Zod - validates projectPath (required), title (required, min 1 char), and description (optional), plus optional userCredentials
    inputSchema: withUserAuth(z.object({
      projectPath: z.string().describe('Full path of the project (e.g., "group/project-name")'),
      title: z.string().min(1).describe('Title of the issue'),
      description: z.string().optional().describe('Description of the issue'),
    })),
  • src/tools.ts:1317-1349 (registration)
    Export of the createIssueTool as part of writeTools array and main tools export - makes it available for registration with the MCP server
    export const writeTools: Tool[] = [
      createIssueTool,
      createMergeRequestTool,
      createNoteTool,
      managePipelineTool,
    ];
    
    export const searchTools: Tool[] = [
      globalSearchTool,
      searchProjectsTool,
      searchIssuesTool,
      searchMergeRequestsTool,
      getUserIssuesTool,
      getUserMergeRequestsTool,
      searchUsersTool,
      searchGroupsTool,
      searchLabelsTool,
      browseRepositoryTool,
      getFileContentTool,
      listGroupMembersTool,
    ];
    
    export const tools: Tool[] = [
      ...readOnlyTools,
      ...userAuthTools,
      ...writeTools,
      updateIssueTool,
      updateMergeRequestTool,
      resolvePathTool,
      getGroupProjectsTool,
      getTypeFieldsTool,
      ...searchTools,
    ];
Behavior3/5

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

The description adds valuable context about authentication requirements ('requires user authentication with write permissions') that goes beyond the annotations. The annotations already declare this is a non-readOnly, non-idempotent, non-destructive operation, but the description provides practical implementation details about authentication that the agent needs to know. No contradiction with annotations exists.

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 that communicates the core purpose and key requirement upfront. Every word serves a purpose with no redundancy or unnecessary elaboration. It's appropriately sized for a tool with good schema documentation.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/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 output schema, the description covers the essential context: what it does and authentication requirements. However, it doesn't mention what happens on success (e.g., returns issue ID) or failure scenarios. Given the comprehensive annotations and schema coverage, the description is mostly complete but could benefit from mentioning expected outcomes.

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?

With 100% schema description coverage, the input schema already documents all parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema, so it meets the baseline expectation without providing extra value. The description's mention of authentication relates to the userCredentials parameter but doesn't add semantic details beyond the schema's description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Create a new issue') and resource ('in a GitLab project'), distinguishing it from sibling tools like 'update_issue' or 'get_issues'. It provides a complete verb+resource+scope combination that leaves no ambiguity about the tool's function.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly states when to use this tool ('Create a new issue') and includes important prerequisites ('requires user authentication with write permissions'). However, it doesn't explicitly mention when NOT to use it or name specific alternatives among the many sibling tools, such as 'update_issue' for modifying existing issues.

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

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