API to MCP Converter
A VS Code extension that automatically analyzes REST APIs in any repository and converts them to Model Context Protocol (MCP) wrappers. This tool makes any REST API accessible through the MCP framework with automatic authentication handling.
Features
🔍 Automatic API Discovery
- Scans workspace for OpenAPI/Swagger specifications
- Detects API endpoints in code files (Express.js, Flask, FastAPI, Spring Boot, etc.)
- Supports multiple programming languages and frameworks
🛠️ MCP Wrapper Generation
- Generates complete MCP server implementations
- Handles various authentication methods (Bearer tokens, API keys, Basic auth, OAuth2)
- Creates ready-to-use Node.js MCP servers
🌳 Visual API Explorer
- Tree view showing discovered APIs and endpoints
- Navigate directly to API definitions in code
- One-click MCP wrapper generation
Supported Frameworks & Languages
- Node.js: Express.js, Fastify, Koa
- Python: Flask, FastAPI, Django REST Framework
- Java: Spring Boot, JAX-RS
- PHP: Laravel, Symfony
- Ruby: Ruby on Rails, Sinatra
- OpenAPI/Swagger: JSON and YAML specifications
Installation
- Install the extension from VS Code Marketplace
- Open a workspace containing REST APIs
- The extension will automatically analyze the workspace on activation
Quick Start
1. Install & Open
- Install from VS Code Marketplace: Search "API to MCP Converter"
- Open any workspace with REST APIs
2. Discover APIs
- Command Palette:
Ctrl+Shift+P
→ "Analyze Workspace for APIs"
- Or click the refresh button in the "API Discovery" panel
3. Generate MCP Wrappers
- Right-click any API in the tree → "Generate MCP Wrapper"
- Or use Command Palette → "Generate MCP Wrapper"
4. Use Generated Servers
- Find generated MCP servers in
demo-output/
folder
- Each server is a complete Node.js MCP implementation
- Configure authentication via environment variables
Usage
Automatic Discovery
The extension automatically scans your workspace when activated and displays discovered APIs in the "API Discovery" tree view in the Explorer panel.
Manual Analysis
Run the command API to MCP: Analyze Workspace for APIs
from the Command Palette (Ctrl+Shift+P
).
Generate MCP Wrappers
- Click on any API in the API Discovery tree view, or
- Use the command
API to MCP: Generate MCP Wrapper
from the Command Palette
- Select the API to convert if multiple APIs are found
Using Generated MCP Servers
Generated MCP servers are saved in the mcp-wrappers/
directory and include:
- Complete Node.js MCP server implementation
package.json
with all necessary dependencies
- Authentication configuration
- Ready-to-use tool definitions
To use a generated MCP server:
cd mcp-wrappers
npm install
node your-api-mcp-server.js
Authentication Configuration
The extension automatically detects authentication requirements and generates appropriate configuration:
API Key Authentication
Set the API_KEY
environment variable:
export API_KEY="your-api-key"
Bearer Token Authentication
Set the BEARER_TOKEN
environment variable:
export BEARER_TOKEN="your-bearer-token"
Basic Authentication
Set the BASIC_AUTH
environment variable (format: username:password):
export BASIC_AUTH="username:password"
OAuth2
Set the OAUTH_TOKEN
environment variable:
export OAUTH_TOKEN="your-oauth-token"
Commands
API to MCP: Analyze Workspace for APIs
- Scan workspace for API definitions
API to MCP: Generate MCP Wrapper
- Create MCP wrapper for selected API
API to MCP: Show API Tree
- Focus on the API Discovery tree view
Configuration
The extension works out of the box with no configuration required. It automatically detects:
- OpenAPI/Swagger specifications (YAML/JSON)
- Common API route patterns in popular frameworks
- Authentication schemes from API specifications
Development
Prerequisites
- Node.js 18+
- npm or yarn
- VS Code 1.103.0+
Building from Source
git clone <repository-url>
cd apitomcp
npm install
npm run compile
Testing
Press F5
in VS Code to launch the Extension Development Host and test the extension.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
MIT License - see LICENSE file for details.
Changelog
See CHANGELOG.md for release history.
Note: This extension generates MCP servers that require the Model Context Protocol SDK. Make sure to install the necessary dependencies in your generated MCP server directory.