Get the FREE Ultimate OpenClaw Setup Guide →

OpenApiMcpNet

OpenApiMcpNet is an open‑source project that lets you build MCP servers backed by any web API defined with an OpenAPI spec. It automatically maps MCP operations to the corresponding API endpoints, so you can create a fully functional MCP server with minimal manual wiring.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio kerryjiang-openapimcpnet dotnet path/to/OpenApiMcpNet.dll

How to use

OpenApiMcpNet is a .NET library that automatically generates MCP-compatible tools from an OpenAPI (Swagger) specification. It reads an OpenAPI document and creates MCP tools for each operation, including parameters (path, query, header, cookie) and request bodies, with support for OpenAPI features like authentication schemes (OAuth 1.0a and OAuth 2.0 client credentials). You can wire these tools into an MCP server pipeline via the IMcpServerBuilder extensions, enabling AI assistants or LLMs to call REST APIs through standardized MCP tool calls. To use it, install the OpenApiMcpNet package and register the MCP server with your application, then supply the OpenAPI spec (as a string, stream, or parsed document) along with the API base URL. This allows automated tool generation for all endpoints described by the OpenAPI document and handles request construction, authentication, and response parsing.

How to install

Prerequisites:

  • .NET 8.0 or later installed
  • A working .NET project (e.g., ASP.NET Core or a worker) where you can host the MCP server

Installation steps:

  1. Add the package to your project
dotnet add package OpenApiMcpNet
  1. Register and configure the MCP server with tools from your OpenAPI specification (examples are shown in the Quick Start of the README):
using Microsoft.Extensions.DependencyInjection;
using ModelContextProtocol.Server;
using OpenApiMcpNet;

var builder = Host.CreateApplicationBuilder(args);

// Add MCP server with tools from OpenAPI spec
builder.Services.AddMcpServer()
    .WithToolsFromOpenApi(openApiSpecJson, "https://api.example.com");

var host = builder.Build();
await host.RunAsync();
  1. Run your application as you normally would (e.g., via dotnet run) which will start the MCP server exposing the generated MCP tools.

Notes:

  • Ensure your OpenAPI spec is accessible (string, stream, or parsed OpenApiDocument) and that you provide a valid base URL for the API host.

Additional notes

Tips and considerations:

  • The tool generation is based on operationId or a generated name from the HTTP method and path; descriptions come from the OpenAPI summary/description.
  • Input schemas are inferred from parameters and request bodies; the MCP tool will validate and serialize inputs accordingly.
  • Authentication handlers can be customized by implementing IAuthenticationHandler; built-in examples include OAuth 2.0 Client Credentials and OAuth 1.0a as documented in the README.
  • Ensure your hosting environment has network access to the target OpenAPI base URL and any authentication endpoints required by your API.
  • The README references .NET 8 features and dependencies such as ModelContextProtocol and Microsoft.OpenApi.Readers; ensure compatible versions are referenced in your project.
  • If you need to regenerate tools after OpenAPI changes, reconfigure the server with the updated spec and restart the application.

Related MCP Servers

Sponsor this space

Reach thousands of developers