get_available_queries
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
| Name | Required | Description | Default |
|---|---|---|---|
| userCredentials | No | Your GitLab credentials (optional - uses shared token if not provided) |
Implementation Reference
- src/tools.ts:265-285 (handler)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(), }; }, }; - src/gitlab-client.ts:532-548 (handler)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()); } - src/gitlab-client.ts:292-304 (helper)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, ]; - src/tools.ts:276-276 (schema)Input schema definition - uses withUserAuth helper to create an empty object schema that optionally accepts user credentials for authentication
inputSchema: withUserAuth(z.object({}).strict()),