upgrade everything-server to zod v4, latest MCP sdk#4136
Open
KKonstantinov wants to merge 2 commits into
Open
Conversation
Author
|
PS. Also bumped other packages to 1.29.0 SDK. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Upgrade the
everythingserver from Zod v3 to Zod v4, replacing deprecated APIs with their v4 equivalents.Description
Migrate
@modelcontextprotocol/server-everythingfrom Zod v3 (^3.25.0) to Zod v4 (^4.0.0). This is a pragmatic migration that replaces deprecated APIs with clean v4 replacements while keeping.describe()(still supported in v4) for schema metadata.Dependency changes:
zod:^3.25.0→^4.0.0@modelcontextprotocol/sdk:^1.26.0→^1.29.0(adds Zod v4 type compatibility)zod-to-json-schema: removed (never directly imported; Zod v4 has built-inz.toJSONSchema())Code changes (3 files):
tools/gzip-file-as-resource.ts:z.string().url()→z.url()(deprecated string method → top-level function)tools/trigger-elicitation-request-async.ts:z.object({...}).passthrough()→z.looseObject({...})(deprecated method → top-level function)tools/trigger-sampling-request-async.ts: same.passthrough()→z.looseObject()changeServer Details
Motivation and Context
Zod v4 is the current stable release. The deprecated v3 APIs (
.url()on strings,.passthrough()on objects) will be removed in the next major version. Upgrading the reference server keeps it current and demonstrates idiomatic Zod v4 usage for MCP server authors.How Has This Been Tested?
vitest run --coverage)tsc) passes with no type errorsBreaking Changes
None. The tool input schemas, behavior, and MCP protocol surface are unchanged. This is a dependency upgrade with internal API modernization only.
Types of changes
Checklist
Additional context
Zod v4 APIs that remain unchanged in this migration:
.describe()— still supported in v4 (.meta()is preferred but.describe()is not removed). Kept as-is to avoid churning 50+ usages across 15 files..default()— behavior changed in v4 (skips re-validation when input isundefined), but all defaults in this codebase are valid values within their schema constraints, so no impact..parse(),z.object(),z.string(),z.number(),z.enum(),z.union(),z.any(),.optional(),.min(),.max(),z.infer<>— all unchanged in v4.