Skip to content

Preserve unknown nested manifest keys in loose schemas (mcpb clean)#271

Open
aosmcleod wants to merge 1 commit into
modelcontextprotocol:mainfrom
aosmcleod:fix/loose-nested-passthrough
Open

Preserve unknown nested manifest keys in loose schemas (mcpb clean)#271
aosmcleod wants to merge 1 commit into
modelcontextprotocol:mainfrom
aosmcleod:fix/loose-nested-passthrough

Conversation

@aosmcleod

Copy link
Copy Markdown

Problem

The loose schemas exist to validate a manifest while preserving unrecognised data, but .passthrough() was applied only to the root object. Nested z.object() schemas strip unknown keys by default, and cleanMcpb rewrites the manifest with the loose parse result (result.data) — so mcpb clean silently deletes any custom field nested under author, 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 inherit unknownKeys, so McpbManifestMcpConfigSchema and McpbManifestPlatformOverrideSchema are covered via McpServerConfigSchema (verified). The localization/icon sub-schemas already had .passthrough().

Test

Adds a case to test/schemas.test.ts: unknown keys nested in author, server, and server.mcp_config survive 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-validation suites fail in a bare checkout without a build in my environment — they're unrelated to this change and pass in CI.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mcpb clean silently drops unknown nested manifest keys (loose .passthrough() is top-level only)

1 participant