A Model Context Protocol (MCP) server that fetches and interacts with Swagger/OpenAPI documentation with built-in authentication support.
- Fetch and parse Swagger/OpenAPI documentation from various sources:
- Direct JSON/YAML files (e.g.,
/swagger.json,/openapi.yaml) - Swagger UI endpoints (e.g.,
/api-docs) - Multi-API swagger-config.json setups
- Direct JSON/YAML files (e.g.,
- Multiple authentication methods:
- Basic Authentication
- Bearer Token
- API Key
- No authentication
- Cache fetched documentation for improved performance (configurable TTL)
- Comprehensive tools for:
- Fetching and validating Swagger docs
- Listing all API endpoints (with optional tag filtering)
- Searching endpoints by keywords
- Retrieving schema/model definitions
- Getting API information and metadata
- Working with multiple API sources
npm install
npm run buildThere are two ways to configure this MCP server:
- Option A: Using .env file (Local Development)
- Option B: Using MCP Settings (Recommended for Claude Desktop/Code)
-
Copy
.env.exampleto.env:cp .env.example .env
-
Edit
.envand configure your Swagger URL and authentication:# Required: Your Swagger/OpenAPI documentation URL SWAGGER_URL=https://api.example.com/swagger.json # Choose authentication method AUTH_TYPE=basic # or: none, bearer, apiKey # For Basic Auth AUTH_USERNAME=your_username AUTH_PASSWORD=your_password
-
Build and run:
npm install npm run build npm start
Configure directly in your MCP settings file:
- For Claude Code (CLI): Create
.mcp.jsonat your project root - For Claude Desktop: Edit settings via the app or
~/Library/Application Support/Claude/claude_desktop_config.json(macOS) - For other MCP clients: Check their documentation for the correct config file location
For Claude Code CLI, create a .mcp.json file in your project root:
-
Create
.mcp.jsonwith your configuration:{ "mcpServers": { "swagger-docs": { "command": "node", "args": ["/absolute/path/to/swagger-docs-mcp/dist/index.js"], "env": { "SWAGGER_URL": "https://api.example.com/swagger.json", "AUTH_TYPE": "basic", "AUTH_USERNAME": "your_username", "AUTH_PASSWORD": "your_password" } } } } -
Replace
/absolute/path/to/swagger-docs-mcpwith the actual path to your MCP server installation -
Important: Restart Claude Code for the configuration to take effect
For Claude Desktop, configure via the app settings or edit the config file directly:
{
"mcpServers": {
"swagger-docs": {
"command": "node",
"args": ["/absolute/path/to/swagger-docs-mcp/dist/index.js"],
"env": {
"SWAGGER_URL": "https://api.example.com/swagger.json",
"AUTH_TYPE": "basic",
"AUTH_USERNAME": "your_username",
"AUTH_PASSWORD": "your_password"
}
}
}
}{
"mcpServers": {
"swagger-docs": {
"command": "node",
"args": ["/absolute/path/to/swagger-docs-mcp/dist/index.js"],
"env": {
"SWAGGER_URL": "https://api.example.com/swagger.json",
"AUTH_TYPE": "bearer",
"AUTH_TOKEN": "your_bearer_token"
}
}
}
}{
"mcpServers": {
"swagger-docs": {
"command": "node",
"args": ["/absolute/path/to/swagger-docs-mcp/dist/index.js"],
"env": {
"SWAGGER_URL": "https://api.example.com/swagger.json",
"AUTH_TYPE": "apiKey",
"API_KEY": "your_api_key",
"API_KEY_HEADER": "X-API-Key"
}
}
}
}{
"mcpServers": {
"swagger-docs": {
"command": "node",
"args": ["/absolute/path/to/swagger-docs-mcp/dist/index.js"],
"env": {
"SWAGGER_URL": "https://api.example.com/swagger.json",
"AUTH_TYPE": "none"
}
}
}
}| Variable | Required | Description | Default |
|---|---|---|---|
SWAGGER_URL |
Yes | URL to your Swagger/OpenAPI documentation | - |
AUTH_TYPE |
No | Authentication method: none, basic, bearer, or apiKey |
none |
AUTH_USERNAME |
Conditional | Username for Basic Auth (required if AUTH_TYPE=basic) |
- |
AUTH_PASSWORD |
Conditional | Password for Basic Auth (required if AUTH_TYPE=basic) |
- |
AUTH_TOKEN |
Conditional | Bearer token (required if AUTH_TYPE=bearer) |
- |
API_KEY |
Conditional | API Key (required if AUTH_TYPE=apiKey) |
- |
API_KEY_HEADER |
No | Header name for API Key | X-API-Key |
CACHE_TTL |
No | Cache duration in milliseconds | 300000 (5 min) |
Important Notes:
- Replace
/absolute/path/to/swagger-docs-mcpwith the actual absolute path to your installation - The
SWAGGER_URLshould point to your Swagger/OpenAPI documentation - Sensitive credentials should be stored securely and never committed to version control
The MCP server provides the following tools:
fetch_swagger({
url: "https://api.example.com/swagger.json"
})get_endpoints({
tag: "users" // optional - filter by tag
})search_endpoints({
query: "user"
})get_schema({
schemaName: "User"
})get_api_info({})validate_swagger({
url: "https://api.example.com/swagger.json"
})# Run in development mode
npm run dev
# Build TypeScript
npm run build
# Start production server
npm start-
Configure the MCP server with your
SWAGGER_URLand authentication credentials in your MCP settings (.mcp.jsonfor Claude Code or Claude Desktop settings) -
Build the server if you haven't already:
npm install npm run build
-
Restart Claude Code/Desktop to load the MCP server
-
Start using the tools in Claude:
Claude: "Fetch the Swagger documentation from https://api.example.com/swagger.json" → Uses fetch_swagger({ url: "https://api.example.com/swagger.json" }) Claude: "Show me all the user-related endpoints" → Uses get_endpoints({ tag: "users" }) Claude: "Search for authentication endpoints" → Uses search_endpoints({ query: "auth" }) Claude: "Show me the User schema" → Uses get_schema({ schemaName: "User" }) Claude: "What's the API version and description?" → Uses get_api_info({}) -
Work with the documentation - Claude can now answer questions about your API, help generate code that uses the endpoints, explain request/response formats, and more
- Store sensitive credentials in environment variables
- Never commit
.envfiles to version control - Use appropriate authentication method for your API
- The cache TTL can be adjusted based on how frequently your API documentation changes
MIT