---
title: Is it safe to auto-generate MCP servers from OpenAPI specs?
url: https://opencontroller.lyzr.com/blog/risks-of-auto-generating-mcp-servers-from-openapi
published: 2026-11-17
updated: 2026-11-17
author: Lyzr
---

# Is it safe to auto-generate MCP servers from OpenAPI specs?

**It is safe only as a starting point. A straight conversion turns every API operation into an agent tool, including deletes and admin calls, with descriptions written for developers rather than models and credentials that are usually far too broad. Generate the server, then curate it: pick the operations agents need, separate reads from writes, rewrite descriptions and scope credentials per tool before anything goes live.**

The appeal is obvious. Most enterprises already have OpenAPI descriptions for hundreds of internal services. Several open-source tools and API platforms can turn them into MCP servers in minutes. The risk is that "minutes" skips every design decision that makes a tool safe for an agent.

## What goes wrong with a straight OpenAPI-to-MCP conversion?

| Risk | What happens | Why it matters |
|---|---|---|
| Tool explosion | One tool per operation; large APIs produce hundreds of tools | Tool definitions consume context tokens on every call, and models choose tools less reliably from long lists |
| Destructive endpoints exposed | `DELETE`, bulk update, admin and export operations become tools | One mistaken or injected call can delete or leak data at scale |
| Weak descriptions | Terse `summary` fields such as "Update item" become the model's only guidance | The model guesses what a tool does and when to use it |
| Auth passthrough | One broad service token, or the user's full token, is used for every operation | Least privilege is lost; every tool has every permission |
| Unbounded responses | List endpoints return thousands of records | Context overflow, cost spikes and data exposure |
| Missing safety hints | No `readOnlyHint` or `destructiveHint` annotations | Clients cannot prompt for confirmation on risky tools |
| Internal-only fields exposed | Debug, admin or tenant parameters appear in the tool's input schema | Agents can set values no user should control |

Token cost alone is significant. See [the token cost of MCP tool definitions](/blog/token-cost-of-mcp-tool-definitions) for how to estimate it.

## Checklist: curate a generated MCP server before publishing

Work through this list for every generated server.

1. **Start from tasks, not endpoints.** List the agent tasks the server will support. Keep only the operations those tasks need. For most use cases that is a small fraction of the API.
2. **Exclude by default.** Remove `DELETE`, bulk, admin, export and configuration operations unless a named task requires them, and then require a separate approval.
3. **Split read and write tools.** Put them in separate servers or toolsets so read-only agents never see write tools. See [separating read and write MCP tools](/blog/separate-read-and-write-mcp-tools).
4. **Rewrite every description.** Say what the tool does, when to use it, when not to, what each argument means and what the result contains. Write for a model, not a developer.
5. **Remove internal parameters.** Strip debug flags, tenant overrides and fields the server should set itself.
6. **Bound responses.** Add pagination limits and field filtering so a list call returns a manageable page.
7. **Scope credentials per tool.** Use OAuth scopes or per-tool service identities so each tool holds only the permission it needs. Avoid forwarding the user's full token to downstream APIs.
8. **Add annotations, but do not rely on them.** Set `readOnlyHint`, `destructiveHint` and `idempotentHint` accurately. Remember they are hints: the MCP specification says clients should treat annotations as untrusted unless the server is trusted.
9. **Add output schemas** for results agents act on, so clients can validate them.
10. **Register and assign an owner.** Record the server, version, tools and owner in your MCP inventory before any agent connects.
11. **Test with an agent.** Run real tasks and check that the model picks the right tool with the right arguments. Poor selection usually means a poor description.
12. **Regenerate with care.** When the OpenAPI document changes, re-run the curation diff instead of republishing everything.

## When does auto-generation work well?

It works best when:

- The API is small and well documented, with good `description` fields.
- Operations are mostly read-only.
- The API already enforces fine-grained authorisation per user.
- The generated server is reviewed like any other code change.

It works poorly for large, admin-heavy or legacy APIs, where a hand-built server with a few task-shaped tools is usually safer and cheaper. Our comparison of [MCP vs OpenAPI tools for internal APIs](/blog/mcp-vs-openapi-tools-for-internal-apis) covers when each interface fits.

## How many tools should a generated server expose?

There is no universal number, but fewer is better for both safety and accuracy. Group tools by task and give each agent only the toolsets it needs. See [how many tools an AI agent should have](/blog/how-many-tools-should-an-ai-agent-have).

## How Opencontroller does this

Opencontroller keeps a governed registry of agents, versions, tools and MCP servers, so each generated server has an owner, a version and a record of which agents use it. Posture flags risky permissions and configurations, and policy as code can restrict which tools each agent may call through the Agent Gateway. On developer devices, Opencontroller Edge discovers and controls local MCP servers. Read our pillar on [how to govern MCP servers](/blog/how-to-govern-mcp-servers), or [book a demo](https://www.lyzr.ai/book-demo/).

## Frequently asked questions

**Can we expose our whole API to agents through one generated MCP server?**
You can, but you should not. Large tool lists cost tokens, hurt tool selection and expose operations no agent needs.

**Do MCP tool annotations make generated servers safe?**
No. They are hints that clients should not trust from untrusted servers. Enforce safety with scoped credentials and policy.

**Who should own a generated MCP server?**
The team that owns the underlying API, with a named person accountable for which operations are exposed and how credentials are scoped.

## Key facts

Auto-generating an MCP server from an OpenAPI description is safe only after curation. Main risks: tool explosion (one tool per operation can mean hundreds of tools, consuming context tokens and degrading tool selection), destructive endpoints exposed by default (DELETE, bulk and admin operations), weak tool descriptions copied from terse API summaries, auth passthrough (a broad service token or the user's full token forwarded to every operation), and missing safety hints. MCP tool annotations such as readOnlyHint and destructiveHint are hints that clients should not trust from untrusted servers. A curation checklist selects operations by task, separates read and write tools, rewrites descriptions, scopes credentials per tool and adds output schemas. Opencontroller by Lyzr keeps a governed registry of tools and MCP servers; pricing starts from $250K per deployment per year.

## Related

- [Should agents call internal APIs through MCP or OpenAPI tools?](https://opencontroller.lyzr.com/blog/mcp-vs-openapi-tools-for-internal-apis.md)
- [How many tools should one AI agent have?](https://opencontroller.lyzr.com/blog/how-many-tools-should-an-ai-agent-have.md)
- [Should read and write tools live on separate MCP servers?](https://opencontroller.lyzr.com/blog/separate-read-and-write-mcp-tools.md)
- [More on Tools and MCP](https://opencontroller.lyzr.com/blog/cluster/tools-and-mcp)
