SwaggerToMCP
π Convert Swagger/OpenAPI specs into Model Context Protocol (MCP) tool definitions for agentic AI compatibility.
claude mcp add --transport stdio grparry-swaggertomcp dotnet run --project SwaggerToMCP.Cli
How to use
SwaggerToMCP is a command-line tool that converts OpenAPI/Swagger specifications into MCP context JSON, enabling Claude to interact with external APIs through a well-defined tool interface. The project focuses on retaining metadata from the input OpenAPI document and producing a valid MCP Tool object that mirrors operations, parameters, and security definitions. You can leverage this to automate tool generation from your API specs and integrate them into Claude-assisted workflows. The CLI accepts a Swagger/OpenAPI JSON file and outputs a single MCP-context JSON file that describes the available API operations as MCP tools.
Usage is straightforward: run the tool against your OpenAPI file to generate the MCP output, then supply that MCP-context to Claude as a tool configuration. The tool preserves complex constructs such as oneOf, anyOf, allOf, references ($ref), and extended JSON Schema features from OpenAPI 3.1.0, ensuring accurate modeling of APIs in MCP format.
How to install
Prerequisites:
- .NET 9.0 SDK or runtime installed on your system
- Git (optional, for cloning the repository)
Installation steps:
- Clone the repository: git clone https://github.com/grparry/SwaggerToMCP.git
- Navigate to the repository: cd SwaggerToMCP
- Build the CLI project (requires the .NET SDK): dotnet build
- Run the CLI against an OpenAPI/Swagger JSON file to generate MCP output: dotnet run --project SwaggerToMCP.Cli -- -i path/to/swagger.json -o path/to/mcp-context.json
Notes:
- The tool supports OpenAPI 2.0 (Swagger), 3.0, and 3.1.0 specifications, including complex schemas and discriminator handling.
- Ensure your OpenAPI document is accessible from the machine running the CLI (local path or URL).
Additional notes
Tips and common considerations:
- The output MCP file will map OpenAPI operations to MCP Tool objects; review the MCP-context.json to ensure all required fields align with your Claude integration needs.
- If your OpenAPI uses advanced JSON Schema features (oneOf/anyOf/allOf, $ref, discriminators), verify that the generated MCP retains these structures accurately.
- For large specifications, consider testing with a subset of endpoints to validate the conversion before running against the full document.
- Security definitions in OpenAPI (e.g., API keys, OAuth2) are preserved in the MCP output so Claude can authenticate when calling tools.
- If you encounter path or parameter translation issues, check the toolβs output logs for guidance on mapping adjustments or unsupported constructs.
Related MCP Servers
mcp-svelte-docs
π MCP server that lets you search and access Svelte documentation with built-in caching
neurolink
Universal AI Development Platform with MCP server integration, multi-provider support, and professional CLI. Build, test, and deploy AI applications with multiple ai providers.
go-utcp
Official Go implementation of the UTCP
toolkit
A Model Context Protocol server providing LLM Agents with system utilities and tools, including IP geolocation, network diagnostics, system monitoring, cryptographic operations, and QR code generation.
local -gateway
Aggregate multiple MCP servers into a single endpoint with web UI, OAuth 2.1, and profile-based tool management
mcp-sandbox
Turn any JavaScript module into a sandboxed MCP (Model Context Protocol) server with automatic reflection and type inference.