Skip to main content
Glama
ttpears

GitLab MCP Server

by ttpears

Available Queries

get_available_queries
Read-onlyIdempotent

Retrieve available GraphQL queries and mutations from a GitLab schema to understand what operations are supported for API interaction.

Instructions

Get list of available GraphQL queries and mutations from the GitLab schema

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
userCredentialsNoYour GitLab credentials (optional - uses shared token if not provided)

Implementation Reference

  • Tool definition for 'get_available_queries' - defines the tool metadata, input schema (empty object with optional user credentials), and handler function that calls the GitLab client to introspect the schema and return available queries and mutations
    const getAvailableQueriesTools: Tool = {
      name: 'get_available_queries',
      title: 'Available Queries',
      description: 'Get list of available GraphQL queries and mutations from the GitLab schema',
      requiresAuth: false,
      requiresWrite: false,
      annotations: {
        readOnlyHint: true,
        destructiveHint: false,
        idempotentHint: true,
      },
      inputSchema: withUserAuth(z.object({}).strict()),
      handler: async (input, client, userConfig) => {
        const credentials = input.userCredentials ? validateUserConfig(input.userCredentials) : userConfig;
        await client.introspectSchema(credentials);
        return {
          queries: client.getAvailableQueries(),
          mutations: client.getAvailableMutations(),
        };
      },
    };
  • Implementation of getAvailableQueries() and getAvailableMutations() methods that retrieve field names from the introspected GraphQL schema's Query and Mutation types
    getAvailableQueries(): string[] {
      if (!this.schema) return [];
      
      const queryType = this.schema.getQueryType();
      if (!queryType) return [];
      
      return Object.keys(queryType.getFields());
    }
    
    getAvailableMutations(): string[] {
      if (!this.schema) return [];
      
      const mutationType = this.schema.getMutationType();
      if (!mutationType) return [];
      
      return Object.keys(mutationType.getFields());
    }
  • The introspectSchema() method that fetches and builds the GitLab GraphQL schema using GraphQL introspection query, storing it in this.schema for later use by getAvailableQueries() and getAvailableMutations()
    async introspectSchema(userConfig?: UserConfig): Promise<void> {
      if (this.schema) return;
    
      try {
        const client = this.getClient(userConfig);
        const introspectionResult = await client.request<IntrospectionQuery>(
          getIntrospectionQuery()
        );
        this.schema = buildClientSchema(introspectionResult);
      } catch (error) {
        throw new Error(`Failed to introspect GitLab GraphQL schema: ${error}`);
      }
    }
  • src/tools.ts:1294-1310 (registration)
    Tool registration - getAvailableQueriesTools is exported as part of readOnlyTools array, which is then included in the main tools array that gets registered with the MCP server
    export const readOnlyTools: Tool[] = [
      getProjectTool,
      getIssuesTool,
      getMergeRequestsTool,
      executeCustomQueryTool,
      getAvailableQueriesTools,
      getMergeRequestPipelinesTool,
      getPipelineJobsTool,
      getMergeRequestDiffsTool,
      getMergeRequestCommitsTool,
      getNotesTool,
      listMilestonesTool,
      listIterationsTool,
      getTimeTrackingTool,
      getMergeRequestReviewersTool,
      getProjectStatisticsTool,
    ];
  • Input schema definition - uses withUserAuth helper to create an empty object schema that optionally accepts user credentials for authentication
    inputSchema: withUserAuth(z.object({}).strict()),
Behavior3/5

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

Annotations already indicate read-only, idempotent, and non-destructive behavior, so the description doesn't need to repeat these. It adds value by specifying the source ('GitLab schema'), but lacks details on rate limits, authentication needs beyond the optional parameter, or output format (e.g., list structure). 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 front-loads the core purpose without unnecessary words. Every part contributes directly to understanding the tool's function, making it appropriately sized and well-structured for quick comprehension.

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

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (1 optional parameter) and rich annotations (read-only, idempotent), the description is minimally adequate. However, without an output schema, it fails to describe the return format (e.g., array of query names, metadata), leaving a gap in completeness for the agent to interpret results.

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 the parameter 'userCredentials' well-documented as optional GitLab credentials. The description doesn't add extra meaning beyond the schema, such as explaining when credentials are necessary (e.g., for private instances) or default behavior, so it meets the baseline for high coverage without enhancement.

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 ('Get list') and resource ('available GraphQL queries and mutations from the GitLab schema'), making the purpose evident. However, it doesn't explicitly differentiate from sibling tools like 'get_type_fields' or 'execute_custom_query', which also relate to GraphQL operations, leaving some ambiguity about uniqueness.

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?

No guidance is provided on when to use this tool versus alternatives. It doesn't mention prerequisites like needing credentials for private schemas or suggest using it before 'execute_custom_query' to discover available operations, leaving the agent to infer usage context 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/ttpears/gitlab-mcp'

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