Skip to main content
Glama
murilojrpereira

mcp-graphql-bridge

execute_graphql

Execute arbitrary GraphQL queries and mutations against the API when no specific tool exists.

Instructions

Execute any GraphQL query or mutation against the API. Use this when no specific tool exists for your operation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesFull GraphQL query or mutation string including selection set
variablesNoVariables for the operation

Implementation Reference

  • The handler function for the execute_graphql tool. It receives a query string and optional variables, executes the GraphQL request via graphql-request client, and returns the result as formatted JSON text. Errors are caught and returned as error content.
    async ({ query, variables }) => {
      try {
        const data = await client.request(query, variables ?? {});
        return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
      } catch (err) {
        const msg = err instanceof Error ? err.message : String(err);
        return { content: [{ type: "text", text: `Error: ${msg}` }], isError: true };
      }
    }
  • The input schema for execute_graphql. Defines two parameters: 'query' (required string) and 'variables' (optional record of unknown values) for the GraphQL operation.
    {
      query: z.string().describe("Full GraphQL query or mutation string including selection set"),
      variables: z.record(z.unknown()).optional().describe("Variables for the operation"),
    },
  • src/index.ts:292-308 (registration)
    Registration of the execute_graphql tool on the MCP server using server.tool(). It's registered as a generic fallback tool, always available regardless of schema introspection success.
    server.tool(
      "execute_graphql",
      "Execute any GraphQL query or mutation against the API. Use this when no specific tool exists for your operation.",
      {
        query: z.string().describe("Full GraphQL query or mutation string including selection set"),
        variables: z.record(z.unknown()).optional().describe("Variables for the operation"),
      },
      async ({ query, variables }) => {
        try {
          const data = await client.request(query, variables ?? {});
          return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
        } catch (err) {
          const msg = err instanceof Error ? err.message : String(err);
          return { content: [{ type: "text", text: `Error: ${msg}` }], isError: true };
        }
      }
    );
  • The GraphQL client used by the execute_graphql handler to make requests.
    const client = new GraphQLClient(GRAPHQL_URL, { headers });
Behavior2/5

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

No annotations are provided, so the description must convey behavioral traits. It mentions 'execute' but does not disclose whether mutations have side effects, any authentication requirements, rate limits, or error behavior. This is a significant gap for a generic executor.

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?

Two short sentences with no fluff. The purpose is stated first, followed by usage guidance. Every word earns its place.

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 lack of output schema and annotations, the description is minimal. It provides the essential use case but omits details about return values, errors, or constraints like query complexity. Adequate but not fully complete for an executor that could have side effects.

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 baseline is 3. The description does not add any additional meaning beyond the schema for the 'query' or 'variables' parameters. It is adequate but not enhanced.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('execute') and the resource ('GraphQL query or mutation against the API'). It distinguishes itself as a general-purpose fallback when no specific tool exists.

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

Usage Guidelines5/5

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

Explicitly says 'Use this when no specific tool exists for your operation,' providing clear guidance on when to use this tool versus alternatives (like the sibling tool for type details).

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

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