# I turned a real OpenAPI into an MCP server in 5 min (without losing custom code on regen)

> Source: <https://dev.to/christopherdond/i-turned-a-real-openapi-into-an-mcp-server-in-5-min-without-losing-custom-code-on-regen-2j2k>
> Published: 2026-09-20 19:50:35+00:00

I built an OpenAPI to MCP server generator for TypeScript, Python and Go.

The v1 mistake: 1 endpoint = 1 tool. On a real API with 200 operations, you get a 200-tool server. Nobody can use that. That was the exact feedback I got on Reddit, and it was right.

What I changed in 2.1.5:

200 operations across 8 tags become ~8 tools. Each group routes internally by `action`.

node dist/cli/index.js generate -i api.yaml -o ./out --group-by tag

node dist/cli/index.js generate -i api.yaml -o ./out --include-tags pets --group-by tag

Filter before you generate

Only generate what you will use:

node dist/cli/index.js generate -i api.yaml -o ./out --path-prefix "/users/**" node dist/cli/index.js generate -i api.yaml -o ./out --include-paths "/users/**,/orders/

Regen without losing custom code

Your code lives between markers and survives regen with a 3-way merge:

// @@mcp-gen:start:get_pets

const user = await db.users.findById(args.id);

return { content: [{ type: "text", text: JSON.stringify(user) }] };

// @@mcp-gen🔚get_pets

node dist/cli/index.js generate -i api.yaml -o ./out --incremental

Reusable logic goes in handlers.custom.* — never overwritten without --force.

Fase 0 P0 fixes in 2.1.5

TypeScript: real query serialization (get_pets({ limit: 5 }) -> /pets?limit=5)

Python: _build_query / _build_headers in --http mode, including grouped tools

Go: --http wired to the real APIClient, no more not yet wired stubs

Registry is v3-only with actionable errors for removed keys and v2 specs

Try it with the repo example

git clone [https://github.com/ChristopherDond/MCP-Generator.git](https://github.com/ChristopherDond/MCP-Generator.git)

cd MCP-Generator

npm ci

npm run build

node dist/cli/index.js generate -i examples/petstore.yaml -l typescript -o ./my-server

node dist/cli/index.js validate -i examples/petstore.yaml

Or install directly:

npm install -g @christopher_dondici/[mcp-gen@2.1.5](mailto:mcp-gen@2.1.5)

Repo: [https://github.com/ChristopherDond/MCP-Generator](https://github.com/ChristopherDond/MCP-Generator)

Validated with npm run build + npm test (11 suites, 196 tests).
