graphql → ai gqai is a lightweight proxy that exposes GraphQL operations as Model Context Protocol (MCP) tools for AI like Claude, Cursor, and ChatGPT. Define tools using regular GraphQL queries/mutations against your GraphQL backend, and gqai automatically generates an MCP server for you. 🔌 Powered by your GraphQL backend ⚙️ Driven by .graphqlrc.yml + plain .graphql files - 🧰 Define tools using
Add this skill
npx mdskills install fotoetienne/gqaiWell-documented MCP server that bridges GraphQL APIs to AI agents with clear setup and config examples
1# gqai2*graphql → ai*34**gqai** is a lightweight proxy that exposes GraphQL operations as5[Model Context Protocol (MCP)](https://platform.openai.com/docs/guides/function-calling) tools for AI like6Claude, Cursor, and ChatGPT.7Define tools using regular GraphQL queries/mutations against your GraphQL backend, and gqai automatically8generates an MCP server for you.910🔌 Powered by your GraphQL backend11⚙️ Driven by `.graphqlrc.yml` + plain `.graphql` files1213---1415## ✨ Features1617- 🧰 Define tools using GraphQL operations18- 🗂 Automatically discover operations from `.graphqlrc.yml`19- 🧾 Tool metadata compatible with OpenAI function calling / MCP2021---2223## 🛠️ Installation2425```bash26go install github.com/fotoetienne/gqai@latest27```282930## 🚀 Quick Start311. Create a .graphqlrc.yml:3233```yaml34schema: https://graphql.org/graphql/35documents: .36```3738This file tells gqai where to find your GraphQL schema and operations.3940*Note: The `schema` parameter tells gqai where to execute the operations. This must be a live server rather than a static schema file*41422. Add a GraphQL operation4344`get_all_films.graphql`:45```graphql46# Get all Star Wars films47query get_all_films {48 allFilms {49 films {50 title51 episodeID52 }53 }54}55```56573. Add gqai to your `mcp.json` file:5859```60 "gqai": {61 "command": "gqai",62 "args": [63 "run",64 "--config"65 ".graphqlrc.yml"66 ]67 }68```6970That's it! Your AI model can now call the `get_all_films` tool.7172## Usage73### Configuration74#### GraphQL Config75The [graphql config](https://the-guild.dev/graphql/config/docs/user/schema)76file is a YAML file that defines the GraphQL endpoint and the operations77you want to expose as tools. It should be named `.graphqlrc.yml` and placed in the root of your project.7879```yaml80schema: https://graphql.org/graphql/81documents: operations82```8384The `schema` field specifies the GraphQL endpoint, and the `documents` field specifies the directory where your GraphQL operations are located.8586In this example, the `operations` directory contains all the GraphQL operations you want to expose as tools.87Operations are defined in `.graphql` files, and gqai will automatically discover them.8889##### Headers90You can also specify headers to be sent with each request to the GraphQL endpoint. This is useful for authentication or other custom headers.9192```yaml93schema:94 - https://graphql.org/graphql/:95 headers:96 Authorization: Bearer YOUR_TOKEN97 X-Custom-Header: CustomValue98documents: .99```100101##### Using Environment Variables in Headers102You can reference environment variables in header values using the `${VARNAME}` syntax. For example:103104```yaml105schema:106 - https://graphql.org/graphql/:107 headers:108 Authorization: Bearer ${MY_AUTH_TOKEN}109documents: .110```111112You can also provide a default value using the `${VARNAME:-default}` syntax:113114```yaml115schema:116 - https://graphql.org/graphql/:117 headers:118 Authorization: Bearer ${MY_AUTH_TOKEN:-default-token}119documents: .120```121122When gqai loads the config, it will substitute `${MY_AUTH_TOKEN}` with the value of the `MY_AUTH_TOKEN` environment variable, or use `default-token` if the variable is not set. This allows you to keep secrets out of your config files.123124If the environment variable is not set and no default is provided, the value will be left as-is.125126##### Using Environment Variables in Config127You can use environment variables in any part of your `.graphqlrc.yml` config: schema URLs, document paths, include/exclude globs, and header values. Use `${VARNAME}` or `${VARNAME:-default}` syntax:128129```yaml130schema:131 - ${MY_SCHEMA_URL:-https://default/graphql}:132 headers:133 Authorization: Bearer ${MY_AUTH_TOKEN}134documents:135 - ${MY_DOCS_PATH:-operations/**/*.graphql}136include: ${MY_INCLUDE:-operations/include.graphql}137exclude: ${MY_EXCLUDE:-operations/exclude.graphql}138```139140gqai will substitute these with the value of the environment variable, or use the default if not set. This keeps secrets and environment-specific paths out of your config files.141142#### MCP Configuration143##### Claude Desktop144To use gqai with Claude Desktop, you need to add the following configuration to your `mcp.json` file:145146```json147{148 "gqai": {149 "command": "gqai",150 "args": [151 "run",152 "--config",153 ".graphqlrc.yml"154 ]155 }156}157```158159160### 🧪 CLI Testing161#### Call a tool via CLI to test:162163```bash164gqai tools/call get_all_films165```166167This will execute the `get_all_films` tool and print the result.168169```shell170{171 "data": {172 "allFilms": {173 "films": [174 {175 "id": 4,176 "title": "A New Hope"177 },178 {179 "id": 5,180 "title": "The Empire Strikes Back"181 },182 {183 "id": 6,184 "title": "Return of the Jedi"185 },186 ...187 ]188 }189 }190}191```192#### Call a tool with arguments:193194Create a GraphQL operation that takes arguments, and these will be the tool inputs:195196`get_film_by_id.graphql`:197```graphql198query get_film_by_id($id: ID!) {199 film(filmID: $id) {200 episodeID201 title202 director203 releaseDate204 }205}206```207208Call the tool with arguments:209210```bash211gqai tools/call get_film_by_id '{"id": "1"}'212```213214This will execute the `get_film_by_id` tool with the provided arguments.215216```shell217{218 "data": {219 "film": {220 "episodeID": 1,221 "title": "A New Hope",222 "director": "George Lucas",223 "releaseDate": "1977-05-25"224 }225 }226}227```228229## Development230231### Prerequisites232- Go 1.20+233234### Build235```bash236go build -o gqai main.go237```238239### Test240```bash241go test ./...242```243244### Format245```bash246go fmt ./...247```248249### Run MCP server250```bash251./gqai run --config .graphqlrc.yml252```253254### Run CLI255```bash256./gqai tools/call get_all_films257```258259260## About GQAI261262### 🤖 Why gqai?263gqai makes it easy to turn your GraphQL backend into a model-ready tool layer — no code, no extra infra. Just define your operations and let AI call them.264265### 📜 License266MIT — fork it, build on it, all the things.267268### 👋 Author269Made with ❤️ and 🤖vibes by Stephen Spalding && `<your-name-here>`270
Full transparency — inspect the skill content before installing.