Convert OpenAPI specifications to MCP server configurations with automatic parameter mapping and template support
The OpenAPI to MCP Server
tool is designed to convert OpenAPI specifications into Model Context Protocol (MCP) server configurations. This conversion enables AI applications, such as Claude Desktop, Continue, and Cursor, to seamlessly connect to various data sources and tools using a standardized protocol. By leveraging these APIs, developers can build robust, scalable, and interoperable systems for AI workflows.
The tool supports both JSON and YAML formats of OpenAPI files and translates them into MCP configurations. This includes defining server names, tools (endpoints), parameter descriptions, and more.
OpenAPI parameters such as path, query, header, cookie, and body are mapped accurately to their respective MCP structures, ensuring that all necessary information is preserved during the conversion process.
The tool automatically determines the correct position for each parameter based on its location in the OpenAPI specification (e.g., position: path
or position: query
), simplifying configuration management.
Generated configurations include detailed response templates, providing a clear structure and improved readability for AI applications and language models when interacting with the APIs.
The OpenAPI to MCP Server
tool operates by converting OpenAPI paths into MCP tools, ensuring that each API endpoint corresponds directly to an MCP tool definition. The following diagram illustrates the protocol flow:
graph TD
A[AI Application] -->|MCP Client| B[MCP Protocol]
B --> C[MCP Server]
C --> D[Data Source/Tool]
style A fill:#e1f5fe
style C fill:#f3e5f5
style D fill:#e8f5e8
This diagram shows how an AI application, through the MCP Client, sends requests via the MCP Protocol to the MCP Server. The MCP Server then forwards these requests to the appropriate data source or tool.
To get started, you can install the OpenAPI to MCP Server
tool using the following command:
go install github.com/noteworthyten/openapi-to-mcpserver/cmd/openapi-to-mcp@latest
Once installed, you can run the tool as follows:
openapi-to-mcp --input path/to/openapi.json --output path/to/mcp-server.yaml
--input
: Path to the OpenAPI specification file (JSON or YAML) (required).--output
: Path to the output MCP configuration file (YAML) (required).--server-name
: Name of the MCP server (default: "openapi-server").--tool-prefix
: Prefix for tool names (default: "").--format
: Output format (yaml or json) (default: "yaml").--validate
: Validate the OpenAPI specification (default: false).--template
: Path to a template file to patch the output (default: "").Imagine building an online pet store where you need to provide detailed information about pets and handle orders efficiently. Here’s how you could use this tool:
petstore.json
):{
"openapi": "3.0.0",
"info": {
"version": "1.0.0",
"title": "Swagger Petstore"
},
"servers": [
{
"url": "http://petstore.swagger.io/v1"
}
],
"paths": {
"/pets": {
"get": {
"summary": "List all pets",
"operationId": "listPets",
"parameters": [
{
"name": "limit",
"in": "query",
"description": "How many items to return at one time (max 100)",
"required": false,
"schema": {
"type": "integer",
"format": "int32"
}
}
],
"responses": {
"200": {
"description": "A paged collection of pets"
}
}
}
}
}
}
You can integrate a customer support ticket system that allows users to submit and manage tickets efficiently:
ticket-system.json
):{
"openapi": "3.0.0",
"info": {
"version": "1.0.0",
"title": "Customer Support Ticket System"
},
"servers": [
{
"url": "http://support.ticketsys.com/v1"
}
],
"paths": {
"/tickets": {
"post": {
"summary": "Create a Ticket",
"operationId": "createTicket",
"requestBody": { ... },
"responses": { ... }
}
}
}
}
Below is the compatibility matrix for various MCP clients:
MCP Client | Resources | Tools | Prompts | Status |
---|---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ | Full Support |
Continue | ✅ | ✅ | ✅ | Full Support |
Cursor | ❌ | ✅ | ❌ | Tools Only |
The OpenAPI to MCP Server
tool ensures compatibility with the listed clients and supports a wide range of operations. This section highlights key performance metrics, such as response times and API request rates.
When integrating a pet store's data into an AI system using Claude Desktop, you would:
petstore.json
OpenAPI file.This setup allows for seamless integration of pet store data and enhances the overall user experience by enabling more sophisticated AI-driven features, such as personalized recommendations or inventory management.
You can use template-based patching to add common headers, authentication, or other customizations to all tools in the configuration:
template.yaml
):server:
config:
apiKey: ""
tools:
requestTemplate:
headers:
- key: Authorization
value: "APPCODE {{.config.apiKey}}"
- key: X-Ca-Nonce
value: "{{uuidv4}}"
{
"mcpServers": {
"petstore-server": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-petstore"],
"env": {
"API_KEY": "your-api-key"
}
}
}
}
You can enable validation in the tool using the --validate
flag to ensure that your API specification is correct.
Yes, you can define custom headers like Authorization
and X-Ca-Nonce
using a template file, as shown in the example above.
Cursor is compatible only for tools integration but not for resources or prompts. This means that while you can connect Cursor to certain endpoints managed by the server, it cannot handle broader functionalities such as dynamic prompting.
Data security can be ensured by implementing standards like OAuth 2.0 for authentication and utilizing HTTPS/TLS for secure transmission of requests and responses.
Yes, each AI workflow may require a unique setup based on the API specifications and the tools involved. However, the conversion tool simplifies this process by providing accurate MCP configurations from OpenAPI files.
You can fork the repository and contribute to its development. Follow these steps:
git clone https://github.com/noteworthyten/openapi-to-mcpserver.git
.npm install
.Run tests to ensure that your changes do not break existing functionality:
npm test
Explore the vast ecosystem of MCP technologies and resources available:
This comprehensive guide positions OpenAPI to MCP Server
as a powerful tool for integrating AI applications seamlessly into various workflows, ensuring robust and interoperable system architectures.
Learn how to use MCProto Ruby gem to create and chain MCP servers for custom solutions
AI Vision MCP Server offers AI-powered visual analysis, screenshots, and report generation for MCP-compatible AI assistants
Analyze search intent with MCP API for SEO insights and keyword categorization
Connects n8n workflows to MCP servers for AI tool integration and data access
Expose Chicago Public Schools data with a local MCP server accessing SQLite and LanceDB databases
Next-generation MCP server enhances documentation analysis with AI-powered neural processing and multi-language support