About Openapi MCP Generator
Openapi MCP Generator is an MCP server published by salacoste in the Developer Tools category: mCP server: Openapi MCP Generator.
The repository has 1 stars and 1 forks, with the last commit 8 months ago. Six months or more without a commit doesn't mean the server is broken, but check the open issues before depending on it in production.
Install
git clone https://github.com/salacoste/openapi-mcp-generatorThis server has no ConduID identity, so agent calls to it are not receipted. Pin the version you install and review the source before granting it credentials.
Ask AI
Ask AI about Openapi MCP Generator
Powered by Claude · Grounded in docs
Security checks
- ✓README presentThe repository ships documentation.
- !Scoped permissionsDoesn't declare a permission scope. Assume it can do anything its process can.
4 checks have not been run yet.
README
OpenAPI-to-MCP Generator
Automatically generate Model Context Protocol (MCP) servers from OpenAPI 3.0 specifications, enabling AI agents to interact with any REST API.
✨ Features
- ✅ Full OpenAPI 3.0 Support - Parse and convert any valid OpenAPI 3.0 specification
- ✅ Complete Type Generation - TypeScript interfaces for all schemas with JSDoc comments
- ✅ Type Safety Excellence - 99.38% type coverage with CI enforcement (exceeds 95% industry standard)
- ✅ Automatic Tool Creation - MCP tools for every API operation with parameter validation
- ✅ Authentication Support - Built-in support for API Key, Bearer Token, OAuth 2.0, Basic Auth
- ✅ Production Ready - Generated servers compile, run, and integrate with Claude Desktop
- ✅ Fast Generation - Generate complete servers in seconds (<30s for 260KB specs)
- ✅ Error Handling - Comprehensive validation with actionable error messages and rollback support
🚀 Quick Start
Installation
# Install globally (recommended)
npm install -g @openapi-to-mcp/cli
# Or use with npx (no installation)
npx @openapi-to-mcp/cli generate swagger.json --output ./my-mcp-server
Generate MCP Server
# Generate from OpenAPI spec
@openapi-to-mcp/cli generate swagger.json --output ./my-mcp-server
# Example output from Ozon Performance API (260KB spec):
# ✅ Parsing OpenAPI spec... (260KB)
# ✅ Validated OpenAPI schema
# ✅ Resolved 45 $ref references
# ✅ Extracted 220 schemas
# ✅ Extracted 39 operations
# ✅ Extracted 3 security schemes
# ✅ Extracted 12 tags
# ✅ Extracted 1 server(s)
# ✅ Scaffolding project structure...
# ✅ Generating TypeScript interfaces... (220 types)
# ✅ Generating MCP tool definitions... (39 tools)
# ✅ Generating server files...
# ✅ MCP server generated successfully at ./my-mcp-server
# Build and run
cd my-mcp-server
npm install
npm run build
node dist/index.js
Use with Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"my-api": {
"command": "node",
"args": ["/absolute/path/to/my-mcp-server/dist/index.js"],
"env": {
"API_KEY": "your-api-key-here"
}
}
}
}
Restart Claude Desktop and your API tools will be available!
📊 Example Output
From the Ozon Performance API OpenAPI specification (260KB):
my-mcp-server/
├── package.json # Dependencies: @modelcontextprotocol/sdk, axios, zod
├── tsconfig.json # TypeScript config: ES2022, ESM, strict mode
├── README.md # Generated usage instructions
├── .env.example # Environment variables template
└── src/
├── index.ts # MCP server entry point (39 tools registered)
├── types.ts # 220 TypeScript interfaces with JSDoc
├── tools.ts # 39 MCP tool definitions
└── http-client.ts # HTTP client with authentication
Generated Tools (39 total):
postBotsSendMessage- Send messages via botpostPerformanceReports- Get performance analyticspostProductsInfo- Retrieve product informationpostV1ActionsProducts- Manage product actions- And 35 more...
Generated Types (220+ interfaces):
BotSendMessageRequest,BotSendMessageResponsePerformanceReportRequest,PerformanceDataProductInfoRequest,ProductDetails- And 217 more...
📚 Documentation
| Document | Description |
|---|---|
| Quick Start Tutorial | Generate your first MCP server in 5 minutes |
| Generation Pipeline | Architecture and data flow |
| Troubleshooting Guide | Common issues and solutions |
| Project Brief | Project overview, goals, and scope |
| Architecture | System design and algorithms |
| API Reference | Complete API documentation |
| Examples | Usage examples and recipes |
| Testing Guide | Testing strategy and test cases |
🎯 Use Cases
1. E-Commerce APIs (Ozon, Amazon, Shopify)
# Generate MCP server for Ozon Performance API
openapi-to-mcp generate ./ozon-swagger.json \
-o ./ozon-mcp \
-n ozon-performance-api
# AI agent can now:
# - List advertising campaigns
# - Get campaign statistics
# - Update campaign budgets
# - Manage products and ads
2. Developer Tools (GitHub, GitLab, Jira)
# Generate GitHub API MCP server
openapi-to-mcp generate https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json \
-f "repos,issues,pulls" \
-o ./github-mcp
# AI agent can now:
# - Create issues and pull requests
# - Manage repositories
# - Review code
3. Payment Processing (Stripe, PayPal)
# Generate Stripe API MCP server
openapi-to-mcp generate ./stripe-openapi.json \
-f "Customers,PaymentIntents,Charges" \
-o ./stripe-mcp
# AI agent can now:
# - Create customers
# - Process payments
# - Manage subscriptions
4. Internal Company APIs
# Generate MCP server for internal API
openapi-to-mcp generate http://internal-api.company.local/openapi.json \
-o ./company-api-mcp
# AI agent can now:
# - Access internal tools
# - Automate workflows
# - Query business data
🏗️ Architecture
High-Level Overview
OpenAPI Spec → Parser → Generator → MCP Server
↓ ↓
$refs Types
Resolved Tools
Client
Component Structure
openapi-to-mcp/
├── packages/
│ ├── cli/ # Command-line interface
│ ├── parser/ # OpenAPI parsing + $ref resolution
│ ├── generator/ # Code generation (types, tools, client)
│ └── shared/ # Shared utilities and types
├── examples/ # Example generated servers
├── tests/ # Test suites
└── docs/ # Documentation
Key Algorithms
$ref Resolution:
// Handles nested references with circular detection
function resolveRef(ref: string, spec: any): any {
// Parse: "#/components/schemas/Campaign"
// Traverse: spec.components.schemas.Campaign
// Detect circular: visited set tracking
// Return: resolved object
}
Tool Generation:
// Converts OpenAPI operation → MCP tool
function generateTool(path, method, operation): MCPTool {
name: operation.operationId || generated_name,
description: AI-optimized description,
inputSchema: parameters + requestBody,
metadata: { path, method, tags, category }
}
Smart Filtering:
// Tag-based categorization for AI context management
const categories = groupByTags(operations);
// Campaign: 15 methods
// Statistics: 12 methods
// Products: 18 methods
// → AI loads only relevant category
See Architecture Documentation for details.
🔧 CLI Reference
generate
Generate MCP server from OpenAPI specification.
openapi-to-mcp generate <input> [options]
Options:
-o, --output <dir>- Output directory (default:./generated)-n, --name <name>- Package name override-f, --filter <tags>- Comma-separated tags to include--no-types- Skip TypeScript types generation--no-client- Skip HTTP client generation-v, --verbose- Verbose logging
Examples:
# Basic usage
openapi-to-mcp generate ./swagger.json
# Filter by tags
openapi-to-mcp generate ./api.json -f "Campaign,Statistics"
# Custom output and name
openapi-to-mcp generate ./spec.yaml -o ./my-server -n my-api
validate
Validate OpenAPI specification.
openapi-to-mcp validate <input> [options]
Options:
--strict- Enable strict validation-v, --verbose- Verbose output
Example:
openapi-to-mcp validate ./swagger.json
# Output:
# ✓ Valid OpenAPI 3.0.0 specification
# ✓ 39 paths found
# ✓ 87 schemas found
# ⚠ 2 operations without operationId
init
Initialize new MCP server project.
openapi-to-mcp init <name> [options]
Options:
-t, --template <type>- Template type:basic|advanced-d, --directory <dir>- Target directory
📦 Generated Output
File Structure
my-mcp-server/
├── package.json # Package configuration
├── tsconfig.json # TypeScript config
├── README.md # Usage documentation
├── .env.example # Environment variables template
├── src/
│ ├── server.ts # MCP server implementation
│ ├── types.ts # Generated TypeScript types
│ ├── client.ts # HTTP client with auth
│ └── config.ts # Configuration handling
└── dist/ # Compiled JavaScript
└── server.js
Example: server.ts
import { Server } from '@modelcontextprotocol/sdk/server';
import { APIClient } from './client';
export function createServer(config: ServerConfig) {
const client = new APIClient(config);
const server = new Server();
// Generated tool: listCampaigns
server.tool(
'listCampaigns',
{
description: 'List all advertising campaigns\n📂 Category: Campaign',
inputSchema: {
type: 'object',
properties: {
page: { type: 'number', description: 'Page number' },
pageSize: { type: 'number', description: 'Items per page' },
},
},
},
async (input) => {
return await client.get('/api/client/campaign', {
params: input,
});
}
);
// ... 38 more tools
// Meta-tool: listMethods
server.tool('listMethods', ..., async (input) => {
return filterTools(allTools, input.category, input.search);
});
return server;
}
Example: types.ts
// Generated from OpenAPI schemas
export interface Campaign {
id: string;
title: string;
budget?: number;
status: 'ACTIVE' | 'PAUSED' | 'ARCHIVED';
createdAt?: Date;
}
export interface CampaignStatistics {
campaignId: string;
impressions: number;
clicks: number;
spend: number;
}
// ... 85 more interfaces
🧪 Testing
Run Tests
# All tests
npm test
# With coverage
npm run test:coverage
# Watch mode
npm run test:watch
# Integration tests
npm run test:integration
# E2E tests
npm run test:e2e
Test Coverage
Target Requirements:
- Lines: 80%
- Functions: 80%
- Branches: 75%
- Statements: 80%
Current Baseline (as of 2025-01-04):
- Overall: 66% lines, 81% functions, 83% branches, 66% statements
- CLI: 14 passing tests
- Generator: 20 passing tests
- Coverage enforced in CI to prevent regression
Note: Current thresholds set to 65% (lines/statements) and 70% (branches) to prevent regression. Goal is to reach 80% coverage for all new code by Epic 2 completion.
See Testing Guide for details.
🔄 CI/CD
Automated Checks
Every pull request and push to main branch triggers automated quality checks:
Quality Gates (all must pass):
- ✅ TypeScript compilation (strict mode)
- ✅ ESLint (no errors)
- ✅ Unit tests (≥80% coverage)
- ✅ Build succeeds for all packages
Test Matrix:
- Node.js versions: 18, 20, 22 (LTS)
- Operating systems: Ubuntu, macOS, Windows
- Total jobs: 9 parallel tests
Running Checks Locally
Before pushing code, run all CI checks locally:
# Run all checks in order
pnpm install
pnpm tsc --noEmit # TypeScript compilation
pnpm lint # ESLint
pnpm test # Unit tests
pnpm build # Build packages
Troubleshooting CI Failures
TypeScript errors:
- Check
pnpm tsc --noEmitoutput - Ensure all types are properly defined
- Verify
tsconfig.jsonis correct
Linting errors:
- Run
pnpm lintto see errors - Auto-fix:
pnpm lint --fix - Check
.eslintrc.jsonfor rules
Test failures:
- Run
pnpm testlocally - Check test logs in GitHub Actions
- Ensure tests are deterministic
Build failures:
- Verify all dependencies installed
- Check for missing imports
- Review build scripts in
package.json
🛠️ Development
Prerequisites
- Node.js: 20.11.0 LTS (minimum ≥18.0.0)
- pnpm: 8.15.1 or higher
- TypeScript: 5.3.3
Setup
# Clone repository
git clone https://github.com/your-org/openapi-to-mcp.git
cd openapi-to-mcp
# Install dependencies
pnpm install
# Build all packages
pnpm build
# Run tests
pnpm test
# Run linting
pnpm lint
# Format code
pnpm format
Monorepo Structure
openapi-to-mcp/
├── packages/
│ ├── cli/ # Command-line interface
│ ├── parser/ # OpenAPI 3.0 parsing
│ ├── generator/ # Code generation engine
│ └── templates/ # Boilerplate templates
├── examples/ # Real-world test cases
├── tests/ # Cross-package integration tests
├── docs/ # Architecture + API docs
├── scripts/ # Build and utility scripts
├── pnpm-workspace.yaml # pnpm workspace configuration
├── package.json # Root package configuration
├── tsconfig.json # Base TypeScript configuration
└── README.md # This file
Development Workflow
# Create feature branch
git checkout -b feature/my-feature
# Make changes
# ... edit code ...
# Run tests
npm test
# Build
npm run build
# Test locally
openapi-to-mcp generate ./test-spec.json
# Commit
git add .
git commit -m "feat: add my feature"
# Push and create PR
git push origin feature/my-feature
🌟 Examples
Example 1: Ozon Performance API
Input: swagger/swagger.json
- 39 paths
- 87 schemas
- 6 tags (Campaign, Statistics, Ad, Product, etc.)
Command:
openapi-to-mcp generate ./swagger/swagger.json \
-o ./examples/ozon-performance \
-n ozon-performance-api
Output:
- 39 MCP tools + 1 meta-tool (listMethods)
- 87 TypeScript interfaces
- HTTP client with Bearer auth
- Complete MCP server ready to deploy
Usage:
// List campaigns
const campaigns = await mcp.listCampaigns({ page: 1, pageSize: 10 });
// Get statistics
const stats = await mcp.getCampaignStatistics({
campaignId: '12345',
dateFrom: '2025-01-01',
dateTo: '2025-01-31',
});
// Update campaign
await mcp.updateCampaign({
campaignId: '12345',
body: { dailyBudget: 5000 },
});
See Examples Documentation for more.
🤝 Contributing
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Write tests: Ensure 80%+ coverage
- Follow code style: Run
npm run lint - Commit with conventional commits:
feat:,fix:,docs:, etc. - Push and create PR
See CONTRIBUTING.md for details.
📄 License
MIT License - see LICENSE file for details.
🙏 Acknowledgments
- OpenAPI Specification - API standard
- Model Context Protocol - MCP specification
- Ozon Performance API - Test case and validation
📞 Support
- Documentation: docs/
- Issues: GitHub Issues
- Discussions: GitHub Discussions
🗺️ Roadmap
MVP (v0.1.0) - Current
- OpenAPI 3.0 parser with $ref resolution
- TypeScript type generation from schemas
- MCP tool generation from operations
- HTTP client with Bearer/API key auth
- Tag-based smart filtering
- CLI with generate/validate/init commands
- Documentation (brief, research, architecture, API, examples, testing)
Post-MVP (v0.2.0)
- OpenAPI 3.1 support
- Swagger 2.0 support
- OAuth2 authentication
- Server variables support
- Response formatters (compact, verbose, custom)
- Plugin system
- Web UI for generation
- Generated server caching
- Rate limiting
Future (v1.0.0)
- GraphQL to MCP generator
- gRPC to MCP generator
- Live API proxy mode (no generation)
- AI-powered API discovery
- Multi-language support (Python, Go, Rust)
Built with ❤️ for the AI agent ecosystem
README copy captured when this server was indexed; it may lag the repository. The original is authoritative.