OpenAPI Contracts MCP Server
Click on "Install 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., "@OpenAPI Contracts MCP Servercompare the latest provider contract with the consumer contract"
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.
OpenAPI Contracts MCP Server
An MCP (Model Context Protocol) server for managing, browsing, and comparing OpenAPI contracts between providers and consumers. This server enables AI assistants like Claude to access and analyze OpenAPI specifications for contract testing and compatibility validation.
π Features
π MCP Resources: Browse and read OpenAPI contracts as MCP resources
π Contract Comparison: Diff provider and consumer contracts to identify breaking changes
β Compatibility Validation: Check if consumer changes are compatible with provider specs
πΎ Flexible Storage: Local filesystem and/or AWS S3 support
π Easy Integration: Works with VS Code, Claude Desktop, and any MCP client
π Auto-dereferencing: Automatically resolves $ref pointers in OpenAPI specs
π JSON Format: Supports OpenAPI 3.0+ specifications in JSON format
Related MCP server: swag
π Table of Contents
π€ What is MCP?
Model Context Protocol (MCP) is an open protocol that enables AI assistants to securely connect to external data sources and tools. In this context:
MCP Server (this project): Exposes OpenAPI contracts and comparison tools that AI assistants can use
MCP Client: An application that connects to MCP servers (e.g., VS Code with GitHub Copilot, Claude Desktop)
MCP Agent: The AI assistant (e.g., Claude, GitHub Copilot) that uses the resources and tools provided by the server
How It Works
βββββββββββββββββββ βββββββββββββββββββ ββββββββββββββββββββ
β AI Assistant β βββββββΊ β MCP Client β βββββββΊ β MCP Server β
β (Claude/Copilot)β β(VS Code/Desktop)β β (This Project) β
βββββββββββββββββββ βββββββββββββββββββ ββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββ
β OpenAPI Contractsβ
β Local / S3 β
ββββββββββββββββββββWhen you ask the AI assistant about OpenAPI contracts, it can:
Browse available contracts via MCP resources
Read contract specifications
Compare provider vs consumer contracts
Validate compatibility between versions
π― Why Use This MCP Server?
Benefits Over Direct Copy-Paste
You might wonder: "Why not just copy-paste OpenAPI contracts into AI chat?" Here are the key advantages:
1. Centralized Contract Management
Single Source of Truth: Store all provider and consumer contracts in one location
Version Control: Track contract changes over time with Git
Team Collaboration: Share contracts across your organization via S3
No Manual Updates: AI always accesses the latest version automatically
2. Structured Access & Discovery
Automatic Indexing: List all available contracts with
openapi://indexOrganized by Role: Separate provider and consumer contracts
Multi-Source Support: Access both local and S3-stored contracts seamlessly
Resource Templates: Standard URIs for predictable access patterns
3. AI Context Efficiency
Reduced Token Usage: AI can fetch only the contracts it needs, when it needs them
Persistent Context: Contracts are available across multiple chat sessions
Smart Caching: Frequently accessed specs are cached for performance
No Repetition: Never paste the same contract multiple times
4. Advanced Tooling
Contract Comparison: Built-in
diff_contractstool shows breaking changesCompatibility Validation:
validate_compatibilityensures provider-consumer alignmentAutomated Analysis: AI can compare multiple versions without manual intervention
Error Prevention: Catch breaking changes before deployment
5. Enterprise Features
S3 Integration: Store contracts in cloud storage for distributed teams
Access Control: Use IAM roles and policies for security
Scalability: Handle hundreds of contracts without cluttering your workspace
Audit Trail: Track which contracts are accessed and when
6. Developer Experience
IDE Integration: Access contracts directly in VS Code via MCP
No Context Switching: Stay in your development environment
Intelligent Suggestions: AI can proactively suggest relevant contracts
Workflow Automation: Integrate with CI/CD pipelines
Example Workflow
Without MCP Server β
1. Find contract file in your project
2. Open it in editor
3. Copy entire content
4. Paste into AI chat
5. Ask AI to analyze
6. Repeat for each contract
7. Manually track versionsWith MCP Server β
1. Ask: "Compare banking-api-v4 and v5"
2. AI automatically fetches both contracts
3. AI uses diff_contracts tool
4. Get detailed breaking changes analysis
5. All contracts always up-to-dateReal-World Use Cases
API Versioning: Quickly compare v1, v2, v3 to understand evolution
Consumer Validation: Ensure mobile app still works after API changes
Documentation Generation: AI generates docs from latest contracts
Breaking Change Detection: Automated checks before deployment
Contract Testing: Validate consumer expectations against provider specs
When to Use Direct Copy-Paste
Direct paste might be simpler for:
One-time analysis of a single contract
Contracts not stored in your workspace
Quick prototyping without setup
But for production workflows, team collaboration, and ongoing API development, this MCP server provides significant value! π
π Installation
Prerequisites
Node.js 18+ and npm
(Optional) AWS credentials for S3 support
Install Dependencies
npm installBuild the Server
npm run buildRun Tests
# Run all tests
npm test
## βοΈ Configuration
### Environment Variables
Create a `.env` file or set these environment variables:
```bash
# Local Storage (default)
OPENAPI_CONTRACT_DIR=./contracts # Path to local contracts directory
# AWS S3 (optional)
S3_ENABLED=false # Set to 'true' to enable S3
AWS_REGION=us-east-1 # Your AWS region
AWS_ACCESS_KEY_ID=YOUR_ACCESS_KEY # Your AWS access key ID
AWS_SECRET_ACCESS_KEY=YOUR_SECRET # Your AWS secret access key
S3_BUCKET=my-openapi-contracts # S3 bucket name
S3_PREFIX=openapi-contracts # Prefix path in bucket
# Debug
DEBUG_MCP=false # Set to 'true' for verbose loggingAWS S3 Configuration
To use AWS S3 for storing contracts:
Set S3_ENABLED to true
Provide AWS credentials using one of these methods:
Option 1: Environment Variables (Recommended for development)
export AWS_ACCESS_KEY_ID=your-access-key-id export AWS_SECRET_ACCESS_KEY=your-secret-access-key export AWS_REGION=us-east-1Option 2: AWS Credentials File (Recommended for production)
# Create ~/.aws/credentials [default] aws_access_key_id = your-access-key-id aws_secret_access_key = your-secret-access-keyOption 3: IAM Role (Recommended for EC2/ECS)
Attach an IAM role with S3 read permissions to your compute instance
No credentials needed in environment variables
Set S3 bucket details:
S3_ENABLED=true S3_BUCKET=my-openapi-contracts S3_PREFIX=openapi-contractsRequired IAM Permissions:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:GetObject", "s3:ListBucket" ], "Resource": [ "arn:aws:s3:::my-openapi-contracts", "arn:aws:s3:::my-openapi-contracts/*" ] } ] }
Security Note: Never commit AWS credentials to version control. Use .env files (excluded in .gitignore) or AWS credential files.
Directory Structure
Organize your OpenAPI contracts:
contracts/
βββ provider/ # Provider API specifications (JSON files)
β βββ banking-api-v1.json
β βββ banking-api-v2.json
β βββ banking-api-v3.json
βββ consumer/ # Consumer contract expectations (JSON files)
βββ mobile-app-consumer.json
βββ web-portal-consumer.json
βββ api-gateway-consumer.jsonImportant: All OpenAPI specification files must be in JSON format with .json extension. YAML files are not currently supported.
π§ VS Code Setup
To use this MCP server with GitHub Copilot in VS Code:
1. Install VS Code Extension
Install the GitHub Copilot extension from the VS Code marketplace.
2. Configure MCP Server
Create or edit .vscode/mcp.json in your home directory or project root:
Location:
macOS/Linux:
~/.vscode/mcp.jsonor project's.vscode/mcp.jsonWindows:
%USERPROFILE%\.vscode\mcp.json
Development Mode Configuration:
{
"servers": {
"openapi-contract-navigator": {
"command": "npm",
"args": [
"run",
"dev"
],
"env": {
"OPENAPI_CONTRACT_DIR": "/Users/apoorva/Lab/mcp/openapi-contracts-mcp-server/contracts",
"S3_ENABLED": "true",
"AWS_REGION": "eu-west-2",
"S3_BUCKET": "openapi-contracts-adx",
"S3_PREFIX": "openapi-contracts",
"DEBUG_MCP": "false"
},
"cwd": "/absolute/path/to/openapi-contracts-mcp-server"
}
}
}Production Mode Configuration:
{
"servers": {
"openapi-contract-navigator": {
"command": "node",
"args": ["build/index.js"],
"env": {
"OPENAPI_CONTRACT_DIR": "/absolute/path/to/contracts",
"S3_ENABLED": "false",
"AWS_REGION": "us-east-1",
"S3_BUCKET": "my-openapi-contracts",
"S3_PREFIX": "openapi-contracts",
"DEBUG_MCP": "false"
},
"cwd": "/absolute/path/to/openapi-contract-mcp-server"
}
}
}AWS Credentials:
For S3 access, provide credentials via:
Environment variables in mcp.json (Quick setup, less secure):
"env": { "AWS_ACCESS_KEY_ID": "your-access-key-id", "AWS_SECRET_ACCESS_KEY": "your-secret-access-key" }AWS credentials file (Recommended, more secure):
Create
~/.aws/credentials:[default] aws_access_key_id = your-access-key-id aws_secret_access_key = your-secret-access-keyAWS SDK will automatically use these credentials
IAM Role (Best for EC2/ECS):
No credentials needed in configuration
Important Notes:
Use absolute paths for
OPENAPI_CONTRACT_DIRandcwdDevelopment mode (
npm run dev) usestsxfor hot reloadProduction mode requires running
npm run buildfirstβ οΈ Never commit AWS credentials to version control
3. Restart VS Code
Restart VS Code to load the MCP server.
4. Verify Connection
Open the Command Palette (Cmd+Shift+P / Ctrl+Shift+P) and look for MCP-related commands, or ask Copilot:
"List all OpenAPI contracts"
"Compare banking-api-v1 and banking-api-v2"π₯οΈ Claude Desktop Setup
To use this MCP server with Claude Desktop:
1. Locate Claude Config
Find your Claude Desktop configuration file:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.jsonLinux:
~/.config/Claude/claude_desktop_config.json
2. Add Server Configuration
Edit claude_desktop_config.json:
{
"mcpServers": {
"openapi-contract-navigator": {
"command": "node",
"args": [
"/Users/apoorva/Lab/mcp/openapi-contracts-mcp-server/build/index.js"
],
"env": {
"OPENAPI_CONTRACT_DIR": "/Users/apoorva/Lab/mcp/openapi-contracts-mcp-server/contracts",
"S3_ENABLED": "true",
"AWS_REGION": "eu-west-2",
"S3_BUCKET": "openapi-contracts-adx",
"S3_PREFIX": "openapi-contracts",
"DEBUG_MCP": "false"
}
}
}
}AWS Credentials:
For S3 access, provide credentials via:
Environment variables in config (Quick setup):
"env": { "AWS_ACCESS_KEY_ID": "your-access-key-id", "AWS_SECRET_ACCESS_KEY": "your-secret-access-key" }AWS credentials file (Recommended, more secure):
Create
~/.aws/credentials:[default] aws_access_key_id = your-access-key-id aws_secret_access_key = your-secret-access-keyAWS SDK will automatically use these credentials
No need to add credentials to the config file
IAM Role (Best for EC2/ECS):
No credentials needed in configuration
Important Notes:
Use absolute paths for all file paths
Ensure the server is built:
npm run buildβ οΈ Never commit AWS credentials to version control
If using AWS credentials file, omit
AWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEYfrom the config
3. Restart Claude Desktop
Completely quit and restart Claude Desktop.
4. Verify Connection
In Claude, you should see a π icon indicating connected MCP servers. You can now ask:
"Show me all available OpenAPI provider contracts"
"What are the differences between banking-api-v1 and banking-api-v2?"
"Validate if mobile-app-consumer is compatible with banking-api-v3"π Usage
Run in Development Mode
npm run devRun in Production Mode
npm run build
npm startStandalone Testing
You can also run the server standalone for testing:
node build/index.jsThe server communicates via stdio (standard input/output) using the MCP protocol.
π MCP Resources
The server exposes OpenAPI contracts as resources that can be read by AI assistants:
Available Resources
Resource URI | Description |
| Index of all available contracts (local & S3) |
| Server configuration information |
| List of local provider contracts |
| List of local consumer contracts |
| Read a specific local provider contract |
| Read a specific local consumer contract |
| List of S3 provider contracts (if enabled) |
| List of S3 consumer contracts (if enabled) |
| Read a specific S3 provider contract |
| Read a specific S3 consumer contract |
Accessing Resources
When chatting with Claude or Copilot, reference resources naturally:
"Read the banking-api-v1 provider contract"
"Show me the mobile-app-consumer specification"
"List all available contracts"The AI will automatically use the appropriate resource URI.
π οΈ MCP Tools
The server provides tools for contract analysis:
1. diff_contracts
Compare two OpenAPI contracts and identify differences.
Parameters:
base: The baseline contract ({source: "local"|"s3", kind: "provider"|"consumer", name: "filename"})compare: The contract to compare ({source, kind, name})
Example Request (via AI):
"Compare banking-api-v1 (provider) with banking-api-v2 (provider)"Returns:
Breaking changes
Non-breaking changes
Unclassified changes
Summary statistics
2. validate_compatibility
Check if a consumer contract is compatible with a provider contract.
Parameters:
provider: Provider contract reference ({source, name})consumer: Consumer contract reference ({source, name})
Example Request (via AI):
"Is mobile-app-consumer compatible with banking-api-v3?"
"Validate compatibility between web-portal-consumer and banking-api-v2"Returns:
Compatibility status (compatible/incompatible)
List of breaking changes (if any)
Detailed diff information
π Project Structure
openapi-contracts-mcp-server/
βββ contracts/ # Local contract storage
β βββ provider/ # Provider OpenAPI specs
β β βββ banking-api-v1.json
β β βββ banking-api-v2.json
β β βββ banking-api-v3.json
β βββ consumer/ # Consumer OpenAPI specs
β βββ mobile-app-consumer.json
β βββ web-portal-consumer.json
βββ src/
β βββ index.ts # Main MCP server entry point
β βββ env.ts # Environment configuration
β βββ resources/
β β βββ contracts.resources.ts # MCP resource definitions
β βββ store/
β β βββ specStore.ts # Main storage interface
β β βββ localStore.ts # Local filesystem storage
β β βββ s3Store.ts # AWS S3 storage
β βββ tools/
β β βββ diff.tool.ts # Contract diff tool
β β βββ dereferenceOpenApi.ts # OpenAPI $ref resolver
β βββ utils/
β βββ logger.ts # Logging utilities
β βββ normalize.ts # Path normalization
β βββ temp.ts # Temporary file handling
βββ build/ # Compiled JavaScript output
βββ package.json # Node.js dependencies
βββ tsconfig.json # TypeScript configuration
βββ README.md # This fileπ‘ Examples
Example 1: List All Contracts
User: "List all OpenAPI contracts"
AI Response:
I found the following contracts:
Local Providers:
- banking-api-v1.json
- banking-api-v2.json
- banking-api-v3.json
Local Consumers:
- mobile-app-consumer.json
- web-portal-consumer.jsonExample 2: Compare Two Versions
User: "What changed between banking-api-v1 and banking-api-v2?"
AI Response:
Comparing banking-api-v1.json (base) with banking-api-v2.json:
Breaking Changes (2):
- Removed endpoint: DELETE /api/v1/accounts/{id}
- Changed response schema for GET /api/v1/users (removed field: phoneNumber)
Non-Breaking Changes (3):
- Added endpoint: POST /api/v2/transfers
- Added optional field 'email' to User schema
- Updated description for /api/v1/accounts endpointExample 3: Validate Compatibility
User: "Is mobile-app-consumer compatible with banking-api-v3?"
AI Response:
β
Compatible
The mobile-app-consumer contract is compatible with banking-api-v3.
No breaking changes detected. The provider API satisfies all consumer expectations.Example 4: Read Specific Contract
User: "Show me the banking-api-v1 contract"
AI Response:
{
"openapi": "3.0.0",
"info": {
"title": "Banking API",
"version": "1.0.0"
},
"paths": {
"/api/v1/accounts": {
"get": { ... }
}
}
}π Security Considerations
S3 Access: Ensure AWS credentials have appropriate read-only permissions
Local Files: The server only reads files from the configured directory
No Write Operations: This server does not modify contracts
Stdio Communication: MCP uses stdio, which is secure for local processes
π Troubleshooting
Server Not Connecting
Check paths: Ensure all paths in config are absolute
Verify build: Run
npm run buildto ensure the server is compiledCheck logs: Enable
DEBUG_MCP=truefor verbose loggingRestart client: Completely restart VS Code or Claude Desktop
S3 Access Issues
AWS Credentials: Ensure
~/.aws/credentialsis configuredBucket Permissions: Verify IAM permissions for S3 bucket access
Region: Check that
AWS_REGIONmatches your bucket's region
Contracts Not Found
Directory Path: Verify
OPENAPI_CONTRACT_DIRpoints to correct locationFile Structure: Ensure contracts are in
provider/andconsumer/subdirectoriesFile Format: Contracts must be valid JSON files with
.jsonextensionβ Supported:
banking-api-v1.jsonβ Not supported:
banking-api-v1.yaml,banking-api-v1.yml
Valid OpenAPI: Files must be valid OpenAPI 3.0+ specifications
π€ Contributing
Contributions are welcome! Please:
Fork the repository
Create a feature branch
Make your changes with tests
Submit a pull request
π Resources
Built with β€οΈ for contract-driven API development
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/apodi/openapi-contracts-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server