Skip to content
Back to search

swagger-mcp

Swagger to MCP server

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/dcolley--swagger-mcp/badge.svg)](/listings/dcolley--swagger-mcp)

HTML

<a href="/listings/dcolley--swagger-mcp"><img src="/api/listings/dcolley--swagger-mcp/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

1. Clone the repository:

git clone https://github.com/dcolley/swagger-mcp.git
cd swagger-mcp

2. Install dependencies:

yarn install

3. Create a `.env` file based on the example:

cp .env.example .env

4. Configure your Swagger/OpenAPI specification: - Place your Swagger file in the project (e.g., `swagger.json`) - Or provide a URL to your Swagger specification

5. 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

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 202 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # Swagger MCP Server
  2. A server that ingests and serves Swagger/OpenAPI specifications through the Model Context Protocol (MCP).
  3. ## Features
  4. - Loads Swagger/OpenAPI specifications
  5. - Supports multiple authentication methods:
  6. - Basic Auth
  7. - Bearer Token
  8. - API Key (header or query)
  9. - OAuth2
  10. - Automatically generates MCP tools from API endpoints
  11. - Server-Sent Events (SSE) support for real-time communication
  12. - TypeScript support
  13. ## Security
  14. This is a personal server!! Do not expose it to the public internet.
  15. If the underlying API requires authentication, you should not expose the MCP server to the public internet.
  16. ## TODO
  17. - secrets - the MCP server should be able to use secrets from the user to authenticate requests to the API
  18. - Comprehensive test suite
  19. ## Prerequisites
  20. - Node.js (v18 or higher)
  21. - Yarn package manager
  22. - TypeScript
  23. ## Installation
  24. 1. Clone the repository:
  25. ```bash
  26. git clone https://github.com/dcolley/swagger-mcp.git
  27. cd swagger-mcp
  28. ```
  29. 2. Install dependencies:
  30. ```bash
  31. yarn install
  32. ```
  33. 3. Create a `.env` file based on the example:
  34. ```bash
  35. cp .env.example .env
  36. ```
  37. 4. Configure your Swagger/OpenAPI specification:
  38. - Place your Swagger file in the project (e.g., `swagger.json`)
  39. - Or provide a URL to your Swagger specification
  40. 5. Update the configuration in `config.json` with your server settings:
  41. ```json
  42. {
  43. "server": {
  44. "host": "localhost",
  45. "port": 3000
  46. },
  47. "swagger": {
  48. "url": "url-or-path/to/your/swagger.json",
  49. "apiBaseUrl": "https://api.example.com", // Fallback if not specified in Swagger
  50. "defaultAuth": { // Fallback if not specified in Swagger
  51. "type": "apiKey",
  52. "apiKey": "your-api-key",
  53. "apiKeyName": "api_key",
  54. "apiKeyIn": "header"
  55. }
  56. }
  57. }
  58. ```
  59. Note: The server prioritizes settings from the Swagger specification over the config file:
  60. - If the Swagger file contains a `servers` array, the first server URL will be used as the base URL
  61. - If the Swagger file defines security schemes, they will be used for authentication
  62. - The config file settings serve as fallbacks when not specified in the Swagger file
  63. ## Usage
  64. 1. Start the development server:
  65. ```bash
  66. yarn dev
  67. ```
  68. 2. Build for production:
  69. ```bash
  70. yarn build
  71. ```
  72. 3. Start the production server:
  73. ```bash
  74. yarn start
  75. ```
  76. ## API Endpoints
  77. - `GET /health` - Check server health status
  78. - `GET /sse` - Establish Server-Sent Events connection
  79. - `POST /messages` - Send messages to the MCP server
  80. ## Testing
  81. Run the test suite:
  82. ```bash
  83. # Run tests once
  84. yarn test
  85. # Run tests in watch mode
  86. yarn test:watch
  87. # Run tests with coverage report
  88. yarn test:coverage
  89. ```
  90. ## Authentication
  91. The server supports various authentication methods. Configure them in the `config.json` file as fallbacks when not specified in the Swagger file:
  92. ### Basic Auth
  93. ```json
  94. {
  95. "defaultAuth": {
  96. "type": "basic",
  97. "username": "your-username",
  98. "password": "your-password"
  99. }
  100. }
  101. ```
  102. ### Bearer Token
  103. ```json
  104. {
  105. "defaultAuth": {
  106. "type": "bearer",
  107. "token": "your-bearer-token"
  108. }
  109. }
  110. ```
  111. ### API Key
  112. ```json
  113. {
  114. "defaultAuth": {
  115. "type": "apiKey",
  116. "apiKey": "your-api-key",
  117. "apiKeyName": "X-API-Key",
  118. "apiKeyIn": "header"
  119. }
  120. }
  121. ```
  122. ### OAuth2
  123. ```json
  124. {
  125. "defaultAuth": {
  126. "type": "oauth2",
  127. "token": "your-oauth-token"
  128. }
  129. }
  130. ```
  131. ## Development
  132. 1. Start the development server:
  133. ```bash
  134. yarn dev
  135. ```
  136. <!-- 2. Make changes to the code
  137. 3. Run tests to ensure everything works:
  138. ```bash
  139. yarn test
  140. ```
  141. 4. Build the project:
  142. ```bash
  143. yarn build
  144. ``` -->
  145. <!-- ## Contributing
  146. 1. Fork the repository
  147. 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
  148. 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
  149. 4. Push to the branch (`git push origin feature/amazing-feature`)
  150. 5. Open a Pull Request -->
  151. ## License
  152. This project is licensed under the Apache 2.0 License.
  153. ## Environment Variables
  154. - `PORT`: Server port (default: 3000)
  155. - `API_USERNAME`: Username for API authentication (fallback)
  156. - `API_PASSWORD`: Password for API authentication (fallback)
  157. - `API_TOKEN`: API token for authentication (fallback)
  158. - `DEFAULT_API_BASE_URL`: Default base URL for API endpoints (fallback)
  159. - `DEFAULT_SWAGGER_URL`: Default Swagger specification URL

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.