Skip to content

cc-fuyu/create-mcp-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚡ create-mcp-server

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.

npm version License: MIT


Why?

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

Quick Start

npx create-mcp-server

That's it. The interactive CLI will guide you through:

  1. Provide an OpenAPI spec (file path or URL)
  2. Select which API endpoints to expose as tools
  3. Configure project name, transport, and auth
  4. Get a complete, runnable MCP server project

One-liner examples

# 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-api

What Gets Generated

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

Generated Server Features

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 operationId or 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

CLI Options

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

Supported Input Formats

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

Authentication

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

Using the Generated Server

With Claude Desktop

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"
      }
    }
  }
}

With Cursor

Add to .cursor/mcp.json:

{
  "mcpServers": {
    "my-api": {
      "command": "node",
      "args": ["/path/to/my-api-mcp-server/dist/index.js"]
    }
  }
}

With MCP Inspector

cd my-api-mcp-server
npm run inspect

With Docker

cd my-api-mcp-server
docker build -t my-api-mcp .
docker run -e API_KEY=xxx my-api-mcp

Programmatic API

You 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,
});

How It Works

┌─────────────────┐     ┌──────────────┐     ┌─────────────────┐
│  OpenAPI Spec    │────▶│   Parser     │────▶│  Normalized     │
│  (JSON/YAML/URL) │     │              │     │  API Operations │
└─────────────────┘     └──────────────┘     └────────┬────────┘
                                                       │
                                                       ▼
┌─────────────────┐     ┌──────────────┐     ┌─────────────────┐
│  Complete MCP    │◀────│  Code        │◀────│  Selected       │
│  Server Project  │     │  Generator   │     │  Operations     │
└─────────────────┘     └──────────────┘     └─────────────────┘
  1. Parse — Reads and dereferences the OpenAPI spec, handling $ref, auth schemes, and server URLs
  2. Select — Interactive CLI lets you pick which endpoints become MCP tools
  3. Generate — Produces TypeScript source with Zod schemas, HTTP client, and MCP tool registrations
  4. Scaffold — Creates a complete project with package.json, tsconfig, README, and optional Docker support
  5. Build — Compiles TypeScript and installs dependencies automatically

Contributing

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 build

License

MIT

About

Generate a complete MCP server from any OpenAPI specification. The fastest way to turn your API into an MCP-compatible tool server.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors