Two ways to turn an API into MCP
You have an HTTP API and you want Claude, ChatGPT, Cursor or your own agent to use it. There are two broad ways to get there.
- Build or generate a custom MCP server. A generator reads your OpenAPI document and emits one MCP tool per operation. You host the result, keep it in sync with the API and give it a credential.
- Describe the API once and let a bridge serve it. You publish one JSON file at
<base>/aithat says what the API does. A bridge reads it and exposes it to every MCP client through the same four tools.
This page explains why Apitell takes the second route, and walks through it step by step.
The usual way: one tool per OpenAPI operation
OpenAPI-to-MCP generators are the quickest path to a demo. Point one at openapi.json and you get a server where every operationId becomes a tool, every parameter becomes a tool argument and every summary becomes a tool description.
It works for a small API. It breaks down in four places.
Tool explosion
A real API has a lot of operations. A CRM or a billing API easily has a few hundred. Generated one-to-one, every one of them is a tool, and MCP clients put the whole tool list in front of the model on every turn. Connect three such APIs and the model is choosing from hundreds of near-identical names like list_invoice_items and list_invoices. Fewer, clearer tools help a model choose; a longer list makes the wrong pick more likely.
Thin descriptions
OpenAPI summaries were written for people reading reference docs next to a sidebar. “List invoices” says nothing about which filter to use for “unpaid this month”, which field is safe to add up, or which call has to come first. A model reads that summary and guesses. When it guesses wrong it often gets a 200 with the wrong data, not an error.
Another service to run
A generated server is code. It needs hosting, updates when the API changes, dependency upgrades, logs and monitoring. Regenerate it after every API release or it drifts: the spec says one thing, the route does another, and the first agent that believes the spec gets a 404.
Auth moves into the server
The generated server calls your API, so it needs a credential. Usually that is an API key in its environment, or pasted into the client’s mcp.json. Every user who installs it gets a copy of a key.
The other way: one file at <base>/ai
The AI Context spec takes a different approach. Your service publishes one JSON file per versioned API base and answers GET <base>/ai with it. That is all your service does. No SDK, no generated server, no batch endpoint.
The file carries what a model needs to use the API well: what the service is, its operations and their arguments, what each returned field means and whether it may be summed, a few questions to start with, and worked examples. A trimmed tool entry of the base /v1/support/tickets looks like this — its path is relative to the base:
{
"name": "tickets_list",
"mode": "read",
"purpose": "Tickets of this workspace, newest first, filtered by status.",
"method": "GET",
"path": "/",
"input_schema": {
"properties": {
"status": { "type": "string", "enum": ["open", "pending", "resolved", "closed"],
"description": "Only tickets in this state. Omit for every state." },
"limit": { "type": "integer", "minimum": 1, "maximum": 100, "default": 20 }
}
}
}
A bridge reads the file and serves it over MCP with four tools, whatever the size of the API:
ai_discover: what is connected and how each base is organized.ai_search: which operations answer a question, ranked.ai_describe: one operation in full, with its schema, notes and examples.ai_call: the call itself, up to eight in one batch, each validated against the schema before anything is sent.
Search and describe never cost a request to your service; the description is already read. Only ai_call reaches your routes, and each call is one request to your own route, behind your own authentication.
Step by step
1. Draft the file with the ai-context skill
Nobody writes this file by hand from the schema. The open-source ai-context skill for Claude Code reads your service’s code, which is the truth, plus your docs, and drafts the file. It has three modes:
createdrafts the file from your routes and docs.grillasks you, in small batches, what the code cannot answer: what a tool is for, whether a number adds up, what an enum value means.updatere-reads the code after a route changes and touches only the structural keys; your prose stays as written.
Already have an OpenAPI document? The skill reads it with the rest of your docs, as wording to confirm with you. The structure (methods, paths, arguments) still comes from the routes in your code, so a spec that drifted from the code does not drift into the file.
The skill never invents prose. If you answer “don’t know”, the key stays empty and is reported. An empty key is visible; an invented one is a wrong answer served to every caller.
2. Serve it at GET <base>/ai
Return the same bytes to every caller, with an ETag so a bridge can re-check it cheaply. A static file from your web server is enough:
location = /v2/orders/ai {
default_type application/json;
alias /srv/orders/ai-context.json;
}
Or a few lines in Go:
//go:embed ai-context.json
var aiContext []byte
mux.HandleFunc("GET /v2/orders/ai", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.Write(aiContext)
})
The file may sit behind your authentication. A request without a credential then gets your 401, and its body should carry the file’s auth block so a caller knows how to get a token.
3. Check it with apitell check
apitell check ships with the open-source bridge. It validates the file strictly (an unknown key is an error, not a silent skip), then runs every starting question and every example as a batch:
apitell check ai-context.json # validate, dry-run every example
apitell check ai-context.json \
--base https://staging.example.com/v2/orders --live # call the routes
apitell check https://api.example.com/v2/orders # resolve the base as a bridge would
With --live, the credential comes from APITELL_TOKEN or APITELL_TOKEN_FILE, and every example must answer 2xx. An example that writes runs live only with --allow-writes.
4. Put the check in CI
apitell check exits 1 on the first failure, so it belongs in the same pipeline as your tests. When a route changes, run the skill’s update, commit the new file, and the check tells you before an agent does.
5. Connect it
To try it locally, point the open-source bridge at your base:
export APITELL_BASES=https://api.example.com/v2/orders
export APITELL_TOKEN_FILE=~/.config/example/token
apitell stdio
For a team, connect the base in the hosted gateway instead. Everyone adds one URL, https://mcp.apitell.com/mcp, signs in, and your API appears next to every other connected API. No MCP server to build or host.
How auth stays yours
Converting an API to MCP should not mean handing your auth model to someone else.
- Your routes, your rules. The file declares where the credential goes (
bearer,basic, or a named header). Every call is a request to your own route with that credential, and your API enforces its own permissions exactly as it does today.mode: readorwritein the file describes an operation; it is not a permission. - Your credential goes to your base and nowhere else. A description whose
service.basenames another host is refused, and every tool path must be absolute on your host. A file cannot redirect a credential. - In the hosted gateway, the agent never holds it. Your API’s key or OAuth grant sits in the vault, bound to your host, and is added at the last hop. The AI client signs in to Apitell with OAuth and only ever holds that sign-in. Writes are off until allowed and can require approval.
When a generator is still fine
If your API has ten operations, one user and no secrets, a generated server is a reasonable afternoon project. Once you have more operations, more people, or a key you would not paste into a chat, one described base behind a gateway is less to run and less to leak.
Try it
Write your first file with the skill, run apitell check, then create a free workspace and connect your base. Read how API providers publish at /ai, the full AI Context spec, or how Apitell compares with running one MCP server per API.