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.
go install github.com/wimspaargaren/gql-gen-mcp@latestYou 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 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-mcpThe generated MCP server is a stdio server. Install it on your system with go install ..
MCP server definition:
"bookstore-api": {
"command": "bookstore",
"args": []
},Check out the example directory for a full example with a dummy bookstore GraphQL API.
- Configuration via flags
- No support for introspection or type query
- No support for federated GraphQL
- Generate MCP tools based on introspection query