feat: add --manifest flag to pack command (#87) · modelcontextprotocol/mcpb@f467163 · GitHub
Skip to content

Commit f467163

Browse files
feat: add --manifest flag to pack command (#87)
Allow specifying an external manifest file path with `mcpb pack --manifest <path>`. 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) <noreply@anthropic.com>
1 parent 1dca91e commit f467163

3 files changed

Lines changed: 127 additions & 18 deletions

File tree

‎src/cli/cli.ts‎

Lines changed: 27 additions & 16 deletions

‎src/cli/pack.ts‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ interface PackOptions {
2222
extensionPath: string;
2323
outputPath?: string;
2424
silent?: boolean;
25+
manifestPath?: string;
2526
}
2627

2728
function formatFileSize(bytes: number): string {
@@ -50,6 +51,7 @@ export async function packExtension({
5051
extensionPath,
5152
outputPath,
5253
silent,
54+
manifestPath: customManifestPath,
5355
}: PackOptions): Promise<boolean> {
5456
const resolvedPath = resolve(extensionPath);
5557
const logger = getLogger({ silent });
@@ -60,9 +62,18 @@ export async function packExtension({
6062
return false;
6163
}
6264

63-
// Check if manifest exists
64-
const manifestPath = join(resolvedPath, "manifest.json");
65+
// Resolve manifest path
66+
const manifestPath = customManifestPath
67+
? resolve(customManifestPath)
68+
: join(resolvedPath, "manifest.json");
69+
6570
if (!existsSync(manifestPath)) {
71+
if (customManifestPath) {
72+
// When --manifest is explicitly provided, error immediately
73+
logger.error(`ERROR: Manifest file not found: ${customManifestPath}`);
74+
return false;
75+
}
76+
6677
logger.log(`No manifest.json found in ${extensionPath}`);
6778
const shouldInit = await confirm({
6879
message: "Would you like to create a manifest.json file?",
@@ -135,6 +146,15 @@ export async function packExtension({
135146
mcpbIgnorePatterns,
136147
);
137148

149+
// When using a custom manifest path, inject the manifest into the bundle
150+
if (customManifestPath) {
151+
const manifestStat = statSync(manifestPath);
152+
files["manifest.json"] = {
153+
data: readFileSync(manifestPath),
154+
mode: manifestStat.mode,
155+
};
156+
}
157+
138158
// Print package header
139159
logger.log(`\n📦 ${manifest.name}@${manifest.version}`);
140160

‎test/cli.test.ts‎

Lines changed: 78 additions & 0 deletions

0 commit comments

Comments
 (0)