Skip to main content
Glama
OpenAPI Zod MCP Server

OpenAPI Zod MCP Server

by amir-gorji

OpenAPI Zod MCP Server

npm version License: MIT

Point an AI at an OpenAPI spec, pick an endpoint, and get a 100% correct Zod v4 schema written directly to disk. Zero hallucinations. Zero token costs.

how-it-works.webm

Recorded with a half-full context window on a large project, using a weaker model β€” the agent is already under pressure, but the schema generation remains perfect.


🀯 Why use this instead of just asking Claude/Cursor?

LLMs are notoriously bad at inferring strict Zod schemas. They hallucinate field names, mess up nesting, and introduce subtle type bugs that only surface at runtime. Furthermore, pasting a swagger file into chat eats up 5,000–20,000 input tokens, and generating the schema burns hundreds of output tokens.

openapi-zod-mcp bypasses the model entirely for codegen.

The LLM simply acts as an orchestrator. It triggers the MCP tool, and the tool deterministically parses the spec and writes the exact Zod schema directly to your disk. The schema never passes through the LLM token stream.

πŸ’Ž The Guarantees

  • 🚫 No Hallucinations: Deterministic parsing. Same spec + endpoint = identical output, every time.

  • πŸ’Έ Token-Free Generation: The LLM only sees "success: wrote PetSchema...". Save thousands of tokens per session.

  • ⚑ Blazing Fast: Generates schemas in ~50–200ms (vs. 5–30+ seconds of LLM typing) β€” up to 600x faster.

  • πŸ›‘οΈ No undefined hell: Optional fields safely use .nullable().optional().default(null).

  • πŸ”’ Fully Readonly: All objects and arrays carry .readonly() by default.

Related MCP server: openapi-mcp-proxy

Integrate directly with Claude Desktop, Cursor, or any MCP-compatible client. The AI can browse your API specs via list_endpoints and write schemas via generate_schema.

Cursor / VS Code (.vscode/mcp.json)

{
  "servers": {
    "openapi-zod-mcp": {
      "type": "stdio",
      "command": "npx",
      "args": ["openapi-zod-mcp"]
    }
  }
}

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      A MCP server that exposes OpenAPI schema information to LLMs like Claude. This server allows an LLM to explore and understand large OpenAPI schemas through a set of specialized tools, without needing to load the whole schema into the context
      50
      MIT