Generate a complete MCP server from any OpenAPI specification in seconds.
Turn any REST API into an MCP (Model Context Protocol) server that works with Claude, ChatGPT, Cursor, and other AI assistants — no boilerplate, no manual wiring.
Every API that wants to work with AI assistants needs an MCP server. Writing one by hand means parsing specs, wiring up HTTP calls, defining Zod schemas, and setting up transports. create-mcp-server does all of that automatically.
| Feature | create-mcp-server | openmcp | Manual |
|---|---|---|---|
| Code generation (own & customize) | ✅ | ❌ (runtime proxy) | ✅ |
| Zero config quick start | ✅ | ✅ | ❌ |
| Interactive endpoint selection | ✅ | ❌ | ❌ |
| Auto Zod schema generation | ✅ | ❌ | ❌ |
| Auth detection & setup | ✅ | ✅ | ❌ |
| Claude Desktop config | ✅ | ✅ | ❌ |
| Dockerfile included | ✅ | ❌ | ❌ |
| MCP Inspector integration | ✅ | ❌ | ❌ |
npx create-mcp-serverThat's it. The interactive CLI will guide you through:
- Provide an OpenAPI spec (file path or URL)
- Select which API endpoints to expose as tools
- Configure project name, transport, and auth
- Get a complete, runnable MCP server project
# From a URL
npx create-mcp-server https://petstore3.swagger.io/api/v3/openapi.json
# From a local file
npx create-mcp-server ./my-api-spec.yaml
# Non-interactive (include all endpoints, use defaults)
npx create-mcp-server https://api.example.com/openapi.json --yes --all
# Custom output directory and project name
npx create-mcp-server ./spec.json --name my-api-server --output ./servers/my-apimy-api-mcp-server/
├── src/
│ └── index.ts # Complete MCP server with all tool definitions
├── test/
│ └── server.test.ts # Basic test scaffolding
├── dist/ # Compiled JavaScript (after build)
├── package.json # Dependencies & scripts
├── tsconfig.json # TypeScript configuration
├── .env.example # Environment variable template
├── .gitignore
├── Dockerfile # (optional) Docker deployment
├── .dockerignore # (optional)
└── README.md # Project documentation with tool list
The generated MCP server includes:
- Full MCP SDK integration using
@modelcontextprotocol/sdk - Zod schemas for every tool input, auto-generated from OpenAPI parameter/body definitions
- Smart tool naming derived from
operationIdor method+path - HTTP client with proper error handling, query params, path params, headers, and request bodies
- Auth support — API key, Bearer token, or Basic auth, configured via environment variables
- stdio transport (default) for Claude Desktop / Cursor, or SSE transport for remote deployment
Usage: create-mcp-server [input] [options]
Arguments:
input Path or URL to OpenAPI specification
Options:
-o, --output <dir> Output directory
-n, --name <name> Project name
-t, --transport <type> Transport type: stdio (default), sse
-a, --all Include all API operations (skip selection)
-y, --yes Skip confirmation prompts (use defaults)
--docker Include Dockerfile
--no-tests Skip generating test files
-p, --package-manager Package manager: npm (default), yarn, pnpm
-V, --version Output version number
-h, --help Display help
| Format | Example |
|---|---|
| OpenAPI 3.0 JSON | ./openapi.json |
| OpenAPI 3.0 YAML | ./openapi.yaml |
| OpenAPI 3.1 JSON | ./openapi31.json |
| Swagger 2.0 JSON | ./swagger.json (auto-converted) |
| Remote URL | https://api.example.com/openapi.json |
The generator automatically detects authentication schemes from the OpenAPI spec:
| Scheme | Detection | Configuration |
|---|---|---|
| API Key | securitySchemes.type: apiKey |
API_KEY env var |
| Bearer Token | securitySchemes.type: http, scheme: bearer |
API_TOKEN env var |
| Basic Auth | securitySchemes.type: http, scheme: basic |
API_USERNAME + API_PASSWORD env vars |
| OAuth 2.0 | securitySchemes.type: oauth2 |
Bearer token fallback |
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"my-api": {
"command": "node",
"args": ["/path/to/my-api-mcp-server/dist/index.js"],
"env": {
"API_KEY": "your-api-key"
}
}
}
}Add to .cursor/mcp.json:
{
"mcpServers": {
"my-api": {
"command": "node",
"args": ["/path/to/my-api-mcp-server/dist/index.js"]
}
}
}cd my-api-mcp-server
npm run inspectcd my-api-mcp-server
docker build -t my-api-mcp .
docker run -e API_KEY=xxx my-api-mcpYou can also use create-mcp-server as a library:
import { parseOpenApiSpec, generateProject } from 'create-mcp-server';
const spec = await parseOpenApiSpec('https://api.example.com/openapi.json');
await generateProject({
projectName: 'my-api-server',
projectDescription: 'MCP server for My API',
apiSpec: spec,
selectedOperations: spec.operations,
outputDir: './output',
transport: 'stdio',
authType: 'api-key',
authConfig: { headerName: 'X-API-Key', envVarName: 'API_KEY' },
packageManager: 'npm',
includeDocker: true,
includeTests: true,
});┌─────────────────┐ ┌──────────────┐ ┌─────────────────┐
│ OpenAPI Spec │────▶│ Parser │────▶│ Normalized │
│ (JSON/YAML/URL) │ │ │ │ API Operations │
└─────────────────┘ └──────────────┘ └────────┬────────┘
│
▼
┌─────────────────┐ ┌──────────────┐ ┌─────────────────┐
│ Complete MCP │◀────│ Code │◀────│ Selected │
│ Server Project │ │ Generator │ │ Operations │
└─────────────────┘ └──────────────┘ └─────────────────┘
- Parse — Reads and dereferences the OpenAPI spec, handling
$ref, auth schemes, and server URLs - Select — Interactive CLI lets you pick which endpoints become MCP tools
- Generate — Produces TypeScript source with Zod schemas, HTTP client, and MCP tool registrations
- Scaffold — Creates a complete project with package.json, tsconfig, README, and optional Docker support
- Build — Compiles TypeScript and installs dependencies automatically
Contributions are welcome! Please open an issue or submit a pull request.
git clone https://github.com/anthropics/create-mcp-server.git
cd create-mcp-server
npm install
npm run buildMIT