Swagger MCP Server
A server that enables interaction with any API that has a Swagger/OpenAPI specification through Model Context Protocol (MCP), automatically generating tools from API endpoints and supporting multiple authentication methods.
dcolley
README
Swagger MCP Server
A server that ingests and serves Swagger/OpenAPI specifications through the Model Context Protocol (MCP).
Features
- Loads Swagger/OpenAPI specifications
- Supports multiple authentication methods:
- Basic Auth
- Bearer Token
- API Key (header or query)
- OAuth2
- Automatically generates MCP tools from API endpoints
- Server-Sent Events (SSE) support for real-time communication
- TypeScript support
Security
This is a personal server!! Do not expose it to the public internet. If the underlying API requires authentication, you should not expose the MCP server to the public internet.
TODO
- secrets - the MCP server should be able to use secrets from the user to authenticate requests to the API
- Comprehensive test suite
Prerequisites
- Node.js (v18 or higher)
- Yarn package manager
- TypeScript
Installation
- Clone the repository:
git clone https://github.com/dcolley/swagger-mcp.git
cd swagger-mcp
- Install dependencies:
yarn install
- Create a
.env
file based on the example:
cp .env.example .env
-
Configure your Swagger/OpenAPI specification:
- Place your Swagger file in the project (e.g.,
swagger.json
) - Or provide a URL to your Swagger specification
- Place your Swagger file in the project (e.g.,
-
Update the configuration in
config.json
with your server settings:
{
"server": {
"host": "localhost",
"port": 3000
},
"swagger": {
"url": "url-or-path/to/your/swagger.json",
"apiBaseUrl": "https://api.example.com", // Fallback if not specified in Swagger
"defaultAuth": { // Fallback if not specified in Swagger
"type": "apiKey",
"apiKey": "your-api-key",
"apiKeyName": "api_key",
"apiKeyIn": "header"
}
}
}
Note: The server prioritizes settings from the Swagger specification over the config file:
- If the Swagger file contains a
servers
array, the first server URL will be used as the base URL - If the Swagger file defines security schemes, they will be used for authentication
- The config file settings serve as fallbacks when not specified in the Swagger file
Usage
- Start the development server:
yarn dev
- Build for production:
yarn build
- Start the production server:
yarn start
API Endpoints
GET /health
- Check server health statusGET /sse
- Establish Server-Sent Events connectionPOST /messages
- Send messages to the MCP server
Testing
Run the test suite:
# Run tests once
yarn test
# Run tests in watch mode
yarn test:watch
# Run tests with coverage report
yarn test:coverage
Authentication
The server supports various authentication methods. Configure them in the config.json
file as fallbacks when not specified in the Swagger file:
Basic Auth
{
"defaultAuth": {
"type": "basic",
"username": "your-username",
"password": "your-password"
}
}
Bearer Token
{
"defaultAuth": {
"type": "bearer",
"token": "your-bearer-token"
}
}
API Key
{
"defaultAuth": {
"type": "apiKey",
"apiKey": "your-api-key",
"apiKeyName": "X-API-Key",
"apiKeyIn": "header"
}
}
OAuth2
{
"defaultAuth": {
"type": "oauth2",
"token": "your-oauth-token"
}
}
Development
- Start the development server:
yarn dev
<!-- 2. Make changes to the code
- Run tests to ensure everything works:
yarn test
- Build the project:
yarn build
``` -->
<!-- ## Contributing
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request -->
## License
This project is licensed under the Apache 2.0 License.
## Environment Variables
- `PORT`: Server port (default: 3000)
- `API_USERNAME`: Username for API authentication (fallback)
- `API_PASSWORD`: Password for API authentication (fallback)
- `API_TOKEN`: API token for authentication (fallback)
- `DEFAULT_API_BASE_URL`: Default base URL for API endpoints (fallback)
- `DEFAULT_SWAGGER_URL`: Default Swagger specification URL
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
MCP Package Docs Server
Facilitates LLMs to efficiently access and fetch structured documentation for packages in Go, Python, and NPM, enhancing software development with multi-language support and performance optimization.
Claude Code MCP
An implementation of Claude Code as a Model Context Protocol server that enables using Claude's software engineering capabilities (code generation, editing, reviewing, and file operations) through the standardized MCP interface.
@kazuph/mcp-taskmanager
Model Context Protocol server for Task Management. This allows Claude Desktop (or any MCP client) to manage and execute tasks in a queue-based system.
Linear MCP Server
Enables interaction with Linear's API for managing issues, teams, and projects programmatically through the Model Context Protocol.
mermaid-mcp-server
A Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images.
Jira-Context-MCP
MCP server to provide Jira Tickets information to AI coding agents like Cursor

Linear MCP Server
A Model Context Protocol server that integrates with Linear's issue tracking system, allowing LLMs to create, update, search, and comment on Linear issues through natural language interactions.

Sequential Thinking MCP Server
This server facilitates structured problem-solving by breaking down complex issues into sequential steps, supporting revisions, and enabling multiple solution paths through full MCP integration.