Skip to main content
Glama
FabrWill

GraphQL MCP Server

by FabrWill

introspect

Retrieve GraphQL schema details to understand available queries, types, and fields before executing operations.

Instructions

Introspect the GraphQL schema, use this tool before doing a query to get the schema information if you do not have it available as a resource already.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
__ignore__NoThis does not do anything

Implementation Reference

  • src/index.ts:78-113 (registration)
    Registration of the "introspect" MCP tool using server.tool(), including input schema and inline handler function.
    server.tool( "introspect", "Introspect the GraphQL schema, use this tool before doing a query to get the schema information if you do not have it available as a resource already.", { // This is a workaround to help clients that can't handle an empty object as an argument // They will often send undefined instead of an empty object which is not allowed by the schema __ignore__: z .boolean() .default(false) .describe("This does not do anything"), }, async () => { try { const schema = await introspectEndpoint(env.ENDPOINT, env.HEADERS); return { content: [ { type: "text", text: schema, }, ], }; } catch (error) { return { isError: true, content: [ { type: "text", text: `Failed to introspect schema: ${error}`, }, ], }; } } );
  • Inline handler function for the "introspect" tool that calls introspectEndpoint and returns the GraphQL schema as text content or error.
    async () => { try { const schema = await introspectEndpoint(env.ENDPOINT, env.HEADERS); return { content: [ { type: "text", text: schema, }, ], }; } catch (error) { return { isError: true, content: [ { type: "text", text: `Failed to introspect schema: ${error}`, }, ], }; } }
  • Input schema for the "introspect" tool using Zod (dummy __ignore__ boolean field to workaround client issues with empty objects).
    { // This is a workaround to help clients that can't handle an empty object as an argument // They will often send undefined instead of an empty object which is not allowed by the schema __ignore__: z .boolean() .default(false) .describe("This does not do anything"), },
  • Helper function 'introspectEndpoint' that performs GraphQL introspection query on the endpoint and returns the schema in SDL format.
    export async function introspectEndpoint( endpoint: string, headers?: Record<string, string>, ) { const response = await fetch(endpoint, { method: "POST", headers: { "Content-Type": "application/json", ...headers, }, body: JSON.stringify({ query: getIntrospectionQuery(), }), }); if (!response.ok) { throw new Error(`GraphQL request failed: ${response.statusText}`); } const responseJson = (await response.json()) as any; // Transform to a schema object const schema = buildClientSchema(responseJson.data); // Print the schema SDL return printSchema(schema); }
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/FabrWill/gql-mcp'

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