openapi-to-mcp

Generates an MCP server from an OpenAPI or Swagger specification using the mcp-use TypeScript SDK.

10.6k|1.4k|Updated Mar 28, 2025
One-click install
npx skills add https://github.com/mcp-use/mcp-use --skill openapi-to-mcp
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: openapi-to-mcp
Source: https://github.com/mcp-use/mcp-use/tree/main/skills/openapi-to-mcp
Command: npx skills add https://github.com/mcp-use/mcp-use --skill openapi-to-mcp

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @apidevtools/swagger-parser, dotenv, mcp-use, zod, and includes references (resource) components.

What problem does it solve?

Turning an existing REST API into something an LLM can call requires manually writing tool definitions, schemas, and auth wiring for every endpoint. This Skill automates that entire conversion: it ingests an OpenAPI 3.x or Swagger 2.0 document and produces a working, deployable MCP server where each API operation becomes a typed MCP tool.

Core Features & Use Cases

  • Spec-to-tool generation: Dereferences the spec, maps operations to snake_case tool names, and converts OpenAPI schemas into zod schemas with descriptions, enums, and constraints preserved.
  • Auth wiring: Handles apiKey, HTTP bearer, HTTP basic, and OAuth2 bearer schemes via environment variables, keeping secrets out of code and conversation.
  • Test and deploy pipeline: Verifies tools with the mcp-use client CLI and inspector chat, then deploys to mcp-use cloud for use from ChatGPT or Claude connectors.
  • Use Case: You have a swagger.json for your company's internal API. The Skill scaffolds a project, generates one tool per endpoint with proper zod validation, lets you test calls in the inspector, and deploys a public HTTPS MCP endpoint your team can install in Claude.

Quick Start

Ask the agent to turn your OpenAPI spec file into an MCP server, for example: build an MCP server from the attached openapi.yaml and deploy it.

Frequently Asked Questions about openapi-to-mcp

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I turn an OpenAPI spec into an MCP server?

Provide the spec as a file, URL, or pasted document. The Skill dereferences it with swagger-parser, maps each operation to an MCP tool with a zod schema, scaffolds a project with create-mcp-use-app, and wires auth through environment variables.

How to convert Swagger 2.0 to MCP tools?

Swagger 2.0 specs are first converted to OpenAPI 3 using the swagger2openapi CLI, then processed like any OpenAPI 3.x document. Each operation becomes one MCP tool with parameters merged into a single zod schema.

Does the generated MCP server support API key or bearer authentication?

Yes, it supports apiKey, HTTP bearer, HTTP basic, and OAuth2 bearer schemes declared in the spec's securitySchemes. Secrets are read from environment variables like API_KEY or BEARER_TOKEN and never committed or placed in the conversation.

Can I expose only some endpoints from a large OpenAPI spec?

Yes, for specs over roughly 30 operations the Skill asks you to filter by tag, path prefix, explicit operation list, or HTTP method. The filter is written into index.ts as a visible constant you can edit later.

Why does the inspector show zero tools for my MCP server?

Usually the operation filter in index.ts excluded everything, or openapi.dereferenced.json is missing or stale. Re-run the load-spec script, check the filter constants, and verify the inspector URL has the server parameter correctly URL-encoded.

When should I not use OpenAPI-to-MCP generation?

Avoid it for GraphQL or gRPC services, for designing a brand-new API from scratch, or when the goal is a widget-driven MCP App where most tools render custom UI. The schema converter and templates are OpenAPI-specific.