Skip to content

Expose zod for SDK consumers to avoid version compatibility issuesΒ #802

@jmandel

Description

@jmandel

When building MCP tools, consumers need zod for input schemas but get type errors due to version mismatches with the SDK's internal zod dependency.

Problem:

import { z } from 'zod'; // Consumer's version (3.23.8)
server.registerTool('tool', {
  inputSchema: z.string() // Type error - incompatible with SDK's zod 3.25.76
});

Error: Type 'ZodString' is missing properties "~standard", "~validate"

Solutions

Option 1: Re-export from main index

// src/index.ts
export { z } from 'zod';

Usage: import { z } from '@modelcontextprotocol/sdk'

Option 2: Move zod to peerDependencies
Force consumers to install compatible zod version themselves.

Recommendation: Option 1 - simpler, no breaking changes, consumers get exact same zod version as SDK.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions