Preserve unknown nested manifest keys in loose schemas (mcpb clean)#271
Open
aosmcleod wants to merge 1 commit into
Open
Preserve unknown nested manifest keys in loose schemas (mcpb clean)#271aosmcleod wants to merge 1 commit into
aosmcleod wants to merge 1 commit into
Conversation
The loose schemas exist to validate while preserving unrecognised data, but .passthrough() was applied only to the root object. Nested z.object() schemas (author, server, mcp_config/server config, repository, tool, prompt, user_config option) strip unknown keys, so cleanMcpb — which rewrites the manifest with the loose parse result — silently deleted any custom field nested under those objects. Add .passthrough() to the nested object schemas across all loose versions (0.1-0.4). .extend()/.partial() derivatives inherit it, so mcp_config and platform_overrides are covered via McpServerConfigSchema. Adds a test asserting nested unknown keys survive a loose parse. Fixes modelcontextprotocol#264
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.
Problem
The loose schemas exist to validate a manifest while preserving unrecognised data, but
.passthrough()was applied only to the root object. Nestedz.object()schemas strip unknown keys by default, andcleanMcpbrewrites the manifest with the loose parse result (result.data) — somcpb cleansilently deletes any custom field nested underauthor,server,server.mcp_config,repository, tools, prompts, or user_config options.Fixes #264.
Fix
Add
.passthrough()to the nested object schemas across all loose versions (0.1–0.4):McpServerConfigSchema,McpbManifestAuthorSchema,McpbManifestRepositorySchema,McpbManifestServerSchema,McpbManifestToolSchema,McpbManifestPromptSchema,McpbUserConfigurationOptionSchema..extend()/.partial()derivatives inheritunknownKeys, soMcpbManifestMcpConfigSchemaandMcpbManifestPlatformOverrideSchemaare covered viaMcpServerConfigSchema(verified). Thelocalization/iconsub-schemas already had.passthrough().Test
Adds a case to
test/schemas.test.ts: unknown keys nested inauthor,server, andserver.mcp_configsurvive a loose 0.4 parse. Fails against the old schema, passes with the fix.yarn lint+yarn test(schemas/config suites) green.Note:
validate/cli/icon-validationsuites fail in a bare checkout without a build in my environment — they're unrelated to this change and pass in CI.