specmatic
A Model Context Protocol (MCP) server that exposes Specmatic's contract testing capabilities to AI coding agents like Claude Code. This server enables comprehensive API contract validation and mock server management for development workflows.
claude mcp add --transport stdio specmatic-specmatic-mcp-server npx specmatic-mcp
How to use
Specmatic MCP Server exposes Specmatic’s API Contract Testing, API Resiliency Testing, and API Mocking capabilities to AI agents. You can interact with the server using natural language prompts to run contract tests against an API, start and manage mock servers from OpenAPI specs, perform resiliency tests to validate error handling, and check for breaking changes between your local spec and a reference branch. The server provides tools such as run_contract_test, run_resiliency_test, manage_mock_server, and (when using the npm package) backward_compatibility_check. For example, you can ask the agent to run contract tests against your API at a given URL with a provided spec, start a mock server on a specific port, or list and stop active mock servers.
To use these tools, ensure the MCP client is connected to the specmatic MCP server. You’ll typically reference the available tools by name (e.g., run_contract_test, run_resiliency_test, manage_mock_server) and provide inputs like the OpenAPI spec, the API base URL, and the spec format (yaml or json). The backward_compatibility_check tool is available when you install via the npm package and is not available in Docker due to git access requirements.
How to install
Prerequisites:
- MCP-compatible environment (e.g., Claude Code, VSCode MCP extension, Cursor, GitHub Copilot, etc.)
- Node.js and npm (for the npm package) or Docker (for the Docker deployment)
- Git (for backward compatibility checking with the npm package)
Option A — Install via npm package (recommended):
- Install Node.js and npm (follow your OS guidelines; ensure stable version is used).
- Install the npm package globally (optional) and/or set up your MCP client:
- npm install -g specmatic-mcp
- Start the MCP server via the npm-based command from your MCP client configuration, for example:
- npx specmatic-mcp
- In your MCP client, add a server entry similar to: { "servers": { "specmatic": { "command": "npx", "args": ["specmatic-mcp"], "env": {} } } }
Option B — Run via Docker:
- Ensure Docker is installed and running.
- Run the Docker image for Specmatic MCP: docker run --rm -i --network=host -v <path-to-your-project>/reports:/app/reports specmatic/specmatic-mcp:latest
- In your MCP client, add a server entry similar to the Docker configuration: { "servers": { "specmatic": { "command": "docker", "args": [ "run", "--rm", "-i", "--network=host", "-v", "<REPLACE_WITH_YOUR_PROJECT_PATH>/reports:/app/reports", "specmatic/specmatic-mcp:latest" ], "env": {} } } }
Prerequisites vary by method:
- npm package: Node.js, npm, Java Runtime Environment (JRE), and Git if using backward compatibility checks
- Docker: Docker installed and running
Additional notes
Tips and notes:
- The backward_compatibility_check tool is available only when using the npm package and requires Git access to compare specs against a repository history.
- For local testing (localhost APIs), the Docker host network mode (--network=host) is often required so mock servers and local APIs are accessible from the container.
- When using Docker, mount a reports directory to persist JUnit XML reports generated at ./reports inside the container.
- If you encounter path resolution issues with volume mappings, use absolute paths for the host side of the mount.
- The MCP setup supports multiple servers; you can add several entries under the mcp.json configuration to manage different specs or ports concurrently.
- Ensure your OpenAPI spec format (yaml/json) is correctly specified when invoking tools like run_contract_test and run_resiliency_test.
Related MCP Servers
anytype
An MCP server enabling AI assistants to interact with Anytype - your encrypted, local and collaborative wiki - to organize objects, lists, and more through natural language.
openmcp
Turn any openapi file into an mcp server, with just the tools you need.
mcp-typescribe
An MCP server implementation enabling LLMs to work with new APIs and frameworks
mockloop
Intelligent Model Context Protocol (MCP) server for AI-assisted API development. Generate mock servers from OpenAPI specs with advanced logging, performance analytics, and server discovery. Optimized for AI development workflows with comprehensive testing insights and automated analysis.
tally
MCP server for Tally.so - manage forms through AI with natural language commands and safety-first bulk operations
openapi-directory
An MCP Server for APIs.guru remarkable Wikipedia for Web APIs. Providing tools, prompts and resources to help eliminate LLM Coding Agent hallucinations.