Using Swagger 2 API Specification
As the Swagger 2 API does not have
operrationId
they 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.json
Click 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.yaml
yaml file
Fix the operation id
- clone the repo mcp-schema-optimization
- cd to the
mcp-schema-optimization
folder runuv sync
- run the following command where
spec.yml
is the input file andtest_output.json
is the outputbashuv run python main.py spec.yml test_output.json
- this will generate a file called
test_output.json
which has the operation id fixed