# Swagger To Mcp

> 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.

- **Type:** Skill
- **Install:** `agentstack add skill-mcp-com-ai-api-to-mcp-skills-api-to-mcp-skills`
- **Verified:** Pending review
- **Seller:** [mcp-com-ai](https://agentstack.voostack.com/s/mcp-com-ai)
- **Installs:** 0
- **Category:** [Cloud & Infrastructure](https://agentstack.voostack.com/c/cloud-infrastructure)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [mcp-com-ai](https://github.com/mcp-com-ai)
- **Source:** https://github.com/mcp-com-ai/api-to-mcp-skills
- **Website:** https://mcp.com.ai

## Install

```sh
agentstack add skill-mcp-com-ai-api-to-mcp-skills-api-to-mcp-skills
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# 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

1. **Verify HAPI CLI installation**
   ```bash
   hapi --version
   ```
   
   If 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:latest` image directly

2. **Validate OpenAPI spec** is v3.x (not v2/Swagger). HAPI requires OpenAPI 3.0+ specifications.

### Phase 2: Local Development & Testing

1. **Start local MCP server**
   ```bash
   hapi serve  \
     --openapi  \
     --url  \
     --headless \
     --port 3030
   ```

2. **Verify server health**
   ```bash
   curl -s http://localhost:3030/health
   # Expected: 200 OK
   
   curl -s http://localhost:3030/mcp/ping
   # Expected: pong
   ```

3. **Test MCP endpoint** — The MCP transport is available at `/mcp` using Streamable HTTP:
   - `POST /mcp` — JSON-RPC messages
   - `GET /mcp` — Server info (returns 204)

### Phase 3: Deployment

Choose deployment target based on requirements:

#### Option A: Cloudflare Workers (Recommended for simplicity)

1. **Authenticate** (first time only):
   ```bash
   hapi login
   ```

2. **Deploy**:
   ```bash
   hapi deploy \
     --openapi  \
     --url  \
     --name  \
     --project 
   ```

3. **Verify deployment**:
   ```bash
   curl -s https://..workers.dev/health
   ```

#### Option B: Docker (Self-hosted)

```bash
docker run --name hapi- -d --rm \
  -p 3030:3030 \
  hapimcp/hapi-cli:latest serve  \
  --openapi  \
  --url  \
  --port 3030 \
  --headless
```

### Phase 4: Verification Checklist

Before considering deployment complete:

- [ ] `/health` returns 200 OK
- [ ] `/mcp/ping` returns `pong`
- [ ] 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//`

## References

For detailed documentation, consult:
- [references/hapi-cli-commands.md](references/hapi-cli-commands.md) — Complete CLI reference
- [references/deployment-patterns.md](references/deployment-patterns.md) — Docker & Cloudflare recipes
- [references/troubleshooting.md](references/troubleshooting.md) — Common issues & fixes

## Quick Examples

### Petstore API (Demo)
```bash
hapi serve petstore \
  --openapi https://petstore3.swagger.io/api/v3/openapi.json \
  --url https://petstore3.swagger.io/api/v3 \
  --headless --port 3030
```

### Custom API
```bash
hapi serve my-api \
  --openapi https://my-api.example.com/openapi.json \
  --url https://my-api.example.com \
  --headless --port 3030
```

### Deploy to Cloudflare
```bash
hapi deploy \
  --openapi https://my-api.example.com/openapi.json \
  --url https://my-api.example.com \
  --name my-api-mcp
```

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [mcp-com-ai](https://github.com/mcp-com-ai)
- **Source:** [mcp-com-ai/api-to-mcp-skills](https://github.com/mcp-com-ai/api-to-mcp-skills)
- **License:** MIT
- **Homepage:** https://mcp.com.ai

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** yes
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: flagged — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-mcp-com-ai-api-to-mcp-skills-api-to-mcp-skills
- Seller: https://agentstack.voostack.com/s/mcp-com-ai
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
