feat!: drop Zod v3 support (#1460)

This commit is contained in:
Matt 2026-02-03 19:48:08 +00:00 • committed by GitHub
commit be5670f4fa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 669 additions and 947 deletions

View file

@ -31,8 +31,7 @@ server.registerTool(
'get-protocol-info',
{
title: 'Protocol Info',
description: 'Returns protocol version configuration',
inputSchema: {}
description: 'Returns protocol version configuration'
},
async (): Promise<CallToolResult> => ({
content: [

View file

@ -33,8 +33,7 @@ const mcpServer = new McpServer(
mcpServer.registerTool(
'register_user',
{
description: 'Register a new user account by collecting their information',
inputSchema: {}
description: 'Register a new user account by collecting their information'
},
async () => {
try {
@ -132,8 +131,7 @@ mcpServer.registerTool(
mcpServer.registerTool(
'create_event',
{
description: 'Create a calendar event by collecting event details',
inputSchema: {}
description: 'Create a calendar event by collecting event details'
},
async () => {
try {
@ -237,8 +235,7 @@ mcpServer.registerTool(
mcpServer.registerTool(
'update_shipping_address',
{
description: 'Update shipping address with validation',
inputSchema: {}
description: 'Update shipping address with validation'
},
async () => {
try {

View file

@ -22,7 +22,7 @@ import { isInitializeRequest, McpServer, UrlElicitationRequiredError } from '@mo
import cors from 'cors';
import type { Request, Response } from 'express';
import express from 'express';
import { z } from 'zod';
import * as z from 'zod/v4';
import { InMemoryEventStore } from './inMemoryEventStore.js';
@ -42,9 +42,9 @@ const getServer = () => {
'payment-confirm',
{
description: 'A tool that confirms a payment directly with a user',
inputSchema: {
inputSchema: z.object({
cartId: z.string().describe('The ID of the cart to confirm')
}
})
},
async ({ cartId }, extra): Promise<CallToolResult> => {
/*
@ -75,9 +75,9 @@ const getServer = () => {
'third-party-auth',
{
description: 'A demo tool that requires third-party OAuth credentials',
inputSchema: {
inputSchema: z.object({
param1: z.string().describe('First parameter')
}
})
},
async (_, extra): Promise<CallToolResult> => {
/*

View file

@ -26,7 +26,7 @@ server.registerTool(
{
title: 'Greeting Tool',
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 {

View file

@ -26,9 +26,9 @@ const getServer = () => {
'greet',
{
description: 'A simple greeting tool',
inputSchema: {
inputSchema: z.object({
name: z.string().describe('Name to greet')
}
})
},
async ({ name }): Promise<CallToolResult> => {
return {
@ -47,9 +47,9 @@ const getServer = () => {
'multi-greet',
{
description: 'A tool that sends different greetings with delays between them',
inputSchema: {
inputSchema: z.object({
name: z.string().describe('Name to greet')
}
})
},
async ({ name }, extra): Promise<CallToolResult> => {
const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));

View file

@ -17,11 +17,11 @@ server.registerTool(
'get_weather',
{
description: 'Get weather information for a city',
inputSchema: {
inputSchema: z.object({
city: z.string().describe('City name'),
country: z.string().describe('Country code (e.g., US, UK)')
},
outputSchema: {
}),
outputSchema: z.object({
temperature: z.object({
celsius: z.number(),
fahrenheit: z.number()
@ -32,7 +32,7 @@ server.registerTool(
speed_kmh: z.number(),
direction: z.string()
})
}
})
},
async ({ city, country }) => {
// Parameters are available but not used in this example

View file

@ -20,9 +20,9 @@ const getServer = () => {
'greeting-template',
{
description: 'A simple greeting prompt template',
argsSchema: {
argsSchema: z.object({
name: z.string().describe('Name to include in greeting')
}
})
},
async ({ name }): Promise<GetPromptResult> => {
return {
@ -44,10 +44,10 @@ const getServer = () => {
'start-notification-stream',
{
description: 'Starts sending periodic notifications for testing resumability',
inputSchema: {
inputSchema: z.object({
interval: z.number().describe('Interval in milliseconds between notifications').default(100),
count: z.number().describe('Number of notifications to send (0 for 100)').default(10)
}
})
},
async ({ interval, count }, extra): Promise<CallToolResult> => {
const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));

View file

@ -58,9 +58,9 @@ const getServer = () => {
{
title: 'Greeting Tool', // Display name for UI
description: 'A simple greeting tool',
inputSchema: {
inputSchema: z.object({
name: z.string().describe('Name to greet')
}
})
},
async ({ name }): Promise<CallToolResult> => {
return {
@ -79,9 +79,9 @@ const getServer = () => {
'multi-greet',
{
description: 'A tool that sends different greetings with delays between them',
inputSchema: {
inputSchema: z.object({
name: z.string().describe('Name to greet')
},
}),
annotations: {
title: 'Multiple Greeting Tool',
readOnlyHint: true,
@ -135,9 +135,9 @@ const getServer = () => {
'collect-user-info',
{
description: 'A tool that collects user information through form elicitation',
inputSchema: {
inputSchema: z.object({
infoType: z.enum(['contact', 'preferences', 'feedback']).describe('Type of information to collect')
}
})
},
async ({ infoType }, extra): Promise<CallToolResult> => {
let message: string;
@ -298,9 +298,9 @@ const getServer = () => {
{
title: 'Greeting Template', // Display name for UI
description: 'A simple greeting prompt template',
argsSchema: {
argsSchema: z.object({
name: z.string().describe('Name to include in greeting')
}
})
},
async ({ name }): Promise<GetPromptResult> => {
return {
@ -322,10 +322,10 @@ const getServer = () => {
'start-notification-stream',
{
description: 'Starts sending periodic notifications for testing resumability',
inputSchema: {
inputSchema: z.object({
interval: z.number().describe('Interval in milliseconds between notifications').default(100),
count: z.number().describe('Number of notifications to send (0 for 100)').default(50)
}
})
},
async ({ interval, count }, extra): Promise<CallToolResult> => {
const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
@ -427,9 +427,9 @@ const getServer = () => {
{
title: 'List Files with ResourceLinks',
description: 'Returns a list of files as ResourceLinks without embedding their content',
inputSchema: {
inputSchema: z.object({
includeDescriptions: z.boolean().optional().describe('Whether to include descriptions in the resource links')
}
})
},
async ({ includeDescriptions = true }): Promise<CallToolResult> => {
const resourceLinks: ResourceLink[] = [
@ -479,9 +479,9 @@ const getServer = () => {
{
title: 'Delay',
description: 'A simple tool that delays for a specified duration, useful for testing task execution',
inputSchema: {
inputSchema: z.object({
duration: z.number().describe('Duration in milliseconds').default(5000)
}
})
},
{
async createTask({ duration }, { taskStore, taskRequestedTtl }) {

View file

@ -13,9 +13,9 @@ mcpServer.registerTool(
'summarize',
{
description: 'Summarize any text using an LLM',
inputSchema: {
inputSchema: z.object({
text: z.string().describe('Text to summarize')
}
})
},
async ({ text }) => {
// Call the LLM through MCP sampling