feat(sdk): add validateMcpb() for pre-install bundle validation#94
Merged
mgoldsborough merged 5 commits intoNimbleBrainInc:mainfrom May 7, 2026
Merged
Conversation
Validates .mcpb archives without side effects: extracts to temp dir, checks manifest.json against McpbManifestSchema, verifies entry point exists, cleans up. Returns typed result with manifest or error list. Closes NimbleBrainInc#93 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
11 tasks
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add valid and broken .mcpb fixtures derived from mcp-obsidian-cli and assert validateMcpb passes on the well-formed bundle and fails with a manifest error on the corrupted one. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Tightens the contract at the schema layer: entry_point is now constrained to a non-empty relative path within the bundle (no NUL bytes, no absolute POSIX/Windows paths, no UNC paths, no `..` segments). Previously every consumer that read a manifest trusted entry_point to be a safe relative path despite the schema saying `z.string()`. validateMcpb, loadLocalBundle, and prepareServer all do `join(dir, entry_point)`. A malicious manifest with `entry_point: "../../etc/passwd"` would pass validation and resolve to a system file at runtime. Fixing one consumer (validateMcpb) leaves the trust violation in place for the others; fixing the schema fixes them all. Adds SafeRelativePathSchema in packages/schemas. Pure-JS so the package stays browser-safe (consumed by apps/web). Comprehensive schema-level tests plus end-to-end coverage at the validateMcpb layer. Also updates the SDK's public-export smoke test and README to include validateMcpb (gap from PR NimbleBrainInc#94). Verified: 96 schemas tests pass, 234 sdk-typescript tests pass, every real manifest in the repo (registry seed, scanner fixtures with a server block) still parses, and the original entry_point repro now correctly returns valid: false.
Closes a Windows-traversal gap in SafeRelativePathSchema:
- `\foo` (drive-root-relative) — `path.join("C:\cache\bundle", "\\foo")`
resolves to `\foo` on the current drive
- `C:foo` (drive without separator) — drive-relative absolute
The simplest correct rule for a path inside a ZIP archive is "no
backslashes anywhere." MCPB bundles are zip archives whose central
directory uses forward slashes; backslash paths have no legitimate use.
Combining that with rejecting any drive-letter prefix subsumes all
Windows-style traversal forms.
This was referenced May 7, 2026
Contributor
|
Follow-ups from QA review (filed as separate issues — none block this PR):
|
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.
Summary
validateMcpb(path)function that validates.mcpbarchives without side effectsMcpbManifestSchema, verifies entry point exists, cleans up{ valid: true, manifest }or{ valid: false, errors: string[] }McpbValidationResult,McpbValidationSuccess,McpbValidationFailureTest plan
npx pnpm@9.15.4 testpassesCloses #93
🤖 Generated with Claude Code