Skip to main content
Glama

openapi-mcp

Local Code Mode OpenAPI server, CLI, and contract engine for AI coding agents and CI.

npm version Runtime: Bun Protocol: Model Context Protocol License: MIT

openapi-mcp is a local Model Context Protocol (MCP) server, CLI, and reusable TypeScript engine for OpenAPI 3.0/3.1 and Swagger 2.0 specifications. It lets AI coding agents and CI pipelines inspect endpoints, schemas, and contract diffs without loading entire specification files into context.

Key Capabilities

  • Monorepo Spec Discovery (openapi://specs/catalog) — Scans workspaces for OpenAPI entry files while skipping symlinks, unreadable directories (EACCES/EPERM), and build or dependency folders (node_modules, vendor, dist, .git, etc.).

  • Indexed Endpoints & Paginated Search (openapi://endpoints/index, openapi://endpoints/search) — Summarizes HTTP methods, paths, 2xx/4xx/5xx status codes, error bodies, auth schemes, deprecation flags, and { file, line } source locations, soft-capped at 64 KB.

  • Schema Index & Reverse References (openapi://schemas/index, openapi://schemas/search) — Lists components.schemas / definitions with required fields, properties, unusedSchemas, source locations, and reverse usedBy operation references.

  • Single-Pass Contract Diagnostics (openapi://spec/diagnostics, openapi-mcp check) — Reports broken $refs, duplicate operationIds, undeclared path parameters, unknown security schemes, and missing error contracts in one pass.

  • Sandboxed Query Engine (openapi_query) — Runs read-only JavaScript in QuickJS WASM against frozen spec and built-in helpers (helpers.op, helpers.example, helpers.schemaRefs).

  • Semantic Contract Diff (openapi_diff, openapi-mcp diff) — Compares two local specifications and classifies changes into breaking and nonBreaking.

  • MCP Prompts & Agent Skill — Ships four guided prompts (sync-frontend-api, audit-error-contracts, review-breaking-changes, generate-test-fixtures) and a portable Agent Skill at skills/use-openapi-mcp/SKILL.md.

Related MCP server: LockSpec

Installation

Install precompiled single-file binaries for Linux, macOS, or Windows with SHA-256 verification (no Node.js or Bun required):

Linux & macOS:

curl -fsSL https://raw.githubusercontent.com/Shironim/openapi-mcp/master/scripts/install.sh | sh

Windows (PowerShell):

irm https://raw.githubusercontent.com/Shironim/openapi-mcp/master/scripts/install.ps1 | iex

You can also download archives directly from GitHub Releases (openapi-mcp-linux-x64, openapi-mcp-linux-arm64, openapi-mcp-darwin-x64, openapi-mcp-darwin-arm64, openapi-mcp-windows-x64.exe, and checksums.txt).

Via npm or Bun

Requires Node.js >=18.20.0 or Bun >=1.4.3:

npm install -g @dimassetoid/openapi-mcp
# or
bun add -g @dimassetoid/openapi-mcp

Or run without global installation:

npx @dimassetoid/openapi-mcp serve
# or
bunx @dimassetoid/openapi-mcp serve

Quick Start

MCP Client Setup

Add openapi-mcp to your MCP client configuration (for example .mcp.json):

{
  "mcpServers": {
    "openapi-mcp": {
      "command": "openapi-mcp",
      "args": ["serve", "--root", "/path/to/repo"]
    }
  }
}

Once connected, ask your agent:

Which endpoint creates an order, what does its 422 validation schema look like, and what is a valid example payload?

CI & Local CLI

Run contract diagnostics or breaking-change checks directly in your terminal or CI pipeline:

openapi-mcp check --root . --spec openapi.yml --strict
openapi-mcp diff openapi.yml openapi-v2.yml --fail-on-breaking

CLI Reference

openapi-mcp <command> [options]

Command

Description

serve

Start the MCP server over stdio (also starts automatically when stdin is piped)

check

Validate an OpenAPI spec and report contract issues

diff <base> <target>

Compare two local OpenAPI specs for breaking changes

Option

Description

--root <dir>

Workspace root directory (defaults to current directory)

--spec <path>

Path to OpenAPI spec file (serve, check)

--strict

Exit with code 1 if warnings are found (check)

--fail-on-breaking

Exit with code 1 if breaking changes are found (diff)

--json

Output results as JSON (check, diff)

-h, --help

Show help message (written to stderr)

-v, --version

Show version number (written to stderr)

Documentation

Development

bun install
bun run typecheck
bun test
bun run build
bun run compile:all          # Build standalone binaries into release/
sh scripts/verify-package.sh # Verify npm tarball, TypeScript consumer, and stdio smoke test

License

MIT

Available Tools

2 tools
openapi_diffA
Read-onlyIdempotent

Compare two local OpenAPI specs (base_spec_path vs target_spec_path) and classify semantic contract changes into breaking vs non-breaking.

Inputs: base_spec_path (required), target_spec_path (required), root, max_bytes.

openapi_queryB
Read-onlyIdempotent

Query the resolved, read-only OpenAPI spec using synchronous JavaScript against spec and built-in helpers (helpers.op, helpers.example, helpers.schemaRefs).

Inputs: code (required), root, max_bytes, spec_path.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 2 tools

    Disambiguation5/5

    openapi_query is a single-spec read/inspection tool, while openapi_diff explicitly takes two specs and classifies breaking vs non-breaking changes; the action and input shape differences make misselection unlikely.

    Naming Consistency5/5

    Both tools use the same `<domain>_<action>` pattern (openapi_query, openapi_diff) with lowercase snake_case, giving a fully predictable convention that would scale if more tools were added.

    Tool Count4/5

    Two tools is slightly thin, but the design is coherent: openapi_query is a general-purpose escape hatch over `spec`/`helpers`, and openapi_diff covers the one specialized workflow (contract comparison) that a generic query tool handles poorly.

    Completeness3/5

    Read-side inspection via arbitrary JS query plus semantic diff is a solid core, but obvious adjacent operations are absent — spec validation/linting, loading specs from URLs or registries, and any write/edit capability for the spec itself.

    Maintenance

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers