Home / MCP / Swagger MCP Server

Swagger MCP Server

Parses Swagger/OpenAPI docs to generate TypeScript types and framework-specific API clients via the MCP protocol.

typescript
Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
    "mcpServers": {
        "swagger_mcp": {
            "command": "node",
            "args": [
                "start-server.js"
            ]
        }
    }
}

Swagger MCP Server is a specialized MCP server that parses Swagger/OpenAPI documents and generates TypeScript types and API clients. It optimizes handling of large docs, supports multiple OpenAPI versions, and exposes its capabilities via MCP for easy integration with large language models and automation workflows.

How to use

You interact with the Swagger MCP Server through an MCP client. Start by running the local server, then issue MCP commands to parse OpenAPI definitions, generate TypeScript types, or produce API clients. The server supports both standard and optimized parsing modes, and can tailor outputs for different client frameworks such as Axios, Fetch, or React Query.

How to install

Prerequisites: you need Node.js installed on your system. Ensure you have a supported runtime environment for running MCP servers.

Step 1: Install dependencies using your preferred package manager.

npm install
# or
pnpm install

Step 2: Start the server. The default communication transport is standard input/output (stdio). Run the startup command shown in the example.

node start-server.js

Step 3: Connect with an MCP client over stdio. Use the provided examples to issue commands for parsing Swagger/OpenAPI documents, generating TypeScript types, or creating API clients.

Optional: If you need to run a debugging session with the MCP Inspector, use a pipe-based connection to the server as shown in the debugging flow.

Configuration and runtime notes

The server is designed to work over stdio by default. You can customize behavior via commands and options issued through MCP messages. For large Swagger/OpenAPI documents, enable optimized parsing with caching and lazy loading to reduce memory usage and speed up responses.

Caching is stored in the project’s .api-cache directory. If you need to clear cached data, delete the directory or disable caching in your requests.

Tools and capabilities overview

The server exposes a set of MCP tools to cover common OpenAPI workflows. These include parsing documents, generating TypeScript definitions, and producing client code for multiple frameworks.

Examples of typical MCP commands (conceptual description)

Parse an OpenAPI document to extract operations and schemas. Generate corresponding TypeScript types and then create an API client in your framework of choice. All steps can be driven through a single MCP session or split into separate sessions for modular workflows.

Security and access notes

When running locally, follow best practices for securing access to your development environment. If you expose the server to networks, consider restricting access and using authenticated MCP clients where supported.

Available tools

parse-swagger

Parse Swagger/OpenAPI documents to return API operation information and basic schema details.

parse-swagger-optimized

Optimized parsing of Swagger/OpenAPI with caching, lazy loading, and advanced options for large documents.

parse-swagger-lite

Lightweight parsing optimized for very large docs to return essential information quickly.

generate-typescript-types

Generate TypeScript type definitions from an OpenAPI document.

generate-typescript-types-optimized

Optimized TypeScript type generation with caching and selective schema inclusion.

generate-api-client

Generate API client code for a chosen framework from the OpenAPI document.

generate-api-client-optimized

Optimized API client generation with caching, lazy loading, and framework-specific options.

file-writer

Write content to the file system as part of your MCP workflow.