Skip to main content
Glama
blurrah

mcp-graphql

introspect-schema

Retrieve GraphQL schema details by introspecting the endpoint, enabling users to access schema information before executing queries. Supports custom headers and endpoint overrides.

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
endpointNoOptional: Override the default endpoint, the already used endpoint is: http://localhost:3000/graphql
headersNoOptional: Add additional headers, the already used headers are: {}

Implementation Reference

  • The inline handler function for the 'introspect-schema' tool. It determines the schema source based on environment variables and calls the appropriate introspection helper, returning the schema as text content or an error.
    async () => {
    	try {
    		let schema: string;
    		if (env.SCHEMA) {
    			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: `Failed to introspect schema: ${error}`,
    				},
    			],
    		};
    	}
    },
  • Zod input schema for the tool, featuring a dummy '__ignore__' boolean parameter to accommodate clients sending undefined arguments.
    	// 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:75-115 (registration)
    Registers the 'introspect-schema' tool with the MCP server, providing name, description, input schema, and handler function.
    server.tool(
    	"introspect-schema",
    	"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 {
    			let schema: string;
    			if (env.SCHEMA) {
    				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: `Failed to introspect schema: ${error}`,
    					},
    				],
    			};
    		}
    	},
    );
  • 'introspectEndpoint' helper function that sends an introspection query to a GraphQL endpoint and returns the schema in SDL format using GraphQL utilities.
    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.data);
    
    	// Print the schema SDL
    	return printSchema(schema);
    }
  • 'introspectLocalSchema' helper function that reads a local GraphQL schema file and returns its contents.
    export async function introspectLocalSchema(path: string) {
    	const schema = await readFile(path, "utf8");
    	return schema;
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. The description mentions timing ('before doing a query') but doesn't explain what the introspection actually returns, whether it's a one-time operation or cached, what format the schema information comes in, or any authentication/rate limit considerations. For a tool with zero annotation coverage, this leaves significant behavioral gaps.

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 core purpose ('Introspect the GraphQL schema') followed by usage guidance. Every word earns its place with no redundancy or unnecessary elaboration. The structure is clear and appropriately sized for the tool's complexity.

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 has no output schema and no annotations, the description should do more to explain what the introspection returns and any behavioral considerations. While it adequately covers purpose and basic usage, it lacks details about the return format, error conditions, or operational characteristics that would help an agent use it effectively. The description is minimally viable but has clear gaps in completeness.

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 100%, so the schema already documents both parameters thoroughly with descriptions of their optional nature and default values. The description adds no parameter-specific information beyond what's in the schema. With high schema coverage, the baseline score of 3 is appropriate since the description doesn't need to compensate for schema gaps.

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 verb ('introspect') and resource ('GraphQL schema'), and specifies the purpose is to 'get the schema information'. It distinguishes from the sibling tool 'query-graphql' by indicating this is for schema discovery rather than query execution. However, it doesn't explicitly contrast with the sibling beyond implied timing ('before doing a query').

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

Usage Guidelines4/5

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

The description provides clear context on when to use this tool: 'before doing a query to get the schema information if you do not have it available as a resource already'. It implies an alternative (having the schema as a pre-existing resource) and gives timing guidance. However, it doesn't explicitly state when NOT to use it or provide detailed comparison with the sibling tool beyond the basic distinction.

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

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

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