Skip to main content
Glama

Swagger to MCP

Swagger to MCP Server

Convert any Swagger/OpenAPI specification into a dynamic Model Context Protocol (MCP) server.

Features

  • πŸš€ Automatically generates MCP tools from Swagger/OpenAPI specs

  • πŸ“˜ Supports both local files (.yaml, .yml, .json) and remote URLs

  • βœ… Built-in JSON schema validation using AJV

  • πŸ”„ Dynamic endpoint mapping with path parameters

  • πŸͺΆ Generates MCP manifest (mcp.json) for easy integration

Installation

pnpm install

Usage

Start the MCP server

pnpm start

Or with a custom Swagger file:

node server.js --swagger=./path/to/your/spec.yaml

Generate manifest only (without starting server)

node server.js --swagger=./petstore.yaml --manifest-only

Use a remote Swagger URL

node server.js --swagger=https://petstore.swagger.io/v2/swagger.json

Configuration

Create a .env file to configure the server:

MCP_PORT=4000

How It Works

  1. Load Swagger/OpenAPI spec - From local file or URL

  2. Parse endpoints - Extract all paths and operations

  3. Generate MCP tools - Each endpoint becomes an MCP tool with:

    • Input schema validation

    • Output schema definition

    • HTTP request handler

  4. Start MCP server - Listen on configured port and handle tool requests

Example

The included petstore.yaml provides a simple example:

openapi: 3.0.1 info: title: Swagger Petstore version: 1.0.0 servers: - url: https://petstore.swagger.io/v2 paths: /pet/{petId}: get: summary: Find pet by ID operationId: getPetById parameters: - name: petId in: path required: true schema: type: integer responses: '200': description: successful operation

This generates an MCP tool that can fetch pet information by ID.

License

MIT

-
security - not tested
A
license - permissive license
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

Automatically converts Swagger/OpenAPI specifications into dynamic MCP tools, enabling interaction with any REST API through natural language by loading specs from local files or URLs.

  1. Features
    1. Installation
      1. Usage
        1. Start the MCP server
        2. Generate manifest only (without starting server)
        3. Use a remote Swagger URL
      2. Configuration
        1. How It Works
          1. Example
            1. License

              MCP directory API

              We provide all the information about MCP servers via our MCP API.

              curl -X GET 'https://glama.ai/api/mcp/v1/servers/suhailtajshaik/swagger-to-mcp'

              If you have feedback or need assistance with the MCP directory API, please join our Discord server