what is OpenAPI x MCP?
OpenAPI x MCP is a command-line interface (CLI) tool designed to generate a type-safe Model Context Protocol (MCP) server from an OpenAPI specification.
how to use OpenAPI x MCP?
To use OpenAPI x MCP, install it via npm and run the command pnpm generate <ABSOLUTE_PATH_TO_SPEC_YAML_OR_JSON>
to generate the server code. You can then build and start the server locally.
key features of OpenAPI x MCP?
- Generates MCP server code from OpenAPI specifications
- Supports local server execution
- Uses dotenv for environment variable management
- Type-safe implementation with TypeScript
use cases of OpenAPI x MCP?
- Quickly setting up a server for API development.
- Ensuring type safety in server implementations.
- Facilitating the development of applications that rely on OpenAPI specifications.
FAQ from OpenAPI x MCP?
- Is OpenAPI x MCP stable for production use?
No, this project is experimental and APIs may change significantly between versions.
- How do I run the server locally?
After generating the server code, run
pnpm build:server
followed bypnpm start
to start the server athttp://localhost:3001
.
- Where can I find the project repository?
The project is hosted on GitHub at https://github.com/usemodel-dev/cli.
OpenAPI x MCP
Generate a type-safe MCP (Model Context Protocol) server from an OpenAPI specification.
CLI Commands
The package provides several CLI commands for managing your MCP server:
Generate Server Code
Generate the MCP server code from your OpenAPI specification:
npx -y -p @usemodel-dev/cli@latest cli generate <ABSOLUTE_PATH_TO_SPEC_YAML_OR_JSON>
This will create the mcp server files in the
cwd()
directory.
Configure MCP Client Settings
The config command provides two operations for managing MCP server configurations:
Add or Update Configuration
Add or update MCP server settings for different clients:
npx -y -p @usemodel-dev/cli@latest cli config add <client> '<config_json>'
Where:
<client>
can be one of:cursor
,windsurf
, orclaude
<config_json>
is a JSON string containing your configuration
Example:
# Add or update a server configuration for Cursor
npx -y -p @usemodel-dev/cli@latest cli config add cursor '{"@yourorg/mcp": {"url": "http://localhost:3000", "env": { "apiKey": "XXX" } } }'
Remove Configuration
Remove a specific server configuration from a client:
npx -y -p @usemodel-dev/cli@latest cli config remove <client> <servername>
Example:
# Remove a server configuration from Cursor
npx -y -p @usemodel-dev/cli@latest cli config remove cursor @yourorg/mcp
The configurations are stored in the following locations based on the client:
- Cursor:
~/.cursor/mcp.json
- Windsurf:
~/.codeium/windsurf/mcp_config.json
- Claude:
~/Library/Application Support/Claude/claude_desktop_config.json
All configurations are stored under the mcpServers
key in the config file. When adding new configurations, they will be merged with existing ones, and when updating existing configurations, they will be overwritten.
Run the server
npx -y -p @usemodel-dev/cli@latest server
Run the server locally
Build the server
pnpm build
You need to run generate command before thi.s
pnpm start
This will start the server at http:localhost:3001
Environment Variables
The server uses dotenv for configuration. Create a .env
file in your project root with the necessary environment variables.
Dependencies
This package uses several key dependencies:
- @modelcontextprotocol/sdk: For MCP implementation
- express: For the server framework
- openapi-typescript: For TypeScript type generation
- zod: For runtime type validation
Contributing
This project is hosted on GitHub at https://github.com/@usemodel-dev/cli.git. Feel free to open issues or submit pull requests.
License
MIT
Package Information
Current version: 0.0.1