swagger-json-mcp
Provides tools to query and process Swagger/OpenAPI JSON documents, enabling efficient management of API documentation with features like multi-project handling, smart $ref resolution, and advanced search.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@swagger-json-mcp list available swagger projects"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Swagger JSON MCP Server
A powerful Model Context Protocol (MCP) server designed to efficiently query and process large Swagger/OpenAPI JSON documents. This server solves the common problem of LLMs being unable to process large API documentation files (typically 4000+ lines) by providing structured, intelligent query interfaces.
๐ Features
Core Capabilities
๐ Multi-project Management: Seamlessly handle multiple Swagger/OpenAPI projects
๐ Smart $ref Resolution: Automatically resolve JSON Schema references and handle circular dependencies
๐ Intelligent Search: Advanced search capabilities for APIs and schemas with fuzzy matching
โก Efficient Querying: Get specific API or schema information without loading entire documents
๐ Real-time Updates: Automatically detect and reload changes in Swagger files
MCP Tools
list_swaggers: List all available Swagger projectsget_swagger_overview: Get project overview and statisticsget_api_info: Retrieve complete API information with resolved schemasget_schema: Get fully resolved schema definitionssearch_apis: Search API endpoints with advanced filteringsearch_schemas: Search schema definitions with type filtering
Related MCP server: mcp-swagger-schema
๐ Project Structure
swagger-json-mcp/
โโโ src/
โ โโโ core/ # Core functionality modules
โ โ โโโ SwaggerParser.ts # Swagger JSON parser
โ โ โโโ SchemaResolver.ts # $ref reference resolver
โ โ โโโ SwaggerManager.ts # Multi-project manager
โ โโโ mcp/ # MCP server implementation
โ โ โโโ tools/ # MCP tool definitions
โ โ โโโ types.ts # TypeScript type definitions
โ โโโ utils/ # Utility functions
โ โโโ index.ts # Main entry point
โโโ docs/ # Swagger documentation directory
โ โโโ [project-name]/ # Individual project folders
โ โโโ swagger.json # Swagger/OpenAPI JSON files
โโโ package.json
โโโ tsconfig.json
โโโ README.md๐ ๏ธ Installation
Prerequisites
Node.js >= 18.0.0
pnpm >= 8.0.0
Setup
# Clone the repository
git clone <repository-url>
cd swagger-json-mcp
# Install dependencies
pnpm install
# Build the project
pnpm build
# Run tests
pnpm test๐ Quick Start
1. Prepare Your Swagger Files
Create project directories under docs/ and place your swagger.json files:
docs/
โโโ your-api-project/
โ โโโ swagger.json
โโโ another-project/
โโโ swagger.json2. Start the MCP Server
# Development mode
pnpm dev
# Production mode
pnpm start3. Configure MCP Client
Add to your MCP client configuration:
{
"mcpServers": {
"swagger-json": {
"command": "node",
"args": ["path/to/swagger-json-mcp/dist/index.js"],
"env": {}
}
}
}๐ Usage Examples
List Available Projects
// MCP Tool Call
{
"name": "list_swaggers",
"arguments": {}
}
// Response
{
"projects": [
{
"name": "your-api-project",
"title": "Your API",
"version": "1.0.0",
"apiCount": 42,
"schemaCount": 28
}
]
}Get API Information
// MCP Tool Call
{
"name": "get_api_info",
"arguments": {
"swaggerName": "your-api-project",
"path": "/api/users",
"method": "post"
}
}
// Response includes fully resolved schemas
{
"path": "/api/users",
"method": "post",
"summary": "Create user",
"requestBody": {
// Fully resolved schema without $ref
},
"responses": {
// Fully resolved response schemas
}
}Search APIs
// MCP Tool Call
{
"name": "search_apis",
"arguments": {
"query": "user login",
"swaggerName": "your-api-project",
"method": "post"
}
}
// Response
{
"results": [
{
"path": "/auth/login",
"method": "post",
"summary": "User login",
"score": 0.95
}
]
}Resolve Complex Schemas
// MCP Tool Call
{
"name": "get_schema",
"arguments": {
"swaggerName": "your-api-project",
"schemaName": "UserProfile",
"maxDepth": 10
}
}
// Response includes all nested schemas resolved
{
"schema": {
"type": "object",
"properties": {
// All $ref references resolved recursively
}
},
"dependencies": ["Address", "ContactInfo"],
"circularReferences": []
}๐งช Development
Available Scripts
pnpm build # Compile TypeScript
pnpm dev # Development with hot reload
pnpm test # Run test suite
pnpm lint # Run ESLint
pnpm typecheck # TypeScript type checking
pnpm prettier # Format code
pnpm clean # Clean build directoryCode Quality
TypeScript: Strict mode enabled with comprehensive type definitions
ESLint: Configured with TypeScript and Prettier rules
Vitest: Fast unit testing with full coverage
Prettier: Consistent code formatting
Testing
# Run all tests
pnpm test
# Run tests in watch mode
pnpm test --watch
# Run tests with coverage
pnpm test --coverage๐๏ธ Architecture
Core Components
SwaggerParser
Validates and parses Swagger/OpenAPI JSON files
Handles multiple OpenAPI versions (2.0, 3.0.x)
Provides structured access to API definitions
SchemaResolver
Recursively resolves
$refreferencesDetects and handles circular dependencies
Configurable resolution depth
Caches resolved schemas for performance
SwaggerManager
Manages multiple Swagger projects
Automatic file discovery and loading
Project lifecycle management
Thread-safe operations
MCP Integration
Full compliance with Model Context Protocol specification
Structured tool definitions with comprehensive validation
Error handling and logging
Async/await throughout for optimal performance
๐ง Configuration
Environment Variables
# Optional: Set log level
LOG_LEVEL=info
# Optional: Custom docs directory
DOCS_DIR=./custom-docs
# Optional: Maximum schema resolution depth
MAX_SCHEMA_DEPTH=10Customization
Modify
src/utils/logger.tsfor custom loggingExtend
src/core/SwaggerManager.tsfor additional project typesAdd new MCP tools in
src/mcp/tools/
๐ค Contributing
Fork the repository
Create a feature branch:
git checkout -b feature/new-featureMake your changes with tests
Run the test suite:
pnpm testEnsure code quality:
pnpm lint && pnpm typecheckCommit changes:
git commit -m 'Add new feature'Push to branch:
git push origin feature/new-featureSubmit a pull request
Development Guidelines
Follow existing code style and conventions
Add tests for new functionality
Update documentation for API changes
Ensure TypeScript compliance
Write clear, descriptive commit messages
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Troubleshooting
Common Issues
Project not loading
Verify
docs/directory structureCheck
swagger.jsonfile validityEnsure proper JSON formatting
$ref resolution failing
Validate JSON Schema reference paths
Check for circular references
Verify component definitions exist
MCP connection issues
Confirm server startup success
Validate MCP client configuration
Check Node.js version compatibility
Debug Mode
Enable detailed logging:
LOG_LEVEL=debug pnpm start๐ Acknowledgments
Model Context Protocol - Protocol specification
OpenAPI Specification - API documentation standard
TypeScript - Type-safe JavaScript
Vitest - Fast testing framework
Made with โค๏ธ for better API documentation accessibility
Available Tools
6 toolsget_api_infoA
็ฒๅ็นๅฎ API ็ๅฎๆด่ณ่จ๏ผ่ชๅ่งฃๆๆๆ็ธ้ schemas
Inputs: path (required), method (required), swaggerName (required).
get_schemaB
็ฒๅๆๅฎ schema ็ๅฎๆดๅฎ็พฉ๏ผ่ชๅ่งฃๆๆๆ $ref ๅผ็จ
Inputs: schemaName (required), swaggerName (required), maxDepth, includeCircular.
get_swagger_overviewB
็ฒๅ Swagger ๆชๆก็ๆด้ซๆฆ่ฆฝๅ็ตฑ่จ่ณ่จ
Inputs: swaggerName (required).
list_swaggersA
ๅๅบๆๆๅฏ็จ็ Swagger ๆชๆก
Inputs: no named parameters.
search_apisA
ๆ็ดข API endpoints๏ผๆฏๆดๆจก็ณๆ็ดขๅๅค็จฎ้ๆฟพๆขไปถ
Inputs: query (required), tag, limit, method, +1 more.
search_schemasA
ๆ็ดข schema ๅฎ็พฉ๏ผๆฏๆดๆจก็ณๆ็ดขๅ้กๅ้ๆฟพ
Inputs: query (required), type, limit, swaggerName.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogโฆ
TDQS
Scored across 6 tools
Each tool targets a distinct resource and action: listing swaggers, getting overviews, retrieving schemas, retrieving API info, and searching APIs or schemas. No overlap in purpose; agents can easily select the right tool.
All tool names follow a consistent verb_noun pattern using snake_case (list_*, get_*, search_*). The nouns are clear and descriptive, with only minor pluralization inconsistencies that do not affect predictability.
Six tools is well-scoped for a Swagger/OpenAPI inspection server. Each tool covers a distinct aspect of reading and exploring API definitions without being excessive or minimal.
The tool surface provides a complete read-only workflow: list available Swagger files, get overview statistics, retrieve detailed schema definitions with $ref resolution, get full API info, and search for APIs/schemas. No obvious gaps for a browsing/inspection use case.
Maintenance
Related MCP Connectors
MCP server for AI access to Swagger by SmartBear.
MCP server providing access to the Scorecard API to evaluate and optimize LLM systems.
Token-free MCP server for structured RevoGrid Core, Pro, and Enterprise knowledge retrieval.
Related MCP Servers
- AlicenseAqualityDmaintenanceAn MCP server that provides tools for exploring large OpenAPI schemas without loading entire schemas into LLM context. Perfect for discovering and analyzing endpoints, data models, and API structure efficiently.914MIT
- AlicenseBqualityDmaintenanceAn MCP server that allows users to query and retrieve request and response JSON schemas directly from Swagger/OpenAPI specifications. It supports automatic reference resolution and path parameter matching to help AI models interact with API interfaces.17 npmMIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that enables AI agents to explore, search, and query API definitions from OpenAPI/Swagger JSON files.19 npmMIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that automatically crawls, indexes, and serves API reference documentation for LLMs, enabling to search and retrieve endpoint details.MIT