# MCP Swagger API π
<div align="center">
[](https://nodejs.org/)
[](https://nestjs.com/)
[](https://www.typescriptlang.org/)
[](LICENSE)
**Enterprise-grade REST API server for seamless OpenAPI to MCP protocol conversion**
Transform your existing REST APIs into Model Context Protocol (MCP) tools with zero configuration
[π Quick Start](#quick-start) β’ [π Documentation](#documentation) β’ [π§ API Reference](#api-reference) β’ [π οΈ Development](#development)
</div>
---
## π― What is MCP Swagger API?
MCP Swagger API is a **NestJS-powered backend service** that bridges the gap between traditional REST APIs and AI assistants through the Model Context Protocol (MCP). It automatically converts OpenAPI/Swagger specifications into MCP-compatible tools, enabling AI assistants to interact with your APIs seamlessly.
### π Key Benefits
- **π Zero Configuration**: Paste your OpenAPI spec and get MCP tools instantly
- **π― AI-Native**: Purpose-built for LLM and AI assistant integration
- **π Production Ready**: Enterprise-grade NestJS foundation with monitoring
- **π Multi-Protocol**: Support for HTTP, WebSocket, and Stdio transports
- **π Real-time**: Live status monitoring and dynamic tool management
## β¨ Core Features
### π¨ Intelligent API Conversion
- **Multi-format Input**: JSON, YAML, URL, or raw objects
- **Smart Parsing**: Auto-detection of OpenAPI 2.0/3.x specifications
- **Dynamic Tools**: Real-time MCP tool generation from API endpoints
- **Type Safety**: Full TypeScript support with automatic type inference
### β‘ Enterprise-Grade Architecture
- **NestJS Foundation**: Modular, scalable, and maintainable codebase
- **Built-in Security**: CORS, Helmet, compression, and rate limiting
- **Health Monitoring**: Comprehensive status checks and diagnostics
- **Event System**: Real-time updates and notifications
### π Flexible Integration
- **Embedded MCP Server**: No external dependencies required
- **Multiple Transports**: HTTP, WebSocket, and Stdio protocols
- **RESTful API**: Clean, documented endpoints for easy integration
- **Swagger Documentation**: Auto-generated API documentation
## π Quick Start
### Prerequisites
- Node.js β₯ 18.0.0
- pnpm β₯ 8.0.0 (recommended)
### Installation & Setup
```bash
# Install dependencies
pnpm install
# Start development server
pnpm start:dev
# Build for production
pnpm build
```
The API server will be available at `http://localhost:3000`
### π― Basic Usage
**Create an MCP Server from OpenAPI:**
```bash
curl -X POST http://localhost:3000/api/v1/mcp/create \
-H "Content-Type: application/json" \
-d '{
"openApiData": "https://petstore.swagger.io/v2/swagger.json",
"config": {
"name": "petstore-api",
"version": "1.0.0",
"port": 3322,
"transport": "http"
}
}'
```
**Check Server Status:**
```bash
curl http://localhost:3000/api/v1/mcp/status
```
## π§ API Reference
### Core Endpoints
| Method | Endpoint | Description |
|--------|----------|-------------|
| `POST` | `/api/v1/mcp/create` | Create MCP server from OpenAPI spec |
| `GET` | `/api/v1/mcp/status` | Get current server status |
| `POST` | `/api/v1/mcp/reload` | Reload tools from updated spec |
| `DELETE` | `/api/v1/mcp/stop` | Stop running MCP server |
| `POST` | `/api/v1/openapi/parse` | Parse and validate OpenAPI spec |
| `POST` | `/api/v1/openapi/validate` | Validate OpenAPI specification |
### Configuration Options
```typescript
interface MCPServerConfig {
name: string; // Server identifier
version: string; // Server version
description?: string; // Optional description
port: number; // Port number (3000-65535)
transport: 'http' | 'websocket' | 'stdio';
}
```
## ποΈ Architecture
```
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β MCP Swagger API β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β βββββββββββββββ ββββββββββββββββ βββββββββββββββββββ β
β β OpenAPI β β NestJS API β β MCP Server β β
β β Parser ββ β Controller ββ β Generator β β
β βββββββββββββββ ββββββββββββββββ βββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β βββββββββββββββ ββββββββββββββββ βββββββββββββββββββ β
β β Validation β β Security β β Monitoring β β
β β Service β β Middleware β β Service β β
β βββββββββββββββ ββββββββββββββββ βββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
```
## π οΈ Technology Stack
- **Framework**: NestJS 10+ (Node.js/TypeScript)
- **Protocol**: Model Context Protocol (MCP)
- **Parser**: Custom OpenAPI 3.x parser with monorepo integration
- **Security**: Helmet, CORS, Rate Limiting, Input Validation
- **Documentation**: Swagger/OpenAPI auto-generation
- **Testing**: Jest with comprehensive test coverage
- **DevOps**: TypeScript, ESLint, Prettier
## π Use Cases
### π€ AI Assistant Integration
Connect your REST APIs to Claude, ChatGPT, or custom AI assistants through standardized MCP protocol.
### π API Modernization
Transform legacy REST APIs into AI-friendly tools without changing existing infrastructure.
### π― Rapid Prototyping
Quickly convert API specifications into interactive tools for testing and development.
### π Enterprise Integration
Scale MCP tool generation across multiple APIs and services in enterprise environments.
## π οΈ Development
### Project Structure
```
src/
βββ modules/ # Feature modules
β βββ mcp/ # MCP server management
β βββ openapi/ # OpenAPI parsing & validation
βββ services/ # Business logic services
βββ controllers/ # REST API controllers
βββ config/ # Configuration management
βββ common/ # Shared utilities
βββ types/ # TypeScript definitions
```
### Development Commands
```bash
# Start development server with hot reload
pnpm start:dev
# Run tests
pnpm test
# Run tests with coverage
pnpm test:cov
# Lint and format code
pnpm lint
pnpm format
# Build for production
pnpm build
```
## π Documentation
- [ποΈ Architecture Overview](../docs/mcp-swagger-ui-architecture.md)
- [π Development Guide](../docs/mcp-swagger-ui-development-guide.md)
- [π Technical Documentation](../docs/mcp-swagger-ui-technical-documentation.md)
- [π§ API Documentation](http://localhost:3000/api) (when server is running)
## π€ Contributing
We welcome contributions! Please see our [Contributing Guide](../../CONTRIBUTING.md) for details.
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request
## π License
This project is licensed under the MIT License - see the [LICENSE](../../LICENSE) file for details.
## π Acknowledgments
- [Model Context Protocol](https://modelcontextprotocol.io/) for the protocol specification
- [NestJS](https://nestjs.com/) for the fantastic framework
- [OpenAPI Initiative](https://www.openapis.org/) for API standardization
---
<div align="center">
**Made with β€οΈ by the MCP Swagger Team**
[β Star this repo](../../stargazers) β’ [π Report issues](../../issues) β’ [π‘ Request features](../../issues/new)
</div>