swagger-mcp-server
Converts any Swagger/OpenAPI specification into an intelligent MCP server, enabling AI assistants to query API endpoints, schemas, and generate code on demand.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@swagger-mcp-servershow all endpoints from the petstore API"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
π Universal Swagger β MCP Server Converter
Stop wrestling with massive API docs in your AI assistant's context window. Start having intelligent conversations about any API.
β Love this project? Give it a star! β
π 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
π‘ The Problem Every Developer Faces
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:
β Copy-pasting documentation chunks into chat windows
β Missing crucial schema relationships between endpoints
β Getting outdated or incomplete code examples
β Losing context when working across multiple API endpoints
β Wasting hours on what should be simple integrations
β¨ The Solution: Intelligent API Knowledge for AI
Transform any Swagger/OpenAPI specification into an intelligent MCP server that gives your AI assistant superpowers:
π― What Your AI Can Now Do:
# 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π From 0 to AI-Powered API Integration in 30 Seconds:
# 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"π Real-World Impact:
β‘ 10x Faster Integration: From hours to minutes for complex APIs
π― Perfect Code Generation: AI understands full API context and relationships
π Instant API Discovery: Natural language search across any documentation size
π‘οΈ Enterprise Ready: Works offline, handles massive APIs (10MB+), production deployment
π Universal Compatibility: Cursor, Claude, VS Code, or any MCP-compatible tool
Ready to supercharge your API development workflow? Jump to π Quick Start and experience the future of AI-assisted API integration.
π Table of Contents
π Quick Start - Get running in 5 minutes
ποΈ Architecture - System overview
π MCP Server Methods - API reference
π§ CLI Commands - Command reference
π€ AI Tool Integrations - VS Code, Cursor setup
π Configuration - Basic setup
π‘ Examples - Sample APIs and use cases
π§ Troubleshooting - Common issues
π Complete Documentation - All guides
π Getting Help - Support resources
β¨ What is swagger-mcp-server?
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).
Key Benefits
π Intelligent Search: Find relevant endpoints using natural language queries
π Schema Awareness: Get complete type information and relationships
π» Code Generation: Generate working examples in multiple languages
β‘ Fast Responses: Sub-200ms search, optimized for AI agent workflows
π Easy Integration: Works with VS Code, Cursor, and custom AI tools
π‘οΈ Production Ready: SSL, authentication, monitoring, and deployment guides
Use Cases
API Integration: Help AI assistants understand and use your APIs correctly
Documentation Search: Quickly find specific endpoints and schemas
Code Generation: Generate accurate API client code and examples
API Exploration: Discover API capabilities through intelligent search
Development Workflow: Integrate API knowledge into your coding environment
π Quick Start
Step 1: Get Your Swagger JSON File
Before converting, you need to obtain the Swagger/OpenAPI JSON specification from any API documentation site:
π Finding the Swagger JSON (Most Common Method)
Visit any API documentation website (e.g.,
docs.example.com/api)Open Browser DevTools (
F12orCmd/Ctrl + Shift + I)Go to Network tab and refresh the page
Look for
swagger.jsonor similar files in the network requestsClick on the JSON file and copy the response
Save it to your project in the
swagger-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π Alternative Methods to Get Swagger 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 useStep 2: Installation
# 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.pyStep 3: Convert & Start
# 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"}}'Step 4: What Happens Next
π Congratulations! Your API is now AI-ready. Here's what you get:
π§ Intelligent API Knowledge
Complete endpoint mapping with search capability
Schema relationships preserved and queryable
Code examples generated on-demand in multiple languages
Context-aware responses for any API size
π€ AI Assistant Integration
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β¨ Start Building with AI Superpowers
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.
ποΈ Architecture
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 β
ββββββββββββββββββββCore Components
π Parser: Stream-based JSON parsing for large OpenAPI files (up to 10MB)
πΎ Storage: SQLite database with optimized search indexes and relationships
π Server: MCP protocol implementation with JSON-RPC over HTTP
π Search: Intelligent endpoint and schema search with relevance ranking
π» Examples: Multi-language code generation (cURL, JavaScript, Python, Go)
π Detailed Architecture: See docs/architecture/ for complete technical documentation and design decisions.
π§ Development Setup
Prerequisites
Python 3.11 or higher (tested with Python 3.13.3)
Poetry (recommended for dependency management) or pip
pipx (for Poetry installation)
Git
System Dependencies
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
# Install Poetry
pipx install poetryLocal Development
Clone and setup:
git clone https://github.com/salacoste/openapi-mcp-swagger.git cd openapi-mcp-swaggerSetup virtual environment and install dependencies:
Option A: Using Poetry (Recommended):
# Install all dependencies including dev dependencies poetry install --with dev # Activate virtual environment poetry shellOption B: Using pip with virtual environment:
# Create virtual environment python3 -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate # Upgrade pip pip install --upgrade pip # Install essential dependencies for development pip install pytest pytest-asyncio aiosqlite sqlalchemy structlog greenlet # Install optional dev dependencies pip install black isort flake8 mypy pytest-covVerify installation:
# Test import of main modules python -c " import sys; sys.path.append('src') from swagger_mcp_server.storage.migrations import Migration print('β Installation successful!') "Run tests:
# With Poetry poetry run pytest src/tests/unit/test_storage/ -v # With pip/venv (make sure .venv is activated) PYTHONPATH=src python -m pytest src/tests/unit/test_storage/ -v # Run performance tests PYTHONPATH=src python -m pytest src/tests/performance/ -v # Run with coverage pytest --cov=src/swagger_mcp_server --cov-report=htmlRun linting:
# Format code black src/ isort src/ # Check linting flake8 src/ mypy src/swagger_mcp_server/
π§ͺ Testing
The project uses a comprehensive testing strategy:
Unit Tests: 80%+ coverage requirement, focused on individual components
Integration Tests: Full MCP server workflow testing
Performance Tests: Validation of response time requirements (<200ms search, <500ms schema)
Fixtures: Sample OpenAPI specifications for consistent testing
Running Tests
# All tests with coverage
poetry run pytest --cov=swagger_mcp_server --cov-report=html
# Unit tests only
poetry run pytest -m unit
# Integration tests only
poetry run pytest -m integration
# Performance/benchmark tests
poetry run pytest -m performance --benchmark-onlyπ Project Structure
swagger-mcp-server/
βββ src/
β βββ swagger_mcp_server/ # Main package
β β βββ parser/ # OpenAPI parsing
β β βββ storage/ # Database layer
β β βββ server/ # MCP implementation
β β βββ config/ # Configuration
β β βββ examples/ # Code generation
β βββ tests/ # Test suite
βββ scripts/ # Utility scripts
βββ data/ # Sample data
βββ docs/ # Documentation
βββ .github/ # CI/CD workflows
βββ pyproject.toml # Project configurationπ MCP Server Methods
The server implements three core MCP methods:
searchEndpoints(keywords, httpMethods)
Search for API endpoints using keywords and HTTP method filters.
// Example usage
const results = await mcpClient.call('searchEndpoints', {
keywords: ['user', 'authentication'],
httpMethods: ['GET', 'POST']
});getSchema(componentName)
Retrieve complete schema definitions with dependencies.
const schema = await mcpClient.call('getSchema', {
componentName: 'User'
});getExample(endpoint, format)
Generate working code examples in multiple formats.
const example = await mcpClient.call('getExample', {
endpoint: '/api/users',
format: 'curl' // 'curl', 'javascript', 'python'
});π Complete API Reference: See docs/api/MCP_PROTOCOL.md for detailed protocol documentation, client libraries, and integration examples.
π§ CLI Commands
Essential commands for everyday use:
# Convert Swagger to MCP server
swagger-mcp-server convert api.json --name my-api --port 8080
# Start server
swagger-mcp-server serve --config config.yaml
# Check server status
swagger-mcp-server status --all
# Configuration management
swagger-mcp-server config create production --output prod-config.yaml
# Setup and installation
swagger-mcp-server setup --verifyπ Complete CLI Reference: See docs/reference/CLI_REFERENCE.md for all commands, options, and usage examples.
β‘ Performance Requirements
Search Response: < 200ms target, < 500ms maximum
Schema Retrieval: < 500ms target, < 1s maximum
File Processing: < 2s for files up to 5MB
Memory Usage: Process 10MB files within 2GB RAM
Concurrency: Support 100+ concurrent AI agent connections
π Performance Tuning: See docs/guides/PERFORMANCE.md for optimization strategies and scaling guidelines.
π€ AI Tool Integrations
swagger-mcp-server works seamlessly with popular AI coding assistants:
VS Code + Continue
{
"mcpServers": {
"my-api": {
"command": "swagger-mcp-server",
"args": ["serve", "--config", "config.yaml"]
}
}
}Cursor AI
{
"mcp": {
"servers": {
"api-docs": "http://localhost:8080"
}
}
}π Integration Guides: See docs/examples/integrations/ for complete setup instructions for VS Code, Cursor, and custom AI agents.
π Configuration
Basic Configuration
# config.yaml
server:
host: localhost
port: 8080
database:
path: ./mcp_server.db
search:
index_directory: ./search_index
logging:
level: INFO
console: trueEnvironment-Specific Configs
Development: docs/examples/configurations/development.yaml
Production: docs/examples/configurations/production.yaml
π Configuration Guide: See docs/guides/BASIC_CONFIG.md for configuration basics and docs/reference/CONFIGURATION.md for complete reference.
π‘ Examples
Sample APIs
We provide realistic sample APIs for testing:
E-commerce Platform (45 endpoints): docs/examples/swagger-files/ecommerce-api.json
Banking API (67 endpoints): docs/examples/swagger-files/banking-api.json
Healthcare API (52 endpoints): docs/examples/swagger-files/healthcare-api.json
Quick Test
# Use our sample e-commerce API
swagger-mcp-server examples create-sample --type ecommerce --output sample-api.json
swagger-mcp-server convert sample-api.json --name demo
cd mcp-server-demo && swagger-mcp-server serveπ Examples Catalog: See docs/examples/swagger-files/README.md for all available sample APIs and use cases.
π€ Contributing
We welcome contributions! Please see our contribution guidelines for details.
Development Workflow
Fork the repository
Create a feature branch:
git checkout -b feat/my-featureMake your changes with tests
Run the test suite:
pytestRun linting:
black src/ && flake8 src/Commit with conventional commits:
git commit -m "feat: add new feature"Push and create a pull request
Code Quality Standards
Code Coverage: Minimum 80% (target 85%+)
Type Hints: Required for all public functions
Documentation: Comprehensive docstrings for public APIs
Performance: All changes must meet response time requirements
Security: No credentials in logs, input validation required
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π·οΈ Version History
v0.1.0: Initial release with core parsing and MCP server functionality
π§ Troubleshooting
Common Issues
Installation Problems:
# Python version issues
python --version # Should be 3.9+
# Permission errors
pip install --user swagger-mcp-server
# Package conflicts
python -m venv venv && source venv/bin/activateRuntime Issues:
# Port already in use
swagger-mcp-server serve --port 9000
# Database locked
swagger-mcp-server stop --all
# Search index corruption
rm -rf search_index/ && swagger-mcp-server serveπ Comprehensive Troubleshooting: See docs/troubleshooting/COMMON_ISSUES.md for detailed solutions to installation, configuration, and runtime problems.
π Complete Documentation
π Getting Started
Installation Guide - System requirements, installation methods, verification
Quick Start Tutorial - 5-minute setup with sample API
Basic Configuration - Essential configuration for new users
π Reference Documentation
CLI Reference - Complete command reference with examples
Configuration Reference - All configuration options and settings
MCP Protocol API - Protocol documentation and client libraries
π‘ Examples and Integrations
Sample APIs - Realistic APIs for testing and learning
Configuration Templates - Environment-specific configurations
AI Tool Integrations - VS Code, Cursor, and custom integrations
π§ Advanced Topics
Deployment Guide - Production deployment and scaling
Performance Tuning - Optimization and monitoring
Security Configuration - Hardening and best practices
π Support and Troubleshooting
Common Issues - Frequently encountered problems
Error Reference - Error messages and solutions
Diagnostic Tools - Debugging and analysis tools
π οΈ Development
Development Setup - Complete development environment setup
Contributing Guide - How to contribute to the project
Architecture Documentation - Technical design and decisions
π Main Documentation Hub: See docs/README.md for the complete documentation index with detailed navigation.
π Getting Help
Quick Help
π New Users: Start with Quick Start Tutorial
π§ Problems: Check Common Issues
βοΈ Configuration: See Basic Configuration
π€ AI Integration: Follow Integration Guides
Community Support
π Issues: GitHub Issues for bugs and feature requests
π¬ Discussions: GitHub Discussions for questions and community support
π Documentation: Complete docs with searchable content
π‘ Examples: Working examples for common use cases
Before Reporting Issues
β Check Common Issues
β Search existing issues
β Try with minimal configuration
β Include system info and logs in your report
π Show Your Support π
If this project helped solve your API integration challenges, please consider starring it!
π― Why your star matters:
π Increases visibility for developers facing similar challenges
πͺ Motivates continued development and new features
π Helps us prioritize community-requested improvements
π€ Shows appreciation for open-source work
Quick Actions:
β Star β’ π΄ Fork β’ π Issues β’ π¬ Discuss
Thank you for being part of our community! π
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/salacoste/openapi-mcp-swagger'
If you have feedback or need assistance with the MCP directory API, please join our Discord server