mcp-spec-aggregator
A Model Context Protocol (MCP) mechanism designed to ingest and expose numerous OpenAPI schema definitions. This facilitates advanced comprehension and interaction with diverse APIs directly within LLM-enhanced Integrated Development Environments (IDEs). It maintains a centralized registry of accessible API interfaces and fully dereferences complex schemas for maximum contextual richness.
Author

ReAPI-com
Quick Info
Actions
Tags
ReAPI's MCP OpenAPI Specification Aggregator
This server component, implementing the Model Context Protocol (MCP), is engineered to load, process, and serve a collection of OpenAPI specification documents. Its primary role is to act as an intermediary, connecting your structured API definitions with sophisticated, language-model-driven development tooling, such as Cursor and other AI-assisted code editors.
Core Capabilities
- Ingestion of multiple OpenAPI definitions from a specified local file system location.
- Exposure of all discovered API endpoints and data structures via the standardized MCP interface.
- Equipping Large Language Models (LLMs) with comprehensive, in-IDE knowledge of your proprietary APIs.
- Automated resolution and inclusion of all referenced components (full schema dereferencing).
- Systematic maintenance of an inventory, or catalog, of all integrated API services.
Supported By ReAPI
This open-source MCP service is backed by ReAPI, a cutting-edge platform dedicated to streamlining the entire lifecycle of API development, from initial design through rigorous testing.
🎨 API Content Management System (CMS)
- Intuitive, visual interface for API specification design (low-code).
- Automatic generation and publishing of current OpenAPI documentation.
- Real-time collaborative editing environment for teams.
- Integrated version control and lifecycle management for specifications.
🧪 Advanced API Testing Suite
- The most developer-centric, no-code solution for API validation.
- Simplified creation and orchestration of test scenarios.
- Robust assertion frameworks and data validation capabilities.
- Serverless execution environment in the cloud.
- Optimized for both Quality Assurance personnel and software engineers.
- Seamless integration hooks for Continuous Integration/Continuous Deployment (CI/CD) pipelines.
Explore the full potential of API development by trying ReAPI for complimentary access at reapi.com.
Configuration for Cursor Integration
To connect this OpenAPI aggregation service with the Cursor IDE, select one of the following configuration scopes:
Approach A: Local Project Configuration (Recommended)
Define the server settings within a .cursor/mcp.json file placed in your root project directory. This compartmentalization is preferred for managing distinct API contexts across separate codebases.
{ "mcpServers": { "@reapi/mcp-openapi": { "command": "npx", "args": ["-y", "@reapi/mcp-openapi@latest", "--dir", "./specs"], "env": {} } } }
Pro Tip: Utilizing a relative directory path (e.g.,
./specs) ensures the configuration remains self-contained and easily transferable among team members.Guidance: We advise targeting the
@latestrelease channel, as active development frequently introduces performance enhancements and new functionalities.Crucial Note: Project-level configuration is essential for respecting LLM context window limitations. Consolidating too many specification metadata objects into a single location risks exceeding the token budget, causing operational failures. Organizing specs by project helps maintain context size within acceptable bounds.
Approach B: Global Configuration
Establish or modify ~/.cursor/mcp.json in your user's home directory to make this service universally accessible across all projects:
{ "mcpServers": { "@reapi/mcp-openapi": { "command": "npx", "args": ["-y", "@reapi/mcp-openapi@latest", "--dir", "/path/to/your/specs"], "env": {} } } }
Activating the Server in Cursor Settings
Once the configuration file is saved:
- Launch the Cursor IDE.
- Navigate to Settings > Cursor Settings > MCP.
- Toggle the
@reapi/mcp-openapiserver to the 'enabled' state. - Click the synchronization icon adjacent to the server entry to enforce the new settings.
Note: By default, Cursor mandates user consent before executing any MCP tool. To bypass this prompt and enable silent execution, activate Yolo mode within the Cursor configuration panel.
The service is now operational. Should you incorporate new OpenAPI documentation files into the monitored directory, you can prompt a metadata reload via the Cursor chat interface using commands such as:
"Please refresh the API catalog" "Reload the OpenAPI specifications"
OpenAPI Document Requirements
- Place all OpenAPI 3.x compliant definitions within the designated directory:
- Support extends to both JSON and YAML serialization formats.
- Files must bear extensions:
.json,.yaml, or.yml. -
The internal scanner automatically detects and parses all eligible specification files.
-
Custom Specification Identification (
specId): - By default, the filename (excluding the extension) serves as the unique ID for the specification.
- To override this default, incorporate the vendor extension
x-spec-idwithin the OpenAPIinfoobject: yaml openapi: 3.0.0 info: title: My API version: 1.0.0 x-spec-id: my-custom-api-id # Override identifier
Criticality: Assigning a distinct
x-spec-idis vital when dealing with multiple specifications that exhibit: - Overlapping or identical endpoint paths. - Duplicated resource schema names. - Conflicts in defined operation identifiers.The specification ID ensures unambiguous resolution of these resources. For instance: yaml
user-service.yaml
info: x-spec-id: user-service paths: /users: get: ...
admin-service.yaml
info: x-spec-id: admin-service paths: /users: get: ...
This structure allows specific referencing, such as
user-service/usersversusadmin-service/users.
Operational Flow
- The server initiates a recursive scan of the configured repository path for API schema files.
- It systematically parses and resolves all internal references within the documents.
- It constructs and maintains a comprehensive catalog detailing all accessible endpoints and data contracts.
- This catalog information is subsequently exposed through the MCP communication layer.
- LLM integrations utilize this context to:
- Enrich the knowledge base for the language model.
- Power context-aware intelligent code suggestion.
- Aid developers in correct API integration patterns.
- Facilitate generation of API-aware code blocks.
Available MCP Functions (Tools)
refresh-api-catalog- Triggers an immediate reprocessing and update of the API metadata index.
-
Output: Confirmation message upon successful catalog refresh.
-
get-api-catalog - Retrieves the current, comprehensive catalog, encompassing metadata for all specifications, their respective operations, and schemas.
-
Output: The entirety of the indexed API catalog structure.
-
search-api-operations - Executes a search query across all registered API operations.
- Inputs:
query(String): The textual search term.specId(Optional String): Filter results to a specific API document ID.
-
Output: A list of matching operation objects.
-
search-api-schemas - Queries the indexed data schemas based on a specified term.
- Inputs:
query(String): The textual search term.specId(Optional String): Scope the search to a particular specification ID.
-
Output: A list of matching schema definitions.
-
load-api-operation-by-operationId - Fetches the full definition for an operation identified by its unique ID.
- Inputs:
specId(String): Identifier of the source API specification.operationId(String): The target operation's unique identifier.
-
Output: The complete operation definition object.
-
load-api-operation-by-path-and-method - Retrieves an operation using its URL path and HTTP verb.
- Inputs:
specId(String): Identifier of the source API specification.path(String): The resource path (e.g., "/resource/{id}").method(String): The HTTP verb (e.g., "POST").
-
Output: The complete operation definition object.
-
load-api-schema-by-schemaName - Retrieves a specific data schema definition by its name.
- Inputs:
specId(String): Identifier of the source API specification.schemaName(String): The name of the required schema component.
- Output: The complete schema definition object.
Development Trajectory (Roadmap)
- Semantically Informed Search
- Implementation of natural language processing for more accurate discovery of operations and schemas.
-
Refinement of search logic through deep semantic comprehension.
-
External Source Synchronization
-
Introduction of capabilities to pull and update specifications directly from remote repositories (e.g., Git, API Gateways).
-
Code Pattern Exposure
- Providing pre-vetted code templates through the MCP protocol.
-
Offering LLMs standardized reference patterns for reliable code scaffolding.
-
Community Involvement
- Encouraging feature proposals and defect reports.
- Welcoming external contributions to enhance the server's functionality.
Illustrative Prompts for Cursor Interaction
These examples show how to leverage the aggregation service within the Cursor IDE context:
- Catalog Exploration
"Enumerate all integrated APIs and detail their available endpoints" "Provide a list of all loaded specification manifests and their associated paths"
- Endpoint Specification Retrieval
"Display the full contract for the 'create pet' API call" "Identify all mandatory input arguments required for submitting a new pet object?" "Detail the expected data structure returned upon successful execution of the pet creation endpoint"
- Data Modeling and Mocking
"Generate representative mock payload data conforming to the Pet schema" "Construct a syntactically correct request body for the pet creation operation" "Present several valid examples of the Pet object structure based on the schema definition"
- Code Artifact Generation
"Generate an Axios-based client library dedicated to the pet API" "Draft a TypeScript interface definition corresponding to the Pet data model" "Write a standard React hook designed to interface with the pet creation endpoint"
- Integration Support
"Assist in implementing robust error handling routines for the pet API calls" "Produce a set of unit tests targeting the generated pet API client module" "Develop a cohesive service class that centrally manages all interactions with the pet resource"
- Reference Documentation
"Generate a cURL command demonstrating typical usage of the pet API" "Create comprehensive JSDoc annotations for the methods within the pet API client" "Draft a dedicated README section detailing the integration procedure for the pet API"
- Validation and Type Safety
"Generate a Zod schema validator for the Pet entity" "Create definitive TypeScript types for all anticipated response payloads from the pet endpoints" "Outline the steps to enforce strict input validation on request payloads for pet-related operations"
- Discovery and Filtering
"Locate every endpoint associated with the management of pet entities" "Isolate all API methods that support binary file transmission" "List all operations that return results presented in a paginated format"
These examples illustrate the utility of the MCP server for accelerating API-centric development tasks. Feel empowered to customize or combine these directives for highly specific requirements.
Collaboration
We welcome contributions! Please submit any proposed enhancements or fixes via a Pull Request to the repository.
