swagger-to-mcp
Skill3 starsChanged 10 months agoMITView on GitHub
Convert OpenAPI v3 specifications into MCP servers using HAPI CLI. Supports local, Docker, and Cloudflare Workers deployment. Zero code required. Use when you need to expose API functionality as MCP tools or deploy API-based services to multiple hosting platforms.
- Pipes a download into a shell
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 25
If not installed, install using:
- Very specific: line 28
Docker: Use hapimcp/hapi-cli:latest image directly
- Distinctive: line 95
Before considering deployment complete:
- Very specific: line 105
Use --headless flag when the MCP server proxies requests to an existing backend API.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
API to MCP Server Skill
Convert OpenAPI v3 specifications into fully functional MCP (Model Context Protocol) servers using HAPI CLI — no code required.
Workflow
Phase 1: Environment Setup
Verify HAPI CLI installation
hapi --versionIf not installed, install using:
- Linux/macOS:
curl -fsSL https://get.mcp.com.ai/hapi.sh | bash - Windows:
irm https://get.mcp.com.ai/hapi.ps1 | iex - Docker: Use
hapimcp/hapi-cli:latestimage directly
- Linux/macOS:
- Validate OpenAPI spec is v3.x (not v2/Swagger). HAPI requires OpenAPI 3.0+ specifications.
Phase 2: Local Development & Testing
- Start local MCP server
hapi serve <project-name> \ --openapi <path-or-url-to-openapi-spec> \ --url <backend-api-url> \ --headless \ --port 3030 - Verify server health
curl -s http://localhost:3030/health # Expected: 200 OK curl -s http://localhost:3030/mcp/ping # Expected: pong - Test MCP endpoint — The MCP transport is available at
/mcpusing Streamable HTTP:POST /mcp— JSON-RPC messagesGET /mcp— Server info (returns 204)
Phase 3: Deployment
Choose deployment target based on requirements:
Option A: Cloudflare Workers (Recommended for simplicity)
- Authenticate (first time only):
hapi login - Deploy:
hapi deploy \ --openapi <path-or-url-to-openapi-spec> \ --url <backend-api-url> \ --name <worker-name> \ --project <project-name> - Verify deployment:
curl -s https://<worker-name>.<account>.workers.dev/health
Option B: Docker (Self-hosted)
docker run --name hapi-<project> -d --rm \
-p 3030:3030 \
hapimcp/hapi-cli:latest serve <project-name> \
--openapi <openapi-url> \
--url <backend-api-url> \
--port 3030 \
--headlessPhase 4: Verification Checklist
Before considering deployment complete:
/healthreturns 200 OK/mcp/pingreturnspong- At least one tool call succeeds via MCP transport
- Error responses include actionable messages
Key Concepts
Headless Mode
Use --headless flag when the MCP server proxies requests to an existing backend API. Without this flag, HAPI serves the OpenAPI spec documentation UI.
Streamable HTTP Transport
HAPI uses Streamable HTTP (not stdio). MCP clients connect via HTTP POST to /mcp endpoint. SSE is supported for streaming responses.
OpenAPI Spec Sources
HAPI accepts specs from:
- Local file path:
--openapi ./specs/api.yaml - Remote URL:
--openapi https://api.example.com/openapi.json - Pre-loaded specs in
~/.hapi/specs/<project>/
References
For detailed documentation, consult:
- references/hapi-cli-commands.md — Complete CLI reference
- references/deployment-patterns.md — Docker & Cloudflare recipes
- references/troubleshooting.md — Common issues & fixes
Quick Examples
Petstore API (Demo)
hapi serve petstore \
--openapi https://petstore3.swagger.io/api/v3/openapi.json \
--url https://petstore3.swagger.io/api/v3 \
--headless --port 3030Custom API
hapi serve my-api \
--openapi https://my-api.example.com/openapi.json \
--url https://my-api.example.com \
--headless --port 3030Deploy to Cloudflare
hapi deploy \
--openapi https://my-api.example.com/openapi.json \
--url https://my-api.example.com \
--name my-api-mcpDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

