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 GraphQL operations
- 🗂 Automatically discover operations from
.graphqlrc.yml
- 🧾 Tool metadata compatible with OpenAI function calling / MCP
go install github.com/fotoetienne/gqai@latest
- Create a .graphqlrc.yml:
schema: https://graphql.org/graphql/
documents: .
This file tells gqai where to find your GraphQL schema and operations.
Note: The schema
parameter tells gqai where to execute the operations. This must be a live server rather than a static schema file
- Add a GraphQL operation
get_all_films.graphql
:
# Get all Star Wars films
query get_all_films {
allFilms {
films {
title
episodeID
}
}
}
- Add gqai to your
mcp.json
file:
"gqai": {
"command": "gqai",
"args": [
"run",
"--config"
".graphqlrc.yml"
]
}
That's it! Your AI model can now call the get_all_films
tool.
gqai tools/call get_all_films
This will execute the get_all_films
tool and print the result.
{
"data": {
"allFilms": {
"films": [
{
"id": 4,
"title": "A New Hope"
},
{
"id": 5,
"title": "The Empire Strikes Back"
},
{
"id": 6,
"title": "Return of the Jedi"
},
...
]
}
}
}
Create a GraphQL operation that takes arguments, and these will be the tool inputs:
get_film_by_id.graphql
:
query get_film_by_id($id: ID!) {
film(filmID: $id) {
episodeID
title
director
releaseDate
}
}
Call the tool with arguments:
gqai tools/call get_film_by_id '{"id": "1"}'
This will execute the get_film_by_id
tool with the provided arguments.
{
"data": {
"film": {
"episodeID": 1,
"title": "A New Hope",
"director": "George Lucas",
"releaseDate": "1977-05-25"
}
}
}
Auto-generated tool specs for each operation, so you can plug into any LLM that supports tool use.
gqai 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.
MIT — fork it, build on it, all the things.
Made with ❤️ and 🤖vibes by Stephen Spalding && <your-name-here>