Swagger MCP Server
Allows AI assistants to interact with any REST API documented with OpenAPI/Swagger, enabling endpoint discovery, deep inspection, cURL generation, and TypeScript type generation.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Swagger MCP ServerLoad Petstore API spec and list endpoints"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Swagger MCP Server
A Model Context Protocol (MCP) server that brings OpenAPI/Swagger documentation directly into your AI assistant. Point it at any Swagger/OpenAPI JSON URL and instantly get endpoint discovery, deep inspection, cURL generation, and TypeScript type generation — all inside Cursor or Claude.
Table of Contents
Related MCP server: mcp-swagger
Overview
The Swagger MCP Server acts as a bridge between your AI assistant and any REST API documented with OpenAPI 3.x or Swagger 2.x. Once registered as an MCP server in Cursor or Claude Desktop, it exposes a set of tools and prompts that let your AI:
Fetch and cache an OpenAPI spec from a URL
Browse all available API endpoints grouped by tag
Inspect full endpoint contracts (parameters, request body, responses) with
$refresolutionGenerate ready-to-run
curlcommands with schema-derived sample bodiesGenerate copy-paste TypeScript interfaces and types from response/request schemas
The server runs over stdio transport (standard input/output), which is the native transport for MCP in Cursor and Claude Desktop.
Features
Feature | Description |
Spec fetching & caching | Downloads OpenAPI JSON and caches it locally under |
Endpoint discovery | Lists all endpoints grouped by OpenAPI tags |
Deep inspection | Full parameter, request body, and response details with recursive |
cURL generation | Executable |
TypeScript types | Generates |
Guided prompts | Step-by-step AI workflow prompts for setup, exploration, implementation, and testing |
Multi-project support | Register multiple API projects and switch between them instantly |
Persistent state | Remembers all registered projects and the active one across server restarts |
How It Works
AI Client (Cursor / Claude Desktop)
│
│ stdio (MCP protocol)
▼
swagger-mcp-server (src/server.ts)
│
├── Tools ──► utility + helpers
│ │
│ ▼
│ doc/*.json ← cached OpenAPI spec
│ doc/.project-config.json ← active project state
│
└── Prompts ──► guided AI instructionsFirst-use flow
Call
generate-swagger-jsonwith aprojectNameandswaggerUrlServer fetches the JSON spec, validates it, and saves it under
doc/A grouped summary (
-grouped.json) is also saved for fast browsingThe project is added to
doc/.project-config.jsonand set as active
Subsequent calls
All other tools read from the cached spec for the active project — no network calls needed
State is restored automatically from
doc/.project-config.jsonon server start
Multi-project flow
Register as many projects as you need — each call to
generate-swagger-jsonadds a new entryUse
list-projectsto see all registered projects and which is activeUse
switch-projectto change the active project — all tools immediately use the new project's spec
Prerequisites
Node.js v18 or later
npm v9 or later
An OpenAPI/Swagger spec accessible at a direct JSON URL (not the Swagger UI HTML page)
Installation
# 1. Clone the repository
git clone https://github.com/your-org/swagger-mcp.git
cd swagger-mcp
# 2. Install dependencies
npm install
# 3. (Optional) copy the env sample
cp .env.sample .envNo build step is required for local use — the server runs directly via tsx.
To verify the server starts correctly:
npm startYou should see the server start with no errors. Press Ctrl+C to stop it.
Setup in Cursor
Cursor supports MCP servers through its MCP configuration file. You can configure the Swagger MCP server at either the global level (available in all projects) or the project level.
Global configuration (recommended)
Open or create the Cursor MCP config file at:
~/.cursor/mcp.jsonAdd the following entry under mcpServers:
{
"mcpServers": {
"swagger-mcp": {
"command": "node",
"args": [
"/absolute/path/to/swagger/node_modules/tsx/dist/cli.mjs",
"/absolute/path/to/swagger/src/server.ts"
],
"cwd": "/absolute/path/to/swagger"
}
}
}Replace /absolute/path/to/swagger with the actual path to this repository. For example:
{
"mcpServers": {
"swagger-mcp": {
"command": "node",
"args": [
"/Users/yourname/projects/swagger/node_modules/tsx/dist/cli.mjs",
"/Users/yourname/projects/swagger/src/server.ts"
],
"cwd": "/Users/yourname/projects/swagger"
}
}
}Project-level configuration
Create a .cursor/mcp.json file in the root of your project with the same structure as above.
Enabling the server in Cursor
Open Cursor Settings (
Cmd+,)Navigate to Features → MCP
You should see
swagger-mcplisted — toggle it onRestart Cursor or reload the window (
Cmd+Shift+P→Developer: Reload Window)
Verifying it works
Open a Cursor chat and type:
Use the setup-project prompt to get startedOr invoke a tool directly:
Call the available-api-endpoints toolIf the server is running correctly, the AI will respond with results from your cached API spec.
Setup in Claude Desktop
Claude Desktop uses the same MCP configuration format.
Locate the config file
Platform | Path |
macOS |
|
Windows |
|
Add the server
Open (or create) the config file and add:
{
"mcpServers": {
"swagger-mcp": {
"command": "node",
"args": [
"/absolute/path/to/swagger/node_modules/tsx/dist/cli.mjs",
"/absolute/path/to/swagger/src/server.ts"
],
"cwd": "/absolute/path/to/swagger"
}
}
}Restart Claude Desktop
Fully quit and reopen Claude Desktop. The MCP server will start alongside it.
Verifying it works
In a Claude conversation, you can ask:
List all available API endpointsOr use a prompt:
Use the explore-api promptClaude will use the swagger-mcp tools to answer from your cached spec.
MCP Inspector (Debug)
The MCP Inspector is a browser-based tool for testing MCP servers interactively. It lets you call tools and prompts manually, inspect inputs/outputs, and debug issues.
npm run inspectorThis launches the Inspector against the running server. Open the URL shown in the terminal (usually http://localhost:5173) and you can:
Browse all registered tools and prompts
Fill in arguments and execute tool calls
See raw JSON responses
Available Tools
Tools are callable functions exposed to the AI. All tools read from the locally cached OpenAPI spec (except generate-swagger-json which fetches from the network).
generate-swagger-json
Must be called first. Fetches the OpenAPI spec from a URL and caches it locally.
Argument | Type | Required | Description |
| string | Yes | A short name for this API project (e.g. |
| string | Yes | Direct URL to the OpenAPI JSON spec (not the Swagger UI page) |
Returns: Saved file paths, API title, version, and total endpoint count.
Example:
Generate swagger JSON for projectName "myapi" and swaggerUrl "https://api.example.com/api-docs-json"list-projects
Lists all API projects that have been registered via generate-swagger-json.
Argument | Type | Required | Description |
(none) | — | — | — |
Returns: All projects with their name, JSON URL, saved spec path, registration date, and which is currently active.
switch-project
Switches the active API project. All subsequent tool calls will use the newly activated project's spec.
Argument | Type | Required | Description |
| string | Yes | The name of the project to activate (must already be registered) |
Returns: Confirmation with the new active project's details.
Example:
Switch to project "medex"available-api-endpoints
Lists all API endpoints grouped by OpenAPI tag.
Argument | Type | Required | Description |
(none) | — | — | — |
Returns: Endpoints grouped by tag with method and path, plus total count.
endpoint-detail
Returns the full contract for a specific endpoint: path/query/header parameters, request body schema (with $ref resolved), and all response schemas.
Argument | Type | Required | Description |
| string | Yes | API path, e.g. |
| string | No | HTTP method ( |
generate-curl
Generates a ready-to-run curl command for an endpoint. The sample request body is auto-generated from the schema (with placeholder values like "example@email.com", "uuid-here", etc.).
Argument | Type | Required | Description |
| string | Yes | API path |
| string | Yes | HTTP method |
| string | No | Override the base URL (defaults to the spec's server URL) |
| object | No | Values for path parameters |
| object | No | Values for query parameters |
| object | No | Additional headers |
| object | No | Override the auto-generated request body |
generate-typescript-types
Generates TypeScript interface or type definitions from an endpoint's schemas.
Argument | Type | Required | Description |
| string | Yes | API path |
| string | Yes | HTTP method |
| array | Yes | Which parts to generate: |
| string | Yes |
|
| array | No | Specific response codes to include (e.g. |
Available Prompts
Prompts are pre-built guided workflows that chain multiple tools together and provide context-aware instructions to the AI.
setup-project
Onboards a new API project. Guides you through calling generate-swagger-json and confirms the spec was loaded successfully.
Arguments: None
explore-api
Browse and summarize available API endpoints. Optionally filter by a specific tag.
Argument | Type | Required | Description |
| string | No | Filter endpoints to a specific OpenAPI tag |
implement-endpoint
Full implementation workflow for a single endpoint. Chains endpoint-detail → generate-curl → generate-typescript-types and presents everything needed to implement an API call.
Argument | Type | Required | Description |
| string | Yes | API path |
| string | Yes | HTTP method |
generate-types
Generates TypeScript types with configurable options.
Argument | Type | Required | Description |
| string | Yes | API path |
| string | Yes | HTTP method |
| array | No | Which parts to include (defaults to all) |
| string | No |
|
test-endpoint
Generates a curl command and a Jest/Vitest test scaffold for an endpoint.
Argument | Type | Required | Description |
| string | Yes | API path |
| string | Yes | HTTP method |
Typical Workflow
1. Initialize a project
Use the setup-project promptThe AI will ask for your project name and Swagger JSON URL, then load and cache the spec.
1b. Register additional projects (optional)
Generate swagger JSON for projectName "payments-api" and swaggerUrl "https://pay.example.com/api-docs-json"Each call to generate-swagger-json adds a new project without removing existing ones.
1c. Switch between projects
List all my registered projectsSwitch to project "payments-api"2. Explore the API
Use the explore-api promptOr filter by tag:
Use the explore-api prompt with tag "users"3. Deep-dive into an endpoint
Use the implement-endpoint prompt with path "/auth/login" and method "POST"This returns the full parameter/body/response contract, a sample curl command, and TypeScript types.
4. Generate types only
Use the generate-types prompt with path "/users/{id}" method "GET" style "interface"5. Scaffold a test
Use the test-endpoint prompt with path "/auth/register" method "POST"Project Structure
swagger/
├── src/
│ ├── server.ts # MCP server entry point (stdio transport)
│ ├── state/
│ │ └── project.state.ts # In-memory + persisted project config
│ ├── types/
│ │ ├── index.ts # Tool / Prompt characteristic types
│ │ ├── endpoint.types.ts # HTTP / endpoint domain types
│ │ └── openapi.types.ts # OpenAPI spec types + type guard
│ ├── tools/
│ │ ├── generate-swagger-json.tool.ts
│ │ ├── list-projects.tool.ts
│ │ ├── switch-project.tool.ts
│ │ ├── available-endpoints.tool.ts
│ │ ├── endpoint-detail.tool.ts
│ │ ├── generate-curl.tool.ts
│ │ └── generate-typescript-types.tool.ts
│ ├── prompts/
│ │ ├── setup-project.prompt.ts
│ │ ├── explore-api.prompt.ts
│ │ ├── implement-endpoint.prompt.ts
│ │ ├── generate-types.prompt.ts
│ │ └── test-endpoint.prompt.ts
│ ├── helpers/
│ │ ├── endpoint-detail.helper.ts # $ref resolution + endpoint parsing
│ │ ├── curl-builder.helper.ts # curl command generation
│ │ └── typescript-type-builder.helper.ts # JSON Schema → TypeScript
│ └── utility/
│ ├── add-tool-registry.utility.ts
│ ├── add-prompt-registry.utility.ts
│ └── swagger.utility.ts # Fetch, save, load, parse OpenAPI specs
├── doc/
│ ├── .project-config.json # Multi-project registry + active project pointer
│ └── *.json # Cached OpenAPI specs + grouped summaries (gitignored)
├── .env.sample # Environment variable template
├── package.json
└── tsconfig.jsonEnvironment Variables
Copy .env.sample to .env. The variables are optional placeholders for future use — none are required for the server to run.
Variable | Description |
| Reserved for future Cursor integration |
| Your API's development base URL |
| Your API's staging base URL |
| Your API's production base URL |
| Default API title label |
| Default API version label |
| Default API description |
Troubleshooting
The server doesn't appear in Cursor / Claude
Verify the absolute paths in your MCP config are correct
Confirm
node_modulesis installed (npm install)Check that Node.js is accessible at the
commandpath — runwhich nodeto confirmReload Cursor (
Cmd+Shift+P→Developer: Reload Window) or restart Claude Desktop
generate-swagger-json returns an error about HTML
The swaggerUrl must point to the raw JSON spec, not the Swagger UI page. In Swagger UI, look for a link like /api-docs-json, /openapi.json, or /swagger.json — use that URL, not the browser page URL.
Tools return "No project configured"
Run generate-swagger-json first to initialize a project. Once registered, use list-projects to confirm it appears, and switch-project to activate it if needed.
Tools are querying the wrong API
You may have multiple projects registered. Call list-projects to check which project is currently active, then call switch-project with the correct name.
State is lost after restart
The server auto-restores state from doc/.project-config.json on startup. If this file is missing or corrupted, re-run generate-swagger-json.
MCP Inspector won't connect
Make sure you are not already running npm start in another terminal — only one process can hold stdio. Stop any running instance before launching the Inspector.
TypeScript types are missing fields
Deeply nested $ref schemas are resolved up to 10 levels deep to prevent circular reference loops. If a schema is cut off, it means the nesting exceeds this limit.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/nksmkj7/swagger-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server