MCPcopy Create free account
hub / github.com/modelcontextprotocol/mcpb / initExtension

Function initExtension

src/cli/init.ts:945–1048  ·  view source on GitHub ↗
(
  targetPath: string = process.cwd(),
  nonInteractive = false,
)

Source from the content-addressed store, hash-verified

943}
944
945export async function initExtension(
946 targetPath: string = process.cwd(),
947 nonInteractive = false,
948): Promise<boolean> {
949 const resolvedPath = resolve(targetPath);
950 const manifestPath = join(resolvedPath, "manifest.json");
951
952 if (existsSync(manifestPath)) {
953 if (nonInteractive) {
954 console.log(
955 "manifest.json already exists. Use --force to overwrite in non-interactive mode.",
956 );
957 return false;
958 }
959 const overwrite = await confirm({
960 message: "manifest.json already exists. Overwrite?",
961 default: false,
962 });
963 if (!overwrite) {
964 console.log("Cancelled");
965 return false;
966 }
967 }
968
969 if (!nonInteractive) {
970 console.log(
971 "This utility will help you create a manifest.json file for your MCPB bundle.",
972 );
973 console.log("Press ^C at any time to quit.\n");
974 } else {
975 console.log("Creating manifest.json with default values...");
976 }
977
978 try {
979 const packageData = readPackageJson(resolvedPath);
980
981 // Prompt for all information or use defaults
982 const basicInfo = nonInteractive
983 ? getDefaultBasicInfo(packageData, resolvedPath)
984 : await promptBasicInfo(packageData, resolvedPath);
985 const longDescription = nonInteractive
986 ? undefined
987 : await promptLongDescription(basicInfo.description);
988 const authorInfo = nonInteractive
989 ? getDefaultAuthorInfo(packageData)
990 : await promptAuthorInfo(packageData);
991 const urls = nonInteractive
992 ? { homepage: "", documentation: "", support: "" }
993 : await promptUrls();
994 const visualAssets = nonInteractive
995 ? { icon: "", icons: [], screenshots: [] }
996 : await promptVisualAssets();
997 // const localization = nonInteractive
998 // ? undefined
999 // : await promptLocalization();
1000 const serverConfig = nonInteractive
1001 ? getDefaultServerConfig(packageData)
1002 : await promptServerConfig(packageData);

Callers 2

packExtensionFunction · 0.85
cli.tsFile · 0.85

Calls 15

readPackageJsonFunction · 0.85
getDefaultBasicInfoFunction · 0.85
promptBasicInfoFunction · 0.85
promptLongDescriptionFunction · 0.85
getDefaultAuthorInfoFunction · 0.85
promptAuthorInfoFunction · 0.85
promptUrlsFunction · 0.85
promptVisualAssetsFunction · 0.85
getDefaultServerConfigFunction · 0.85
promptServerConfigFunction · 0.85
promptToolsFunction · 0.85
promptPromptsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…