Skip to main content
Glama

openapi-mcp

Local OpenAPI contract inspection for AI coding agents.

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

openapi-mcp is a local MCP server that helps coding agents work with the APIs documented in your repository. It reads OpenAPI files in YAML or JSON, follows local references across files, and builds an index of operations. An agent can find an endpoint and inspect the part of its contract needed for a change.

What It Does

  • Service discovery. The workspace catalog lists OpenAPI files across a monorepo. If Billing and Sales both define GET /invoices, the agent can select Billing’s specification for its request.

  • Endpoint search. The endpoint index shows methods, paths, summaries, and declared response statuses. Agents can search by text, tag, or operation ID and page through matching operations.

  • Request and response inspection (openapi_query). This read-only tool lets an agent inspect parameters, request bodies, and response schemas. For example, before changing a checkout form, it can look up which fields the orders API declares in its 422 response.

  • Integration review. The sync-frontend-api prompt guides an agent through comparing a frontend caller with the documented contract. The audit-error-contracts prompt guides it through checking which error responses declare a status and which also describe the response body.

Related MCP server: swagger-openapi-mcp

Installation

Install the package with npm:

npm install -g @dimassetoid/openapi-mcp

A standalone executable is also available for Linux, macOS, and Windows. Standalone and Bun installation instructions

Quick Start

Configure your MCP client to run openapi-mcp serve --root /path/to/repo. Replace the path with the repository containing your OpenAPI files. Once connected, try asking your agent:

Which endpoint creates an order, and what does its specification say happens when validation fails?

For a monorepo, include the service name in your question so the agent can select its spec. MCP client configuration · Monorepo setup

CLI Reference

Command

Purpose

openapi-mcp serve

Start the MCP server in the current workspace.

openapi-mcp serve --root <dir> --spec <path>

Set the workspace and default specification.

openapi-mcp --help

Show usage and options.

openapi-mcp --version

Print the installed version.

Documentation

Development

# Clone the repository and install dependencies
git clone https://github.com/Shironim/openapi-mcp.git
cd openapi-mcp
bun install

# Run tests, check types, and build the package
bun test
bun run typecheck
bun run build

Standalone builds and package verification

License

MIT

Available Tools

1 tool
openapi_queryA
Read-onlyIdempotent

Query the resolved, read-only OpenAPI spec using synchronous JavaScript. Inspect the default endpoint index or query a specific path, request schema, or response schema.

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 1 tool

    Disambiguation5/5

    With only one tool there is no possibility of misselection between competing tools. The single tool cleanly covers the whole surface (index, path, request schema, response schema) through one entry point rather than fragmenting into overlapping tools.

    Naming Consistency4/5

    The lone name 'openapi_query' is clear, snake_case, and domain-prefixed. It uses a noun_verb order rather than the more common verb_noun, and a single name gives no pattern to verify consistency against, so it falls just short of a 5.

    Tool Count3/5

    A single general-purpose JavaScript query tool is a defensible minimal design that subsumes many specific operations. However, it is thin for an API-inspection server — no dedicated helpers for listing endpoints or fetching schemas — pushing it to the borderline range.

    Completeness4/5

    The server explicitly scopes itself to read-only querying of a resolved OpenAPI spec, and arbitrary JS over the spec can reach endpoints, paths, and request/response schemas. Minor gaps exist (e.g., no explicit security-scheme or validation/operationId lookup helpers), but nothing blocks core inspection workflows.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers