swagger-mcp

MCP.Pizza Chef: dcolley

Point it at a Swagger or OpenAPI file and every operation described there becomes something your assistant can call. Know the gaps before you rely on it: settings come only from config.json, and not one of the environment variables the README lists is ever read. The key-name setting is ignored as well, since the header name is hard-coded to api_key. It also listens on every network interface with no login, and the maintainer warns in the README never to put it on the public internet.

Coding
Data

Use This MCP server To

Ask about a service my team documents without opening its docs Look up a record in an internal system by name Try a documented request without writing any code myself Create or update a record in a service I run See which operations a service offers before building against it

README

Swagger MCP Server

A server that ingests and serves Swagger/OpenAPI specifications through the Model Context Protocol (MCP).

Features

  • Loads Swagger/OpenAPI specifications
  • Supports multiple authentication methods:
    • Basic Auth
    • Bearer Token
    • API Key (header or query)
    • OAuth2
  • Automatically generates MCP tools from API endpoints
  • Server-Sent Events (SSE) support for real-time communication
  • TypeScript support

Security

This is a personal server!! Do not expose it to the public internet. If the underlying API requires authentication, you should not expose the MCP server to the public internet.

TODO

  • secrets - the MCP server should be able to use secrets from the user to authenticate requests to the API
  • Comprehensive test suite

Prerequisites

  • Node.js (v18 or higher)
  • Yarn package manager
  • TypeScript

Installation

  1. Clone the repository:
git clone https://github.com/dcolley/swagger-mcp.git
cd swagger-mcp
  1. Install dependencies:
yarn install
  1. Create a .env file based on the example:
cp .env.example .env
  1. Configure your Swagger/OpenAPI specification:

    • Place your Swagger file in the project (e.g., swagger.json)
    • Or provide a URL to your Swagger specification
  2. Update the configuration in config.json with your server settings:

{
  "server": {
    "host": "localhost",
    "port": 3000
  },
  "swagger": {
    "url": "url-or-path/to/your/swagger.json",
    "apiBaseUrl": "https://api.example.com",  // Fallback if not specified in Swagger
    "defaultAuth": {  // Fallback if not specified in Swagger
      "type": "apiKey",
      "apiKey": "your-api-key",
      "apiKeyName": "api_key",
      "apiKeyIn": "header"
    }
  }
}

Note: The server prioritizes settings from the Swagger specification over the config file:

  • If the Swagger file contains a servers array, the first server URL will be used as the base URL
  • If the Swagger file defines security schemes, they will be used for authentication
  • The config file settings serve as fallbacks when not specified in the Swagger file

Usage

  1. Start the development server:
yarn dev
  1. Build for production:
yarn build
  1. Start the production server:
yarn start

API Endpoints

  • GET /health - Check server health status
  • GET /sse - Establish Server-Sent Events connection
  • POST /messages - Send messages to the MCP server

Testing

Run the test suite:

# Run tests once
yarn test

# Run tests in watch mode
yarn test:watch

# Run tests with coverage report
yarn test:coverage

Authentication

The server supports various authentication methods. Configure them in the config.json file as fallbacks when not specified in the Swagger file:

Basic Auth

{
  "defaultAuth": {
    "type": "basic",
    "username": "your-username",
    "password": "your-password"
  }
}

Bearer Token

{
  "defaultAuth": {
    "type": "bearer",
    "token": "your-bearer-token"
  }
}

API Key

{
  "defaultAuth": {
    "type": "apiKey",
    "apiKey": "your-api-key",
    "apiKeyName": "X-API-Key",
    "apiKeyIn": "header"
  }
}

OAuth2

{
  "defaultAuth": {
    "type": "oauth2",
    "token": "your-oauth-token"
  }
}

Development

  1. Start the development server:
yarn dev

License

This project is licensed under the Apache 2.0 License.

Environment Variables

  • PORT: Server port (default: 3000)
  • API_USERNAME: Username for API authentication (fallback)
  • API_PASSWORD: Password for API authentication (fallback)
  • API_TOKEN: API token for authentication (fallback)
  • DEFAULT_API_BASE_URL: Default base URL for API endpoints (fallback)
  • DEFAULT_SWAGGER_URL: Default Swagger specification URL

swagger-mcp FAQ

Do I need a key to use this?
The server itself needs none, but the service you point it at usually does. You must put that credential in config.json, because the environment variables listed in the README are never actually read by the code.
Can I use this to call an internal service my company runs?
Yes — as long as you have its Swagger or OpenAPI file and the web address the service lives at.
The README says I can name my own key header. Does that work?
No. The code hard-codes the header name to api_key no matter what you configure. Only the query-string option honours the name you choose.
Is my credential handled safely?
Not especially. It sits in plain text in config.json, the server listens on every network interface with no login, and credentials can also be passed in through the chat itself. Run it only on a machine you control.
Which apps does it work in?
Any assistant that can connect to a server over a local web address. It runs as its own web server rather than a simple command, so setup is more manual than most.
How hard is setup?
Developer-level. You clone the project, install it with Yarn, build it, and edit a configuration file by hand.
What does it do straight out of the box?
It loads a public pet-store demo service. You have to edit config.json before it does anything useful with your own systems.
Is the project still maintained?
Yes, it had code changes in July 2026, though the README still lists handling secrets properly as an unfinished item.