frontmcp 1.0.4 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +10 -4
- package/src/commands/build/adapters/cloudflare.d.ts +1 -1
- package/src/commands/build/adapters/cloudflare.js +1 -0
- package/src/commands/build/adapters/cloudflare.js.map +1 -1
- package/src/commands/build/adapters/distributed.d.ts +15 -0
- package/src/commands/build/adapters/distributed.js +30 -0
- package/src/commands/build/adapters/distributed.js.map +1 -0
- package/src/commands/build/adapters/index.d.ts +3 -2
- package/src/commands/build/adapters/index.js +4 -1
- package/src/commands/build/adapters/index.js.map +1 -1
- package/src/commands/build/adapters/lambda.d.ts +1 -1
- package/src/commands/build/adapters/lambda.js +1 -0
- package/src/commands/build/adapters/lambda.js.map +1 -1
- package/src/commands/build/adapters/vercel.d.ts +1 -1
- package/src/commands/build/adapters/vercel.js +1 -0
- package/src/commands/build/adapters/vercel.js.map +1 -1
- package/src/commands/build/exec/cli-runtime/generate-cli-entry.js +122 -34
- package/src/commands/build/exec/cli-runtime/generate-cli-entry.js.map +1 -1
- package/src/commands/build/exec/config.d.ts +2 -2
- package/src/commands/build/exec/config.js.map +1 -1
- package/src/commands/build/exec/esbuild-bundler.d.ts +1 -1
- package/src/commands/build/exec/esbuild-bundler.js +1 -1
- package/src/commands/build/exec/esbuild-bundler.js.map +1 -1
- package/src/commands/build/exec/index.d.ts +1 -1
- package/src/commands/build/exec/index.js +5 -38
- package/src/commands/build/exec/index.js.map +1 -1
- package/src/commands/build/exec/skill-assets.d.ts +27 -0
- package/src/commands/build/exec/skill-assets.js +60 -0
- package/src/commands/build/exec/skill-assets.js.map +1 -0
- package/src/commands/build/index.d.ts +1 -1
- package/src/commands/build/index.js +44 -5
- package/src/commands/build/index.js.map +1 -1
- package/src/commands/build/mcpb/binary.d.ts +37 -0
- package/src/commands/build/mcpb/binary.js +72 -0
- package/src/commands/build/mcpb/binary.js.map +1 -0
- package/src/commands/build/mcpb/constants.d.ts +21 -0
- package/src/commands/build/mcpb/constants.js +31 -0
- package/src/commands/build/mcpb/constants.js.map +1 -0
- package/src/commands/build/mcpb/index.d.ts +20 -0
- package/src/commands/build/mcpb/index.js +241 -0
- package/src/commands/build/mcpb/index.js.map +1 -0
- package/src/commands/build/mcpb/manifest.d.ts +183 -0
- package/src/commands/build/mcpb/manifest.js +252 -0
- package/src/commands/build/mcpb/manifest.js.map +1 -0
- package/src/commands/build/mcpb/stage.d.ts +50 -0
- package/src/commands/build/mcpb/stage.js +94 -0
- package/src/commands/build/mcpb/stage.js.map +1 -0
- package/src/commands/build/mcpb/user-config.d.ts +26 -0
- package/src/commands/build/mcpb/user-config.js +147 -0
- package/src/commands/build/mcpb/user-config.js.map +1 -0
- package/src/commands/build/mcpb/validate.d.ts +27 -0
- package/src/commands/build/mcpb/validate.js +218 -0
- package/src/commands/build/mcpb/validate.js.map +1 -0
- package/src/commands/build/mcpb/zip.d.ts +37 -0
- package/src/commands/build/mcpb/zip.js +85 -0
- package/src/commands/build/mcpb/zip.js.map +1 -0
- package/src/commands/build/register.d.ts +1 -1
- package/src/commands/build/register.js +7 -1
- package/src/commands/build/register.js.map +1 -1
- package/src/commands/build/sdk/index.d.ts +1 -1
- package/src/commands/build/sdk/index.js +1 -1
- package/src/commands/build/sdk/index.js.map +1 -1
- package/src/commands/build/types.d.ts +1 -1
- package/src/commands/build/types.js.map +1 -1
- package/src/commands/mcpb/register.d.ts +2 -0
- package/src/commands/mcpb/register.js +14 -0
- package/src/commands/mcpb/register.js.map +1 -0
- package/src/commands/mcpb/validate.d.ts +1 -0
- package/src/commands/mcpb/validate.js +28 -0
- package/src/commands/mcpb/validate.js.map +1 -0
- package/src/commands/scaffold/create.js +5 -7
- package/src/commands/scaffold/create.js.map +1 -1
- package/src/config/define-config.d.ts +26 -0
- package/src/config/define-config.js +31 -0
- package/src/config/define-config.js.map +1 -0
- package/src/config/frontmcp-config.loader.d.ts +32 -0
- package/src/config/frontmcp-config.loader.js +113 -0
- package/src/config/frontmcp-config.loader.js.map +1 -0
- package/src/config/frontmcp-config.schema.d.ts +1062 -0
- package/src/config/frontmcp-config.schema.js +313 -0
- package/src/config/frontmcp-config.schema.js.map +1 -0
- package/src/config/frontmcp-config.types.d.ts +287 -0
- package/src/config/frontmcp-config.types.js +14 -0
- package/src/config/frontmcp-config.types.js.map +1 -0
- package/src/config/index.d.ts +5 -0
- package/src/config/index.js +13 -0
- package/src/config/index.js.map +1 -0
- package/src/core/args.d.ts +7 -2
- package/src/core/args.js +12 -2
- package/src/core/args.js.map +1 -1
- package/src/core/bridge.d.ts +1 -1
- package/src/core/bridge.js +10 -0
- package/src/core/bridge.js.map +1 -1
- package/src/core/cli.js +3 -1
- package/src/core/cli.js.map +1 -1
- package/src/core/program.js +15 -13
- package/src/core/program.js.map +1 -1
- package/src/index.d.ts +2 -0
- package/src/index.js +7 -0
- package/src/index.js.map +1 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* buildMcpb() — produce a `.mcpb` archive (MCP Bundle, spec v0.3).
|
|
3
|
+
*
|
|
4
|
+
* Pipeline:
|
|
5
|
+
* 1. Load exec config, resolve entry, compile TypeScript (reuses exec).
|
|
6
|
+
* 2. Bundle via esbuild (reuses exec's bundler).
|
|
7
|
+
* 3. Extract tool/prompt/skill schema from the compiled bundle.
|
|
8
|
+
* 4. Optionally build an SEA binary for the host platform.
|
|
9
|
+
* 5. Stage the MCPB layout on disk (manifest + server/ + bin/ + icon + README).
|
|
10
|
+
* 6. Deterministic zip → {outDir}/{name}-{version}.mcpb
|
|
11
|
+
* 7. Clean up intermediates unless --stage-only.
|
|
12
|
+
*/
|
|
13
|
+
import type { ParsedArgs } from '../../../core/args';
|
|
14
|
+
import { type FrontMcpConfigParsed } from '../../../config';
|
|
15
|
+
import type { McpbDeployment } from '../../../config/frontmcp-config.types';
|
|
16
|
+
export interface BuildMcpbOptions extends ParsedArgs {
|
|
17
|
+
/** Resolved MCPB deployment config (from frontmcp.config if present). */
|
|
18
|
+
mcpbDeployment?: McpbDeployment;
|
|
19
|
+
}
|
|
20
|
+
export declare function buildMcpb(opts: BuildMcpbOptions, configParsed?: FrontMcpConfigParsed): Promise<void>;
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* buildMcpb() — produce a `.mcpb` archive (MCP Bundle, spec v0.3).
|
|
4
|
+
*
|
|
5
|
+
* Pipeline:
|
|
6
|
+
* 1. Load exec config, resolve entry, compile TypeScript (reuses exec).
|
|
7
|
+
* 2. Bundle via esbuild (reuses exec's bundler).
|
|
8
|
+
* 3. Extract tool/prompt/skill schema from the compiled bundle.
|
|
9
|
+
* 4. Optionally build an SEA binary for the host platform.
|
|
10
|
+
* 5. Stage the MCPB layout on disk (manifest + server/ + bin/ + icon + README).
|
|
11
|
+
* 6. Deterministic zip → {outDir}/{name}-{version}.mcpb
|
|
12
|
+
* 7. Clean up intermediates unless --stage-only.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.buildMcpb = buildMcpb;
|
|
16
|
+
const tslib_1 = require("tslib");
|
|
17
|
+
const fs = tslib_1.__importStar(require("fs"));
|
|
18
|
+
const path = tslib_1.__importStar(require("path"));
|
|
19
|
+
const utils_1 = require("@frontmcp/utils");
|
|
20
|
+
const colors_1 = require("../../../core/colors");
|
|
21
|
+
const fs_1 = require("../../../shared/fs");
|
|
22
|
+
const tsconfig_1 = require("../../../core/tsconfig");
|
|
23
|
+
const config_1 = require("../../../config");
|
|
24
|
+
const config_2 = require("../exec/config");
|
|
25
|
+
const esbuild_bundler_1 = require("../exec/esbuild-bundler");
|
|
26
|
+
const binary_1 = require("./binary");
|
|
27
|
+
const manifest_1 = require("./manifest");
|
|
28
|
+
const user_config_1 = require("./user-config");
|
|
29
|
+
const stage_1 = require("./stage");
|
|
30
|
+
const zip_1 = require("./zip");
|
|
31
|
+
const constants_1 = require("./constants");
|
|
32
|
+
const version_1 = require("../../../core/version");
|
|
33
|
+
async function buildMcpb(opts, configParsed) {
|
|
34
|
+
const cwd = process.cwd();
|
|
35
|
+
const outDir = path.resolve(cwd, opts.outDir || 'dist');
|
|
36
|
+
console.log(`${(0, colors_1.c)('cyan', '[build:mcpb]')} Building MCP Bundle...`);
|
|
37
|
+
// Snapshot outDir before any build work so cleanup only removes artifacts
|
|
38
|
+
// this build produced — files the user had sitting there are preserved.
|
|
39
|
+
const preExistingEntries = fs.existsSync(outDir)
|
|
40
|
+
? new Set(fs.readdirSync(outDir))
|
|
41
|
+
: new Set();
|
|
42
|
+
// 1. Resolve exec + mcpb config
|
|
43
|
+
const rawConfig = await (0, config_2.loadExecConfig)(cwd);
|
|
44
|
+
const execConfig = (0, config_2.normalizeConfig)(rawConfig);
|
|
45
|
+
// When a v1 frontmcp.config is present, its build.esbuild / build.dependencies
|
|
46
|
+
// win — the legacy loader returns the raw file without merging these.
|
|
47
|
+
if (configParsed?.build?.esbuild) {
|
|
48
|
+
execConfig.esbuild = {
|
|
49
|
+
...(execConfig.esbuild ?? {}),
|
|
50
|
+
...configParsed.build.esbuild,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (configParsed?.build?.dependencies?.nativeAddons) {
|
|
54
|
+
execConfig.dependencies = {
|
|
55
|
+
...(execConfig.dependencies ?? {}),
|
|
56
|
+
nativeAddons: [
|
|
57
|
+
...(execConfig.dependencies?.nativeAddons ?? []),
|
|
58
|
+
...configParsed.build.dependencies.nativeAddons,
|
|
59
|
+
],
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
if (configParsed?.nodeVersion) {
|
|
63
|
+
execConfig.nodeVersion = configParsed.nodeVersion;
|
|
64
|
+
}
|
|
65
|
+
const mcpbDeployment = opts.mcpbDeployment
|
|
66
|
+
?? (configParsed ? (0, config_1.findDeployment)(configParsed, 'mcpb') : undefined);
|
|
67
|
+
console.log(`${(0, colors_1.c)('cyan', '[build:mcpb]')} name: ${execConfig.name}`);
|
|
68
|
+
console.log(`${(0, colors_1.c)('cyan', '[build:mcpb]')} version: ${execConfig.version}`);
|
|
69
|
+
// 2. Resolve entry
|
|
70
|
+
const entry = await (0, fs_1.resolveEntry)(cwd, execConfig.entry || opts.entry);
|
|
71
|
+
console.log(`${(0, colors_1.c)('cyan', '[build:mcpb]')} entry: ${path.relative(cwd, entry)}`);
|
|
72
|
+
// 3. TypeScript compile (same as exec pipeline)
|
|
73
|
+
await (0, utils_1.ensureDir)(outDir);
|
|
74
|
+
const tsconfigPath = path.join(cwd, 'tsconfig.json');
|
|
75
|
+
const hasTsconfig = await (0, utils_1.fileExists)(tsconfigPath);
|
|
76
|
+
const tscArgs = ['-y', 'tsc'];
|
|
77
|
+
if (hasTsconfig) {
|
|
78
|
+
tscArgs.push('--project', tsconfigPath);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
tscArgs.push(entry);
|
|
82
|
+
tscArgs.push('--rootDir', path.dirname(entry));
|
|
83
|
+
tscArgs.push('--experimentalDecorators', '--emitDecoratorMetadata');
|
|
84
|
+
tscArgs.push('--target', tsconfig_1.REQUIRED_DECORATOR_FIELDS.target);
|
|
85
|
+
}
|
|
86
|
+
tscArgs.push('--module', 'commonjs', '--outDir', outDir, '--skipLibCheck');
|
|
87
|
+
await (0, utils_1.runCmd)('npx', tscArgs);
|
|
88
|
+
console.log(`${(0, colors_1.c)('green', '[build:mcpb]')} TypeScript compiled`);
|
|
89
|
+
// 4. esbuild bundle → dist/{name}.bundle.js
|
|
90
|
+
const compiledEntry = path.join(outDir, path.basename(entry).replace(/\.tsx?$/, '.js'));
|
|
91
|
+
const bundleResult = await (0, esbuild_bundler_1.bundleWithEsbuild)(compiledEntry, outDir, execConfig);
|
|
92
|
+
console.log(`${(0, colors_1.c)('green', '[build:mcpb]')} bundle: ${path.relative(cwd, bundleResult.bundlePath)} (${(0, esbuild_bundler_1.formatSize)(bundleResult.bundleSize)})`);
|
|
93
|
+
// 5. Schema extraction
|
|
94
|
+
const { extractSchemas, SYSTEM_TOOL_NAMES } = await import('../exec/cli-runtime/schema-extractor.js');
|
|
95
|
+
const schema = await extractSchemas(bundleResult.bundlePath);
|
|
96
|
+
const userToolCount = schema.tools.filter((t) => !SYSTEM_TOOL_NAMES.has(t.name)).length;
|
|
97
|
+
console.log(`${(0, colors_1.c)('cyan', '[build:mcpb]')} extracted: ${userToolCount} tools, ${schema.resources.length} resources, ${schema.prompts.length} prompts`);
|
|
98
|
+
// 6. SEA binaries (optional)
|
|
99
|
+
const seaRequested = !!(opts.sea || mcpbDeployment?.sea?.enabled);
|
|
100
|
+
const mergeFrom = opts.mergeFrom ?? mcpbDeployment?.sea?.mergeFrom;
|
|
101
|
+
const binaries = [];
|
|
102
|
+
if (seaRequested) {
|
|
103
|
+
const hostPlatform = (0, binary_1.resolveHostPlatform)();
|
|
104
|
+
if (!hostPlatform) {
|
|
105
|
+
console.log(`${(0, colors_1.c)('yellow', '[build:mcpb]')} Unknown host platform ${process.platform}-${process.arch}; skipping SEA build`);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
console.log(`${(0, colors_1.c)('cyan', '[build:mcpb]')} building SEA binary for ${hostPlatform}...`);
|
|
109
|
+
const seaBundleName = `${execConfig.name}.sea-temp`;
|
|
110
|
+
const seaBundle = await (0, esbuild_bundler_1.bundleWithEsbuild)(compiledEntry, outDir, execConfig, {
|
|
111
|
+
selfContained: true,
|
|
112
|
+
outputName: seaBundleName,
|
|
113
|
+
});
|
|
114
|
+
const { buildSea } = await import('../exec/sea-builder.js');
|
|
115
|
+
const seaResult = await buildSea(seaBundle.bundlePath, outDir, execConfig.name);
|
|
116
|
+
fs.unlinkSync(seaBundle.bundlePath);
|
|
117
|
+
binaries.push({
|
|
118
|
+
platform: hostPlatform,
|
|
119
|
+
srcPath: seaResult.executablePath,
|
|
120
|
+
fileName: (0, binary_1.binaryFileName)(execConfig.name, hostPlatform),
|
|
121
|
+
});
|
|
122
|
+
console.log(`${(0, colors_1.c)('green', '[build:mcpb]')} SEA binary: ${path.relative(cwd, seaResult.executablePath)} (${(0, esbuild_bundler_1.formatSize)(seaResult.executableSize)})`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (mergeFrom) {
|
|
126
|
+
const absMergeDir = path.isAbsolute(mergeFrom) ? mergeFrom : path.resolve(cwd, mergeFrom);
|
|
127
|
+
const merged = (0, binary_1.mergeBinariesFrom)(absMergeDir, execConfig.name);
|
|
128
|
+
if (merged.length === 0) {
|
|
129
|
+
console.log(`${(0, colors_1.c)('yellow', '[build:mcpb]')} mergeFrom "${absMergeDir}" produced no binaries`);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
console.log(`${(0, colors_1.c)('cyan', '[build:mcpb]')} merging ${merged.length} cross-platform binaries from ${path.relative(cwd, absMergeDir)}`);
|
|
133
|
+
// Replace any duplicate platform entries from the local SEA build with merge-from versions.
|
|
134
|
+
for (const bin of merged) {
|
|
135
|
+
const idx = binaries.findIndex((b) => b.platform === bin.platform);
|
|
136
|
+
if (idx >= 0)
|
|
137
|
+
binaries.splice(idx, 1);
|
|
138
|
+
binaries.push(bin);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// 7. Translate setup steps → user_config + env
|
|
143
|
+
const { userConfig, env: userConfigEnv, warnings } = (0, user_config_1.setupStepsToUserConfig)(execConfig.setup?.steps, mcpbDeployment);
|
|
144
|
+
for (const w of warnings) {
|
|
145
|
+
console.log(`${(0, colors_1.c)('yellow', '[build:mcpb]')} ${w}`);
|
|
146
|
+
}
|
|
147
|
+
// 8. Stage — outDir is already {dist}/mcpb (set by buildSingleTarget per-target layout)
|
|
148
|
+
const stageDir = path.join(outDir, '__stage');
|
|
149
|
+
if (fs.existsSync(stageDir)) {
|
|
150
|
+
fs.rmSync(stageDir, { recursive: true, force: true });
|
|
151
|
+
}
|
|
152
|
+
const iconOverride = opts.icon ?? mcpbDeployment?.icon;
|
|
153
|
+
const pkgMeta = (0, manifest_1.loadPackageJsonMeta)(cwd);
|
|
154
|
+
const iconAbs = (0, manifest_1.resolveIconPath)(cwd, iconOverride, pkgMeta.icon);
|
|
155
|
+
const iconAbsPath = iconAbs ? path.resolve(cwd, iconAbs) : undefined;
|
|
156
|
+
const stageResult = (0, stage_1.stageMcpbDirectory)({
|
|
157
|
+
stageDir,
|
|
158
|
+
cwd,
|
|
159
|
+
serverBundlePath: bundleResult.bundlePath,
|
|
160
|
+
name: execConfig.name,
|
|
161
|
+
version: execConfig.version,
|
|
162
|
+
schema,
|
|
163
|
+
iconPath: iconAbsPath,
|
|
164
|
+
binaries,
|
|
165
|
+
});
|
|
166
|
+
if (stageResult.skillAssetCount > 0) {
|
|
167
|
+
console.log(`${(0, colors_1.c)('green', '[build:mcpb]')} copied ${stageResult.skillAssetCount} skill asset(s) to server/_skills/`);
|
|
168
|
+
}
|
|
169
|
+
if (stageResult.hasIcon) {
|
|
170
|
+
console.log(`${(0, colors_1.c)('green', '[build:mcpb]')} icon: ${iconAbs}`);
|
|
171
|
+
}
|
|
172
|
+
// 9. Manifest
|
|
173
|
+
const platformOverrides = (0, binary_1.buildPlatformOverrides)(binaries);
|
|
174
|
+
const manifest = (0, manifest_1.generateMcpbManifest)({
|
|
175
|
+
name: execConfig.name,
|
|
176
|
+
version: execConfig.version,
|
|
177
|
+
nodeVersion: execConfig.nodeVersion,
|
|
178
|
+
cwd,
|
|
179
|
+
deployment: mcpbDeployment,
|
|
180
|
+
schema,
|
|
181
|
+
userConfig,
|
|
182
|
+
userConfigEnv,
|
|
183
|
+
platformOverrides,
|
|
184
|
+
hasIcon: stageResult.hasIcon,
|
|
185
|
+
cliVersion: (0, version_1.getSelfVersion)(),
|
|
186
|
+
});
|
|
187
|
+
(0, stage_1.writeManifest)(stageDir, manifest);
|
|
188
|
+
console.log(`${(0, colors_1.c)('green', '[build:mcpb]')} wrote manifest.json`);
|
|
189
|
+
// 10. Zip (unless --stage-only)
|
|
190
|
+
if (opts.stageOnly) {
|
|
191
|
+
console.log(`${(0, colors_1.c)('yellow', '[build:mcpb]')} --stage-only set; leaving ${path.relative(cwd, stageDir)} for inspection`);
|
|
192
|
+
cleanupIntermediates(outDir, preExistingEntries, ['__stage']);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
const archivePath = path.join(outDir, `${execConfig.name}-${execConfig.version}.mcpb`);
|
|
196
|
+
const zipResult = await (0, zip_1.createDeterministicZip)(stageDir, archivePath, {
|
|
197
|
+
deterministic: !opts.noDeterministic && (mcpbDeployment?.deterministic ?? true),
|
|
198
|
+
});
|
|
199
|
+
console.log(`${(0, colors_1.c)('green', '[build:mcpb]')} ${path.relative(cwd, zipResult.archivePath)} (${(0, esbuild_bundler_1.formatSize)(zipResult.size)})`);
|
|
200
|
+
console.log(`${(0, colors_1.c)('gray', '[build:mcpb]')} sha256: ${zipResult.sha256}`);
|
|
201
|
+
if (zipResult.size > constants_1.ARCHIVE_SIZE_ERROR) {
|
|
202
|
+
console.log(`${(0, colors_1.c)('yellow', '[build:mcpb]')} Archive is ${(zipResult.size / 1024 / 1024).toFixed(1)} MB — consider tuning externals`);
|
|
203
|
+
}
|
|
204
|
+
else if (zipResult.size > constants_1.ARCHIVE_SIZE_WARN) {
|
|
205
|
+
console.log(`${(0, colors_1.c)('yellow', '[build:mcpb]')} Archive is ${(zipResult.size / 1024 / 1024).toFixed(1)} MB`);
|
|
206
|
+
}
|
|
207
|
+
// 11. Cleanup
|
|
208
|
+
fs.rmSync(stageDir, { recursive: true, force: true });
|
|
209
|
+
cleanupIntermediates(outDir, preExistingEntries, [`${execConfig.name}-${execConfig.version}.mcpb`]);
|
|
210
|
+
console.log(`\n${(0, colors_1.c)('green', 'MCPB build completed.')}`);
|
|
211
|
+
console.log(`${(0, colors_1.c)('gray', 'Install:')} open ${path.relative(cwd, zipResult.archivePath)}`);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Remove intermediates this build produced, leaving pre-existing files and the
|
|
215
|
+
* keep-list alone. The tsc + esbuild stages write intermediates directly into
|
|
216
|
+
* outDir (same pattern as the exec target uses); we keep the archive and — in
|
|
217
|
+
* stage-only mode — the `__stage/` directory so the user can inspect it.
|
|
218
|
+
*
|
|
219
|
+
* `preExisting` is the set of entries that were in `outDir` before the build
|
|
220
|
+
* started. Anything in that set is preserved unconditionally so a shared
|
|
221
|
+
* outDir (e.g., `--out-dir dist` alongside other targets) is not clobbered.
|
|
222
|
+
*/
|
|
223
|
+
function cleanupIntermediates(outDir, preExisting, keep) {
|
|
224
|
+
if (!fs.existsSync(outDir))
|
|
225
|
+
return;
|
|
226
|
+
const keepSet = new Set(keep);
|
|
227
|
+
for (const entry of fs.readdirSync(outDir)) {
|
|
228
|
+
if (keepSet.has(entry))
|
|
229
|
+
continue;
|
|
230
|
+
if (preExisting.has(entry))
|
|
231
|
+
continue;
|
|
232
|
+
const full = path.join(outDir, entry);
|
|
233
|
+
try {
|
|
234
|
+
fs.rmSync(full, { recursive: true, force: true });
|
|
235
|
+
}
|
|
236
|
+
catch {
|
|
237
|
+
// best-effort — a race with an external process shouldn't fail the build
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/commands/build/mcpb/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;AA0BH,8BAyNC;;AAjPD,+CAAyB;AACzB,mDAA6B;AAC7B,2CAAgE;AAEhE,iDAAyC;AACzC,2CAAkD;AAClD,qDAAmE;AACnE,4CAA4E;AAE5E,2CAAiE;AACjE,6DAAwE;AACxE,qCAA4H;AAC5H,yCAAwF;AACxF,+CAAuD;AACvD,mCAA4D;AAC5D,+BAA+C;AAC/C,2CAAoE;AACpE,mDAAuD;AAOhD,KAAK,UAAU,SAAS,CAC7B,IAAsB,EACtB,YAAmC;IAE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,MAAM,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACpD,CAAC;QAAC,MAAM,CAAC;YACP,yEAAyE;QAC3E,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/**\n * buildMcpb() — produce a `.mcpb` archive (MCP Bundle, spec v0.3).\n *\n * Pipeline:\n * 1. Load exec config, resolve entry, compile TypeScript (reuses exec).\n * 2. Bundle via esbuild (reuses exec's bundler).\n * 3. Extract tool/prompt/skill schema from the compiled bundle.\n * 4. Optionally build an SEA binary for the host platform.\n * 5. Stage the MCPB layout on disk (manifest + server/ + bin/ + icon + README).\n * 6. Deterministic zip → {outDir}/{name}-{version}.mcpb\n * 7. Clean up intermediates unless --stage-only.\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { ensureDir, fileExists, runCmd } from '@frontmcp/utils';\nimport type { ParsedArgs } from '../../../core/args';\nimport { c } from '../../../core/colors';\nimport { resolveEntry } from '../../../shared/fs';\nimport { REQUIRED_DECORATOR_FIELDS } from '../../../core/tsconfig';\nimport { findDeployment, type FrontMcpConfigParsed } from '../../../config';\nimport type { McpbDeployment } from '../../../config/frontmcp-config.types';\nimport { loadExecConfig, normalizeConfig } from '../exec/config';\nimport { bundleWithEsbuild, formatSize } from '../exec/esbuild-bundler';\nimport { buildPlatformOverrides, mergeBinariesFrom, resolveHostPlatform, binaryFileName, type BinaryEntry } from './binary';\nimport { generateMcpbManifest, loadPackageJsonMeta, resolveIconPath } from './manifest';\nimport { setupStepsToUserConfig } from './user-config';\nimport { stageMcpbDirectory, writeManifest } from './stage';\nimport { createDeterministicZip } from './zip';\nimport { ARCHIVE_SIZE_ERROR, ARCHIVE_SIZE_WARN } from './constants';\nimport { getSelfVersion } from '../../../core/version';\n\nexport interface BuildMcpbOptions extends ParsedArgs {\n /** Resolved MCPB deployment config (from frontmcp.config if present). */\n mcpbDeployment?: McpbDeployment;\n}\n\nexport async function buildMcpb(\n opts: BuildMcpbOptions,\n configParsed?: FrontMcpConfigParsed,\n): Promise<void> {\n const cwd = process.cwd();\n const outDir = path.resolve(cwd, opts.outDir || 'dist');\n\n console.log(`${c('cyan', '[build:mcpb]')} Building MCP Bundle...`);\n\n // Snapshot outDir before any build work so cleanup only removes artifacts\n // this build produced — files the user had sitting there are preserved.\n const preExistingEntries = fs.existsSync(outDir)\n ? new Set<string>(fs.readdirSync(outDir))\n : new Set<string>();\n\n // 1. Resolve exec + mcpb config\n const rawConfig = await loadExecConfig(cwd);\n const execConfig = normalizeConfig(rawConfig);\n\n // When a v1 frontmcp.config is present, its build.esbuild / build.dependencies\n // win — the legacy loader returns the raw file without merging these.\n if (configParsed?.build?.esbuild) {\n execConfig.esbuild = {\n ...(execConfig.esbuild ?? {}),\n ...configParsed.build.esbuild,\n };\n }\n if (configParsed?.build?.dependencies?.nativeAddons) {\n execConfig.dependencies = {\n ...(execConfig.dependencies ?? {}),\n nativeAddons: [\n ...(execConfig.dependencies?.nativeAddons ?? []),\n ...configParsed.build.dependencies.nativeAddons,\n ],\n };\n }\n if (configParsed?.nodeVersion) {\n execConfig.nodeVersion = configParsed.nodeVersion;\n }\n\n const mcpbDeployment =\n opts.mcpbDeployment\n ?? (configParsed ? (findDeployment(configParsed, 'mcpb') as McpbDeployment | undefined) : undefined);\n\n console.log(`${c('cyan', '[build:mcpb]')} name: ${execConfig.name}`);\n console.log(`${c('cyan', '[build:mcpb]')} version: ${execConfig.version}`);\n\n // 2. Resolve entry\n const entry = await resolveEntry(cwd, execConfig.entry || opts.entry);\n console.log(`${c('cyan', '[build:mcpb]')} entry: ${path.relative(cwd, entry)}`);\n\n // 3. TypeScript compile (same as exec pipeline)\n await ensureDir(outDir);\n const tsconfigPath = path.join(cwd, 'tsconfig.json');\n const hasTsconfig = await fileExists(tsconfigPath);\n const tscArgs: string[] = ['-y', 'tsc'];\n if (hasTsconfig) {\n tscArgs.push('--project', tsconfigPath);\n } else {\n tscArgs.push(entry);\n tscArgs.push('--rootDir', path.dirname(entry));\n tscArgs.push('--experimentalDecorators', '--emitDecoratorMetadata');\n tscArgs.push('--target', REQUIRED_DECORATOR_FIELDS.target);\n }\n tscArgs.push('--module', 'commonjs', '--outDir', outDir, '--skipLibCheck');\n await runCmd('npx', tscArgs);\n console.log(`${c('green', '[build:mcpb]')} TypeScript compiled`);\n\n // 4. esbuild bundle → dist/{name}.bundle.js\n const compiledEntry = path.join(outDir, path.basename(entry).replace(/\\.tsx?$/, '.js'));\n const bundleResult = await bundleWithEsbuild(compiledEntry, outDir, execConfig);\n console.log(\n `${c('green', '[build:mcpb]')} bundle: ${path.relative(cwd, bundleResult.bundlePath)} (${formatSize(bundleResult.bundleSize)})`,\n );\n\n // 5. Schema extraction\n const { extractSchemas, SYSTEM_TOOL_NAMES } = await import('../exec/cli-runtime/schema-extractor.js');\n const schema = await extractSchemas(bundleResult.bundlePath);\n const userToolCount = schema.tools.filter((t) => !SYSTEM_TOOL_NAMES.has(t.name)).length;\n console.log(\n `${c('cyan', '[build:mcpb]')} extracted: ${userToolCount} tools, ${schema.resources.length} resources, ${schema.prompts.length} prompts`,\n );\n\n // 6. SEA binaries (optional)\n const seaRequested = !!(opts.sea || mcpbDeployment?.sea?.enabled);\n const mergeFrom = opts.mergeFrom ?? mcpbDeployment?.sea?.mergeFrom;\n const binaries: BinaryEntry[] = [];\n\n if (seaRequested) {\n const hostPlatform = resolveHostPlatform();\n if (!hostPlatform) {\n console.log(\n `${c('yellow', '[build:mcpb]')} Unknown host platform ${process.platform}-${process.arch}; skipping SEA build`,\n );\n } else {\n console.log(`${c('cyan', '[build:mcpb]')} building SEA binary for ${hostPlatform}...`);\n const seaBundleName = `${execConfig.name}.sea-temp`;\n const seaBundle = await bundleWithEsbuild(compiledEntry, outDir, execConfig, {\n selfContained: true,\n outputName: seaBundleName,\n });\n const { buildSea } = await import('../exec/sea-builder.js');\n const seaResult = await buildSea(seaBundle.bundlePath, outDir, execConfig.name);\n fs.unlinkSync(seaBundle.bundlePath);\n binaries.push({\n platform: hostPlatform,\n srcPath: seaResult.executablePath,\n fileName: binaryFileName(execConfig.name, hostPlatform),\n });\n console.log(\n `${c('green', '[build:mcpb]')} SEA binary: ${path.relative(cwd, seaResult.executablePath)} (${formatSize(seaResult.executableSize)})`,\n );\n }\n }\n\n if (mergeFrom) {\n const absMergeDir = path.isAbsolute(mergeFrom) ? mergeFrom : path.resolve(cwd, mergeFrom);\n const merged = mergeBinariesFrom(absMergeDir, execConfig.name);\n if (merged.length === 0) {\n console.log(`${c('yellow', '[build:mcpb]')} mergeFrom \"${absMergeDir}\" produced no binaries`);\n } else {\n console.log(\n `${c('cyan', '[build:mcpb]')} merging ${merged.length} cross-platform binaries from ${path.relative(cwd, absMergeDir)}`,\n );\n // Replace any duplicate platform entries from the local SEA build with merge-from versions.\n for (const bin of merged) {\n const idx = binaries.findIndex((b) => b.platform === bin.platform);\n if (idx >= 0) binaries.splice(idx, 1);\n binaries.push(bin);\n }\n }\n }\n\n // 7. Translate setup steps → user_config + env\n const { userConfig, env: userConfigEnv, warnings } = setupStepsToUserConfig(\n execConfig.setup?.steps,\n mcpbDeployment,\n );\n for (const w of warnings) {\n console.log(`${c('yellow', '[build:mcpb]')} ${w}`);\n }\n\n // 8. Stage — outDir is already {dist}/mcpb (set by buildSingleTarget per-target layout)\n const stageDir = path.join(outDir, '__stage');\n if (fs.existsSync(stageDir)) {\n fs.rmSync(stageDir, { recursive: true, force: true });\n }\n const iconOverride = opts.icon ?? mcpbDeployment?.icon;\n const pkgMeta = loadPackageJsonMeta(cwd);\n const iconAbs = resolveIconPath(cwd, iconOverride, pkgMeta.icon);\n const iconAbsPath = iconAbs ? path.resolve(cwd, iconAbs) : undefined;\n\n const stageResult = stageMcpbDirectory({\n stageDir,\n cwd,\n serverBundlePath: bundleResult.bundlePath,\n name: execConfig.name,\n version: execConfig.version,\n schema,\n iconPath: iconAbsPath,\n binaries,\n });\n if (stageResult.skillAssetCount > 0) {\n console.log(`${c('green', '[build:mcpb]')} copied ${stageResult.skillAssetCount} skill asset(s) to server/_skills/`);\n }\n if (stageResult.hasIcon) {\n console.log(`${c('green', '[build:mcpb]')} icon: ${iconAbs}`);\n }\n\n // 9. Manifest\n const platformOverrides = buildPlatformOverrides(binaries);\n const manifest = generateMcpbManifest({\n name: execConfig.name,\n version: execConfig.version,\n nodeVersion: execConfig.nodeVersion,\n cwd,\n deployment: mcpbDeployment,\n schema,\n userConfig,\n userConfigEnv,\n platformOverrides,\n hasIcon: stageResult.hasIcon,\n cliVersion: getSelfVersion(),\n });\n writeManifest(stageDir, manifest);\n console.log(`${c('green', '[build:mcpb]')} wrote manifest.json`);\n\n // 10. Zip (unless --stage-only)\n if (opts.stageOnly) {\n console.log(`${c('yellow', '[build:mcpb]')} --stage-only set; leaving ${path.relative(cwd, stageDir)} for inspection`);\n cleanupIntermediates(outDir, preExistingEntries, ['__stage']);\n return;\n }\n\n const archivePath = path.join(outDir, `${execConfig.name}-${execConfig.version}.mcpb`);\n const zipResult = await createDeterministicZip(stageDir, archivePath, {\n deterministic: !opts.noDeterministic && (mcpbDeployment?.deterministic ?? true),\n });\n console.log(\n `${c('green', '[build:mcpb]')} ${path.relative(cwd, zipResult.archivePath)} (${formatSize(zipResult.size)})`,\n );\n console.log(`${c('gray', '[build:mcpb]')} sha256: ${zipResult.sha256}`);\n\n if (zipResult.size > ARCHIVE_SIZE_ERROR) {\n console.log(\n `${c('yellow', '[build:mcpb]')} Archive is ${(zipResult.size / 1024 / 1024).toFixed(1)} MB — consider tuning externals`,\n );\n } else if (zipResult.size > ARCHIVE_SIZE_WARN) {\n console.log(`${c('yellow', '[build:mcpb]')} Archive is ${(zipResult.size / 1024 / 1024).toFixed(1)} MB`);\n }\n\n // 11. Cleanup\n fs.rmSync(stageDir, { recursive: true, force: true });\n cleanupIntermediates(outDir, preExistingEntries, [`${execConfig.name}-${execConfig.version}.mcpb`]);\n\n console.log(`\\n${c('green', 'MCPB build completed.')}`);\n console.log(`${c('gray', 'Install:')} open ${path.relative(cwd, zipResult.archivePath)}`);\n}\n\n/**\n * Remove intermediates this build produced, leaving pre-existing files and the\n * keep-list alone. The tsc + esbuild stages write intermediates directly into\n * outDir (same pattern as the exec target uses); we keep the archive and — in\n * stage-only mode — the `__stage/` directory so the user can inspect it.\n *\n * `preExisting` is the set of entries that were in `outDir` before the build\n * started. Anything in that set is preserved unconditionally so a shared\n * outDir (e.g., `--out-dir dist` alongside other targets) is not clobbered.\n */\nfunction cleanupIntermediates(outDir: string, preExisting: Set<string>, keep: string[]): void {\n if (!fs.existsSync(outDir)) return;\n const keepSet = new Set(keep);\n for (const entry of fs.readdirSync(outDir)) {\n if (keepSet.has(entry)) continue;\n if (preExisting.has(entry)) continue;\n const full = path.join(outDir, entry);\n try {\n fs.rmSync(full, { recursive: true, force: true });\n } catch {\n // best-effort — a race with an external process shouldn't fail the build\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCPB manifest generator + Zod schema for the emitted manifest.
|
|
3
|
+
*
|
|
4
|
+
* Source priority when resolving fields:
|
|
5
|
+
* deployment.* (frontmcp.config) > package.json > hard defaults
|
|
6
|
+
*
|
|
7
|
+
* See https://github.com/modelcontextprotocol/mcpb/blob/main/MANIFEST.md
|
|
8
|
+
*/
|
|
9
|
+
import { z } from '@frontmcp/lazy-zod';
|
|
10
|
+
import { type ExtractedSchema } from '../exec/cli-runtime/schema-extractor';
|
|
11
|
+
import type { McpbAuthor, McpbCompatibility, McpbDeployment, McpbRepository, McpbUserConfigEntry } from '../../../config/frontmcp-config.types';
|
|
12
|
+
export interface McpbMcpConfig {
|
|
13
|
+
command: string;
|
|
14
|
+
args?: string[];
|
|
15
|
+
env?: Record<string, string>;
|
|
16
|
+
platform_overrides?: Record<string, McpbMcpConfig>;
|
|
17
|
+
}
|
|
18
|
+
export interface McpbManifest {
|
|
19
|
+
manifest_version: string;
|
|
20
|
+
name: string;
|
|
21
|
+
version: string;
|
|
22
|
+
description: string;
|
|
23
|
+
display_name?: string;
|
|
24
|
+
long_description?: string;
|
|
25
|
+
author: McpbAuthor;
|
|
26
|
+
license?: string;
|
|
27
|
+
homepage?: string;
|
|
28
|
+
repository?: {
|
|
29
|
+
type: string;
|
|
30
|
+
url: string;
|
|
31
|
+
};
|
|
32
|
+
documentation?: string;
|
|
33
|
+
support?: string;
|
|
34
|
+
icon?: string;
|
|
35
|
+
keywords?: string[];
|
|
36
|
+
privacy_policies?: string[];
|
|
37
|
+
compatibility?: McpbCompatibility;
|
|
38
|
+
server: {
|
|
39
|
+
type: 'node' | 'python' | 'binary' | 'uv';
|
|
40
|
+
entry_point: string;
|
|
41
|
+
mcp_config: McpbMcpConfig;
|
|
42
|
+
};
|
|
43
|
+
tools?: Array<{
|
|
44
|
+
name: string;
|
|
45
|
+
description: string;
|
|
46
|
+
}>;
|
|
47
|
+
tools_generated?: boolean;
|
|
48
|
+
prompts?: Array<{
|
|
49
|
+
name: string;
|
|
50
|
+
description?: string;
|
|
51
|
+
}>;
|
|
52
|
+
prompts_generated?: boolean;
|
|
53
|
+
user_config?: Record<string, McpbUserConfigEntry>;
|
|
54
|
+
_meta?: Record<string, unknown>;
|
|
55
|
+
}
|
|
56
|
+
export declare const mcpbManifestSchema: import("@frontmcp/lazy-zod").ZodObject<{
|
|
57
|
+
manifest_version: import("@frontmcp/lazy-zod").ZodString;
|
|
58
|
+
name: import("@frontmcp/lazy-zod").ZodString;
|
|
59
|
+
version: import("@frontmcp/lazy-zod").ZodString;
|
|
60
|
+
description: import("@frontmcp/lazy-zod").ZodString;
|
|
61
|
+
display_name: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodString>;
|
|
62
|
+
long_description: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodString>;
|
|
63
|
+
author: import("@frontmcp/lazy-zod").ZodObject<{
|
|
64
|
+
name: import("@frontmcp/lazy-zod").ZodString;
|
|
65
|
+
email: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodString>;
|
|
66
|
+
url: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodString>;
|
|
67
|
+
}, import("zod/v4/core").$strict>;
|
|
68
|
+
license: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodString>;
|
|
69
|
+
homepage: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodString>;
|
|
70
|
+
repository: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodObject<{
|
|
71
|
+
type: import("@frontmcp/lazy-zod").ZodString;
|
|
72
|
+
url: import("@frontmcp/lazy-zod").ZodString;
|
|
73
|
+
}, import("zod/v4/core").$strict>>;
|
|
74
|
+
documentation: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodString>;
|
|
75
|
+
support: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodString>;
|
|
76
|
+
icon: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodString>;
|
|
77
|
+
keywords: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodArray<import("@frontmcp/lazy-zod").ZodString>>;
|
|
78
|
+
privacy_policies: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodArray<import("@frontmcp/lazy-zod").ZodString>>;
|
|
79
|
+
compatibility: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodObject<{
|
|
80
|
+
claude_desktop: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodString>;
|
|
81
|
+
platforms: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodArray<import("@frontmcp/lazy-zod").ZodEnum<{
|
|
82
|
+
darwin: "darwin";
|
|
83
|
+
win32: "win32";
|
|
84
|
+
linux: "linux";
|
|
85
|
+
}>>>;
|
|
86
|
+
runtimes: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodObject<{
|
|
87
|
+
node: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodString>;
|
|
88
|
+
python: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodString>;
|
|
89
|
+
}, import("zod/v4/core").$strict>>;
|
|
90
|
+
}, import("zod/v4/core").$strict>>;
|
|
91
|
+
server: import("@frontmcp/lazy-zod").ZodObject<{
|
|
92
|
+
type: import("@frontmcp/lazy-zod").ZodEnum<{
|
|
93
|
+
node: "node";
|
|
94
|
+
binary: "binary";
|
|
95
|
+
python: "python";
|
|
96
|
+
uv: "uv";
|
|
97
|
+
}>;
|
|
98
|
+
entry_point: import("@frontmcp/lazy-zod").ZodString;
|
|
99
|
+
mcp_config: z.ZodType<McpbMcpConfig, unknown>;
|
|
100
|
+
}, import("zod/v4/core").$strict>;
|
|
101
|
+
tools: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodArray<import("@frontmcp/lazy-zod").ZodObject<{
|
|
102
|
+
name: import("@frontmcp/lazy-zod").ZodString;
|
|
103
|
+
description: import("@frontmcp/lazy-zod").ZodString;
|
|
104
|
+
}, import("zod/v4/core").$strict>>>;
|
|
105
|
+
tools_generated: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodBoolean>;
|
|
106
|
+
prompts: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodArray<import("@frontmcp/lazy-zod").ZodObject<{
|
|
107
|
+
name: import("@frontmcp/lazy-zod").ZodString;
|
|
108
|
+
description: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodString>;
|
|
109
|
+
}, import("zod/v4/core").$strict>>>;
|
|
110
|
+
prompts_generated: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodBoolean>;
|
|
111
|
+
user_config: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodRecord<import("@frontmcp/lazy-zod").ZodString, import("@frontmcp/lazy-zod").ZodObject<{
|
|
112
|
+
type: import("@frontmcp/lazy-zod").ZodEnum<{
|
|
113
|
+
string: "string";
|
|
114
|
+
number: "number";
|
|
115
|
+
boolean: "boolean";
|
|
116
|
+
directory: "directory";
|
|
117
|
+
file: "file";
|
|
118
|
+
}>;
|
|
119
|
+
title: import("@frontmcp/lazy-zod").ZodString;
|
|
120
|
+
description: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodString>;
|
|
121
|
+
required: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodBoolean>;
|
|
122
|
+
default: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodUnion<readonly [import("@frontmcp/lazy-zod").ZodString, import("@frontmcp/lazy-zod").ZodNumber, import("@frontmcp/lazy-zod").ZodBoolean]>>;
|
|
123
|
+
multiple: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodBoolean>;
|
|
124
|
+
sensitive: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodBoolean>;
|
|
125
|
+
min: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodNumber>;
|
|
126
|
+
max: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodNumber>;
|
|
127
|
+
}, import("zod/v4/core").$strict>>>;
|
|
128
|
+
_meta: import("@frontmcp/lazy-zod").ZodOptional<import("@frontmcp/lazy-zod").ZodRecord<import("@frontmcp/lazy-zod").ZodString, import("@frontmcp/lazy-zod").ZodUnknown>>;
|
|
129
|
+
}, import("zod/v4/core").$strict>;
|
|
130
|
+
export interface PackageJsonMeta {
|
|
131
|
+
name?: string;
|
|
132
|
+
version?: string;
|
|
133
|
+
description?: string;
|
|
134
|
+
author?: string | McpbAuthor;
|
|
135
|
+
license?: string;
|
|
136
|
+
homepage?: string;
|
|
137
|
+
repository?: string | {
|
|
138
|
+
type?: string;
|
|
139
|
+
url?: string;
|
|
140
|
+
};
|
|
141
|
+
keywords?: string[];
|
|
142
|
+
icon?: string;
|
|
143
|
+
}
|
|
144
|
+
/** Read and parse package.json from the given directory. Returns {} if absent. */
|
|
145
|
+
export declare function loadPackageJsonMeta(cwd: string): PackageJsonMeta;
|
|
146
|
+
/**
|
|
147
|
+
* Parse npm-style "Name <email> (url)" into an McpbAuthor.
|
|
148
|
+
* Falls back to `{ name: <raw> }` when parsing fails.
|
|
149
|
+
*/
|
|
150
|
+
export declare function parseAuthor(author: unknown): McpbAuthor;
|
|
151
|
+
/** Normalize repository field (string → {type, url}). */
|
|
152
|
+
export declare function normalizeRepository(repo: McpbRepository | PackageJsonMeta['repository'] | undefined): {
|
|
153
|
+
type: string;
|
|
154
|
+
url: string;
|
|
155
|
+
} | undefined;
|
|
156
|
+
/** Resolve first-existing icon path. */
|
|
157
|
+
export declare function resolveIconPath(cwd: string, deploymentIcon?: string, pkgIcon?: string): string | undefined;
|
|
158
|
+
export interface GenerateMcpbManifestInput {
|
|
159
|
+
/** Resolved server name. */
|
|
160
|
+
name: string;
|
|
161
|
+
/** Resolved server version. */
|
|
162
|
+
version: string;
|
|
163
|
+
/** Optional resolved node version range (e.g., ">=22.0.0"). */
|
|
164
|
+
nodeVersion?: string;
|
|
165
|
+
/** Project root. Used for icon resolution and package.json fallback. */
|
|
166
|
+
cwd: string;
|
|
167
|
+
/** Deployment config from frontmcp.config (may be undefined). */
|
|
168
|
+
deployment?: McpbDeployment;
|
|
169
|
+
/** Schema extracted from the compiled server bundle. */
|
|
170
|
+
schema: ExtractedSchema;
|
|
171
|
+
/** env → user_config reference map built by user-config.ts. */
|
|
172
|
+
userConfigEnv: Record<string, string>;
|
|
173
|
+
/** user_config entries built by user-config.ts. */
|
|
174
|
+
userConfig: Record<string, McpbUserConfigEntry>;
|
|
175
|
+
/** platform_overrides from binary.ts (may be empty). */
|
|
176
|
+
platformOverrides?: Record<string, McpbMcpConfig>;
|
|
177
|
+
/** Whether an icon was copied into the staged archive root. */
|
|
178
|
+
hasIcon?: boolean;
|
|
179
|
+
/** Tool name of the CLI version emitting this manifest (for _meta). */
|
|
180
|
+
cliVersion?: string;
|
|
181
|
+
}
|
|
182
|
+
/** Produce the final MCPB manifest object. */
|
|
183
|
+
export declare function generateMcpbManifest(input: GenerateMcpbManifestInput): McpbManifest;
|