Skip to main content
Glama
letoribo

mcp-graphql-enhanced

introspect-schema

Analyze GraphQL schemas to retrieve type definitions, directives, and descriptions. Filter results to focus on specific types for targeted schema exploration.

Instructions

Introspect the GraphQL schema. Optionally filter to specific types.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
typeNamesNoA list of specific type names to filter the introspection.
descriptionsNo
directivesNo

Implementation Reference

  • The main asynchronous handler function implementing the 'introspect-schema' tool. It handles optional typeNames filtering by calling introspectTypes, otherwise fetches the full schema using endpoint configuration or local/URL schema, and returns the schema as text content or error.
    const introspectSchemaHandler = async ({ typeNames, descriptions = true, directives = true }: any) => {     if (typeNames === null) { typeNames = undefined; } try {       if (typeNames && typeNames.length > 0) {         const filtered = await introspectTypes(env.ENDPOINT, env.HEADERS, typeNames);         return { content: [{ type: "text", text: filtered }] };       } else {         let schema;         if (env.SCHEMA) {           if (env.SCHEMA.startsWith("http://") || env.SCHEMA.startsWith("https://")) {             schema = await introspectSchemaFromUrl(env.SCHEMA);           } else {             schema = await introspectLocalSchema(env.SCHEMA);           }         } else {           schema = await introspectEndpoint(env.ENDPOINT, env.HEADERS);         }         return { content: [{ type: "text", text: schema }] };       }     } catch (error) {       return {         isError: true,         content: [{ type: "text", text: `Introspection failed: ${error}` }],       };     } };
  • Zod input schema for the 'introspect-schema' tool parameters: typeNames (optional array of strings), descriptions and directives (optional booleans defaulting to true).
      {     typeNames: z.array(z.string()).optional().describe("A list of specific type names to filter the introspection."),     descriptions: z.boolean().optional().default(true),     directives: z.boolean().optional().default(true),   },
  • src/index.ts:124-133 (registration)
    MCP server.tool registration for the 'introspect-schema' tool, including name, description, input schema, and handler binding.
    server.tool(   "introspect-schema",   "Introspect the GraphQL schema. Optionally filter to specific types.",   {     typeNames: z.array(z.string()).optional().describe("A list of specific type names to filter the introspection."),     descriptions: z.boolean().optional().default(true),     directives: z.boolean().optional().default(true),   },   introspectSchemaHandler );
  • src/index.ts:122-122 (registration)
    Internal toolHandlers Map registration for HTTP transport handling.
    toolHandlers.set("introspect-schema", introspectSchemaHandler);
  • Helper function to introspect a remote GraphQL endpoint using getIntrospectionQuery and return the schema SDL.
    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(); // Transform to a schema object const schema = buildClientSchema((responseJson as any).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/letoribo/mcp-graphql-enhanced'

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