"One command. Any API. Instant MCP server."
The mcp-server-generator is a high-performance, enterprise-grade compiler that transforms any OpenAPI/Swagger specification into a production-ready Model Context Protocol (MCP) server.
LLMs often struggle with large OpenAPI specs due to context window limits and "hallucination noise." This tool solves that by applying Semantic Compression and Resource Grouping to deliver ultra-efficient tool definitions that "just work."
Our 5-stage pipeline is designed for maximum resilience, correctness, and LLM efficiency.
graph TD
A[OpenAPI/Swagger Spec] -->|Stage 1| B(Parser & Normalizer)
B -->|Stage 2| C(Semantic Analyzer)
C -->|Stage 3| D(Resource Mapper)
D -->|Stage 4| E(Description Optimizer)
E -->|Stage 5| F(Code Emitter)
subgraph "The Compiler Pipeline"
B
C
D
E
F
end
F --> G[Production MCP Server]
G --> H[LLM / Claude Desktop]
Stop wasting thousands of tokens on "This endpoint returns a list of...". Our optimizer strips implementation details and boilerplate, enforcing a strict token budget per tool.
- Boilerplate Removal: Regex-based stripping of common API phrases.
- Contextual Truncation: Sentence-level pruning that preserves core intent.
- Token Budgeting: Ensures every tool fits comfortably in a 200k-2M context.
Instead of overwhelming the LLM with 500 individual endpoints, we group CRUD operations by resource.
- Grouped Tools:
/users,POST /users, and/users/{id}become a singlemanage_userstool. - Action Parameter: Uses an
actionenum (list,create,get,update,delete) to dispatch requests. - Efficiency: Reduces tool count by 60-80% without losing functionality.
The generated servers include a full authentication layer out-of-the-box.
- OAuth2 Client Credentials: Full implementation with automatic Token Caching & Refresh.
- Configurable Timeouts: Environment-variable controlled API timeouts.
- Exponential Backoff: Built-in retries for 429/5xx errors.
Transform your API spec into a TypeScript project in seconds.
# Generate from Remote URL
npx mcp-generate https://api.stripe.com/v1/openapi.json -o ./stripe-mcp
# Generate from Local File
npx mcp-generate ./petstore.yaml -o ./petstore-mcpThe output is a complete, standalone Node.js project.
cd ./stripe-mcp
npm install
cp .env.example .env # Add your API keys
npm run build
npm start- Runtime: Node.js 18+ (Native
fetchimplementation) - Language: TypeScript 5.x (Strict mode)
- Protocol: Model Context Protocol (MCP) SDK v1.x
- Validation: Zod-based runtime schema validation
- Reliability: Exponential backoff, AbortController timeouts, and token-aware caching.
| API Size | Original Spec | Generated Tools | Reduction | Outcome |
|---|---|---|---|---|
| Petstore | 10 KB | 3 | 0% | ✨ Perfect |
| Medium API | 500 KB | 12 | 75% | ✨ Great |
| Enterprise | 5 MB | 45 | 92% | ✨ Functional |
| Massive | 20 MB | 80 | 98% | ✨ Context-Safe |
- v0.1.0-alpha: Core 5-stage pipeline & OAuth2 CC.
- v0.2.0: HTTP/SSE Transport for remote MCP clients.
- v0.3.0: Streaming response support for high-latency APIs.
- v1.0.0: Verified "Zero-Edit" production release.
We follow Standard Engineering Principles. Contributions are welcome via pull requests. For large architectural changes, please open an issue first.
- Fork the repository
- Clone your fork
- Branch for your feature (
git checkout -b feat/my-innovation) - Confirm all tests pass (
npm run test)
Distributed under the MIT License. See LICENSE for more information.
Built with Precision for the Agentic Era.