From 2ed548101641deb02fe83fb2177749fccae8cd08 Mon Sep 17 00:00:00 2001 From: Alexander Sklar Date: Wed, 3 Dec 2025 11:27:59 -0800 Subject: [PATCH 01/18] Bump version and update dependencies in package.json update filesystem server version --- examples/file-system-node/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/file-system-node/package.json b/examples/file-system-node/package.json index e810564..78173f8 100644 --- a/examples/file-system-node/package.json +++ b/examples/file-system-node/package.json @@ -1,10 +1,10 @@ { "name": "ant.dir.ant.anthropic.filesystem", - "version": "0.1.3", + "version": "0.1.4", "type": "module", "private": true, "main": "server/index.js", "dependencies": { - "@modelcontextprotocol/server-filesystem": "2025.1.14" + "@modelcontextprotocol/server-filesystem": "2025.11.25" } } From 761e834ba873c2deabef106d9b66e20715b3a398 Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Wed, 3 Dec 2025 20:11:58 -0800 Subject: [PATCH 02/18] feat: add --manifest-version option to init command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allow developers to specify which manifest version to use when initializing a new manifest.json file. Usage: mcpb init --manifest-version 0.3 šŸ¤– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/cli/cli.ts | 36 +++++++++++++++++++++++------------- src/cli/init.ts | 27 ++++++++++++++++++++------- 2 files changed, 43 insertions(+), 20 deletions(-) diff --git a/src/cli/cli.ts b/src/cli/cli.ts index ac38b52..7499d89 100644 --- a/src/cli/cli.ts +++ b/src/cli/cli.ts @@ -51,19 +51,29 @@ program .command("init [directory]") .description("Create a new MCPB extension manifest") .option("-y, --yes", "Accept all defaults (non-interactive mode)") - .action((directory?: string, options?: { yes?: boolean }) => { - void (async () => { - try { - const success = await initExtension(directory, options?.yes); - process.exit(success ? 0 : 1); - } catch (error) { - console.error( - `ERROR: ${error instanceof Error ? error.message : "Unknown error"}`, - ); - process.exit(1); - } - })(); - }); + .option( + "--manifest-version ", + "Manifest version to use in the generated manifest", + ) + .action( + (directory?: string, options?: { yes?: boolean; manifestVersion?: string }) => { + void (async () => { + try { + const success = await initExtension( + directory, + options?.yes, + options?.manifestVersion, + ); + process.exit(success ? 0 : 1); + } catch (error) { + console.error( + `ERROR: ${error instanceof Error ? error.message : "Unknown error"}`, + ); + process.exit(1); + } + })(); + }, + ); // Validate command program diff --git a/src/cli/init.ts b/src/cli/init.ts index 9e62777..f2dfb53 100644 --- a/src/cli/init.ts +++ b/src/cli/init.ts @@ -1,12 +1,12 @@ import { confirm, input, select } from "@inquirer/prompts"; import { existsSync, readFileSync, writeFileSync } from "fs"; import { basename, join, resolve } from "path"; -import type { z } from "zod"; -// Import the schema for DEFAULT_MANIFEST_VERSION -// TODO: Allow dynamic manifest version choice -import type { McpbManifestSchema } from "../schemas/0.2.js"; -import { DEFAULT_MANIFEST_VERSION } from "../shared/constants.js"; +import { + DEFAULT_MANIFEST_VERSION, + MANIFEST_SCHEMAS, +} from "../shared/constants.js"; +import type { McpbManifestAny } from "../types.js"; interface PackageJson { name?: string; @@ -877,18 +877,19 @@ export function buildManifest( license: string; repository?: { type: string; url: string }; }, + manifestVersion: keyof typeof MANIFEST_SCHEMAS = DEFAULT_MANIFEST_VERSION, // localization?: { // resources: string; // default_locale: string; // }, -): z.infer { +): McpbManifestAny { const { name, displayName, version, description, authorName } = basicInfo; const { authorEmail, authorUrl } = authorInfo; const { serverType, entryPoint, mcp_config } = serverConfig; const { keywords, license, repository } = optionalFields; return { - manifest_version: DEFAULT_MANIFEST_VERSION, + manifest_version: manifestVersion, name, ...(displayName && displayName !== name ? { display_name: displayName } @@ -945,10 +946,21 @@ export function printNextSteps() { export async function initExtension( targetPath: string = process.cwd(), nonInteractive = false, + manifestVersion?: string, ): Promise { const resolvedPath = resolve(targetPath); const manifestPath = join(resolvedPath, "manifest.json"); + // Validate manifest version if provided + if (manifestVersion && !(manifestVersion in MANIFEST_SCHEMAS)) { + console.error( + `ERROR: Invalid manifest version "${manifestVersion}". Supported versions: ${Object.keys(MANIFEST_SCHEMAS).join(", ")}`, + ); + return false; + } + const effectiveManifestVersion = (manifestVersion || + DEFAULT_MANIFEST_VERSION) as keyof typeof MANIFEST_SCHEMAS; + if (existsSync(manifestPath)) { if (nonInteractive) { console.log( @@ -1029,6 +1041,7 @@ export async function initExtension( compatibility, userConfig, optionalFields, + effectiveManifestVersion, ); // Write manifest From 1dbbffc9727637a9bb4b7a796bdd45781ef9c22c Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Wed, 3 Dec 2025 20:33:10 -0800 Subject: [PATCH 03/18] fix: make mcp_config required for all server types in v0.4 schema MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit šŸ¤– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- package.json | 2 +- schemas/mcpb-manifest-v0.4.schema.json | 3 ++- src/schemas/0.4.ts | 3 +-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 99389da..09a33ee 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@anthropic-ai/mcpb", "description": "Tools for building MCP Bundles", - "version": "2.1.1", + "version": "2.1.2", "type": "module", "main": "dist/index.js", "module": "dist/index.js", diff --git a/schemas/mcpb-manifest-v0.4.schema.json b/schemas/mcpb-manifest-v0.4.schema.json index 69496ba..5917415 100644 --- a/schemas/mcpb-manifest-v0.4.schema.json +++ b/schemas/mcpb-manifest-v0.4.schema.json @@ -188,7 +188,8 @@ }, "required": [ "type", - "entry_point" + "entry_point", + "mcp_config" ], "additionalProperties": false }, diff --git a/src/schemas/0.4.ts b/src/schemas/0.4.ts index e706e26..e044b91 100644 --- a/src/schemas/0.4.ts +++ b/src/schemas/0.4.ts @@ -37,8 +37,7 @@ export const McpbManifestMcpConfigSchema = McpServerConfigSchema.extend({ export const McpbManifestServerSchema = z.strictObject({ type: z.enum(["python", "node", "binary", "uv"]), entry_point: z.string(), - // mcp_config is optional for UV type (UV handles execution) - mcp_config: McpbManifestMcpConfigSchema.optional(), + mcp_config: McpbManifestMcpConfigSchema, }); export const McpbManifestCompatibilitySchema = z.strictObject({ From 163fa29a1c4c19fa308532d788006deeb021bdfb Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Wed, 3 Dec 2025 21:03:04 -0800 Subject: [PATCH 04/18] style: fix Prettier formatting in cli.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Break function parameters onto separate lines with trailing comma. šŸ¤– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/cli/cli.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cli/cli.ts b/src/cli/cli.ts index 7499d89..817b659 100644 --- a/src/cli/cli.ts +++ b/src/cli/cli.ts @@ -56,7 +56,10 @@ program "Manifest version to use in the generated manifest", ) .action( - (directory?: string, options?: { yes?: boolean; manifestVersion?: string }) => { + ( + directory?: string, + options?: { yes?: boolean; manifestVersion?: string }, + ) => { void (async () => { try { const success = await initExtension( From 24aa4efc88f8726bb56f6641cc21f693045f0847 Mon Sep 17 00:00:00 2001 From: Adam Jones Date: Mon, 12 Jan 2026 22:50:15 +0000 Subject: [PATCH 05/18] chore: update licensing to Apache 2.0 for new contributions --- LICENSE | 217 +++++++++++++++++++++++++++++++++++++++++++++++++++++- README.md | 2 +- 2 files changed, 214 insertions(+), 5 deletions(-) diff --git a/LICENSE b/LICENSE index 8f30a63..4a93985 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,216 @@ -Copyright 2025 Anthropic, PBC. +The MCP project is undergoing a licensing transition from the MIT License to the Apache License, Version 2.0 ("Apache-2.0"). All new code and specification contributions to the project are licensed under Apache-2.0. Documentation contributions (excluding specifications) are licensed under CC-BY-4.0. -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +Contributions for which relicensing consent has been obtained are licensed under Apache-2.0. Contributions made by authors who originally licensed their work under the MIT License and who have not yet granted explicit permission to relicense remain licensed under the MIT License. -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +No rights beyond those granted by the applicable original license are conveyed for such contributions. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +--- + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to the Licensor for inclusion in the Work by the copyright + owner or by an individual or Legal Entity authorized to submit on behalf + of the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + +--- + +MIT License + +Copyright (c) 2024-2025 Model Context Protocol a Series of LF Projects, LLC. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +--- + +Creative Commons Attribution 4.0 International (CC-BY-4.0) + +Documentation in this project (excluding specifications) is licensed under +CC-BY-4.0. See https://creativecommons.org/licenses/by/4.0/legalcode for +the full license text. diff --git a/README.md b/README.md index f47446c..34aaaf5 100644 --- a/README.md +++ b/README.md @@ -169,4 +169,4 @@ yarn test # License -This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. +This project is licensed under the Apache License 2.0 for new contributions, with existing code under MIT - see the [LICENSE](LICENSE) file for details. From 19afbcdc18ba0158cad3c70460beda2ad2786777 Mon Sep 17 00:00:00 2001 From: vcolin7 Date: Fri, 6 Feb 2026 16:13:29 -0800 Subject: [PATCH 06/18] Update MCPB signature format description Clarify the MCPB signature format in documentation. --- CLI.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CLI.md b/CLI.md index 02787f8..247f211 100644 --- a/CLI.md +++ b/CLI.md @@ -292,7 +292,8 @@ MCPB uses PKCS#7 (Cryptographic Message Syntax) for digital signatures: ``` [Original MCPB ZIP content] MCPB_SIG_V1 -[Base64-encoded PKCS#7 signature] +[4-byte little-endian length prefix] +[DER-encoded PKCS#7 signature] MCPB_SIG_END ``` From bb676eb17dbfe7672badd77405c9f4c8de1b80b2 Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Thu, 12 Mar 2026 08:59:13 -0500 Subject: [PATCH 07/18] fix: update ZIP EOCD comment_length when signing MCPB files (#194) The signMcpbFile function appended a signature block to the ZIP file but did not update the EOCD comment_length field. Strict ZIP parsers (like Claude Desktop's) rejected these files because the declared comment length didn't account for the appended signature data. Now scans backwards for the EOCD magic bytes, reads the current comment_length, and adds the signature block length before concatenating. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/node/sign.ts | 28 +++++++++++++++++++++++++- test/sign.e2e.test.ts | 46 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) diff --git a/src/node/sign.ts b/src/node/sign.ts index e0ed5ce..bd4c8c4 100644 --- a/src/node/sign.ts +++ b/src/node/sign.ts @@ -89,8 +89,20 @@ export function signMcpbFile( // Create signature block with PKCS#7 data const signatureBlock = createSignatureBlock(pkcs7Signature); + // Update ZIP EOCD comment_length to include signature block + // This ensures strict ZIP parsers accept the signed file + const updatedContent = Buffer.from(mcpbContent); + const eocdOffset = findEocdOffset(updatedContent); + if (eocdOffset !== -1) { + const currentCommentLength = updatedContent.readUInt16LE(eocdOffset + 20); + updatedContent.writeUInt16LE( + currentCommentLength + signatureBlock.length, + eocdOffset + 20, + ); + } + // Append signature block to MCPB file - const signedContent = Buffer.concat([mcpbContent, signatureBlock]); + const signedContent = Buffer.concat([updatedContent, signatureBlock]); writeFileSync(mcpbPath, signedContent); } @@ -218,6 +230,20 @@ export async function verifyMcpbFile( } } +/** + * Finds the offset of the ZIP End of Central Directory record + * by scanning backwards for the EOCD magic bytes (0x06054b50) + */ +function findEocdOffset(buffer: Buffer): number { + // EOCD is at least 22 bytes, scan backwards from the end + for (let i = buffer.length - 22; i >= 0; i--) { + if (buffer.readUInt32LE(i) === 0x06054b50) { + return i; + } + } + return -1; +} + /** * Creates a signature block buffer with PKCS#7 signature */ diff --git a/test/sign.e2e.test.ts b/test/sign.e2e.test.ts index cbf1c4f..9af52a0 100755 --- a/test/sign.e2e.test.ts +++ b/test/sign.e2e.test.ts @@ -468,4 +468,50 @@ describe("MCPB Signing E2E Tests", () => { it("should remove signatures", async () => { await testSignatureRemoval(); }); + + it("should update EOCD comment_length after signing", async () => { + const testFile = path.join(TEST_DIR, "test-eocd.mcpb"); + fs.copyFileSync(TEST_MCPB, testFile); + + // Read original EOCD comment_length + const originalContent = fs.readFileSync(testFile); + let eocdOffset = -1; + for (let i = originalContent.length - 22; i >= 0; i--) { + if (originalContent.readUInt32LE(i) === 0x06054b50) { + eocdOffset = i; + break; + } + } + expect(eocdOffset).toBeGreaterThanOrEqual(0); + const originalCommentLength = originalContent.readUInt16LE(eocdOffset + 20); + expect(originalCommentLength).toBe(0); // Fresh ZIP has no comment + + // Sign the file + signMcpbFile(testFile, SELF_SIGNED_CERT, SELF_SIGNED_KEY); + + // Read signed file and verify EOCD comment_length was updated + const signedContent = fs.readFileSync(testFile); + let signedEocdOffset = -1; + for (let i = signedContent.length - 22; i >= 0; i--) { + if (signedContent.readUInt32LE(i) === 0x06054b50) { + signedEocdOffset = i; + break; + } + } + expect(signedEocdOffset).toBeGreaterThanOrEqual(0); + const signedCommentLength = signedContent.readUInt16LE( + signedEocdOffset + 20, + ); + + // Comment length should equal everything after the EOCD record's original end + const eocdMinSize = 22; // minimum EOCD size (no comment) + const dataAfterEocd = + signedContent.length - + (signedEocdOffset + eocdMinSize + originalCommentLength); + expect(signedCommentLength).toBe(dataAfterEocd); + expect(signedCommentLength).toBeGreaterThan(0); + + // Clean up + fs.unlinkSync(testFile); + }); }); From a5d9ae8ed28786a6bb7cddb114553bdf8a808dd6 Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Thu, 12 Mar 2026 11:16:30 -0500 Subject: [PATCH 08/18] fix: repair broken examples and graduate UV runtime from experimental MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - hello-world-node: wrap server startup in async main() with proper await on server.connect(transport) — fixes crash on initialize in Claude Desktop UtilityProcess runtime (closes #200) - hello-world-uv: add required mcp_config block — v0.4 schema requires it but the example omitted it, causing mcpb pack to fail - file-manager-python: convert from broken v0.1/python to v0.4/uv — the old manifest had privacy_policies on v0.1 (schema violation), used command "python" (ENOENT on macOS), and had no bundled deps. Now uses UV runtime with proper mcp_config (closes #47, closes #72) - Graduate UV runtime from experimental across docs and schema comments - Bump DEFAULT_MANIFEST_VERSION from 0.2 to 0.3 All three examples verified: pack succeeds, server responds to MCP initialize over stdio, tools/list returns expected tools. Co-Authored-By: Claude Opus 4.6 (1M context) --- .gitignore | 2 ++ MANIFEST.md | 6 ++-- README.md | 2 +- examples/file-manager-python/.mcpbignore | 7 +++++ examples/file-manager-python/manifest.json | 23 +++++++------- examples/file-manager-python/pyproject.toml | 31 +++---------------- examples/file-manager-python/requirements.txt | 2 -- examples/hello-world-node/server/index.js | 12 +++++-- examples/hello-world-uv/README.md | 6 ++-- examples/hello-world-uv/manifest.json | 6 +++- src/schemas/0.4.ts | 1 - src/schemas_loose/0.4.ts | 1 - src/shared/constants.ts | 2 +- 13 files changed, 44 insertions(+), 57 deletions(-) create mode 100644 examples/file-manager-python/.mcpbignore delete mode 100644 examples/file-manager-python/requirements.txt diff --git a/.gitignore b/.gitignore index ca98aa1..b01aba3 100644 --- a/.gitignore +++ b/.gitignore @@ -88,6 +88,8 @@ typings/ # Claude files .claude.json .claude/ +CLAUDE.md +PROJECT_STATUS.md # Vite .vite/ diff --git a/MANIFEST.md b/MANIFEST.md index 1bb7f50..8ba7fa2 100644 --- a/MANIFEST.md +++ b/MANIFEST.md @@ -403,11 +403,9 @@ Four server types are supported: - **`node`**: Node.js server with bundled dependencies - **`python`**: Python server with bundled dependencies - **`binary`**: Compiled executable -- **`uv`**: Python server using UV runtime (experimental, v0.4+) +- **`uv`**: Python server using UV runtime (v0.4+) -### UV Runtime (Experimental, v0.4+) - -> **Note:** UV runtime support is experimental and may change in future versions. +### UV Runtime (v0.4+) The `uv` server type enables cross-platform Python extensions without bundling dependencies. Instead, dependencies are declared in `pyproject.toml` and installed by the host application using UV. diff --git a/README.md b/README.md index 34aaaf5..d9f1fbe 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ bundle.mcpb (ZIP file) ### Bundling Dependencies -**UV Runtime (Experimental - v0.4+):** +**UV Runtime (v0.4+):** - Use `server.type = "uv"` in manifest - Include `pyproject.toml` with dependencies (no bundled packages needed) diff --git a/examples/file-manager-python/.mcpbignore b/examples/file-manager-python/.mcpbignore new file mode 100644 index 0000000..f753254 --- /dev/null +++ b/examples/file-manager-python/.mcpbignore @@ -0,0 +1,7 @@ +.venv/ +__pycache__/ +*.pyc +.pytest_cache/ +.mypy_cache/ +*.egg-info/ +uv.lock diff --git a/examples/file-manager-python/manifest.json b/examples/file-manager-python/manifest.json index 964b2aa..69b43e2 100644 --- a/examples/file-manager-python/manifest.json +++ b/examples/file-manager-python/manifest.json @@ -1,28 +1,28 @@ { - "$schema": "../../dist/mcpb-manifest.schema.json", - "manifest_version": "0.1", + "manifest_version": "0.4", "name": "file-manager-python", "display_name": "Python File Manager MCP", - "version": "0.1.0", + "version": "0.2.0", "description": "A Python MCP server for file operations", - "long_description": "This extension provides file management capabilities through a Python MCP server. It demonstrates Python-based MCP Bundle development, including file operations, directory management, and proper MCP protocol implementation.", + "long_description": "This extension provides file management capabilities through a Python MCP server. It demonstrates Python-based MCP Bundle development using UV runtime, including file operations, directory management, and proper MCP protocol implementation.", "author": { "name": "Anthropic", "email": "support@anthropic.com", "url": "https://github.com/anthropics" }, "server": { - "type": "python", + "type": "uv", "entry_point": "server/main.py", "mcp_config": { - "command": "python", + "command": "uv", "args": [ - "${__dirname}/server/main.py", + "run", + "--directory", "${__dirname}", + "server/main.py", "--workspace=${user_config.workspace_directory}" ], "env": { - "DEBUG": "${user_config.debug_mode}", - "PYTHONPATH": "${__dirname}/server/lib" + "DEBUG": "${user_config.debug_mode}" } } }, @@ -62,8 +62,7 @@ "claude_desktop": ">=0.10.0", "platforms": ["darwin", "win32", "linux"], "runtimes": { - "python": ">=3.8.0 <4" + "python": ">=3.10.0 <4" } - }, - "privacy_policies": [] + } } diff --git a/examples/file-manager-python/pyproject.toml b/examples/file-manager-python/pyproject.toml index 7895f32..5a1e799 100644 --- a/examples/file-manager-python/pyproject.toml +++ b/examples/file-manager-python/pyproject.toml @@ -1,31 +1,8 @@ -[build-system] -requires = ["setuptools>=42", "wheel"] -build-backend = "setuptools.build_meta" - [project] name = "file-manager-python" -version = "0.1.0" +version = "0.2.0" description = "A Python MCP server for file operations" -authors = [ - {name = "Anthropic", email = "support@anthropic.com"} +requires-python = ">=3.10" +dependencies = [ + "mcp>=1.0.0", ] -license = {text = "MIT"} -classifiers = [ - "Private :: Do Not Upload" # Prevents accidental uploads to PyPI -] - -[project.dependencies] -mcp = ">=1.0.0" -trio = ">=0.22.0" - -[tool.setuptools] -packages = ["server"] - -[project.scripts] -bundle-deps = "python:install_deps" - -# Custom scripts section for DXT development -[tool.dxt] -bundle = "pip install \"mcp[all]\" --target server/lib --upgrade --force-reinstall" -test = "python server/main.py --debug" -pack = "npx @anthropic-ai/dxt pack" \ No newline at end of file diff --git a/examples/file-manager-python/requirements.txt b/examples/file-manager-python/requirements.txt deleted file mode 100644 index d90d65c..0000000 --- a/examples/file-manager-python/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -mcp>=1.0.0 -trio>=0.22.0 diff --git a/examples/hello-world-node/server/index.js b/examples/hello-world-node/server/index.js index 03efb72..1d68293 100644 --- a/examples/hello-world-node/server/index.js +++ b/examples/hello-world-node/server/index.js @@ -64,7 +64,13 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => { }); // Start the server -const transport = new StdioServerTransport(); -server.connect(transport); +async function main() { + const transport = new StdioServerTransport(); + await server.connect(transport); + console.error("Hello World MCP server running..."); +} -console.error("Hello World MCP server running..."); +main().catch((error) => { + console.error("Fatal error in main():", error); + process.exit(1); +}); diff --git a/examples/hello-world-uv/README.md b/examples/hello-world-uv/README.md index ae898df..853bb06 100644 --- a/examples/hello-world-uv/README.md +++ b/examples/hello-world-uv/README.md @@ -1,6 +1,4 @@ -# Hello World UV Runtime Example (Experimental) - -> **Note:** UV runtime support is experimental and may change in future versions. +# Hello World UV Runtime Example This example demonstrates a minimal MCP server using **UV runtime**. @@ -28,7 +26,7 @@ hello-world-uv/ **UV Runtime** (this example): - `server.type = "uv"` - No bundled dependencies -- No `mcp_config` needed +- `mcp_config` uses `uv run` to auto-resolve deps from `pyproject.toml` - Small bundle size (~2 KB) - Works on any platform diff --git a/examples/hello-world-uv/manifest.json b/examples/hello-world-uv/manifest.json index f3d3b4a..534ef4d 100644 --- a/examples/hello-world-uv/manifest.json +++ b/examples/hello-world-uv/manifest.json @@ -10,7 +10,11 @@ "icon": "icon.png", "server": { "type": "uv", - "entry_point": "src/server.py" + "entry_point": "src/server.py", + "mcp_config": { + "command": "uv", + "args": ["run", "--directory", "${__dirname}", "src/server.py"] + } }, "compatibility": { "platforms": ["darwin", "linux", "win32"], diff --git a/src/schemas/0.4.ts b/src/schemas/0.4.ts index e044b91..ae97d17 100644 --- a/src/schemas/0.4.ts +++ b/src/schemas/0.4.ts @@ -1,5 +1,4 @@ // v0.4: Adds UV runtime support for Python extensions -// NOTE: This schema version is experimental and subject to change. import * as z from "zod"; export const MANIFEST_VERSION = "0.4"; diff --git a/src/schemas_loose/0.4.ts b/src/schemas_loose/0.4.ts index d75eed3..395fd60 100644 --- a/src/schemas_loose/0.4.ts +++ b/src/schemas_loose/0.4.ts @@ -1,5 +1,4 @@ // v0.4: Adds UV runtime support for Python extensions -// NOTE: This schema version is experimental and subject to change. import * as z from "zod"; export const MANIFEST_VERSION = "0.4"; diff --git a/src/shared/constants.ts b/src/shared/constants.ts index 4dd48a5..a7c460a 100644 --- a/src/shared/constants.ts +++ b/src/shared/constants.ts @@ -15,7 +15,7 @@ export const LATEST_MANIFEST_VERSION = "0.4" as const; /** * Default manifest version for new packages */ -export const DEFAULT_MANIFEST_VERSION = "0.2" as const; +export const DEFAULT_MANIFEST_VERSION = "0.3" as const; /** * Map of manifest versions to their strict schemas From cc4aa751b6eab80dcda3f29e2028c1c07c609ada Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Fri, 13 Mar 2026 16:36:47 -0500 Subject: [PATCH 09/18] feat: add Rust binary calculator example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit First example of the binary server type — a compiled Rust MCP server packaged as an MCPB. Based on the official Rust SDK calculator example (rmcp 1.2.0, 2 tools: sum/sub, ~80 LOC). Includes Cargo.toml, Dockerfile for Docker-based builds, .mcpbignore to exclude source from the bundle, and README with build/pack/test instructions. Co-Authored-By: Claude Opus 4.6 (1M context) --- examples/README.md | 11 ++-- examples/calculator-rust/.gitignore | 3 + examples/calculator-rust/.mcpbignore | 7 +++ examples/calculator-rust/Cargo.toml | 18 ++++++ examples/calculator-rust/Dockerfile | 11 ++++ examples/calculator-rust/README.md | 87 ++++++++++++++++++++++++++ examples/calculator-rust/manifest.json | 36 +++++++++++ examples/calculator-rust/src/main.rs | 80 +++++++++++++++++++++++ 8 files changed, 248 insertions(+), 5 deletions(-) create mode 100644 examples/calculator-rust/.gitignore create mode 100644 examples/calculator-rust/.mcpbignore create mode 100644 examples/calculator-rust/Cargo.toml create mode 100644 examples/calculator-rust/Dockerfile create mode 100644 examples/calculator-rust/README.md create mode 100644 examples/calculator-rust/manifest.json create mode 100644 examples/calculator-rust/src/main.rs diff --git a/examples/README.md b/examples/README.md index 24480ed..334e531 100644 --- a/examples/README.md +++ b/examples/README.md @@ -14,11 +14,12 @@ But, the MCP servers themselves are not robust secure production ready servers a ## Examples Included -| Example | Type | Demonstrates | -| --------------------- | ------- | ---------------------------------------- | -| `hello-world-node` | Node.js | Basic MCP server with simple time tool | -| `chrome-applescript` | Node.js | Browser automation via AppleScript | -| `file-manager-python` | Python | File system operations and path handling | +| Example | Type | Demonstrates | +| --------------------- | ------- | ------------------------------------------- | +| `hello-world-node` | Node.js | Basic MCP server with simple time tool | +| `chrome-applescript` | Node.js | Browser automation via AppleScript | +| `file-manager-python` | Python | File system operations and path handling | +| `calculator-rust` | Binary | Compiled Rust binary as MCP Bundle | ## Usage diff --git a/examples/calculator-rust/.gitignore b/examples/calculator-rust/.gitignore new file mode 100644 index 0000000..ae1d722 --- /dev/null +++ b/examples/calculator-rust/.gitignore @@ -0,0 +1,3 @@ +target/ +Cargo.lock +server/mcp-calculator diff --git a/examples/calculator-rust/.mcpbignore b/examples/calculator-rust/.mcpbignore new file mode 100644 index 0000000..3b44c2b --- /dev/null +++ b/examples/calculator-rust/.mcpbignore @@ -0,0 +1,7 @@ +Cargo.toml +Cargo.lock +src/ +target/ +Dockerfile +README.md +.gitignore diff --git a/examples/calculator-rust/Cargo.toml b/examples/calculator-rust/Cargo.toml new file mode 100644 index 0000000..dfbca7e --- /dev/null +++ b/examples/calculator-rust/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "mcp-calculator" +version = "1.0.0" +edition = "2024" + +[dependencies] +rmcp = { version = "1.2.0", features = ["server", "macros", "transport-io", "schemars"] } +tokio = { version = "1", features = ["macros", "rt-multi-thread", "io-std"] } +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" +anyhow = "1.0" +tracing = "0.1" +tracing-subscriber = { version = "0.3", features = ["env-filter", "std", "fmt"] } +schemars = "1.0" + +[profile.release] +strip = true +lto = true diff --git a/examples/calculator-rust/Dockerfile b/examples/calculator-rust/Dockerfile new file mode 100644 index 0000000..a8358f5 --- /dev/null +++ b/examples/calculator-rust/Dockerfile @@ -0,0 +1,11 @@ +FROM rust:1.94-bookworm AS builder + +WORKDIR /app +COPY Cargo.toml ./ +COPY src/ ./src/ + +RUN cargo build --release + +FROM debian:bookworm-slim +COPY --from=builder /app/target/release/mcp-calculator /mcp-calculator +ENTRYPOINT ["/mcp-calculator"] diff --git a/examples/calculator-rust/README.md b/examples/calculator-rust/README.md new file mode 100644 index 0000000..adaf4d1 --- /dev/null +++ b/examples/calculator-rust/README.md @@ -0,0 +1,87 @@ +# Calculator Rust Binary Example + +Demonstrates packaging a compiled Rust binary as an MCP Bundle using the `binary` server type. Based on the [official Rust MCP SDK calculator example](https://github.com/modelcontextprotocol/rust-sdk/tree/main/examples/servers). + +## What is Binary Server Type? + +Unlike `node` or `uv` server types where the source code is bundled and executed by a runtime, the `binary` server type packages a pre-compiled native executable. This is useful for: + +- Rust, Go, C/C++ MCP servers +- Performance-sensitive workloads +- Servers with no runtime dependencies + +The tradeoff is that binaries are platform-specific — you need a separate build for each target OS/architecture. + +## Structure + +``` +calculator-rust/ +ā”œā”€ā”€ manifest.json # server.type = "binary" +ā”œā”€ā”€ Cargo.toml # Rust project +ā”œā”€ā”€ Dockerfile # Build via Docker +ā”œā”€ā”€ .mcpbignore # Exclude source from bundle +ā”œā”€ā”€ .gitignore # Exclude build artifacts +└── src/ + └── main.rs # Calculator MCP server (~80 LOC) +``` + +After building, the `server/` directory is created with the compiled binary. + +## Building + +### Native (requires Rust 1.85+) + +```bash +cd examples/calculator-rust +cargo build --release +mkdir -p server +cp target/release/mcp-calculator server/ +``` + +### Docker (no local Rust required) + +```bash +cd examples/calculator-rust +docker build -t mcp-calculator . +# Extract the binary (linux only) +docker create --name calc mcp-calculator +docker cp calc:/mcp-calculator server/mcp-calculator +docker rm calc +chmod +x server/mcp-calculator +``` + +## Packing + +```bash +mcpb pack examples/calculator-rust +``` + +The `.mcpbignore` file excludes source code and build artifacts — only `manifest.json` and `server/mcp-calculator` end up in the bundle. + +## Testing + +```bash +# MCP protocol handshake +echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}' \ + | ./server/mcp-calculator + +# Tool call +(printf '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}\n' +printf '{"jsonrpc":"2.0","method":"notifications/initialized"}\n' +printf '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"sum","arguments":{"a":3,"b":4}}}\n' +sleep 1) | ./server/mcp-calculator +``` + +Expected: `sum(3, 4)` returns `{"text":"7"}`. + +## Tools + +- **sum** — Calculate the sum of two numbers +- **sub** — Calculate the difference of two numbers + +## Notes + +- Binary size: ~2.5 MB (stripped, LTO enabled) +- The `Cargo.toml` uses `edition = "2024"` (Rust 1.85+) +- Logs are written to stderr via `tracing`, so they don't interfere with MCP's stdio transport +- Uses the [rmcp](https://crates.io/crates/rmcp) crate (official Rust MCP SDK) diff --git a/examples/calculator-rust/manifest.json b/examples/calculator-rust/manifest.json new file mode 100644 index 0000000..fd31518 --- /dev/null +++ b/examples/calculator-rust/manifest.json @@ -0,0 +1,36 @@ +{ + "$schema": "../../dist/mcpb-manifest.schema.json", + "manifest_version": "0.3", + "name": "calculator-rust", + "display_name": "Calculator (Rust Binary)", + "version": "1.0.0", + "description": "A simple calculator MCP server compiled from Rust", + "long_description": "Demonstrates packaging a compiled Rust binary as an MCP Bundle using the binary server type. The server provides sum and sub tools for basic arithmetic. Based on the official Rust MCP SDK calculator example.", + "author": { + "name": "Model Context Protocol" + }, + "server": { + "type": "binary", + "entry_point": "server/mcp-calculator", + "mcp_config": { + "command": "${__dirname}/server/mcp-calculator", + "args": [], + "env": {} + } + }, + "tools": [ + { + "name": "sum", + "description": "Calculate the sum of two numbers" + }, + { + "name": "sub", + "description": "Calculate the difference of two numbers" + } + ], + "keywords": ["calculator", "rust", "binary", "example"], + "license": "Apache-2.0", + "compatibility": { + "platforms": ["darwin", "linux"] + } +} diff --git a/examples/calculator-rust/src/main.rs b/examples/calculator-rust/src/main.rs new file mode 100644 index 0000000..4a0f885 --- /dev/null +++ b/examples/calculator-rust/src/main.rs @@ -0,0 +1,80 @@ +use anyhow::Result; +use rmcp::{ + ServerHandler, ServiceExt, + handler::server::{router::tool::ToolRouter, wrapper::Parameters}, + model::{ServerCapabilities, ServerInfo}, + schemars, tool, tool_handler, tool_router, + transport::stdio, +}; +use tracing_subscriber::{self, EnvFilter}; + +// --- Calculator types --- + +#[derive(Debug, serde::Deserialize, schemars::JsonSchema)] +pub struct SumRequest { + #[schemars(description = "the left hand side number")] + pub a: i32, + pub b: i32, +} + +#[derive(Debug, serde::Deserialize, schemars::JsonSchema)] +pub struct SubRequest { + #[schemars(description = "the left hand side number")] + pub a: i32, + #[schemars(description = "the right hand side number")] + pub b: i32, +} + +// --- Calculator server --- + +#[derive(Debug, Clone)] +pub struct Calculator { + tool_router: ToolRouter, +} + +#[tool_router] +impl Calculator { + pub fn new() -> Self { + Self { + tool_router: Self::tool_router(), + } + } + + #[tool(description = "Calculate the sum of two numbers")] + fn sum(&self, Parameters(SumRequest { a, b }): Parameters) -> String { + (a + b).to_string() + } + + #[tool(description = "Calculate the difference of two numbers")] + fn sub(&self, Parameters(SubRequest { a, b }): Parameters) -> String { + (a - b).to_string() + } +} + +#[tool_handler] +impl ServerHandler for Calculator { + fn get_info(&self) -> ServerInfo { + ServerInfo::new(ServerCapabilities::builder().enable_tools().build()) + .with_instructions("A simple calculator".to_string()) + } +} + +// --- Main --- + +#[tokio::main] +async fn main() -> Result<()> { + tracing_subscriber::fmt() + .with_env_filter(EnvFilter::from_default_env().add_directive(tracing::Level::DEBUG.into())) + .with_writer(std::io::stderr) + .with_ansi(false) + .init(); + + tracing::info!("Starting Calculator MCP server"); + + let service = Calculator::new().serve(stdio()).await.inspect_err(|e| { + tracing::error!("serving error: {:?}", e); + })?; + + service.waiting().await?; + Ok(()) +} From a907aead99c57b32a939e5d359ffd797fad0c991 Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Fri, 13 Mar 2026 16:41:30 -0500 Subject: [PATCH 10/18] chore: remove Dockerfile and .gitignore from calculator-rust example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Align with other examples — no example ships a Dockerfile or its own .gitignore. Rust build artifacts are now covered by the repo-level .gitignore instead. Co-Authored-By: Claude Opus 4.6 (1M context) --- .gitignore | 6 ++++++ examples/calculator-rust/.gitignore | 3 --- examples/calculator-rust/.mcpbignore | 2 -- examples/calculator-rust/Dockerfile | 11 ----------- examples/calculator-rust/README.md | 16 +--------------- 5 files changed, 7 insertions(+), 31 deletions(-) delete mode 100644 examples/calculator-rust/.gitignore delete mode 100644 examples/calculator-rust/Dockerfile diff --git a/.gitignore b/.gitignore index ca98aa1..ec20709 100644 --- a/.gitignore +++ b/.gitignore @@ -88,6 +88,8 @@ typings/ # Claude files .claude.json .claude/ +CLAUDE.md +PROJECT_STATUS.md # Vite .vite/ @@ -107,4 +109,8 @@ self-signed-key.pem invalid-json.json **/server/lib/** +# Rust example build artifacts +examples/calculator-rust/target/ +examples/calculator-rust/server/ + .yarn/install-state.gz \ No newline at end of file diff --git a/examples/calculator-rust/.gitignore b/examples/calculator-rust/.gitignore deleted file mode 100644 index ae1d722..0000000 --- a/examples/calculator-rust/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -target/ -Cargo.lock -server/mcp-calculator diff --git a/examples/calculator-rust/.mcpbignore b/examples/calculator-rust/.mcpbignore index 3b44c2b..29c73c3 100644 --- a/examples/calculator-rust/.mcpbignore +++ b/examples/calculator-rust/.mcpbignore @@ -2,6 +2,4 @@ Cargo.toml Cargo.lock src/ target/ -Dockerfile README.md -.gitignore diff --git a/examples/calculator-rust/Dockerfile b/examples/calculator-rust/Dockerfile deleted file mode 100644 index a8358f5..0000000 --- a/examples/calculator-rust/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM rust:1.94-bookworm AS builder - -WORKDIR /app -COPY Cargo.toml ./ -COPY src/ ./src/ - -RUN cargo build --release - -FROM debian:bookworm-slim -COPY --from=builder /app/target/release/mcp-calculator /mcp-calculator -ENTRYPOINT ["/mcp-calculator"] diff --git a/examples/calculator-rust/README.md b/examples/calculator-rust/README.md index adaf4d1..1482131 100644 --- a/examples/calculator-rust/README.md +++ b/examples/calculator-rust/README.md @@ -18,9 +18,7 @@ The tradeoff is that binaries are platform-specific — you need a separate buil calculator-rust/ ā”œā”€ā”€ manifest.json # server.type = "binary" ā”œā”€ā”€ Cargo.toml # Rust project -ā”œā”€ā”€ Dockerfile # Build via Docker ā”œā”€ā”€ .mcpbignore # Exclude source from bundle -ā”œā”€ā”€ .gitignore # Exclude build artifacts └── src/ └── main.rs # Calculator MCP server (~80 LOC) ``` @@ -29,7 +27,7 @@ After building, the `server/` directory is created with the compiled binary. ## Building -### Native (requires Rust 1.85+) +Requires [Rust](https://rustup.rs/) 1.85+. ```bash cd examples/calculator-rust @@ -38,18 +36,6 @@ mkdir -p server cp target/release/mcp-calculator server/ ``` -### Docker (no local Rust required) - -```bash -cd examples/calculator-rust -docker build -t mcp-calculator . -# Extract the binary (linux only) -docker create --name calc mcp-calculator -docker cp calc:/mcp-calculator server/mcp-calculator -docker rm calc -chmod +x server/mcp-calculator -``` - ## Packing ```bash From f4671638a2db51abb19dc312b00277bd58bc0b66 Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Sun, 15 Mar 2026 06:54:22 -0500 Subject: [PATCH 11/18] feat: add --manifest flag to pack command (#87) Allow specifying an external manifest file path with `mcpb pack --manifest `. The manifest resolves relative to CWD, is validated, injected into the bundle, and errors immediately if the specified file is not found. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/cli/cli.ts | 43 ++++++++++++++++---------- src/cli/pack.ts | 24 +++++++++++++-- test/cli.test.ts | 78 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 127 insertions(+), 18 deletions(-) diff --git a/src/cli/cli.ts b/src/cli/cli.ts index 817b659..5ba121c 100644 --- a/src/cli/cli.ts +++ b/src/cli/cli.ts @@ -101,22 +101,33 @@ program program .command("pack [directory] [output]") .description("Pack a directory into an MCPB extension") - .action((directory: string = process.cwd(), output?: string) => { - void (async () => { - try { - const success = await packExtension({ - extensionPath: directory, - outputPath: output, - }); - process.exit(success ? 0 : 1); - } catch (error) { - console.error( - `ERROR: ${error instanceof Error ? error.message : "Unknown error"}`, - ); - process.exit(1); - } - })(); - }); + .option( + "-m, --manifest ", + "Path to manifest file (defaults to manifest.json in directory)", + ) + .action( + ( + directory: string = process.cwd(), + output: string | undefined, + options: { manifest?: string }, + ) => { + void (async () => { + try { + const success = await packExtension({ + extensionPath: directory, + outputPath: output, + manifestPath: options.manifest, + }); + process.exit(success ? 0 : 1); + } catch (error) { + console.error( + `ERROR: ${error instanceof Error ? error.message : "Unknown error"}`, + ); + process.exit(1); + } + })(); + }, + ); // Unpack command program diff --git a/src/cli/pack.ts b/src/cli/pack.ts index e2411bf..1e35d47 100644 --- a/src/cli/pack.ts +++ b/src/cli/pack.ts @@ -22,6 +22,7 @@ interface PackOptions { extensionPath: string; outputPath?: string; silent?: boolean; + manifestPath?: string; } function formatFileSize(bytes: number): string { @@ -50,6 +51,7 @@ export async function packExtension({ extensionPath, outputPath, silent, + manifestPath: customManifestPath, }: PackOptions): Promise { const resolvedPath = resolve(extensionPath); const logger = getLogger({ silent }); @@ -60,9 +62,18 @@ export async function packExtension({ return false; } - // Check if manifest exists - const manifestPath = join(resolvedPath, "manifest.json"); + // Resolve manifest path + const manifestPath = customManifestPath + ? resolve(customManifestPath) + : join(resolvedPath, "manifest.json"); + if (!existsSync(manifestPath)) { + if (customManifestPath) { + // When --manifest is explicitly provided, error immediately + logger.error(`ERROR: Manifest file not found: ${customManifestPath}`); + return false; + } + logger.log(`No manifest.json found in ${extensionPath}`); const shouldInit = await confirm({ message: "Would you like to create a manifest.json file?", @@ -135,6 +146,15 @@ export async function packExtension({ mcpbIgnorePatterns, ); + // When using a custom manifest path, inject the manifest into the bundle + if (customManifestPath) { + const manifestStat = statSync(manifestPath); + files["manifest.json"] = { + data: readFileSync(manifestPath), + mode: manifestStat.mode, + }; + } + // Print package header logger.log(`\nšŸ“¦ ${manifest.name}@${manifest.version}`); diff --git a/test/cli.test.ts b/test/cli.test.ts index e7757ac..2586d7c 100644 --- a/test/cli.test.ts +++ b/test/cli.test.ts @@ -258,6 +258,84 @@ describe("DXT CLI", () => { expect(originalFile2).toEqual(unpackedFile2); }); + it("should pack with --manifest pointing to a separate directory", () => { + const projectDir = join(__dirname, "temp-manifest-project"); + const manifestDir = join(__dirname, "temp-manifest-separate"); + const manifestPackedPath = join(__dirname, "test-manifest-flag.mcpb"); + + try { + // Create project directory with source files (no manifest) + fs.mkdirSync(join(projectDir, "server"), { recursive: true }); + fs.writeFileSync( + join(projectDir, "server", "index.js"), + "console.log('hello');", + ); + + // Create separate manifest directory + fs.mkdirSync(manifestDir, { recursive: true }); + fs.writeFileSync( + join(manifestDir, "manifest.json"), + JSON.stringify({ + manifest_version: DEFAULT_MANIFEST_VERSION, + name: "Test Separate Manifest", + version: "1.0.0", + description: "Test with separate manifest", + author: { name: "MCPB" }, + server: { + type: "node", + entry_point: "server/index.js", + mcp_config: { command: "node" }, + }, + }), + ); + + const result = execSync( + `node ${cliPath} pack ${projectDir} ${manifestPackedPath} --manifest ${join(manifestDir, "manifest.json")}`, + { encoding: "utf-8" }, + ); + + expect(fs.existsSync(manifestPackedPath)).toBe(true); + expect(result).toContain("Validating manifest"); + } finally { + fs.rmSync(projectDir, { recursive: true, force: true }); + fs.rmSync(manifestDir, { recursive: true, force: true }); + if (fs.existsSync(manifestPackedPath)) { + fs.unlinkSync(manifestPackedPath); + } + } + }); + + it("should fail with --manifest pointing to nonexistent file", () => { + const projectDir = join(__dirname, "temp-manifest-missing-project"); + + try { + fs.mkdirSync(projectDir, { recursive: true }); + fs.writeFileSync(join(projectDir, "index.js"), "console.log('hello');"); + + expect(() => { + execSync( + `node ${cliPath} pack ${projectDir} /tmp/out.mcpb --manifest /nonexistent/manifest.json`, + { encoding: "utf-8", stdio: "pipe" }, + ); + }).toThrow(); + + try { + execSync( + `node ${cliPath} pack ${projectDir} /tmp/out.mcpb --manifest /nonexistent/manifest.json`, + { encoding: "utf-8", stdio: "pipe" }, + ); + } catch (error: unknown) { + const execError = error as { stdout?: Buffer; stderr?: Buffer }; + const output = + (execError.stdout?.toString() || "") + + (execError.stderr?.toString() || ""); + expect(output).toContain("Manifest file not found"); + } + } finally { + fs.rmSync(projectDir, { recursive: true, force: true }); + } + }); + it("should preserve executable file permissions after packing and unpacking", () => { // Skip this test on Windows since it doesn't support Unix permissions if (process.platform === "win32") { From f14863bcdcb090c5cf9556c718cdcc18aa77e5b5 Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Sun, 15 Mar 2026 06:56:55 -0500 Subject: [PATCH 12/18] feat: enhanced structural validation for mcpb validate (#57) Add three pre-pack validators to catch common runtime failures early: - validateEntryPoint: checks file exists, extension matches server type, binary has executable bit (Unix) - validateCommandVariables: scans mcp_config for unrecognized ${...} variables against the runtime allowlist - validateSensitiveFiles: warns about credentials.json, *.pem, *.key, .ssh/, etc. that would be bundled validateManifest() now accepts optional { projectDir } to separate the manifest directory from the source file directory. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/cli/pack.ts | 6 +- src/node/validate.ts | 246 ++++++++++++++++++++++- test/cli.test.ts | 11 ++ test/icon-validation.test.ts | 4 + test/server/index.js | 1 + test/validate.test.ts | 369 +++++++++++++++++++++++++++++++++++ 6 files changed, 629 insertions(+), 8 deletions(-) create mode 100644 test/server/index.js create mode 100644 test/validate.test.ts diff --git a/src/cli/pack.ts b/src/cli/pack.ts index e2411bf..d2aba54 100644 --- a/src/cli/pack.ts +++ b/src/cli/pack.ts @@ -83,7 +83,11 @@ export async function packExtension({ // Validate manifest first logger.log("Validating manifest..."); - if (!validateManifest(manifestPath)) { + if ( + !validateManifest(manifestPath, { + projectDir: resolvedPath, + }) + ) { logger.error("ERROR: Cannot pack extension with invalid manifest"); return false; } diff --git a/src/node/validate.ts b/src/node/validate.ts index d1ee8fd..b958798 100644 --- a/src/node/validate.ts +++ b/src/node/validate.ts @@ -2,7 +2,7 @@ import { existsSync, readFileSync, statSync } from "fs"; import * as fs from "fs/promises"; import { DestroyerOfModules } from "galactus"; import * as os from "os"; -import { dirname, isAbsolute, join, resolve } from "path"; +import { dirname, extname, isAbsolute, join, resolve } from "path"; import prettyBytes from "pretty-bytes"; import { unpackExtension } from "../cli/unpack.js"; @@ -11,6 +11,7 @@ import { MANIFEST_SCHEMAS_LOOSE, } from "../shared/constants.js"; import { getManifestVersionFromRawData } from "../shared/manifestVersionResolve.js"; +import { getAllFilesWithCount, readMcpbIgnorePatterns } from "./files.js"; /** * Check if a buffer contains a valid PNG file signature @@ -108,7 +109,191 @@ function validateIcon( }; } -export function validateManifest(inputPath: string): boolean { +interface ValidationResult { + valid: boolean; + errors: string[]; + warnings: string[]; +} + +// Expected file extensions by server type +const NODE_EXTENSIONS = new Set([".js", ".mjs", ".cjs"]); +const PYTHON_EXTENSIONS = new Set([".py"]); +const SCRIPT_EXTENSIONS = new Set([".js", ".mjs", ".cjs", ".py"]); + +/** + * Validate that the server entry_point file exists and matches the server type + */ +function validateEntryPoint( + manifest: { server: { type: string; entry_point: string } }, + baseDir: string, +): ValidationResult { + const errors: string[] = []; + const warnings: string[] = []; + const { type, entry_point } = manifest.server; + const entryPath = join(baseDir, entry_point); + + if (!existsSync(entryPath)) { + errors.push(`Entry point file not found: ${entry_point}`); + return { valid: false, errors, warnings }; + } + + const ext = extname(entry_point).toLowerCase(); + + if (type === "node" && !NODE_EXTENSIONS.has(ext)) { + warnings.push( + `Unusual entry point extension "${ext}" for server type "node". Expected: .js, .mjs, or .cjs`, + ); + } else if ( + (type === "python" || type === "uv") && + !PYTHON_EXTENSIONS.has(ext) + ) { + warnings.push( + `Unusual entry point extension "${ext}" for server type "${type}". Expected: .py`, + ); + } else if (type === "binary" && SCRIPT_EXTENSIONS.has(ext)) { + warnings.push( + `Entry point has script extension "${ext}" but server type is "binary". Did you mean type "node" or "python"?`, + ); + } + + // For binary type on Unix, check executable bit + if (type === "binary" && process.platform !== "win32") { + const stat = statSync(entryPath); + if (!(stat.mode & 0o111)) { + errors.push( + `Binary entry point is not executable: ${entry_point}. Run: chmod +x ${entry_point}`, + ); + } + } + + return { valid: errors.length === 0, errors, warnings }; +} + +// Valid variable patterns from src/shared/config.ts replaceVariables() +const VALID_VARIABLE_PATTERN = + /^\$\{(__dirname|pathSeparator|\/|user_config\..+)\}$/; + +/** + * Validate that ${...} variables in mcp_config are recognized + */ +function validateCommandVariables(manifest: { + server: { + mcp_config: { + command?: string; + args?: string[]; + env?: Record; + platform_overrides?: Record< + string, + { + command?: string; + args?: string[]; + env?: Record; + } + >; + }; + }; +}): ValidationResult { + const errors: string[] = []; + const warnings: string[] = []; + + function checkString(value: string, context: string): void { + const variablePattern = /\$\{([^}]+)\}/g; + let match; + while ((match = variablePattern.exec(value)) !== null) { + const fullVar = match[0]; + if (!VALID_VARIABLE_PATTERN.test(fullVar)) { + errors.push( + `Invalid variable "${fullVar}" in ${context}. Valid variables: \${__dirname}, \${pathSeparator}, \${/}, \${user_config.}`, + ); + } + } + } + + function checkConfig( + config: { command?: string; args?: string[]; env?: Record }, + prefix: string, + ): void { + if (config.command) checkString(config.command, `${prefix}command`); + if (config.args) { + config.args.forEach((arg, i) => checkString(arg, `${prefix}args[${i}]`)); + } + if (config.env) { + for (const [key, val] of Object.entries(config.env)) { + checkString(val, `${prefix}env.${key}`); + } + } + } + + const { mcp_config } = manifest.server; + checkConfig(mcp_config, "mcp_config."); + + if (mcp_config.platform_overrides) { + for (const [platform, override] of Object.entries( + mcp_config.platform_overrides, + )) { + checkConfig(override, `mcp_config.platform_overrides.${platform}.`); + } + } + + return { valid: errors.length === 0, errors, warnings }; +} + +// Sensitive file patterns not already covered by EXCLUDE_PATTERNS in files.ts +const SENSITIVE_PATTERNS = [ + /(^|\/)credentials\.json$/i, + /(^|\/)secrets\./i, + /\.pem$/i, + /\.key$/i, + /\.p12$/i, + /\.pfx$/i, + /\.jks$/i, + /(^|\/)\.aws\//, + /(^|\/)\.ssh\//, + /(^|\/)id_rsa/, + /(^|\/)id_ed25519/, + /(^|\/)id_ecdsa/, + /\.keystore$/i, + /(^|\/)token\.json$/i, +]; + +/** + * Check if the file list that would be bundled contains sensitive files + */ +function validateSensitiveFiles(baseDir: string): ValidationResult { + const warnings: string[] = []; + + try { + const mcpbIgnorePatterns = readMcpbIgnorePatterns(baseDir); + const { files } = getAllFilesWithCount( + baseDir, + baseDir, + {}, + mcpbIgnorePatterns, + ); + + for (const filePath of Object.keys(files)) { + for (const pattern of SENSITIVE_PATTERNS) { + if (pattern.test(filePath)) { + warnings.push( + `Potentially sensitive file will be included in bundle: ${filePath}`, + ); + break; + } + } + } + } catch { + // If we can't read the directory, skip this check silently — + // pack will fail with a clearer error later + } + + // Sensitive files are always warnings, never errors — a .pem might be a legitimate TLS cert + return { valid: true, errors: [], warnings }; +} + +export function validateManifest( + inputPath: string, + options?: { projectDir?: string }, +): boolean { try { const resolvedPath = resolve(inputPath); let manifestPath = resolvedPath; @@ -131,17 +316,23 @@ export function validateManifest(inputPath: string): boolean { if (result.success) { console.log("Manifest schema validation passes!"); - // Validate icon if present + const manifestDir = dirname(manifestPath); + // projectDir is where source files live — defaults to the manifest's directory + const projectDir = options?.projectDir + ? resolve(options.projectDir) + : manifestDir; + let hasErrors = false; + + // Validate icon if present (always relative to manifest directory) if (manifestData.icon) { - const baseDir = dirname(manifestPath); - const iconValidation = validateIcon(manifestData.icon, baseDir); + const iconValidation = validateIcon(manifestData.icon, manifestDir); if (iconValidation.errors.length > 0) { console.log("\nERROR: Icon validation failed:\n"); iconValidation.errors.forEach((error) => { console.log(` - ${error}`); }); - return false; + hasErrors = true; } if (iconValidation.warnings.length > 0) { @@ -152,7 +343,48 @@ export function validateManifest(inputPath: string): boolean { } } - return true; + // Validate entry point (relative to project directory) + const entryPointValidation = validateEntryPoint(manifestData, projectDir); + if (entryPointValidation.errors.length > 0) { + console.log("\nERROR: Entry point validation failed:\n"); + entryPointValidation.errors.forEach((error) => { + console.log(` - ${error}`); + }); + hasErrors = true; + } + if (entryPointValidation.warnings.length > 0) { + console.log("\nEntry point warnings:\n"); + entryPointValidation.warnings.forEach((warning) => { + console.log(` - ${warning}`); + }); + } + + // Validate command variables + const variableValidation = validateCommandVariables(manifestData); + if (variableValidation.errors.length > 0) { + console.log("\nERROR: Command variable validation failed:\n"); + variableValidation.errors.forEach((error) => { + console.log(` - ${error}`); + }); + hasErrors = true; + } + if (variableValidation.warnings.length > 0) { + console.log("\nCommand variable warnings:\n"); + variableValidation.warnings.forEach((warning) => { + console.log(` - ${warning}`); + }); + } + + // Check for sensitive files (relative to project directory) + const sensitiveValidation = validateSensitiveFiles(projectDir); + if (sensitiveValidation.warnings.length > 0) { + console.log("\nSensitive file warnings:\n"); + sensitiveValidation.warnings.forEach((warning) => { + console.log(` - ${warning}`); + }); + } + + return !hasErrors; } else { console.log("ERROR: Manifest validation failed:\n"); result.error.issues.forEach((issue) => { diff --git a/test/cli.test.ts b/test/cli.test.ts index e7757ac..7ecc402 100644 --- a/test/cli.test.ts +++ b/test/cli.test.ts @@ -99,6 +99,10 @@ describe("DXT CLI", () => { 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, ]); fs.writeFileSync(join(testDir, "icon.png"), validPngBuffer); + + // Create entry point file referenced by test manifests + fs.mkdirSync(join(testDir, "server"), { recursive: true }); + fs.writeFileSync(join(testDir, "server", "index.js"), "// fixture"); }); afterAll(() => { @@ -196,6 +200,9 @@ describe("DXT CLI", () => { fs.writeFileSync(join(tempDir, "file1.txt"), "hello"); fs.mkdirSync(join(tempDir, "subdir")); fs.writeFileSync(join(tempDir, "subdir", "file2.txt"), "world"); + // Create entry point file referenced by manifest + fs.mkdirSync(join(tempDir, "server"), { recursive: true }); + fs.writeFileSync(join(tempDir, "server", "index.js"), "// fixture"); }); afterAll(() => { @@ -291,6 +298,10 @@ describe("DXT CLI", () => { }), ); + // Create entry point file referenced by manifest + fs.mkdirSync(join(tempExecDir, "server"), { recursive: true }); + fs.writeFileSync(join(tempExecDir, "server", "index.js"), "// fixture"); + // Create an executable script const executableScript = join(tempExecDir, "run-script.sh"); fs.writeFileSync( diff --git a/test/icon-validation.test.ts b/test/icon-validation.test.ts index b55abd4..bdc7bbe 100644 --- a/test/icon-validation.test.ts +++ b/test/icon-validation.test.ts @@ -93,6 +93,10 @@ describe("Icon Validation", () => { "Not a PNG file", ); + // Create entry point file referenced by test manifests + fs.mkdirSync(join(testFixturesDir, "server"), { recursive: true }); + fs.writeFileSync(join(testFixturesDir, "server", "index.js"), "// fixture"); + // Create test manifests createTestManifest("valid-local-icon.json", { icon: "valid-icon.png", diff --git a/test/server/index.js b/test/server/index.js new file mode 100644 index 0000000..c8a782c --- /dev/null +++ b/test/server/index.js @@ -0,0 +1 @@ +// test fixture diff --git a/test/validate.test.ts b/test/validate.test.ts new file mode 100644 index 0000000..e998fb2 --- /dev/null +++ b/test/validate.test.ts @@ -0,0 +1,369 @@ +import { execSync } from "node:child_process"; +import fs from "node:fs"; +import { join } from "node:path"; + +import { DEFAULT_MANIFEST_VERSION } from "../src/shared/constants"; + +interface ExecSyncError extends Error { + stdout: Buffer; + stderr: Buffer; + status: number | null; +} + +describe("Enhanced Validation", () => { + const cliPath = join(__dirname, "../dist/cli/cli.js"); + const fixturesDir = join(__dirname, "fixtures", "validate"); + + function createManifest( + dir: string, + overrides: Record = {}, + ) { + const manifest = { + manifest_version: DEFAULT_MANIFEST_VERSION, + name: "test-extension", + version: "1.0.0", + description: "Test extension for validation", + author: { name: "Test Author" }, + server: { + type: "node", + entry_point: "server/index.js", + mcp_config: { + command: "node", + args: ["${__dirname}/server/index.js"], + }, + }, + ...overrides, + }; + + fs.writeFileSync( + join(dir, "manifest.json"), + JSON.stringify(manifest, null, 2), + ); + } + + beforeAll(() => { + execSync("yarn build", { cwd: join(__dirname, "..") }); + + if (fs.existsSync(fixturesDir)) { + fs.rmSync(fixturesDir, { recursive: true, force: true }); + } + fs.mkdirSync(fixturesDir, { recursive: true }); + }); + + afterAll(() => { + if (fs.existsSync(fixturesDir)) { + fs.rmSync(fixturesDir, { recursive: true, force: true }); + } + }); + + describe("entry point validation", () => { + it("should fail when entry_point file is missing", () => { + const dir = join(fixturesDir, "missing-entry"); + fs.mkdirSync(dir, { recursive: true }); + createManifest(dir); + // Deliberately NOT creating server/index.js + + expect(() => { + execSync(`node ${cliPath} validate ${dir}`, { + encoding: "utf-8", + stdio: "pipe", + }); + }).toThrow(); + + try { + execSync(`node ${cliPath} validate ${dir}`, { + encoding: "utf-8", + stdio: "pipe", + }); + } catch (error: unknown) { + const execError = error as ExecSyncError; + const output = execError.stdout?.toString() || ""; + expect(output).toContain("Entry point file not found"); + } + }); + + it("should warn about extension mismatch (node type with .py file)", () => { + const dir = join(fixturesDir, "ext-mismatch"); + fs.mkdirSync(join(dir, "server"), { recursive: true }); + fs.writeFileSync(join(dir, "server", "main.py"), "print('hello')"); + createManifest(dir, { + server: { + type: "node", + entry_point: "server/main.py", + mcp_config: { command: "node" }, + }, + }); + + const result = execSync(`node ${cliPath} validate ${dir}`, { + encoding: "utf-8", + }); + + expect(result).toContain("Manifest schema validation passes!"); + expect(result).toContain("Unusual entry point extension"); + }); + + it("should fail when binary entry_point is not executable (Unix only)", () => { + if (process.platform === "win32") { + return; + } + + const dir = join(fixturesDir, "binary-not-exec"); + fs.mkdirSync(dir, { recursive: true }); + fs.writeFileSync(join(dir, "myserver"), "#!/bin/sh\necho hi"); + fs.chmodSync(join(dir, "myserver"), 0o644); + createManifest(dir, { + server: { + type: "binary", + entry_point: "myserver", + mcp_config: { command: "./myserver" }, + }, + }); + + expect(() => { + execSync(`node ${cliPath} validate ${dir}`, { + encoding: "utf-8", + stdio: "pipe", + }); + }).toThrow(); + + try { + execSync(`node ${cliPath} validate ${dir}`, { + encoding: "utf-8", + stdio: "pipe", + }); + } catch (error: unknown) { + const execError = error as ExecSyncError; + const output = execError.stdout?.toString() || ""; + expect(output).toContain("not executable"); + } + }); + + it("should pass when binary entry_point is executable (Unix only)", () => { + if (process.platform === "win32") { + return; + } + + const dir = join(fixturesDir, "binary-exec"); + fs.mkdirSync(dir, { recursive: true }); + fs.writeFileSync(join(dir, "myserver"), "#!/bin/sh\necho hi"); + fs.chmodSync(join(dir, "myserver"), 0o755); + createManifest(dir, { + server: { + type: "binary", + entry_point: "myserver", + mcp_config: { command: "./myserver" }, + }, + }); + + const result = execSync(`node ${cliPath} validate ${dir}`, { + encoding: "utf-8", + }); + + expect(result).toContain("Manifest schema validation passes!"); + }); + }); + + describe("command variable validation", () => { + it("should fail on invalid variables like ${BUNDLE_ROOT}", () => { + const dir = join(fixturesDir, "invalid-var"); + fs.mkdirSync(join(dir, "server"), { recursive: true }); + fs.writeFileSync(join(dir, "server", "index.js"), "// fixture"); + createManifest(dir, { + server: { + type: "node", + entry_point: "server/index.js", + mcp_config: { + command: "node", + args: ["${BUNDLE_ROOT}/server/index.js"], + }, + }, + }); + + expect(() => { + execSync(`node ${cliPath} validate ${dir}`, { + encoding: "utf-8", + stdio: "pipe", + }); + }).toThrow(); + + try { + execSync(`node ${cliPath} validate ${dir}`, { + encoding: "utf-8", + stdio: "pipe", + }); + } catch (error: unknown) { + const execError = error as ExecSyncError; + const output = execError.stdout?.toString() || ""; + expect(output).toContain("Invalid variable"); + expect(output).toContain("${BUNDLE_ROOT}"); + } + }); + + it("should fail on invalid variables in env values", () => { + const dir = join(fixturesDir, "invalid-env-var"); + fs.mkdirSync(join(dir, "server"), { recursive: true }); + fs.writeFileSync(join(dir, "server", "index.js"), "// fixture"); + createManifest(dir, { + server: { + type: "node", + entry_point: "server/index.js", + mcp_config: { + command: "node", + args: ["${__dirname}/server/index.js"], + env: { PATH: "${HOME}/bin" }, + }, + }, + }); + + expect(() => { + execSync(`node ${cliPath} validate ${dir}`, { + encoding: "utf-8", + stdio: "pipe", + }); + }).toThrow(); + + try { + execSync(`node ${cliPath} validate ${dir}`, { + encoding: "utf-8", + stdio: "pipe", + }); + } catch (error: unknown) { + const execError = error as ExecSyncError; + const output = execError.stdout?.toString() || ""; + expect(output).toContain("Invalid variable"); + expect(output).toContain("${HOME}"); + } + }); + + it("should pass with valid variables: ${__dirname} and ${user_config.*}", () => { + const dir = join(fixturesDir, "valid-vars"); + fs.mkdirSync(join(dir, "server"), { recursive: true }); + fs.writeFileSync(join(dir, "server", "index.js"), "// fixture"); + createManifest(dir, { + server: { + type: "node", + entry_point: "server/index.js", + mcp_config: { + command: "node", + args: [ + "${__dirname}/server/index.js", + "--key", + "${user_config.api_key}", + ], + env: { SEP: "${pathSeparator}" }, + }, + }, + }); + + const result = execSync(`node ${cliPath} validate ${dir}`, { + encoding: "utf-8", + }); + + expect(result).toContain("Manifest schema validation passes!"); + expect(result).not.toContain("Invalid variable"); + }); + + it("should fail on invalid variables in platform_overrides", () => { + const dir = join(fixturesDir, "invalid-platform-var"); + fs.mkdirSync(join(dir, "server"), { recursive: true }); + fs.writeFileSync(join(dir, "server", "index.js"), "// fixture"); + + const manifest = { + manifest_version: "0.3", + name: "test-extension", + version: "1.0.0", + description: "Test", + author: { name: "Test" }, + server: { + type: "node", + entry_point: "server/index.js", + mcp_config: { + command: "node", + args: ["${__dirname}/server/index.js"], + platform_overrides: { + win32: { + args: ["${APPDATA}/server/index.js"], + }, + }, + }, + }, + }; + + fs.writeFileSync( + join(dir, "manifest.json"), + JSON.stringify(manifest, null, 2), + ); + + expect(() => { + execSync(`node ${cliPath} validate ${dir}`, { + encoding: "utf-8", + stdio: "pipe", + }); + }).toThrow(); + + try { + execSync(`node ${cliPath} validate ${dir}`, { + encoding: "utf-8", + stdio: "pipe", + }); + } catch (error: unknown) { + const execError = error as ExecSyncError; + const output = execError.stdout?.toString() || ""; + expect(output).toContain("Invalid variable"); + expect(output).toContain("${APPDATA}"); + } + }); + }); + + describe("sensitive file detection", () => { + it("should warn about credentials.json in project directory", () => { + const dir = join(fixturesDir, "sensitive-files"); + fs.mkdirSync(join(dir, "server"), { recursive: true }); + fs.writeFileSync(join(dir, "server", "index.js"), "// fixture"); + fs.writeFileSync(join(dir, "credentials.json"), '{"secret": "value"}'); + createManifest(dir); + + const result = execSync(`node ${cliPath} validate ${dir}`, { + encoding: "utf-8", + }); + + // Should pass (warnings only) but show the warning + expect(result).toContain("Manifest schema validation passes!"); + expect(result).toContain("Potentially sensitive file"); + expect(result).toContain("credentials.json"); + }); + + it("should warn about .pem files in project directory", () => { + const dir = join(fixturesDir, "sensitive-pem"); + fs.mkdirSync(join(dir, "server"), { recursive: true }); + fs.writeFileSync(join(dir, "server", "index.js"), "// fixture"); + fs.writeFileSync(join(dir, "server.pem"), "--- CERT ---"); + createManifest(dir); + + const result = execSync(`node ${cliPath} validate ${dir}`, { + encoding: "utf-8", + }); + + expect(result).toContain("Manifest schema validation passes!"); + expect(result).toContain("Potentially sensitive file"); + expect(result).toContain("server.pem"); + }); + }); + + describe("happy path", () => { + it("should pass with all files present and correct types", () => { + const dir = join(fixturesDir, "happy-path"); + fs.mkdirSync(join(dir, "server"), { recursive: true }); + fs.writeFileSync(join(dir, "server", "index.js"), "// server code"); + createManifest(dir); + + const result = execSync(`node ${cliPath} validate ${dir}`, { + encoding: "utf-8", + }); + + expect(result).toContain("Manifest schema validation passes!"); + expect(result).not.toContain("ERROR"); + expect(result).not.toContain("sensitive"); + }); + }); +}); From cb052a20e50f71cf946f7ad49141492f990810c5 Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Thu, 26 Mar 2026 08:23:18 -0500 Subject: [PATCH 13/18] fix: merge platform_overrides env with base env instead of replacing platform_overrides.*.env was replacing the entire mcp_config.env object instead of merging, causing base env vars (including ${user_config.*} references) to be silently dropped when platform overrides defined any env vars. Fixes #217 Co-Authored-By: Claude Opus 4.6 (1M context) --- src/shared/config.ts | 4 +++- test/config.test.ts | 48 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/shared/config.ts b/src/shared/config.ts index b4638bc..7073f58 100644 --- a/src/shared/config.ts +++ b/src/shared/config.ts @@ -117,7 +117,9 @@ export async function getMcpConfigForManifest( result.command = platformConfig.command || result.command; result.args = platformConfig.args || result.args; - result.env = platformConfig.env || result.env; + result.env = platformConfig.env + ? { ...result.env, ...platformConfig.env } + : result.env; } } diff --git a/test/config.test.ts b/test/config.test.ts index 1c34faf..7e29f69 100644 --- a/test/config.test.ts +++ b/test/config.test.ts @@ -269,6 +269,54 @@ describe("getMcpConfigForManifest", () => { expect(result?.args).toEqual(["server.js", "/user/path1", "/user/path2"]); }); + it("should merge platform override env with base env instead of replacing", async () => { + const manifest: McpbManifestAny = { + ...baseManifest, + user_config: { + data_directory: { + type: "directory", + title: "Data Directory", + description: "Where data lives", + required: true, + }, + }, + server: { + type: "node", + entry_point: "server.js", + mcp_config: { + command: "node", + args: ["server.js"], + env: { + DATA_DIR: "${user_config.data_directory}", + EXISTING_VAR: "keep-me", + }, + platform_overrides: { + [process.platform]: { + env: { + PATH: "/usr/local/bin:${HOME}/.local/bin", + }, + }, + }, + }, + }, + }; + + const result = await getMcpConfigForManifest({ + manifest, + extensionPath: "/ext/path", + systemDirs: { ...mockSystemDirs, HOME: "/home/user" }, + userConfig: { data_directory: "/custom/data" }, + pathSeparator: "/", + logger: mockLogger, + }); + + // Base env vars should be preserved after platform override merge + expect(result?.env?.DATA_DIR).toBe("/custom/data"); + expect(result?.env?.EXISTING_VAR).toBe("keep-me"); + // Platform override env should also be present + expect(result?.env?.PATH).toBe("/usr/local/bin:/home/user/.local/bin"); + }); + it("should convert boolean user config values to strings", async () => { const manifest: McpbManifestAny = { ...baseManifest, From 122ef0e9e98bfaf70944090acfc09323aa234aa9 Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Fri, 27 Mar 2026 09:18:30 -0500 Subject: [PATCH 14/18] fix: enforce executable permissions on binary entry points during pack When server.type is "binary", mcpb pack now ensures the entry_point file has execute bits (|0o111) in the ZIP external_attr, regardless of the source filesystem permissions. This prevents EACCES failures when Claude Desktop extracts Windows-built binary MCPBs (which store 644 because Windows has no Unix execute bit). Co-Authored-By: Claude Opus 4.6 (1M context) --- src/cli/pack.ts | 15 +++++++--- test/cli.test.ts | 77 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 4 deletions(-) diff --git a/src/cli/pack.ts b/src/cli/pack.ts index d2aba54..b4d0be9 100644 --- a/src/cli/pack.ts +++ b/src/cli/pack.ts @@ -206,15 +206,22 @@ export async function packExtension({ const zipFiles: Zippable = {}; const isUnix = process.platform !== "win32"; + const isBinaryType = manifest.server?.type === "binary"; + const binaryEntryPoint = isBinaryType ? manifest.server.entry_point : null; for (const [filePath, fileData] of Object.entries(files)) { if (isUnix) { + let mode = fileData.mode & 0o777; + // Ensure binary entry points are always executable in the ZIP, + // regardless of filesystem permissions. Windows-built ZIPs store + // 644 because Windows has no Unix execute bit — CD spawns binary + // entry points directly, so they must have +x to avoid EACCES. + if (binaryEntryPoint && filePath === binaryEntryPoint) { + mode = mode | 0o111; + } // Set external file attributes to preserve Unix permissions // The mode needs to be shifted to the upper 16 bits for ZIP format - zipFiles[filePath] = [ - fileData.data, - { os: 3, attrs: (fileData.mode & 0o777) << 16 }, - ]; + zipFiles[filePath] = [fileData.data, { os: 3, attrs: mode << 16 }]; } else { // On Windows, use default ZIP attributes (no Unix permissions) zipFiles[filePath] = fileData.data; diff --git a/test/cli.test.ts b/test/cli.test.ts index 7ecc402..907a783 100644 --- a/test/cli.test.ts +++ b/test/cli.test.ts @@ -357,5 +357,82 @@ describe("DXT CLI", () => { } } }); + + it("should add group+other execute bits on binary entry points during pack", () => { + // Skip this test on Windows since it doesn't support Unix permissions + if (process.platform === "win32") { + return; + } + + const tempBinDir = join(__dirname, "temp-binary-entry-test"); + const binPackedFilePath = join(__dirname, "test-binary-entry.dxt"); + const binUnpackedDir = join(__dirname, "temp-binary-entry-unpack"); + + try { + // Create a binary-type extension with owner-only execute (0o700) + // This passes validation (has some +x) but pack should add + // group+other execute bits for compatibility with CD extraction + fs.mkdirSync(join(tempBinDir, "server"), { recursive: true }); + fs.writeFileSync( + join(tempBinDir, "manifest.json"), + JSON.stringify({ + manifest_version: DEFAULT_MANIFEST_VERSION, + name: "Test Binary Extension", + version: "1.0.0", + description: "A test extension with binary entry point", + author: { + name: "MCPB", + }, + server: { + type: "binary", + entry_point: "server/myserver", + mcp_config: { + command: "${__dirname}/server/myserver", + }, + }, + }), + ); + + // Create binary entry point with 700 (owner-only execute) + fs.writeFileSync( + join(tempBinDir, "server", "myserver"), + "#!/bin/sh\necho binary", + ); + fs.chmodSync(join(tempBinDir, "server", "myserver"), 0o700); + + // Create a regular file for comparison (should stay 644) + fs.writeFileSync(join(tempBinDir, "config.json"), "{}"); + fs.chmodSync(join(tempBinDir, "config.json"), 0o644); + + // Pack the extension + execSync(`node ${cliPath} pack ${tempBinDir} ${binPackedFilePath}`, { + encoding: "utf-8", + }); + + // Unpack to check stored permissions + execSync( + `node ${cliPath} unpack ${binPackedFilePath} ${binUnpackedDir}`, + { + encoding: "utf-8", + }, + ); + + // Binary entry point should have full execute bits (700 | 111 = 711) + const entryStats = fs.statSync( + join(binUnpackedDir, "server", "myserver"), + ); + expect(entryStats.mode & 0o777).toBe(0o711); + + // Non-entry-point file should retain original permissions + const configStats = fs.statSync(join(binUnpackedDir, "config.json")); + expect(configStats.mode & 0o777).toBe(0o644); + } finally { + fs.rmSync(tempBinDir, { recursive: true, force: true }); + fs.rmSync(binUnpackedDir, { recursive: true, force: true }); + if (fs.existsSync(binPackedFilePath)) { + fs.unlinkSync(binPackedFilePath); + } + } + }); }); }); From dace08d31fa89e7026bcee17d4e85407a580e311 Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Fri, 17 Apr 2026 13:49:30 -0500 Subject: [PATCH 15/18] fix(examples/chrome-applescript): sanitize tab_id to prevent AppleScript injection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The inputSchema `type: "number"` is advisory only — runtime may receive a string payload that gets interpolated into the osascript template. Coerce tab_id via Number.parseInt before interpolating at all four sites. Affected sites: - findTabById(tabId) - executeTabOperation(tabId, ...) (close_tab, switch_to_tab, reload_tab, go_back, go_forward) - execute_javascript handler - get_page_content handler The shared toSafeTabId() helper returns null for missing values (preserving the active-tab fallthrough) and throws on non-numeric input (surfacing misuse via the existing request-level try/catch, consistent with the missing-code path in execute_javascript). --- examples/chrome-applescript/server/index.js | 43 +++++++++++++++------ 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/examples/chrome-applescript/server/index.js b/examples/chrome-applescript/server/index.js index dd96bdd..8ffb778 100644 --- a/examples/chrome-applescript/server/index.js +++ b/examples/chrome-applescript/server/index.js @@ -82,12 +82,28 @@ class ChromeControlServer { } } + // Coerce tab_id to a safe numeric value before interpolating into + // AppleScript. inputSchema type:"number" is advisory — runtime may receive + // a string, which would otherwise be injected into the osascript template. + toSafeTabId(tabId) { + if (tabId === null || tabId === undefined) return null; + const n = Number.parseInt(tabId, 10); + if (Number.isNaN(n)) { + throw new Error("tab_id must be a number"); + } + return n; + } + async findTabById(tabId) { + const safeTabId = this.toSafeTabId(tabId); + if (safeTabId === null) { + return { w: null, t: null, found: false }; + } const script = ` tell application "Google Chrome" repeat with w in windows repeat with t in tabs of w - if (id of t as string) is "${tabId}" then + if (id of t as string) is "${safeTabId}" then return {w, t, true} end if end repeat @@ -103,7 +119,8 @@ class ChromeControlServer { operation, successMessage = "Operation completed", ) { - if (!tabId) { + const safeTabId = this.toSafeTabId(tabId); + if (safeTabId === null) { // No tab ID, execute on active tab return this.executeAppleScript(operation.activeScript); } @@ -112,7 +129,7 @@ class ChromeControlServer { tell application "Google Chrome" repeat with w in windows repeat with t in tabs of w - if (id of t as string) is "${tabId}" then + if (id of t as string) is "${safeTabId}" then ${operation.tabScript} return "${successMessage}" end if @@ -551,6 +568,7 @@ class ChromeControlServer { "JavaScript code is required and must be a string", ); } + const safeTabId = this.toSafeTabId(tab_id); // Wrap the code to capture console.log outputs const wrappedCode = ` @@ -628,12 +646,13 @@ class ChromeControlServer { const escapedCode = this.escapeForAppleScript(wrappedCode); - const script = tab_id - ? ` + const script = + safeTabId != null + ? ` tell application "Google Chrome" repeat with w in windows repeat with t in tabs of w - if (id of t as string) is "${tab_id}" then + if (id of t as string) is "${safeTabId}" then set result to execute t javascript "${escapedCode}" return result end if @@ -642,7 +661,7 @@ class ChromeControlServer { return "Tab not found" end tell ` - : ` + : ` tell application "Google Chrome" execute active tab of front window javascript "${escapedCode}" end tell @@ -695,14 +714,16 @@ class ChromeControlServer { case "get_page_content": { const { tab_id } = args; + const safeTabId = this.toSafeTabId(tab_id); const jsCode = "document.body.innerText"; - const script = tab_id - ? ` + const script = + safeTabId != null + ? ` tell application "Google Chrome" repeat with w in windows repeat with t in tabs of w - if (id of t as string) is "${tab_id}" then + if (id of t as string) is "${safeTabId}" then set pageContent to execute t javascript "${jsCode}" return pageContent end if @@ -711,7 +732,7 @@ class ChromeControlServer { return "Tab not found" end tell ` - : ` + : ` tell application "Google Chrome" execute active tab of front window javascript "${jsCode}" end tell From 73f8475a80d48df534549d231d162c43ae1a9e80 Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Fri, 17 Apr 2026 14:22:56 -0500 Subject: [PATCH 16/18] fix(examples/chrome-applescript): use JSON.stringify for AppleScript string interpolation --- examples/chrome-applescript/server/index.js | 36 ++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/examples/chrome-applescript/server/index.js b/examples/chrome-applescript/server/index.js index 8ffb778..4f19b11 100644 --- a/examples/chrome-applescript/server/index.js +++ b/examples/chrome-applescript/server/index.js @@ -33,17 +33,6 @@ class ChromeControlServer { this.setupHandlers(); } - // Helper methods - escapeForAppleScript(str) { - if (typeof str !== "string") return str; - // Basic AppleScript string escaping - return str - .replace(/\\/g, "\\\\") // Escape backslashes first - .replace(/"/g, '\\"') // Then escape double quotes - .replace(/\n/g, "\\n") // Escape newlines - .replace(/\r/g, "\\r"); // Escape carriage returns - } - async checkChromeAvailable() { try { const script = 'tell application "Google Chrome" to return "available"'; @@ -289,10 +278,23 @@ class ChromeControlServer { throw new Error("URL is required and must be a string"); } - const escapedUrl = this.escapeForAppleScript(url); + try { + new URL(url); + } catch (error) { + return { + content: [ + { + type: "text", + text: `Error: url is not a valid url - ${error.message}`, + }, + ], + isError: true, + }; + } + const script = new_tab - ? `tell application "Google Chrome" to open location "${escapedUrl}"` - : `tell application "Google Chrome" to set URL of active tab of front window to "${escapedUrl}"`; + ? `tell application "Google Chrome" to open location ${JSON.stringify(url)}` + : `tell application "Google Chrome" to set URL of active tab of front window to ${JSON.stringify(url)}`; await this.executeAppleScript(script); return { @@ -644,8 +646,6 @@ class ChromeControlServer { })(); `; - const escapedCode = this.escapeForAppleScript(wrappedCode); - const script = safeTabId != null ? ` @@ -653,7 +653,7 @@ class ChromeControlServer { repeat with w in windows repeat with t in tabs of w if (id of t as string) is "${safeTabId}" then - set result to execute t javascript "${escapedCode}" + set result to execute t javascript ${JSON.stringify(wrappedCode)} return result end if end repeat @@ -663,7 +663,7 @@ class ChromeControlServer { ` : ` tell application "Google Chrome" - execute active tab of front window javascript "${escapedCode}" + execute active tab of front window javascript ${JSON.stringify(wrappedCode)} end tell `; From 5161613c798c4d6d568155eaab4e116e709f3b3e Mon Sep 17 00:00:00 2001 From: Bryan Thompson Date: Wed, 22 Apr 2026 10:51:05 -0500 Subject: [PATCH 17/18] docs: add "Publishing Your Bundle" section to README Covers the recommended distribution pattern (GitHub Release assets), tag convention for monorepos, per-platform asset naming, compatibility. platforms correctness, a minimum CI shape, and ${__dirname} guidance for relocatable entry points. --- README.md | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/README.md b/README.md index d9f1fbe..1fb6fde 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,81 @@ bundle.mcpb (ZIP file) - Include all required shared libraries if dynamic linking used - Test on clean systems without development tools +## Publishing Your Bundle + +Once you've packed an `.mcpb`, you need a way to distribute it. The recommended pattern is to attach it as an asset on a GitHub Release — tagged, versioned, and addressable without any additional hosting. + +### Why GitHub Releases + +- Release tags give consumers a stable, versioned URL per bundle. +- Standard tooling (`gh`, `curl`, release-feed polling) can pull assets directly. +- Monorepos can ship multiple bundles under different tag prefixes. +- No extra infrastructure to run. + +### Tag Convention + +Use a prefixed tag pattern so a single repository can ship more than one bundle: + +``` +- +``` + +Examples: + +``` +my-company-mcp-1.3.0 +analytics-mcp-2.0.1 +``` + +### Per-Platform Assets + +If your server bundles platform-specific binaries, attach one `.mcpb` per platform with a consistent naming suffix: + +``` +--darwin-arm64.mcpb +--darwin-x64.mcpb +--win32-x64.mcpb +``` + +If your server is cross-platform (Node.js, Python, pure script), a single `.mcpb` per release is sufficient. + +Declare `compatibility.platforms` in each bundle's `manifest.json` to match what's actually in the bundle. Do not list platforms you haven't built for — consumers rely on this field to reject incompatible installs. + +### Uploading from CI + +After `mcpb pack` produces the bundle: + +```sh +gh release upload "$TAG" dist/*.mcpb --clobber +``` + +`--clobber` keeps the release job idempotent on re-run. + +### Minimum CI Shape + +Triggered by a tag push or release event, a workflow does four things in order: + +1. **Build** your server for each target platform. +2. **Stage** `manifest.json` + server code + `icon.png` + `LICENSE` into a bundle directory. +3. **Pack** with `mcpb pack ` to produce the `.mcpb`. +4. **Upload** to the GitHub Release via `gh release upload`. + +Signing, if required by your policy, slots in between steps 3 and 4. + +### Entry Point Paths + +`manifest.json` should set `entry_point` to a relative path inside the bundle, and `mcp_config.args` should reference it via `${__dirname}`: + +```json +"entry_point": "server/index.js", +"mcp_config": { + "command": "node", + "args": ["${__dirname}/server/index.js"] +} +``` + +This keeps the bundle relocatable — consumers install to arbitrary paths, and `${__dirname}` resolves to the extracted bundle root at runtime. + # Contributing We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details. From b4acc3f73033b79dea4c8ef14fef1c1b6427f949 Mon Sep 17 00:00:00 2001 From: Tobin South Date: Wed, 22 Apr 2026 17:14:57 +0100 Subject: [PATCH 18/18] Revert "docs: add "Publishing Your Bundle" section to README" --- README.md | 75 ------------------------------------------------------- 1 file changed, 75 deletions(-) diff --git a/README.md b/README.md index 1fb6fde..d9f1fbe 100644 --- a/README.md +++ b/README.md @@ -139,81 +139,6 @@ bundle.mcpb (ZIP file) - Include all required shared libraries if dynamic linking used - Test on clean systems without development tools -## Publishing Your Bundle - -Once you've packed an `.mcpb`, you need a way to distribute it. The recommended pattern is to attach it as an asset on a GitHub Release — tagged, versioned, and addressable without any additional hosting. - -### Why GitHub Releases - -- Release tags give consumers a stable, versioned URL per bundle. -- Standard tooling (`gh`, `curl`, release-feed polling) can pull assets directly. -- Monorepos can ship multiple bundles under different tag prefixes. -- No extra infrastructure to run. - -### Tag Convention - -Use a prefixed tag pattern so a single repository can ship more than one bundle: - -``` -- -``` - -Examples: - -``` -my-company-mcp-1.3.0 -analytics-mcp-2.0.1 -``` - -### Per-Platform Assets - -If your server bundles platform-specific binaries, attach one `.mcpb` per platform with a consistent naming suffix: - -``` ---darwin-arm64.mcpb ---darwin-x64.mcpb ---win32-x64.mcpb -``` - -If your server is cross-platform (Node.js, Python, pure script), a single `.mcpb` per release is sufficient. - -Declare `compatibility.platforms` in each bundle's `manifest.json` to match what's actually in the bundle. Do not list platforms you haven't built for — consumers rely on this field to reject incompatible installs. - -### Uploading from CI - -After `mcpb pack` produces the bundle: - -```sh -gh release upload "$TAG" dist/*.mcpb --clobber -``` - -`--clobber` keeps the release job idempotent on re-run. - -### Minimum CI Shape - -Triggered by a tag push or release event, a workflow does four things in order: - -1. **Build** your server for each target platform. -2. **Stage** `manifest.json` + server code + `icon.png` + `LICENSE` into a bundle directory. -3. **Pack** with `mcpb pack ` to produce the `.mcpb`. -4. **Upload** to the GitHub Release via `gh release upload`. - -Signing, if required by your policy, slots in between steps 3 and 4. - -### Entry Point Paths - -`manifest.json` should set `entry_point` to a relative path inside the bundle, and `mcp_config.args` should reference it via `${__dirname}`: - -```json -"entry_point": "server/index.js", -"mcp_config": { - "command": "node", - "args": ["${__dirname}/server/index.js"] -} -``` - -This keeps the bundle relocatable — consumers install to arbitrary paths, and `${__dirname}` resolves to the extracted bundle root at runtime. - # Contributing We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.