Skip to content

Replace Hand-Rolled zodToJsonSchema with Library #42

Description

@foxintheloop

Problem

apps/mcp-server/src/index.ts (lines 43-141) contains a hand-rolled zodToJsonSchema converter (~100 lines). It handles basic types but misses unions, transforms, pipes, branded types, and other Zod features. This is a maintenance burden and potential source of bugs.

Solution

Replace with the zod-to-json-schema npm package:

import { zodToJsonSchema } from 'zod-to-json-schema';

// In tool list handler:
const jsonSchema = zodToJsonSchema(tool.inputSchema, { target: 'openApi3' });

Remove the ~100 lines of hand-rolled conversion code.

Files

  • apps/mcp-server/src/index.ts — replace converter
  • apps/mcp-server/package.json — add zod-to-json-schema dependency

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions