feat!: drop Zod v3 support (#1460)
This commit is contained in:
parent
bc883afe3c
commit
be5670f4fa
2 changed files with 669 additions and 947 deletions
|
|
@ -1,11 +1,9 @@
|
|||
import type { ZodMatrixEntry } from '@modelcontextprotocol/test-helpers';
|
||||
import { zodTestMatrix } from '@modelcontextprotocol/test-helpers';
|
||||
import * as z from 'zod/v4';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { completable, getCompleter } from '../../src/server/completable.js';
|
||||
|
||||
describe.each(zodTestMatrix)('completable with $zodVersionLabel', (entry: ZodMatrixEntry) => {
|
||||
const { z } = entry;
|
||||
describe('completable with Zod v4', () => {
|
||||
it('preserves types and values of underlying schema', () => {
|
||||
const baseSchema = z.string();
|
||||
const schema = completable(baseSchema, () => []);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import { randomUUID } from 'node:crypto';
|
||||
|
||||
import type { CallToolResult, JSONRPCErrorResponse, JSONRPCMessage } from '@modelcontextprotocol/core';
|
||||
import type { ZodMatrixEntry } from '@modelcontextprotocol/test-helpers';
|
||||
import { zodTestMatrix } from '@modelcontextprotocol/test-helpers';
|
||||
import * as z from 'zod/v4';
|
||||
|
||||
import { McpServer } from '../../src/server/mcp.js';
|
||||
import type { EventId, EventStore, StreamId } from '../../src/server/streamableHttp.js';
|
||||
|
|
@ -118,9 +117,7 @@ function expectErrorResponse(data: unknown, expectedCode: number, expectedMessag
|
|||
});
|
||||
}
|
||||
|
||||
describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
|
||||
const { z } = entry;
|
||||
|
||||
describe('Zod v4', () => {
|
||||
describe('HTTPServerTransport', () => {
|
||||
let transport: WebStandardStreamableHTTPServerTransport;
|
||||
let mcpServer: McpServer;
|
||||
|
|
@ -133,7 +130,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
|
|||
'greet',
|
||||
{
|
||||
description: 'A simple greeting tool',
|
||||
inputSchema: { name: z.string().describe('Name to greet') }
|
||||
inputSchema: z.object({ name: z.string().describe('Name to greet') })
|
||||
},
|
||||
async ({ name }): Promise<CallToolResult> => {
|
||||
return { content: [{ type: 'text', text: `Hello, ${name}!` }] };
|
||||
|
|
@ -439,7 +436,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
|
|||
|
||||
mcpServer.registerTool(
|
||||
'echo',
|
||||
{ description: 'Echo tool', inputSchema: { message: z.string() } },
|
||||
{ description: 'Echo tool', inputSchema: z.object({ message: z.string() }) },
|
||||
async ({ message }): Promise<CallToolResult> => {
|
||||
return { content: [{ type: 'text', text: message }] };
|
||||
}
|
||||
|
|
@ -487,7 +484,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
|
|||
|
||||
mcpServer.registerTool(
|
||||
'greet',
|
||||
{ description: 'Greeting tool', inputSchema: { name: z.string() } },
|
||||
{ description: 'Greeting tool', inputSchema: z.object({ name: z.string() }) },
|
||||
async ({ name }): Promise<CallToolResult> => {
|
||||
return { content: [{ type: 'text', text: `Hello, ${name}!` }] };
|
||||
}
|
||||
|
|
@ -659,7 +656,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
|
|||
|
||||
mcpServer.registerTool(
|
||||
'greet',
|
||||
{ description: 'Greeting tool', inputSchema: { name: z.string() } },
|
||||
{ description: 'Greeting tool', inputSchema: z.object({ name: z.string() }) },
|
||||
async ({ name }): Promise<CallToolResult> => {
|
||||
return { content: [{ type: 'text', text: `Hello, ${name}!` }] };
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue