Swagger MCP Server logo

Swagger MCP Server

by tuskermanshu

The Swagger MCP Server is a Model Context Protocol (MCP) based server that parses Swagger/OpenAPI documents and generates TypeScript types and API client code. It facilitates integration with large language models by providing these functionalities through the MCP protocol.

View on GitHub

Last updated: N/A

What is Swagger MCP Server?

The Swagger MCP Server is a server built on the Model Context Protocol (MCP) that parses Swagger/OpenAPI documents (v2 and v3) and generates TypeScript type definitions and API client code for various frameworks.

How to use Swagger MCP Server?

To use the server, install the dependencies using npm install or pnpm install, then start the server with node start-server.js. Communicate with the server using standard input/output and MCP tools, sending JSON payloads with specific methods and parameters to parse Swagger documents, generate TypeScript types, or generate API clients.

Key features of Swagger MCP Server

  • Parses Swagger/OpenAPI documents (v2 and v3)

  • Generates TypeScript type definitions

  • Generates API client code for different frameworks (Axios, Fetch, React Query, etc.)

  • Provides functionality through the MCP protocol for easy integration with large language models

  • Optimized for handling large documents with caching, lazy loading, and incremental parsing

Use cases of Swagger MCP Server

  • Generating TypeScript types from Swagger/OpenAPI definitions for use in frontend applications.

  • Creating API clients for different frameworks to simplify API interactions.

  • Integrating Swagger/OpenAPI parsing and code generation into automated workflows.

  • Using the server as a backend for large language models that need to understand and interact with APIs.

FAQ from Swagger MCP Server

How do I install the server?

Use npm install or pnpm install to install the dependencies.

How do I start the server?

Run node start-server.js to start the server.

How do I clear the cache?

Delete the .api-cache directory or set useCache: false in the configuration.

What client frameworks are supported?

Currently, Axios, Fetch, and React Query are supported for API client generation.

How do I handle large API documents?

Use the optimized tools with caching and lazy loading enabled, filter by tags or path prefixes, and only include schemas when necessary.