Skip to main content
Glama

introspectGraphQLSchema

Fetch the schema of a GraphQL API using introspection to understand its structure and available operations. Returns the schema in JSON format for analysis and integration.

Instructions

Fetches the schema of the target GraphQL API using introspection. Returns the schema in JSON format.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler function that performs GraphQL schema introspection by executing the standard introspection query and handling responses and errors.
    export async function handleIntrospection(): Promise<IntrospectionResult> {
      const introspectionQuery = getIntrospectionQuery(); // Get the standard query
    
      try {
        console.error("Executing GraphQL introspection query...");
        const response = await executeGraphQL<IntrospectionResult>(
          introspectionQuery
        );
    
        // Check for GraphQL errors returned in the response body
        if (response.errors && response.errors.length > 0) {
          const errorMessages = response.errors.map((e) => e.message).join("; ");
          console.error(
            `GraphQL introspection query returned errors: ${errorMessages}`,
            response.errors
          );
          // Using InternalError as a placeholder.
          throw new McpError(
            ErrorCode.InternalError,
            `Introspection query failed: ${errorMessages}`,
            { details: response.errors } // Include original errors in details
          );
        }
    
        if (!response.data || !response.data.__schema) {
          console.error(
            "Introspection query did not return a valid __schema object.",
            response.data
          );
          // TODO: Revisit ErrorCode mapping once SDK types are clarified.
          // Using InternalError as a placeholder.
          throw new McpError(
            ErrorCode.InternalError,
            "Introspection query did not return a valid schema."
          );
        }
    
        console.error("GraphQL introspection query successful.");
        return response.data; // Return the { data: { __schema: ... } } part
      } catch (error) {
        // Catch errors thrown by executeGraphQL (network, HTTP errors) or our own McpErrors
        console.error("Error executing introspection query:", error);
        if (error instanceof McpError) {
          // Re-throw McpErrors directly
          throw error;
        }
        // Wrap unexpected errors (using PascalCase)
        throw new McpError(
          ErrorCode.InternalError,
          "An unexpected error occurred during schema introspection.",
          { cause: error as Error }
        );
      }
    }
  • Zod schema defining the input for the introspectGraphQLSchema tool, which requires no parameters.
    // Define the Zod schema for the input (no parameters needed)
    export const IntrospectSchemaInput = z.object({});
  • src/server.ts:46-51 (registration)
    Tool registration in the ListTools response, including name, description, and input schema reference.
    {
      name: "introspectGraphQLSchema",
      description:
        "Fetches the schema of the target GraphQL API using introspection. Returns the schema in JSON format.",
      inputSchema: introspectionInputSchema,
    },
  • src/server.ts:80-85 (registration)
    Dispatcher in CallTool handler that validates input and invokes the introspection handler.
    case "introspectGraphQLSchema":
      // Validate arguments using the Zod schema
      IntrospectSchemaInput.parse(args);
      console.error(`Calling handler for ${name}`);
      result = await handleIntrospection();
      break;
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses the tool fetches schema via introspection and returns JSON, which is useful behavioral context. However, it lacks details on permissions, rate limits, error handling, or whether it's read-only/destructive, leaving gaps for a mutation-sensitive context.

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 key information (fetches schema, uses introspection, returns JSON) with no wasted words. It's appropriately sized for a simple tool with no parameters.

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

Completeness3/5

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

Given the tool's simplicity (0 parameters, no output schema, no annotations), the description is adequate but minimal. It explains what the tool does and the return format, but lacks context on behavioral traits like safety or performance, which could be important for an API introspection tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description appropriately doesn't discuss parameters, focusing on the tool's purpose instead, which aligns with the baseline for zero parameters.

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 ('fetches') and resource ('schema of the target GraphQL API'), specifying it uses introspection and returns JSON format. It distinguishes from the sibling 'executeGraphQLOperation' by focusing on schema retrieval rather than operation execution, though it doesn't explicitly name the sibling for differentiation.

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

Usage Guidelines2/5

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

No explicit guidance on when to use this tool versus alternatives is provided. The description implies usage for schema introspection, but it doesn't mention prerequisites, when not to use it, or reference the sibling tool for operational queries.

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/jorgeraad/mcp4gql'

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