OpenAPI to MCP Server: Turn a Swagger Spec into AI Agent Tools Without Code
An OpenAPI spec already describes everything an MCP server needs: one tool per operation, with its name, description and typed parameters. The hard part is not the conversion but choosing which operations the agent gets and what each one is allowed to do.
5 min read / Updated:
Create an MCP server from your specShort answer: converting OpenAPI to MCP maps each operation (method plus path) to one MCP tool, uses the operationId as the tool name, the summary and description as the tool description, and the parameters and request body as the tool's input schema. You can do it with a code generator you deploy yourself, or with a hosted service that reads the spec and serves the MCP server for you. Either way, keep only the operations the agent needs and put a permission on each one.
How does an OpenAPI operation become an MCP tool?
| OpenAPI field | MCP tool field | Why it matters |
|---|---|---|
| operationId | Tool name | The model chooses tools by name; create_customer beats post_customers |
| summary and description | Tool description | Tells the agent when to use it, which matters more than the URL |
| Path and query parameters | Input properties placed in the URL | Identifiers in the path, filters in the query |
| JSON request body | Input properties | Flat bodies are easier for the model to fill correctly |
| required | Required inputs | The agent asks for missing data instead of guessing |
| securitySchemes | Not exposed to the model | The credential is attached when the call is made |
| deprecated: true | Skipped | Old endpoints should not tempt the agent |
Should every endpoint become a tool?
No. Large specs overload agents. Speakeasy, which generates MCP servers from OpenAPI, wrote that "when faced with 200 tools, the model becomes confused as its context window is overwhelmed", and that servers with as many tools as operations are problematic for APIs with more than 500 operations (Speakeasy, June 24, 2025). Start with the operations people actually ask for and leave the rest out or blocked. Fewer, well-described tools lead to better choices.
Generated code or a hosted MCP server?
Open-source generators and SDK vendors turn a spec into MCP server code that you build, deploy, secure and update when the API changes. That gives you full control and fits teams that already ship services. A hosted approach reads the spec and serves the MCP server for you, so there is nothing to deploy; you trade some customization for less operational work. The question to ask of either: where do permissions, approvals and credentials live?
How do you turn a spec into an MCP server in Qaalia?
- Add the system: in Qaalia Chat, open Systems, click Add system and choose "Qaalia creates its MCP server".
- Paste one address: the spec itself (
https://api.example.com/openapi.json, JSON or YAML), the API's base address (Qaalia looks for the spec at usual paths such as/openapi.json,/swagger.jsonand/v3/api-docs) or a documentation page. Without any of these, you can paste the docs orcurlexamples. - Add the credential if needed: a header name such as
AuthorizationorX-API-Keyand its value. It is stored encrypted, the model never sees it and it is only sent to that system's address. - Analyze: Qaalia lists the operations it found, the address each one will call, and the result of up to 3 real read calls made with your credential, so you know the connection works.
- Choose the tools: pick the ones the server will have (up to 200) and click Create MCP server.
- Set permissions: each tool arrives with a suggestion based on its method (reads allowed, creates and edits on approval, deletes blocked). Change any of them, then test a tool with Try.
What does Qaalia read from the spec, exactly?
- OpenAPI 3.x and Swagger 2.0, in JSON or YAML. With a spec, operations are read exactly, without an AI model and without spending tokens.
- One tool per operation for GET, POST, PUT, PATCH and DELETE. The name comes from
operationId(or method and path when there is none); deprecated operations are skipped. - Path and query parameters go in the URL; the JSON body is flattened to its first level. Per-operation headers and cookies are not used: authentication is the system's.
- Auth hints in
securitySchemes(an API key in a header, or bearer tokens) suggest the header to fill in. - Without a spec, your agent's AI model reads the documentation and extracts the operations with the same rules; review them before creating the server.
How are calls to your API kept in bounds?
The base address must be a public https URL, and every call must stay inside it: a tool that resolves to another origin is rejected. Calls have a 30-second limit; a timeout is not retried, because a write may already have been applied, and the agent is told to check first. A 429 is passed to the agent as a rate-limit notice so it waits before repeating. Responses of up to 20,000 characters reach the agent. If your API lacks an operation, you can add it by hand as a manual operation that uses the same address and credential. For an API that only runs on your machine, the Qaalia Connector discovers its spec locally instead.
FAQ
Can I convert a Swagger 2.0 file, or only OpenAPI 3?
Both. Qaalia reads OpenAPI 3.x and Swagger 2.0 specs, in JSON or YAML, from a URL or from the API's usual spec paths.
Do I need to write or host any code?
No. Qaalia creates and serves the MCP server for your system. You choose the tools and their permissions; there is nothing to deploy.
What if my API has hundreds of endpoints?
Choose only the operations the agent needs, up to 200 per server, and block the rest. Blocked tools are not even shown to the model.
What if my API has no OpenAPI spec?
Paste a documentation page, the docs text or curl examples. Your agent's AI model extracts the operations, and you review them before creating the server. You can also add operations by hand.
Does the AI model see my API key?
No. The credential is stored encrypted, attached only when the call is made and only sent to that system's own address.
Related resources
How to Connect an AI Agent to Your API (Safely) in 2026
Step-by-step guide to let an AI agent call your own API: describe operations, set permissions, keep credentials safe, handle retries and test it, with or without code.
MCP Tool Approval: Allow, Require Approval or Block Each Tool
How MCP tool approval works: allow, require approval or block per tool, what the reviewer sees, what happens on timeout and how changed tools are handled.
How to Let a Cloud AI Agent Use Your Localhost API (No Open Ports)
Why cloud AI agents cannot reach localhost, how tunnels help, and how an outbound-only connector lets an agent use a local API, MCP servers and files.

