zod-contract-mock-forge-mcp
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., "@zod-contract-mock-forge-mcp generate a valid mock for my UserSchema"
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.
zod-contract-mock-forge-mcp
An MCP server that turns Zod schemas into mocks, violations, and contract tests — so your AI agent can reason about API contracts without manually crafting payloads.
The Problem
Zod schemas are runtime code. An AI agent cannot execute them, introspect their constraints, or generate valid/invalid payloads without this layer. The agent also cannot detect when the schema and the OpenAPI docs silently diverged, or whether a schema change breaks existing test fixtures.
Related MCP server: SpecBridge MCP
Tools
Mock generation
Tool | Arguments | What it returns |
|
| Valid mock data matching the schema |
|
| N structurally valid but value-diverse mocks — for property-based testing |
Violation generation
Tool | Arguments | What it returns |
|
| Invalid payloads for each constraint: missing fields, type mismatches, min/max, email/uuid/url |
|
| Per-variant violations for every branch of a |
Schema analysis
Tool | Arguments | What it returns |
|
| JSON Schema representation — for LLM understanding of the contract |
|
| Extracts the Zod schema expression from a TypeScript/JS file |
|
| Diffs Zod vs OpenAPI — reports |
|
| Generates mocks from old schema, validates against new — detects breaking changes before tests run |
Contract testing
Tool | Arguments | What it returns |
|
| Contract test boilerplate for Playwright, Jest, Vitest, or MSW |
|
| Validates a JSON payload and explains each violation with a fix suggestion |
Setup
1. Install
npm install -g zod-contract-mock-forge-mcp2. Add to your editor
Cursor / VS Code (.cursor/mcp.json or .vscode/mcp.json)
{
"mcpServers": {
"zod-forge": {
"command": "zod-contract-mock-forge-mcp"
}
}
}Claude Code
claude mcp add zod-forge zod-contract-mock-forge-mcpExample usage
My schema file is src/schemas/user.ts, exported as UserSchema.
My OpenAPI spec is docs/openapi.yaml.
1. introspect_schema — what are the constraints on this schema?
2. generate_mock_variants — give me 10 diverse valid payloads (seed: 42) for CI reproducibility
3. generate_exhaustive_union_violations — test every branch of the role discriminated union
4. detect_schema_drift — has the Zod schema diverged from the OpenAPI docs?
5. evaluate_schema_evolution — does my schema change break any existing mock data?Example output
generate_mock_variants — 3 diverse valid mocks, seeded for CI:
{
"schema_id": "schema_a1b2c3d4",
"count": 3,
"all_valid": true,
"variants": [
{ "name": "Colleen Rowe", "age": 37 },
{ "name": "Pat Reynolds", "age": 24 },
{ "name": "Veronica Konopelski", "age": 45 }
]
}detect_schema_drift — field missing in OpenAPI, extra field in Zod:
{
"drift_count": 2,
"drifts": [
{
"field_path": "role",
"drift_type": "missing_in_openapi",
"zod_value": "string",
"openapi_value": null
},
{
"field_path": "email",
"drift_type": "missing_in_zod",
"zod_value": null,
"openapi_value": "string"
}
]
}evaluate_schema_evolution — new required field breaks existing mocks:
{
"breaking_change": true,
"sample_count": 20,
"invalid_mock_count": 20,
"failure_reasons": [
{
"field_path": "status",
"zod_code": "invalid_type",
"expected": "string",
"received": "undefined",
"affected_mock_count": 20
}
]
}Scripts
npm run build # compile TypeScript → dist/
npm run lint # ESLint
npm run format # Prettier --write
npm run format:check # Prettier check (used in CI)
npm test # VitestLicense
MIT
Available Tools
10 toolsdetect_schema_driftA
Compare a Zod schema in a TypeScript file against an OpenAPI spec — finds silent divergence. Use when Zod and OpenAPI docs are maintained separately and may have drifted apart. Reports missing fields, extra fields, type conflicts, and required/optional mismatches.
Inputs: zod_file_path (required), openapi_file_path (required), schema_export_name (required), openapi_schema_name.
evaluate_schema_evolutionA
Detect breaking changes when a Zod schema is tightened — before tests run. Generates mocks from the old schema, validates them against the new schema, and reports exactly which fields and constraints now reject previously valid data. Use when you changed a schema and want to know if existing test fixtures will break.
Inputs: schema_file_path (required), schema_export_name (required), old_schema_content.
generate_boundary_violationsA
Generate intentionally invalid payloads based on a Zod schema — for negative testing. Use to answer: what invalid inputs should I test against this API?
Inputs: schema_code (required).
generate_exhaustive_union_violationsA
Generate violation payloads for every branch of a z.union() or z.discriminatedUnion() schema. Use when generate_boundary_violations only covers one union variant and you need full branch coverage.
Inputs: schema_code (required).
generate_mock_variantsA
Generate N structurally valid but value-diverse mocks from a Zod schema — for property-based testing. Use when generate_valid_mock is too deterministic and you need varied inputs to surface edge cases. Supply seed for reproducible output in CI.
Inputs: schema_code (required), seed, count.
generate_valid_mockA
Generate valid mock data from a Zod schema string. Use to answer: what does a valid payload for this schema look like?
Inputs: schema_code (required), count.
introspect_schemaA
Convert a Zod schema string to JSON Schema for LLM understanding. Use to answer: what is the structure and constraints of this schema?
Inputs: schema_code (required).
read_schema_from_fileA
Read a Zod schema directly from a TypeScript or JavaScript file. Use to answer: what schema is defined in this file?
Inputs: file_path (required), export_name.
scaffold_api_contract_testA
Generate an API contract test or mock boilerplate for Playwright, Jest, Vitest, or MSW. Use to answer: how do I write a test that validates this API endpoint against this schema?
Inputs: endpoint (required), schema_code (required), method, base_url, +2 more.
suggest_contract_fixA
Validate a JSON payload against a Zod schema and suggest fixes for each violation. Use to answer: why does this payload fail validation, and how do I fix it?
Inputs: payload (required), schema_code (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 10 tools
Each tool targets a distinct operation on Zod schemas: reading, introspecting, generating various mocks, testing, fixing, and comparing. No two tools have overlapping purposes.
All tool names use a consistent verb_noun pattern in snake_case, making the set predictable and easy to navigate.
With 10 tools, the server is well-scoped for its purpose—covering schema analysis, mock generation, testing, and validation without being overwhelming or sparse.
The tool set covers the full workflow: reading schemas, understanding their structure, generating valid/invalid mocks, creating tests, suggesting fixes, and tracking changes. No obvious gaps.
Maintenance
Related MCP Connectors
AI-native mock API server with MCP. Create REST/SOAP mocks from Claude, Cursor, or Windsurf.
MCP server for building and testing AI agents with multi-model experimentation and insights.
MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.
Hosted MCP server for AI-driven data ops. Create apps, manage schemas, and CRUD structured data.
Related MCP Servers
- AlicenseAqualityBmaintenanceMCP server that helps AI agents explore OpenAPI specs, search endpoints, and generate TypeScript types.781 npm10MIT
- AlicenseAqualityDmaintenanceA clone-and-own MCP server that exposes OpenAPI/Huma contract intelligence to AI agents by turning API specifications into deterministic endpoint metadata, schemas, validation facts, and TypeScript declarations.6MIT
- AlicenseNot gradedqualityDmaintenanceTurns any OpenAPI specification into a fully working MCP server with a single command, enabling AI agents to call APIs without writing any glue code.MIT
- AlicenseAqualityDmaintenanceA TypeScript-based MCP server that integrates with Swagger/OpenAPI specifications to expose API endpoints as tools for Large Language Models (LLMs), enabling natural language interaction with any OpenAPI-compliant API.49MIT