Loading repository data…
Loading repository data…
salacoste / repository
Solve AI context window limits for API docs | Convert any Swagger/OpenAPI to searchable MCP server | AI-powered endpoint discovery & code generation | Works with Cursor, Claude, VS Code
Stop wrestling with massive API docs in your AI assistant's context window. Start having intelligent conversations about any API.
🚀 Help us reach more developers who struggle with API integrations!
Your star makes this project more discoverable and motivates continued development.
⭐ Star this repo | 🍴 Fork it | 📢 Share it
You're building an integration with a complex API. The Swagger documentation is 2MB+ of JSON. Your AI assistant can only see tiny fragments at a time. You end up:
Transform any Swagger/OpenAPI specification into an intelligent MCP server that gives your AI assistant superpowers:
# Instead of this painful workflow:
"Here's a 500KB Swagger file, please help me integrate..."
# Error: Context window exceeded
# You get this magical experience:
AI: "I need to create a user and get their profile data"
→ Instantly finds relevant endpoints: POST /users, GET /users/{id}
→ Generates complete TypeScript client with proper types
→ Includes error handling and authentication patterns
→ Shows example requests/responses for testing
# 1. Convert any Swagger file to intelligent MCP server
swagger-mcp-server convert your-api.json
# 2. Connect to Cursor, Claude, or VS Code
# Your AI assistant now knows EVERYTHING about your API
# 3. Start building with superhuman API knowledge
"Create a React hook for user authentication with retry logic"
"Generate Python client for the payment endpoints"
"Show me all endpoints that return user data"
Ready to supercharge your API development workflow? Jump to 🚀 Quick Start and experience the future of AI-assisted API integration.
swagger-mcp-server bridges the gap between API documentation and AI coding assistants. Instead of AI agents struggling with large API docs in their context window, they can now query specific information on-demand through the Model Context Protocol (MCP).
Before converting, you need to obtain the Swagger/OpenAPI JSON specification from any API documentation site:
docs.example.com/api)F12 or Cmd/Ctrl + Shift + I)swagger.json or similar files in the network requestsswagger-openapi-data/ directory:# Save the JSON content to the existing swagger-openapi-data directory
# Either copy-paste or download directly:
curl -o swagger-openapi-data/your-api.json "https://api.example.com/swagger.json"
# Or save manually by copying the JSON content and pasting it into:
# swagger-openapi-data/your-api.json
Method 2: Direct URL Access
# Many APIs expose Swagger at common endpoints:
curl -o swagger-openapi-data/your-api.json "https://api.example.com/swagger.json"
curl -o swagger-openapi-data/your-api.json "https://api.example.com/v1/swagger.json"
curl -o swagger-openapi-data/your-api.json "https://api.example.com/docs/swagger.json"
Method 3: API Documentation Download Most API documentation sites have a "Download OpenAPI" or "Export JSON" button.
Method 4: Use Our Sample API (Already Included)
# We already include a sample Ozon Performance API for testing:
ls swagger-openapi-data/swagger.json # 262KB Ozon API ready to use
# Option 1: Install from source (recommended)
git clone https://github.com/salacoste/openapi-mcp-swagger.git
cd openapi-mcp-swagger
# Option 2: Install dependencies
pip install -r requirements.txt
# Option 3: Use standalone script (no installation required)
chmod +x scripts/standalone-mcp.py
# Convert your Swagger file to MCP server
swagger-mcp-server convert swagger-openapi-data/your-api.json --name your-api
# Or use the included sample API
swagger-mcp-server convert swagger-openapi-data/swagger.json --name ozon-api
# Start the MCP server
cd mcp-server-your-api # or mcp-server-ozon-api
swagger-mcp-server serve
# 4. Test with AI agents or curl
curl -X POST http://localhost:8080 \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"searchEndpoints","params":{"keywords":"user"}}'
🎉 Congratulations! Your API is now AI-ready. Here's what you get:
Connect to your favorite AI coding assistant:
For Cursor IDE:
# Add to .cursor-mcp/config.json
{
"mcpServers": {
"your-api": {
"command": "swagger-mcp-server",
"args": ["serve", "--port", "8080"]
}
}
}
For Claude/VS Code:
# Server will automatically integrate via MCP protocol
# Just point your AI assistant to: http://localhost:8080
Now you can ask your AI assistant:
"Create a TypeScript client for the user authentication endpoints"
"Show me all endpoints that handle payment processing"
"Generate a React hook for real-time order status updates"
"What are the required fields for creating a new product?"
📖 Complete Quick Start: Follow our step-by-step Quick Start Tutorial to get your first MCP server running in 5 minutes with sample data.
The system consists of four main components:
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ AI Agent │◄──►│ MCP Server │◄──►│ Search Engine │
│ │ │ │ │ │
│ • Claude │ │ • JSON-RPC API │ │ • Endpoint Index│
│ • GPT-4 │ │ • Authentication │ │ • Schema Index │
│ • Cursor │ │ • Rate Limiting │ │ • Full-Text │
│ • VS Code │ │ • Monitoring │ │ • Relationships │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│
▼
┌──────────────────┐
│ Swagger Parser │
│ │
│ • Validation │
│ • Schema Extract │
│ • Relationship │
│ • Indexing │
└──────────────────┘
📖 Detailed Architecture: See docs/architecture/ for complete technical documentation and design decisions.
Install system dependencies first:
# macOS (using Homebrew)
brew install python@3.13 pipx
# Ubuntu/Debian
sudo apt update
sudo apt install python3.11-dev python3.11-venv python3-pip pipx