A powerful Node.js server that dynamically converts any OpenAPI/Swagger specification into Model Context Protocol (MCP) tools, making APIs instantly accessible to AI assistants like Claude.
Transform any REST API into AI-friendly tools in seconds:
- Point to any OpenAPI spec (local file or URL)
- Get instant MCP tools for schema analysis AND API execution
- Use with Claude or any MCP-compatible AI assistant
- Universal Compatibility: Works with any OpenAPI 2.x or 3.x specification
- Dual Tool Types: Schema analysis tools + Dynamic HTTP execution tools
- Multiple Transports: HTTP server + STDIO for Claude integration
- Auto-Discovery: Automatically generates CRUD tools from your API paths
- Zero Configuration: Just point to a schema and go
- Production Ready: Full error handling, logging, and monitoring
# Install
git clone https://github.com/your-username/openapi-mcp-server.git
cd openapi-mcp-server
npm install
# Configure (pick one)
export OPENAPI_URL="https://petstore.swagger.io/v2/swagger.json"
export OPENAPI_URL="./samples/petstore.yaml"
export OPENAPI_URL="https://your-api.com/swagger.json"
# Start the server
npm start
That's it! Your API is now available as MCP tools.
- list-endpoints - See all API paths and methods
- get-endpoint - Detailed endpoint information
- get-request-body - Request schemas and validation
- get-response-schema - Response formats
- list-components - Schema components and models
- search-schema - Full-text search across the spec
- list-security-schemes - Authentication methods
For each API endpoint, get semantic tools like:
- search-users -
GET /users
- create-user -
POST /users
- read-user -
GET /users/{id}
- update-user -
PUT /users/{id}
- delete-user -
DELETE /users/{id}
- execute-request - Generic HTTP execution tool
export OPENAPI_URL="https://petstore.swagger.io/v2/swagger.json"
npm start
Result: 15+ tools including search-pet
, create-pet
, update-pet
, etc.
export OPENAPI_URL="https://your-company.com/api/swagger.json"
export API_BASE_URL="https://your-company.com/api"
export API_TOKEN="your-bearer-token"
npm start
Result: Full API access through semantic tools + Claude integration
export OPENAPI_URL="./openapi.yaml"
export API_BASE_URL="http://localhost:3000"
npm start
Result: Local API testing through MCP tools
Variable | Description | Example |
---|---|---|
OPENAPI_URL |
Path or URL to OpenAPI spec | ./spec.yaml or https://api.com/swagger.json |
API_BASE_URL |
Base URL for API execution | https://api.example.com |
API_TOKEN |
Bearer token for authentication | eyJhbGciOiJIUzI1NiIs... |
PORT |
Server port | 8000 (default) |
- Start the MCP client:
npm run client
- Add to your Claude config:
{
"mcpServers": {
"openapi": {
"command": "node",
"args": ["/path/to/openapi-mcp-server/src/client.js"],
"env": {
"OPENAPI_URL": "https://your-api.com/swagger.json"
}
}
}
}
Use the HTTP endpoints directly:
curl -X POST http://localhost:8000/tools/call \
-H "Content-Type: application/json" \
-d '{"name": "list-endpoints", "arguments": {}}'
POST /tools/list
- List available toolsPOST /tools/call
- Execute toolsGET /sse
- Server-Sent Events for real-timeGET /health
- Health monitoring
npm run client
- Direct MCP protocol communication- Perfect for Claude Desktop integration
- Full streaming support
# Test with included Petstore sample
cp .env.example .env
# Edit .env: OPENAPI_URL=./samples/petstore.yaml
npm start
# Run comprehensive tests
npm test # HTTP endpoints
npm run test:mcp # MCP protocol
npm run test:client # Full STDIO client
npm run test:all # Everything
βββ src/
β βββ server.js # HTTP server entry point
β βββ client.js # STDIO client entry point
β βββ tools/
β β βββ registerTools.js # Schema analysis tools
β β βββ registerActions.js # HTTP execution tools
β βββ utils/
β β βββ schemaLoader.js # OpenAPI schema loading
β β βββ toolUtils.js # Tool management
β βββ routes/ # HTTP route handlers
βββ test/ # Comprehensive test suite
βββ samples/ # Example OpenAPI specs
- Schema Loading: Loads OpenAPI spec from file or URL
- Tool Generation: Creates MCP tools for both analysis and execution
- Dynamic Mapping: Maps HTTP operations to semantic tool names
- Parameter Handling: Automatically handles path/query/body parameters
- Authentication: Supports Bearer tokens and API keys
- Transport Agnostic: Works over HTTP or STDIO
// Only generate tools for specific paths
const filteredPaths = ['/users', '/orders'];
# Bearer token
export API_TOKEN="your-bearer-token"
# API key in header
export API_KEY="your-api-key"
Run multiple instances with different configs:
# API 1
PORT=8001 OPENAPI_URL="api1.yaml" npm start &
# API 2
PORT=8002 OPENAPI_URL="api2.yaml" npm start &
- β OpenAPI 3.x (native support)
- β Swagger 2.x (full compatibility)
- β REST APIs with standard HTTP methods
- β Authentication: Bearer, API Key, OAuth2
- β Parameter Types: Path, Query, Header, Body
- β Content Types: JSON, Form data, URL encoded
- Built-in health checks at
/health
- Structured logging with multiple levels
- Request/response tracking
- Error handling and reporting
- Performance metrics
- Request validation using Zod schemas
- Bearer token support
- CORS configuration
- Rate limiting (configurable)
- Error sanitization in production
- Fork the repository
- Add support for your OpenAPI spec
- Run the test suite:
npm run test:all
- Submit a pull request
MIT License - use this to make any API accessible to AI assistants!
Originally inspired by openapi-introspect
by Hannes Junnila. This project expands the concept with dynamic tool generation, HTTP execution, and full MCP protocol support.
Transform any API into AI-accessible tools in minutes, not hours.