Skip to main content
Glama

introspect

Retrieve and analyze the schema of a GraphQL API to ensure accurate query construction. Use this tool to access schema details when direct resources are unavailable.

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

  • Handler function that executes the 'introspect' tool logic by calling the helper function and returning the schema as MCP 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}`, }, ], }; } }
  • Zod input schema for the 'introspect' tool, using a dummy __ignore__ field to handle empty inputs.
    // 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"), },
  • src/index.ts:78-114 (registration)
    Registration of the 'introspect' MCP tool via server.tool, including name, description, schema, and handler.
    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}`, }, ], }; } } );
  • Helper function 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); }

Other Tools

Related 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