Skip to main content

Usage

Basic Usage

Generate code from an OpenAPI specification:

java -jar openapi-mcp-codegen.jar \
--input examples/petstore.yaml \
--output ./generated \
--root-package io.swagger.petstore

CLI Options

OptionShortDescriptionRequired
--input-iPath to the OpenAPI YAML fileYes
--output-oOutput directory for generated codeNo (default: ./generated)
--root-package-rRoot package name (e.g., io.swagger.petstore)Yes
--verbose-vEnable verbose outputNo
--compile-cCompile the generated code after generationNo

Examples

With Verbose Output

java -jar openapi-mcp-codegen.jar \
-i examples/petstore.yaml \
-o ./generated \
-r io.swagger.petstore \
-v

With Auto-Compilation

java -jar openapi-mcp-codegen.jar \
-i examples/petstore.yaml \
-o ./generated \
-r io.swagger.petstore \
-c

This compiles the generated code after generation using the Gradle wrapper that is included in the output directory.

Building the Generated Code

Standard Build

cd generated
./gradlew build

Build Domain + Client JAR Only

Builds a JAR containing only the domain and client packages, excluding the tool package:

./gradlew domainClientJar

This is useful when you want to distribute the SDK separately from the MCP tool implementation.

Next Steps