Using Swagger 2 API Specification
As the Swagger 2 API does not have
operrationIdthey will not work for the MCP composer. Hence we need to convert the swagger 2 file to swagger 3 file and fix theoperationId
Convert v2 to v3 yaml file
Open a tab in browser and navigate to
https://editor.swagger.io/Click "Import" and select the file
example/openapispec/spec.jsonClick Edit > Convert to OpenAPI 3
Click on "Convert" and if there is error ignore for now. As there is no operationId in v2 these error are being there
Copy all from the editor open a new file in your text editor and save the file as
example/openapispec/spec.yamlyaml file
Fix the operation id
- clone the repo mcp-schema-optimization
- cd to the
mcp-schema-optimizationfolder runuv sync - run the following command where
spec.ymlis the input file andtest_output.jsonis the outputbashuv run python main.py spec.yml test_output.json - this will generate a file called
test_output.jsonwhich has the operation id fixed
