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 URLs
- Multiple authentication methods:
- Basic Authentication
- Bearer Token
- API Key
- No authentication
- Cache fetched documentation for improved performance
- Tools for:
- Fetching Swagger docs
- Listing all endpoints
- Searching endpoints
- Getting schema definitions
- Validating Swagger documents
- Getting API information
npm install
npm run buildCopy .env.example to .env and configure:
cp .env.example .envConfigure authentication based on your API requirements:
- No Auth: Set
AUTH_TYPE=none - Basic Auth: Set
AUTH_TYPE=basicwithAUTH_USERNAMEandAUTH_PASSWORD - Bearer Token: Set
AUTH_TYPE=bearerwithAUTH_TOKEN - API Key: Set
AUTH_TYPE=apiKeywithAPI_KEYand optionallyAPI_KEY_HEADER
Add to your MCP settings file (e.g., ~/.config/mcp/settings.json or ~/.claude.json):
{
"mcpServers": {
"swagger-docs": {
"command": "node",
"args": ["/path/to/swagger-docs-mcp/dist/index.js"],
"env": {
"AUTH_TYPE": "basic",
"AUTH_USERNAME": "username",
"AUTH_PASSWORD": "password"
}
}
}
}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 API credentials
- In Claude, use the tools to interact with your API documentation:
- First fetch the Swagger docs: fetch_swagger with your API URL
- List all endpoints: get_endpoints
- Search for specific endpoints: search_endpoints with a query
- Get schema details: get_schema with a schema name
- 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