This MCP server enables Large Language Models (LLMs) to explore and interact with Swagger/OpenAPI specifications, providing tools for loading API specifications, browsing endpoints, and retrieving detailed information about API operations.
To set up the Swagger/OpenAPI MCP server:
npm install
npm run build
The server provides several tools that LLMs can use to interact with API specifications:
load_api
This tool loads an OpenAPI/Swagger specification into the server.
Parameters:
apiId
(string): Unique identifier for this APIsource
(string): URL or file path to the OpenAPI/Swagger specificationExample:
{
"name": "load_api",
"arguments": {
"apiId": "petstore",
"source": "https://petstore.swagger.io/v2/swagger.json"
}
}
get_endpoint_details
Retrieves detailed information about a specific API endpoint.
Parameters:
apiId
(string): ID of the loaded APImethod
(string): HTTP method (GET, POST, etc.)path
(string): API endpoint pathnatural
(boolean, optional): If true, returns a human-readable summaryExample:
{
"name": "get_endpoint_details",
"arguments": {
"apiId": "petstore",
"method": "GET",
"path": "/pet/{petId}",
"natural": true
}
}
list_apis
Lists all currently loaded API specifications.
Parameters: None
search_endpoints
Searches for endpoints matching a specific pattern.
Parameters:
apiId
(string): ID of the loaded APIpattern
(string): Search pattern for endpoint paths or descriptionsExample:
{
"name": "search_endpoints",
"arguments": {
"apiId": "petstore",
"pattern": "pet"
}
}
The server provides these resource endpoints:
swagger://{apiId}/load
Get overview information about a loaded API specification.
swagger://{apiId}/endpoints
Get a list of all available endpoints for an API.
swagger://{apiId}/endpoint/{method}/{path}
Get detailed information about a specific endpoint.
To use this server with Claude Desktop, add the following to your claude_desktop_config.json
:
{
"mcpServers": {
"swagger-explorer": {
"command": "node",
"args": ["/path/to/your/swagger-mcp-server/build/index.js"]
}
}
}
Replace /path/to/your/swagger-mcp-server
with the actual path to your project directory.
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "swagger-explorer" '{"command":"node","args":["/path/to/your/swagger-mcp-server/build/index.js"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"swagger-explorer": {
"command": "node",
"args": [
"/path/to/your/swagger-mcp-server/build/index.js"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"swagger-explorer": {
"command": "node",
"args": [
"/path/to/your/swagger-mcp-server/build/index.js"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect