hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
Integrations
Includes functionality for forking and customizing the repository on GitHub, with workflow configurations for automatic publishing to npm.
Provides a configured GitHub Actions workflow for automatic building and publishing of customized MCP packages to npm when a tag is pushed.
Enables running the MCP server that transforms OpenAPI specifications into tools accessible to AI assistants, with specific support for Node.js environments including installation via npm.
OpenAPI to MCP Server
A tool that creates MCP (Model Context Protocol) servers from OpenAPI/Swagger specifications, enabling AI assistants to interact with your APIs. Create your own branded and customized MCPs for specific APIs or services.
Overview
This project creates a dynamic MCP server that transforms OpenAPI specifications into MCP tools. It enables seamless integration of REST APIs with AI assistants via the Model Context Protocol, turning any API into an AI-accessible tool.
Features
- Dynamic loading of OpenAPI specs from file or HTTP/HTTPS URLs
- Support for OpenAPI Overlays loaded from files or HTTP/HTTPS URLs
- Customizable mapping of OpenAPI operations to MCP tools
- Advanced filtering of operations using glob patterns for both operationId and URL paths
- Comprehensive parameter handling with format preservation and location metadata
- API authentication handling
- OpenAPI metadata (title, version, description) used to configure the MCP server
- Hierarchical description fallbacks (operation description → operation summary → path summary)
- Custom HTTP headers support via environment variables and CLI
- X-MCP header for API request tracking and identification
- Support for custom
x-mcp
extensions at the path level to override tool names and descriptions
Using with AI Assistants
This tool creates an MCP server that allows AI assistants to interact with APIs defined by OpenAPI specifications. The primary way to use it is by configuring your AI assistant to run it directly as an MCP tool.
Setting Up in Claude Desktop
- Ensure you have Node.js installed on your computer
- Open Claude Desktop and navigate to Settings > Developer
- Edit the configuration file (or it will be created if it doesn't exist):
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:
%APPDATA%\Claude\claude_desktop_config.json
- macOS:
- Add this configuration (customize as needed):
- Restart Claude Desktop
- You should now see a hammer icon in the chat input box. Click it to access your API tools.
Customizing the Configuration
You can adjust the args
array to customize your MCP server with various options:
Setting Up in Cursor
- Create a configuration file in one of these locations:
- Project-specific:
.cursor/mcp.json
in your project directory - Global:
~/.cursor/mcp.json
in your home directory
- Project-specific:
- Add this configuration (adjust as needed for your API):
- Restart Cursor or reload the window
Using with Vercel AI SDK
You can also use this MCP server directly in your JavaScript/TypeScript applications using the Vercel AI SDK's MCP client:
Configuration
Configuration is managed via environment variables, command-line options, or a JSON configuration file:
Command Line Options
Environment Variables
You can set these in a .env
file or directly in your environment:
OPENAPI_SPEC_PATH
: Path to OpenAPI spec fileOPENAPI_OVERLAY_PATHS
: Comma-separated paths to overlay JSON filesTARGET_API_BASE_URL
: Base URL for API calls (overrides OpenAPI servers)MCP_WHITELIST_OPERATIONS
: Comma-separated list of operation IDs or URL paths to include (supports glob patterns likegetPet*
orGET:/pets/*
)MCP_BLACKLIST_OPERATIONS
: Comma-separated list of operation IDs or URL paths to exclude (supports glob patterns, ignored if whitelist used)API_KEY
: API Key for the target API (if required)SECURITY_SCHEME_NAME
: Name of the security scheme requiring the API KeySECURITY_CREDENTIALS
: JSON string containing security credentials for multiple schemesCUSTOM_HEADERS
: JSON string containing custom headers to include in all API requestsHEADER_*
: Any environment variable starting withHEADER_
will be added as a custom header (e.g.,HEADER_X_API_Version=1.0.0
adds the headerX-API-Version: 1.0.0
)DISABLE_X_MCP
: Set totrue
to disable adding theX-MCP: 1
header to all API requestsCONFIG_FILE
: Path to a JSON configuration file
JSON Configuration
You can also use a JSON configuration file instead of environment variables or command-line options. The MCP server will look for configuration files in the following order:
- Path specified by
--config
command-line option - Path specified by
CONFIG_FILE
environment variable config.json
in the current directoryopenapi-mcp.json
in the current directory.openapi-mcp.json
in the current directory
Example JSON configuration file:
A full example configuration file with explanatory comments is available at config.example.json
in the root directory.
Configuration Precedence
Configuration settings are applied in the following order of precedence (highest to lowest):
- Command-line options
- Environment variables
- JSON configuration file
Development
Installation
Local Testing
Customizing and Publishing Your Own Version
You can use this repository as a base for creating your own customized OpenAPI to MCP server. This section explains how to fork the repository, customize it for your specific APIs, and publish it as a package.
Forking and Customizing
- Fork the Repository: Fork this repository on GitHub to create your own copy that you can customize.
- Add Your OpenAPI Specs:Copy
- Configure Default Settings:
Create a custom config file that will be bundled with your package:Copy
- Update package.json:Copy
- Ensure Specs are Bundled:
The
files
field in package.json (shown above) ensures your specs and config file will be included in the published package.
Customizing the GitHub Workflow
The repository includes a GitHub Actions workflow for automatic publishing to npm. To customize it for your forked repo:
- Update the Workflow Name:
Edit
.github/workflows/publish-npm.yaml
to update the name if desired:Copy - Set Package Scope (if needed):
If you want to publish under an npm organization scope, uncomment and modify the scope line in the workflow file:Copy
- Set Up npm Token:
Add your npm token as a GitHub secret named
NPM_TOKEN
in your forked repository's settings.
Publishing Your Customized Package
Once you've customized the repository:
- Create and Push a Tag:Copy
- GitHub Actions will:
- Automatically build the package
- Update version in package.json to match the tag
- Publish to npm with your bundled specs and config
Usage After Publication
Users of your customized package can install and use it with npm:
They can override your default settings via environment variables or command line options as described in the Configuration section.
License
MIT
This server cannot be installed
A tool that creates MCP (Model Context Protocol) servers from OpenAPI/Swagger specifications, enabling AI assistants to interact with your APIs.