Skip to content

Make zod optional, allow generic schema-checking functions to be specified #1019

@christianscott

Description

@christianscott

Is your feature request related to a problem? Please describe.

Hello! Thank you for this library. We'd love to start using it but we'd prefer not to introduce a dependency on zod in our monorepo for a couple of reasons:

  1. Zod interacts poorly with TypeScript isolated declarations
  2. We have our own internal schema validation libraries that we'd like to be able to use instead. We write all of our code in a (very?) large monorepo so we try hard to add as few top-level dependencies as possible.
  3. We'd like to be able to share code between MCP tools and other parts of the codebase (which are using the internal library rather than zod).

Describe the solution you'd like

Allow users of this library to pass in their own schema validation functions rather than requiring {input,output}Schema parameters, e.g. the addition tool would become

function parseInput(o: any): { a: number, b: number } { ... }
function parseOutput(o: any): { output: number } { ... }
server.registerTool(
    'add',
    {
        title: 'Addition Tool',
        description: 'Add two numbers',
        parseInput,
        parseOutput
    },
    async ({ a, b }) => {
        const output = { result: a + b };
        return {
            content: [{ type: 'text', text: JSON.stringify(output) }],
            structuredContent: output
        };
    }
);

These parameters would be in addition to the {input,output}Schema, rather than replacing them.

Describe alternatives you've considered

N/A

Additional context

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions