Skip to main content
Glama
OpenAPI MCP Server

OpenAPI MCP Server

by matpb

OpenAPI MCP Server

An MCP (Model Context Protocol) server that provides AI assistants with tools to explore and understand OpenAPI specifications. Point it at any OpenAPI spec (JSON or YAML) and give your AI the ability to search endpoints, explore schemas, and understand API structures.

Features

  • OpenAPI 3.x Support - Works with OpenAPI 3.0 and 3.1 specifications

  • JSON & YAML - Automatically detects and parses both formats

  • Smart Caching - Caches specs with configurable TTL to minimize API calls

  • Reference Resolution - Automatically resolves $ref references for complete schema views

  • Dual Transport - Run via stdio (local) or HTTP stream (remote/Docker)

  • Authentication - Optional API key authentication for HTTP transport

Related MCP server: OpenAPI MCP Server

Available Tools

Tool

Description

search_endpoints

Search API endpoints by path pattern, HTTP method, tags, or description

get_endpoint_details

Get complete details for a specific endpoint including parameters and schemas

search_schemas

Search for schemas/models by name or property

get_schema_details

Get full schema definition with resolved references

get_openapi_spec

Retrieve the full spec or filtered sections (info, paths, components, etc.)

list_guides

List the platform overview and guides, grouped by topic, with id, title and summary

get_guide

Get the full markdown of one platform guide (or overview) by id

search_docs

Search the overview, guides and endpoints (path, operationId, summary, description) to find which one covers a topic

Platform guides

The guide tools read guides that the spec carries itself:

  • Guides are tags carrying an x-guide object with an id (a common naming is guide:<id>). The object holds id, and optionally group, order, summary and verified_against. The tag's description is the guide's markdown.

  • The overview is info.description, exposed as the guide with id overview (it is only present when info.description is not empty).

  • list_guides groups guides as in x-tagGroups (falling back to x-guide.group). Inside a group, guides are ordered by x-guide.order, then by their position. get_guide returns one guide by id (with or without the guide: prefix), and search_docs searches the overview, guides and endpoints (path, operationId, summary, description).

  • get_openapi_spec replaces the guide text with a pointer to get_guide in info, in tags (as an x-note key) and in the default full section (also with pathFilter), so the spec stays small. This only applies when the spec has at least one guide; a spec without guides is returned unchanged.

  • search_docs splits the query on whitespace; an entry matches when every term appears in it, and ranks first when every term is in its title, id or summary (the overview also matches overview and its info.x-guide id and summary). A query starting with guide: also matches the guide:<id> name (guide:overview, and also guide:<x-guide id> when the spec sets one). Endpoint hits always rank after the overview and guides.

  • For a spec without guides, list_guides and search_docs guide results are empty (list_guides returns no groups; the overview still comes from info.description when present), and get_guide reports the available ids.

Quick Start

Prerequisites

  • Node.js >= 18.0.0

  • npm or yarn

Installation

# Clone the repository
git clone https://github.com/matpb/openapi-mcp.git
cd openapi-mcp

# Install dependencies
npm install

# Build
npm run build

Configuration

Create a .env file in the project root (see .env.example):

# Required: URL to your OpenAPI specification
OPENAPI_SPEC_URL=https://api.example.com/openapi.json

# Optional: API key if your spec endpoint requires authentication
OPENAPI_API_KEY=your-api-key

# Optional: Cache TTL in seconds (default: 300)
SPEC_CACHE_TTL=300

# Optional: Spec fetch timeout in seconds (default: 30)
SPEC_FETCH_TIMEOUT=30

# Transport: 'stdio' for local, 'http-stream' for remote (default: stdio)
MCP_TRANSPORT=stdio

# HTTP transport settings (only used when MCP_TRANSPORT=http-stream)
MCP_PORT=8080
API_KEYS=key1,key2  # Comma-separated API keys for client authentication
CORS_ORIGIN=*

Running Locally

# Development (build + run)
npm run dev

# Or production
npm run build
npm start

Environment Variables

Variable

Required

Default

Description

OPENAPI_SPEC_URL

Yes

-

URL to the OpenAPI specification (JSON or YAML)

OPENAPI_API_KEY

No

-

API key for authenticated spec endpoints (sent as X-API-Key header)

SPEC_CACHE_TTL

No

300

How long to cache the spec in seconds

SPEC_FETCH_TIMEOUT

No

30

Timeout of the spec fetch in seconds. After a failed refetch the stale cache is served and the next fetch waits min(SPEC_CACHE_TTL, 60) seconds

MCP_TRANSPORT

No

stdio

Transport type: stdio or http-stream

MCP_PORT

No

8080

Port for HTTP transport

API_KEYS

No

-

Comma-separated API keys for HTTP client authentication

CORS_ORIGIN

No

*

Allowed CORS origins for HTTP transport

Usage

With Claude Desktop

Add to your Claude Desktop configuration (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):

{
  "mcpServers": {
    "openapi": {
      "command": "node",
      "args": ["/path/to/openapi-mcp/dist/index.js"],
      "env": {
        "OPENAPI_SPEC_URL": "https://api.example.com/openapi.json",
        "OPENAPI_API_KEY": "your-api-key"
      }
    }
  }
}

With Claude Code

Add to your project's .mcp.json:

{
  "mcpServers": {
    "openapi": {
      "command": "node",
      "args": ["/path/to/openapi-mcp/dist/index.js"],
      "env": {
        "OPENAPI_SPEC_URL": "https://api.example.com/openapi.json"
      }
    }
  }
}

With MCP Inspector

For testing and debugging, use the MCP Inspector:

# Start the server in HTTP mode
MCP_TRANSPORT=http-stream npm run dev

# Connect Inspector to http://localhost:8080/mcp

Docker Deployment

cd docker

# Set required environment variables
export OPENAPI_SPEC_URL=https://api.example.com/openapi.json
export OPENAPI_API_KEY=your-api-key  # if needed

# Start the server
docker-compose up -d

Using Docker Directly

# Build the image
docker build -f docker/Dockerfile -t openapi-mcp .

# Run the container
docker run -d \
  -p 8080:8080 \
  -e OPENAPI_SPEC_URL=https://api.example.com/openapi.json \
  -e OPENAPI_API_KEY=your-api-key \
  -e API_KEYS=client-key-1,client-key-2 \
  openapi-mcp

Docker Environment

When running in Docker, the server automatically uses HTTP stream transport on port 8080. Configure client authentication by setting the API_KEYS environment variable.

The container includes:

  • Health check endpoint at /mcp

  • Graceful shutdown handling

  • Automatic restart on failure (when using docker-compose)

HTTP API Authentication

When running in HTTP stream mode with API_KEYS configured, clients must include an API key in requests:

# Via header
curl -H "X-API-Key: your-client-key" http://localhost:8080/mcp

# Or via query parameter
curl http://localhost:8080/mcp?api_key=your-client-key

If no API_KEYS are configured, the server runs without authentication (suitable for local development or trusted networks).

Tool Examples

Search for Endpoints

{
  "tool": "search_endpoints",
  "arguments": {
    "pathPattern": "user",
    "method": "GET",
    "limit": 10
  }
}

Get Endpoint Details

{
  "tool": "get_endpoint_details",
  "arguments": {
    "path": "/api/v2/users/{id}",
    "method": "GET",
    "resolveRefs": true
  }
}

Search Schemas

{
  "tool": "search_schemas",
  "arguments": {
    "namePattern": "User",
    "propertyName": "email"
  }
}

Get Schema Details

{
  "tool": "get_schema_details",
  "arguments": {
    "schemaName": "UserResponse",
    "resolveRefs": true,
    "maxDepth": 5
  }
}

Get Spec Section

{
  "tool": "get_openapi_spec",
  "arguments": {
    "section": "paths",
    "pathFilter": "/users"
  }
}

Development

# Install dependencies
npm install

# Build TypeScript
npm run build

# Run in development mode
npm run dev

# Run the tests (compiles to dist-test and runs node --test)
npm test

Project Structure

openapi-mcp/
├── src/
│   ├── index.ts           # Server entry point
│   ├── config.ts          # Environment configuration
│   ├── __tests__/         # node:test suites (npm test)
│   ├── tools/             # MCP tool implementations
│   │   ├── SearchEndpointsTool.ts
│   │   ├── GetEndpointDetailsTool.ts
│   │   ├── SearchSchemasTool.ts
│   │   ├── GetSchemaDetailsTool.ts
│   │   ├── GetOpenAPISpecTool.ts
│   │   ├── ListGuidesTool.ts
│   │   ├── GetGuideTool.ts
│   │   └── SearchDocsTool.ts
│   └── utils/
│       ├── OpenAPIManager.ts  # Spec fetching and caching
│       └── RefResolver.ts     # $ref resolution
├── docker/
│   ├── Dockerfile
│   └── docker-compose.yml
├── .env.example
├── tsconfig.json
├── tsconfig.test.json # Test build (outDir dist-test)
└── package.json

License

MIT

Available Tools

8 tools
get_endpoint_detailsA

Get detailed information about a specific API endpoint including parameters, request body schema, and response schemas.

Inputs: path (required), method (required), resolveRefs.

get_guideA

Return the full markdown of one platform guide by id (from list_guides), or the platform overview with id "overview". Use it when you need to understand a concept, feature or workflow before calling endpoints.

Inputs: id (required).

get_openapi_specA

Return the full OpenAPI spec or a filtered section. Use section to get specific parts (info, paths, components, tags, servers, full). Use pathFilter to filter paths by regex pattern. Platform guides are tags carrying an x-guide object with an id (a common naming is guide:); use list_guides, get_guide and search_docs to read them instead of dumping the spec.

Inputs: section, pathFilter.

get_schema_detailsB

Get detailed information about a specific schema/model including all properties and nested schemas with resolved $ref references.

Inputs: schemaName (required), maxDepth, resolveRefs.

list_guidesA

List the platform guides: the overview plus guides grouped by topic, each with id, title and summary. Call this first to discover what the platform guides cover, then use get_guide for the full text.

Inputs: no named parameters.

search_docsA

Search the platform overview, guides and endpoints (path, operationId, summary, description; endpoint hits rank after guides) for one or more words (case-insensitive; an entry matches when it contains every word, in any order; page through hits with limit and offset). Use it to find which guide or endpoint covers a topic, then open it with get_guide or get_endpoint_details.

Inputs: query (required), limit, offset.

search_endpointsB

Search API endpoints by path pattern, HTTP method, tags, or description. Returns a paginated list of matching endpoints.

Inputs: tags, limit, method, offset, +2 more.

search_schemasA

Search for schemas/models in the OpenAPI spec by name pattern or property name. Returns a paginated list of matching schemas.

Inputs: limit, offset, namePattern, propertyName.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 8 tools

    Disambiguation4/5

    Search/detail pairs are clearly separated for endpoints, schemas, and guides, so those are easy to distinguish. The one real overlap is search_docs, which per its description also searches endpoints and guides, partially duplicating search_endpoints and list_guides; descriptions mitigate this but boundaries are slightly blurred.

    Naming Consistency5/5

    All eight tools follow a clean verb_noun pattern (get_, list_, search_ + resource), with consistent snake_case throughout. No mixing of conventions or vague one-word verbs.

    Tool Count5/5

    Eight tools is well-scoped for an OpenAPI spec exploration server: discovery (list/search), retrieval (get spec/details), and guide access. Each tool earns its place without redundancy at the count level.

    Completeness4/5

    Covers spec retrieval, endpoint discovery/details, schema discovery/details, and platform guides—a full lifecycle for spec reading. Minor gaps: no direct tag listing or explicit security/auth-scheme tool, though those are reachable via get_openapi_spec sections and search_docs.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to load, parse, and query OpenAPI/Swagger documentation from URLs with intelligent search across endpoints, schemas, and authentication methods. Provides 10 specialized tools for comprehensive API exploration including path details, operation lookups, and multi-criteria search capabilities.
      4
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI tools to search and explore API documentation from Apidog projects or OpenAPI/Swagger specifications, providing endpoint details, schemas, and project statistics through natural language queries.
      1
      ISC
    • A
      license
      A
      quality
      D
      maintenance
      Exposes Swagger/OpenAPI API documentation to AI models, enabling exploration, search, and interaction with endpoints, schemas, and execution of API calls.
      14
      27 npm
      2
      MIT