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);
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic action without behavioral details. It doesn't disclose whether this is a read-only operation, its performance characteristics (e.g., heavy vs. lightweight), potential side effects, or what the output looks like (schema format, size). This is inadequate for a tool with 3 parameters and no output schema.

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 main purpose ('introspect the GraphQL schema') and adds optional detail. There is no wasted wording, making it appropriately concise for this tool.

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

Completeness2/5

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

Given 3 parameters, 0% required parameters, 33% schema coverage, no annotations, and no output schema, the description is incomplete. It doesn't explain the tool's behavior, output format, or parameter usage in enough detail for an AI agent to use it effectively without guesswork.

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 33% (only 'typeNames' has a description), so the description must compensate but only mentions 'filter to specific types' which partially explains 'typeNames'. It doesn't address 'descriptions' or 'directives' parameters. The description adds minimal value beyond the schema, meeting the baseline for low coverage.

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 ('introspect') and resource ('GraphQL schema'), and mentions optional filtering. It distinguishes from the sibling 'query-graphql' by focusing on schema inspection rather than query execution. However, it doesn't specify what introspection returns (e.g., schema structure, types, fields), keeping it from a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for schema exploration and mentions optional filtering, but lacks explicit guidance on when to use this tool versus alternatives like 'query-graphql' or when not to use it (e.g., for actual data queries). No prerequisites or exclusions are stated.

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/letoribo/mcp-graphql-enhanced'

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