About openapi2mcp
openapi2mcp is a command-line tool for developers that turns OpenAPI 3.x specifications into FastMCP server code. It also provides basic validation of generated files and can produce an llms.txt description.
Key features
- 01Generate FastMCP server code from JSON or YAML specs
- 02Choose stdio or google_pubsub transport
- 03Set a resource mount path
- 04Generate an llms.txt file
- 05Check generated server syntax and MCP patterns
Use cases
- 01Create an MCP server from an existing API specification
- 02Validate generated server code before use
MCP support
It generates MCP server code from OpenAPI specifications. The generated server exposes the specification's API through MCP.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMEopenapi2mcp
A tool to convert OpenAPI 3.x specifications to FastMCP servers.
Installation
poetry install
Usage / Commands
openapi2mcp provides a command-line interface to generate and manage MCP server code from OpenAPI specifications.
generate
Generates the MCP server Python code from an OpenAPI specification file.
Syntax:
openapi2mcp generate [OPTIONS]
Options:
-i, --input-file PATH: Path to the OpenAPI specification file (JSON or YAML). (Required)-o, --output-file PATH: Path to the output Python file for the generated MCP server. (Required)-t, --transport [stdio|google_pubsub]: The transport mechanism for the MCP server. (Default:stdio)--llms-txt-file PATH: Optional path to generate anllms.txtfile, which provides a description of the generated tools and resources for language models. If not specified,llms.txtwill be created in the same directory as the output server file.--mount TEXT: Optional mount path for resources (e.g.,/myapi/v1). (Default:"")
Example:
openapi2mcp generate --input-file examples/example_openapi.yaml --output-file generated_server.py --transport stdio --mount "/api"
This command will parse examples/example_openapi.yaml, generate an MCP server file named generated_server.py using the stdio transport, and set the resource mount path to /api. It will also generate an llms.txt file in the same directory as generated_server.py.
check
Checks a generated MCP server Python file for basic code validity, including syntax and presence of key MCP patterns.
Syntax:
openapi2mcp check --server-file PATH
Options:
--server-file PATH: Path to the generated MCP server Python file to check. (Required)
Example:
openapi2mcp check --server-file generated_server.py
version
Displays the version of the openapi2mcp tool.
Syntax:
openapi2mcp version
Example:
openapi2mcp version
Examples
See example implementations:
Project Structure
openapi2mcp/parser.py: OpenAPI specification parseropenapi2mcp/generator.py: FastMCP server code generatoropenapi2mcp/cli.py: Command-line interface
License
MIT - See LICENSE
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.