Most of the software your team relies on already has an API. Almost none of it has an MCP server yet. That gap is the whole reason “turn your API into an MCP server” became one of the most-searched MCP topics of the year — if an app exposes a REST API, you can usually make it callable by Claude, ChatGPT, or any Model Context Protocol client without waiting for the vendor to ship an official integration.
The good news: the mechanical part is largely solved. The honest news: a raw auto-conversion is a starting point, not a finished product. This guide walks through what the conversion actually involves, the tools that do it, and the three things — tool count, authentication, and security — that decide whether the result is usable or a liability.
What “turning an API into an MCP server” actually means
An MCP server exposes tools: named actions with a description and a JSON Schema for their inputs, which an AI client can discover and call. A REST API already has the raw material for this — each operation has a method, a path, parameters, and a request body. Converting one to the other means mapping each API operation to one MCP tool, then standing up something that receives the tool call, builds the corresponding HTTP request, executes it, and hands the response back as tool output.
That “something” is the part people underestimate. The API itself doesn’t change; you’re building an adapter in front of it that speaks MCP on one side and HTTP on the other. Where that adapter runs, how it holds your credentials, and how many tools it exposes are all decisions you now own.
The reliable path: start from an OpenAPI spec
If the API publishes an OpenAPI (formerly Swagger) document, the conversion is deterministic. The spec already lists every operation, its parameters, its request and response schemas, and its security scheme, so a generator can produce accurate tool definitions without guessing. A lot of APIs expose this at a predictable path like /openapi.json or /swagger.json.
Several tools do this today, at different levels of effort:
- FastMCP (Python) generates an MCP server from an OpenAPI spec or a FastAPI app, and lets you remap or exclude routes.
- openapi-mcp-generator (TypeScript) and Higress’s openapi-to-mcpserver (Go) are self-hosted CLI generators.
- Managed platforms wrap the same idea with hosting: Azure API Management can expose an existing API’s operations as a remote MCP server, and vendors like Speakeasy and Stainless build tooling around it.
No spec? You have two options: find the API’s reference docs and write the tool definitions by hand, or use a tool that reads the documentation and drafts them for you. The hand-written route is reliable but tedious; the assisted route is fast but must be reviewed, because a model reading prose can misread an endpoint or a parameter.
The trap: one endpoint per tool
The default behavior of almost every generator is one tool per operation. For a small API that’s fine. For a large one it’s a problem: a 500-endpoint API becomes a 500-tool MCP server, and every one of those tool definitions is loaded into the model’s context before it does anything useful. That burns tokens, slows responses, and makes it harder for the model to pick the right tool.
This is the consistent lesson from teams doing conversions at scale: FastMCP’s own docs note that models “achieve significantly better performance with well-designed and curated MCP servers than with auto-converted OpenAPI servers,” and recommend auto-generation for bootstrapping rather than mirroring a whole API. The practical rule is generate first, then curate: drop endpoints an agent will never need, collapse multi-step workflows, rewrite terse descriptions into ones a model can act on, and cap the total tool count.
Authentication is the part that doesn’t map cleanly
MCP has a clean model for how a client authenticates to a server. It has no built-in model for how your new server authenticates to the target API behind it — that’s on you. In practice you’ll hit three cases:
- API key or bearer token — a static secret sent as a header or query parameter. Simple, but it must be stored securely and injected only at call time.
- OAuth2 client credentials — a client ID and secret exchanged for a short-lived token. The adapter has to fetch and refresh that token itself.
- User-delegated OAuth — the hardest case, where each user authorizes access to their own data.
Whichever it is, one rule holds: the credential is infrastructure, not a tool input. It should never appear in the tool list the AI sees, never be logged, and never be echoed back in an error. Store it encrypted and inject it when the adapter builds the outbound request. (If you’re fuzzy on what an AI client is even granting when it connects, our post on MCP OAuth scopes is a good primer.)
What has no MCP equivalent
Set expectations before you convert. Some common API patterns don’t translate: paged list endpoints, webhooks, and streaming responses have no natural MCP counterpart, so an agent may need extra prompting to page through results, and event-driven APIs simply don’t fit the request/response tool model. A generated server is best at the “call an operation, get a result” shape — which, fortunately, is most of what an agent needs.
The security you inherit
The moment you stand up an adapter, you’re making outbound HTTP calls to an API on the AI’s behalf — driven by arguments the model chose, which may in turn come from content it read at runtime. That’s a real attack surface, and it’s worth being deliberate about:
- Guard the target URL. If any part of the request is user- or model-controlled, validate it so a call can’t be pointed at an internal or cloud-metadata address (a classic SSRF risk).
- Treat write and delete operations as different from reads. A generated
delete_*tool has the same one-line footprint as a harmless lookup, but a very different blast radius. Flag them, and keep the destructive ones behind an approval step. - Review the descriptions. If you used an assisted generator, the tool descriptions were written by a model reading docs — the same channel attackers use for tool poisoning. Read them before you trust them, and run the finished server through a vetting checklist.
How gate does this
Building the adapter, the credential vault, the tool curation, and the safety checks yourself is a real project. We built gate’s MCP Builder so you don’t have to. You paste an OpenAPI spec URL — or just a docs URL, and gate finds the spec or reads the page — and it generates the tool definitions for you to review, with each tool flagged read or write and the total capped so you don’t get a thousand-tool wall.
You supply the API credential (a key, a bearer token, or OAuth2 client credentials); gate stores it encrypted, injects it at call time, and never exposes it in the tool list. Every outbound call is checked against an SSRF guard, and the generated server is scanned for prompt injection before it goes live and governed like any other server behind your gateway — per-tool allow / ask / block, destructive tools behind approval, and a plain-language log of every call. Keep the server private to your own gateway, or publish the definition (never your credential) so others can connect it with their own key.
The bottom line
Turning an API into an MCP server is no longer the hard part — spec-based generators make the mechanical conversion nearly free. The work that matters is everything downstream: curating the tool list so it doesn’t bloat the context, handling the target API’s auth without leaking secrets, and treating the whole thing as a new piece of production surface with real security implications. Generate the server in minutes, but govern it before you point an agent at it.