**Automatically generate FAST Model-Context-Protocol (MCP) servers from OpenAPI/Swagger specs.**
Documentation
openapi2mcp
A tool to convert OpenAPI 3.x specifications to FastMCP servers.
Installation
poetry installUsage / 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 PATHOptions:
-
--server-file PATH: Path to the generated MCP server Python file to check. (Required)
Example:
openapi2mcp check --server-file generated_server.pyversion
Displays the version of the openapi2mcp tool.
Syntax:
openapi2mcp versionExample:
openapi2mcp versionExamples
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
Similar MCP
Based on tags & features
Trending MCP
Most active this week