WG

wimspaargaren/gql-gen-mcp

API development
6 stars 4 forks Quality 45 Trend 14MIT

The gql-gen-mcp tool has its name inspired by the awesome github.com/99designs/gqlgen generator. Instead of generating a GraphQL server, it generates Model Context Protocol (MCP) (stdio) servers...

Overview

The gql-gen-mcp tool has its name inspired by the awesome github.com/99designs/gqlgen generator. Instead of generating a GraphQL server, it generates Model Context Protocol (MCP) (stdio) servers based on your GraphQL schema definitions. It's currently based on mark3labs/mcp-go as it's the most widely adopted MCP Go server (April 2025). Gotools just started an implementation see mcp go thread, so perhaps we eventually switch over or make it configurable which server to use as output. You can configure gql gen mcp using a yaml file called .gql-gen-mcp.yaml. Example: Run the gql-gen-mcp tool in the directory where you've defined your .gql-gen-mcp.yaml file. Note that the main.go of your server is only generated once, such that you can configure the server to your needs. The generated MCP server is a stdio server. Install it on your system with go install .. Check out the example directory for a full example with a dummy bookstore GraphQL API.

README

Overview

The gql-gen-mcp tool has its name inspired by the awesome github.com/99designs/gqlgen generator. Instead of generating a GraphQL server, it generates Model Context Protocol (MCP) (stdio) servers based on your GraphQL schema definitions. It’s currently based on mark3labs/mcp-go as it’s the most widely adopted MCP Go server (April 2025). Gotools just started an implementation see mcp go thread, so perhaps we eventually switch over or make it configurable which server to use as output.

Usage

Install gql-gen-mcp

go install github.com/wimspaargaren/gql-gen-mcp@latest

Configuration

You can configure gql gen mcp using a yaml file called .gql-gen-mcp.yaml. Example:

schemas:
  - name: bookstore
    dir: ./bookstore/graphql/definitions
    output: ./mcp/bookstore
Field Description Required Default
name A unique name for the configuration, used for identification. No ``
dir The directory containing the GraphQL schema definitions. No ./
output The output directory for the generated server and tools. No ./
package The package name for the generated server and tools. No main
onlyTools If true, generates only the tools and skips server generation. No false

Run

Run the gql-gen-mcp tool in the directory where you’ve defined your .gql-gen-mcp.yaml file. Note that the main.go of your server is only generated once, such that you can configure the server to your needs.

gql-gen-mcp

Use with your favourite LLM tooling

The generated MCP server is a stdio server. Install it on your system with go install ..

MCP server definition:

"bookstore-api": {
      "command": "bookstore",
      "args": []
  },

Example

Check out the example directory for a full example with a dummy bookstore GraphQL API.

Missing features

  • Configuration via flags
  • No support for introspection or type query
  • No support for federated GraphQL
  • Generate MCP tools based on introspection query
View the full README on GitHub

Install

This server does not publish a one-line install command.

Open the repository installation guide New to MCP? Start with the mcpskill.org guide →