- Explore MCP Servers
- SwaggerToMCP
Swaggertomcp
What is Swaggertomcp
SwaggerToMCP is a command-line interface (CLI) tool that converts Swagger/OpenAPI specifications into Model Context Protocol (MCP) definitions, facilitating compatibility with agentic AI systems like Anthropic’s Claude.
Use cases
Use cases include transforming API definitions for AI interactions, enabling Claude AI to utilize external services, and simplifying the integration process for developers working with OpenAPI specifications.
How to use
To use SwaggerToMCP, clone the repository, build the project using .NET, and run the command with the input Swagger/OpenAPI JSON file and desired output MCPContext JSON file path.
Key features
Key features include conversion of OpenAPI operations to MCP Tool objects, preservation of all metadata, mapping of OpenAPI fields to MCP fields, compliance with MCP schema, handling of complex parameter structures, and support for both OpenAPI 2.0 and 3.0+ specifications.
Where to use
SwaggerToMCP is useful in fields where integration of external APIs with AI systems is required, such as in software development, AI applications, and API management.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Overview
What is Swaggertomcp
SwaggerToMCP is a command-line interface (CLI) tool that converts Swagger/OpenAPI specifications into Model Context Protocol (MCP) definitions, facilitating compatibility with agentic AI systems like Anthropic’s Claude.
Use cases
Use cases include transforming API definitions for AI interactions, enabling Claude AI to utilize external services, and simplifying the integration process for developers working with OpenAPI specifications.
How to use
To use SwaggerToMCP, clone the repository, build the project using .NET, and run the command with the input Swagger/OpenAPI JSON file and desired output MCPContext JSON file path.
Key features
Key features include conversion of OpenAPI operations to MCP Tool objects, preservation of all metadata, mapping of OpenAPI fields to MCP fields, compliance with MCP schema, handling of complex parameter structures, and support for both OpenAPI 2.0 and 3.0+ specifications.
Where to use
SwaggerToMCP is useful in fields where integration of external APIs with AI systems is required, such as in software development, AI applications, and API management.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Content
SwaggerToMCP
A CLI tool that converts Swagger/OpenAPI JSON files into Anthropic’s Model Context Protocol (MCP) format. Now with full OpenAPI 3.1.0 support!
Project Summary: SwaggerToMCP bridges the gap between OpenAPI specifications and Anthropic’s Claude AI by transforming API definitions into the MCP format. This enables seamless integration of external APIs with Claude, allowing the AI to interact with these services through well-defined tool interfaces.
Quick Overview
SwaggerToMCP is a command-line tool that takes a Swagger/OpenAPI JSON file as input and converts it to a valid MCPContext JSON file. The tool preserves all metadata from the OpenAPI input and outputs in compliance with Anthropic’s Model Context Protocol (MCP) schema.
Key Features
- Converts OpenAPI operations to MCP Tool objects
- Preserves all metadata from the OpenAPI specification
- Maps OpenAPI fields to their corresponding MCP fields
- Outputs a JSON file compliant with MCP’s Tool schema
- Handles complex parameter structures and nested schemas
- Supports OpenAPI 2.0 (Swagger), 3.0, and 3.1.0 specifications
- Full OpenAPI 3.1.0 schema support:
- Type arrays (e.g.,
["string", "null"]
) for nullable fields - Schema composition with
oneOf
,anyOf
, andallOf
- Discriminator mapping for polymorphic schemas
- References (
$ref
) alongside other properties
- Type arrays (e.g.,
- Maintains security definitions and requirements
- Provides detailed error reporting for invalid specifications
Installation
# Clone the repository
git clone https://github.com/grparry/SwaggerToMCP.git
cd SwaggerToMCP
# Build the project
dotnet build
Usage Example
# Convert a Swagger/OpenAPI file to MCP format
dotnet run --project SwaggerToMCP.Cli -- -i ./path/to/swagger.json -o ./output/mcp-context.json
# Or with full argument names
dotnet run --project SwaggerToMCP.Cli -- --input ./path/to/swagger.json --output ./output/mcp-context.json
Contributing
Contributions are welcome! Please see our CONTRIBUTING.md file for detailed guidelines on how to contribute to this project.
If you’d like to improve SwaggerToMCP, please feel free to:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
Please ensure your code follows the existing style and includes appropriate tests.
Documentation
For detailed documentation, advanced usage examples, and technical details, please see the detailed README in the SwaggerToMCP directory.
OpenAPI 3.1.0 Support
SwaggerToMCP now fully supports OpenAPI 3.1.0, which brings several significant improvements over OpenAPI 3.0:
Key OpenAPI 3.1.0 Features Supported
-
JSON Schema Alignment
- SwaggerToMCP now correctly parses OpenAPI 3.1.0 documents aligned with JSON Schema 2020-12
- Support for
type
arrays (e.g.,["string", "null"]
) for nullable types
-
Enhanced Schema Composition
- Full support for
oneOf
,anyOf
, andallOf
schema compositions - Proper discriminator handling for polymorphic schemas
- Full support for
-
Extended References
- Support for
$ref
alongside other keywords - This enables more flexible schema definitions and extensions
- Support for
-
Improved Nullable Handling
- Correctly processes both OpenAPI 3.0.x
nullable: true
and OpenAPI 3.1.0 type arrays - Ensures consistent representation in MCP format
- Correctly processes both OpenAPI 3.0.x
These features are automatically detected when parsing OpenAPI documents, with no additional configuration required.
Examples
Check out the examples directory for sample Swagger/OpenAPI files and their corresponding MCP outputs. These examples demonstrate how to use the tool with different API specifications and how to integrate the generated MCP files with Claude.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Citation
If you use this software in your research or projects, please cite it using the information in the CITATION.cff file.
Dev Tools Supporting MCP
The following are the main code editors that support the Model Context Protocol. Click the link to visit the official website for more information.