Graphql

io.github.Docat0209Published by GitHub account Docat0209v0.1.4Updated Oct 27, 2026

Turn any GraphQL API into MCP tools. Zero config, zero code.

VerifiedSTDIODesktop onlyDatabasesDeveloper Tools

Overview

AI-generated overview

Turns any GraphQL endpoint into MCP tools by introspecting its schema, so an assistant can call each query and mutation directly.

What you can do
  • Discover a GraphQL endpoint's queries and mutations through introspection and expose each one as a separate tool
  • Call queries and mutations with flattened, simple parameters instead of nested input objects
  • Limit which operations are exposed with include/exclude patterns and tool-name prefixes
  • Control large responses through automatic array slicing, depth pruning and size limits
  • Cache the introspected schema locally to speed up startup, with an option to force a refresh
  • Flag or block destructive mutations such as delete, remove, drop or purge
When to use it
Useful when you want an assistant to work with a specific GraphQL API without writing a custom server, for example a public countries API or a token-protected service like GitHub's GraphQL API. It suits read-heavy exploration and, with safety settings, controlled mutations.
Requirements
Runs locally via npx (Node.js) as a stdio process; an SSE transport option exists. Needs the GraphQL endpoint URL and network access to it. Authentication is optional and passed as command-line arguments: a bearer token, an API key with header or query placement, or custom headers.
Before you install
Credentials such as bearer tokens or API keys are supplied as command-line arguments, so they may end up in shell history or client config files. Mutations are exposed as tools and can change or delete data; the default mode only warns, so use the safe mode to exclude destructive operations. Tool calls send data to the configured third-party endpoint, and the optional schema cache file stores the endpoint URL locally.

Installation

In SourceWeft

  1. Open Graphql in the dashboard and add it to a workspace.
  2. Enable the server for the chats that should use its tools.

Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.

Other MCP clients

Follow the launch instructions in the repository.

README

graphql-to-mcp

[npm version] [npm downloads] [License: MIT]

Turn any GraphQL API into MCP tools — zero config, zero code.

Point graphql-to-mcp at a GraphQL endpoint and it auto-generates one MCP tool per query/mutation via introspection. Works with Claude Desktop, Cursor, Windsurf, and any MCP client.

Quick Start

Try it now — no install needed:

bash
npx graphql-to-mcp https://countries.trevorblades.com/graphql

Or add to Claude Desktop / Cursor config:

json
{  "mcpServers": {    "countries": {      "command": "npx",      "args": ["-y", "graphql-to-mcp", "https://countries.trevorblades.com/graphql"]    }  }}

That's it. Claude can now query countries, continents, and languages.

Features

  • Zero config — just provide a GraphQL endpoint URL
  • Auto-introspection — discovers all queries and mutations automatically
  • Flat parameter schemas — nested input objects are flattened for better LLM accuracy
  • Smart truncation — large responses are intelligently pruned (array slicing + depth limiting)
  • Auth support — Bearer tokens, API keys (header or query)
  • Retry logic — automatic retries on 429/5xx with exponential backoff
  • Include/exclude filters — expose only the operations you want
  • Schema caching — skip re-introspection with --schema-cache for faster startup
  • Mutation safety — auto-detect destructive mutations (delete*, remove*, etc.) and warn or block them

Usage

CLI

bash
# Public API (no auth)npx graphql-to-mcp https://countries.trevorblades.com/graphql
# With bearer tokennpx graphql-to-mcp https://api.github.com/graphql --bearer ghp_xxxxx
# With API keynpx graphql-to-mcp https://api.example.com/graphql --api-key "X-API-Key:your-key:header"
# Filter operationsnpx graphql-to-mcp https://api.example.com/graphql --include "get*" --exclude "internal*"
# With prefix (avoid name collisions when using multiple APIs)npx graphql-to-mcp https://api.example.com/graphql --prefix myapi
# Cache schema locally for faster restartsnpx graphql-to-mcp https://api.example.com/graphql --schema-cache ./schema.json
# Force re-introspection (ignore cache)npx graphql-to-mcp https://api.example.com/graphql --schema-cache ./schema.json --force-refresh
# Block destructive mutations (delete*, remove*, etc.)npx graphql-to-mcp https://api.example.com/graphql --mutation-safety safe

Claude Desktop / Cursor Config

json
{  "mcpServers": {    "github": {      "command": "npx",      "args": [        "-y", "graphql-to-mcp",        "https://api.github.com/graphql",        "--bearer", "ghp_xxxxx",        "--prefix", "github"      ]    }  }}

Programmatic

typescript
import { createServer } from "graphql-to-mcp";
const server = await createServer({  endpoint: "https://api.example.com/graphql",  auth: { type: "bearer", token: "xxx" },  include: ["getUser", "listUsers"],});

How It Works

  1. Introspect — Fetches the GraphQL schema via introspection query
  2. Flatten — Nested InputObject types are flattened into simple key-value parameters (e.g., input.name → input_name)
  3. Generate — Each query/mutation becomes an MCP tool with a flat JSON Schema
  4. Execute — When an LLM calls a tool, the flat args are reconstructed into proper GraphQL variables and sent to your endpoint

Why Flat Schemas?

LLMs are significantly better at filling flat key-value parameters than deeply nested JSON objects. By flattening InputObject types, we get:

  • Higher accuracy in parameter filling
  • Fewer hallucinated nested structures
  • Better compatibility across different LLM providers

Options

OptionDescriptionDefault
--bearer <token>Bearer token auth—
--api-key <name:value:in>API key auth—
-H, --header <name:value>Custom header (repeatable)—
--include <pattern>Include only matching operationsall
--exclude <pattern>Exclude matching operationsnone
--prefix <name>Tool name prefix—
--timeout <ms>Request timeout30000
--max-retries <n>Retry on 429/5xx3
--transport <stdio|sse>MCP transportstdio
--schema-cache <path>Save/load introspection cache—
--force-refreshIgnore cache, re-introspectfalse
--mutation-safety <mode>warn | safe | unrestrictedwarn

Smart Truncation

GraphQL APIs can return large payloads that overwhelm LLM context windows. graphql-to-mcp automatically:

  • Slices arrays to 20 items (with metadata showing total count)
  • Prunes depth beyond 5 levels (with object/array summaries)
  • Hard truncates at 50K characters as a safety net

Schema Caching

Introspection queries can be slow on large schemas. Use --schema-cache to save the introspection result locally:

bash
# First run: introspects and saves to cachenpx graphql-to-mcp https://api.example.com/graphql --schema-cache ./schema.json
# Subsequent runs: loads from cache (instant startup)npx graphql-to-mcp https://api.example.com/graphql --schema-cache ./schema.json
# Force re-introspection when the API schema changesnpx graphql-to-mcp https://api.example.com/graphql --schema-cache ./schema.json --force-refresh

The cache file stores the endpoint URL and timestamp. If you point at a different endpoint, it automatically re-introspects.

Mutation Safety

By default, graphql-to-mcp detects destructive mutations and adds warnings to their descriptions. This helps LLMs understand the risk before executing them.

Detected patterns: delete*, remove*, drop*, clear*, truncate*, destroy*, purge*, reset* (case-insensitive).

ModeBehavior
warn (default)Adds "DESTRUCTIVE:" prefix to dangerous mutation descriptions
safeCompletely excludes dangerous mutations from the tool list
unrestrictedNo filtering or warnings (previous behavior)
bash
# Safe mode: only expose read queries + non-destructive mutationsnpx graphql-to-mcp https://api.example.com/graphql --mutation-safety safe
# Unrestricted: expose everything (use with caution)npx graphql-to-mcp https://api.example.com/graphql --mutation-safety unrestricted

Use with REST APIs Too

Pair with mcp-openapi to give Claude access to both REST and GraphQL APIs:

json
{  "mcpServers": {    "github-graphql": {      "command": "npx",      "args": ["-y", "graphql-to-mcp", "https://api.github.com/graphql", "--bearer", "ghp_xxx", "--prefix", "gh"]    },    "petstore-rest": {      "command": "npx",      "args": ["-y", "mcp-openapi", "https://petstore3.swagger.io/api/v3/openapi.json"]    }  }}

Related

  • mcp-openapi — Same zero-config approach for REST/OpenAPI APIs

License

MIT

Source: README.md at commit 3c6934d

Tools

0
SourceWeft has not started this package in its sandbox yet, so its tools are not known.

Version history

1
  1. v0.1.4LatestSep 16, 2026

Score

50% of the applicable checks met

How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.

  • Reached in the last 30 days25 pts

    Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.

  • Auth declared10 pts

    Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.

  • Tools listed15 pts

    Answer tools/list without a credential, or ship a package that starts in a sandbox without one.

  • DescriptionRequired15 pts
  • Logo10 pts
  • Documentation15 pts
  • License10 pts