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

Function validateManifest

src/node/validate.ts:111–184  ·  view source on GitHub ↗
(inputPath: string)

Source from the content-addressed store, hash-verified

109}
110
111export function validateManifest(inputPath: string): boolean {
112 try {
113 const resolvedPath = resolve(inputPath);
114 let manifestPath = resolvedPath;
115
116 // If input is a directory, look for manifest.json inside it
117 if (existsSync(resolvedPath) && statSync(resolvedPath).isDirectory()) {
118 manifestPath = join(resolvedPath, "manifest.json");
119 }
120
121 const manifestContent = readFileSync(manifestPath, "utf-8");
122 const manifestData = JSON.parse(manifestContent);
123 const manifestVersion = getManifestVersionFromRawData(manifestData);
124 if (!manifestVersion) {
125 console.log("Unrecognized or unsupported manifest version");
126 return false;
127 }
128
129 const result = MANIFEST_SCHEMAS[manifestVersion].safeParse(manifestData);
130
131 if (result.success) {
132 console.log("Manifest schema validation passes!");
133
134 // Validate icon if present
135 if (manifestData.icon) {
136 const baseDir = dirname(manifestPath);
137 const iconValidation = validateIcon(manifestData.icon, baseDir);
138
139 if (iconValidation.errors.length > 0) {
140 console.log("\nERROR: Icon validation failed:\n");
141 iconValidation.errors.forEach((error) => {
142 console.log(` - ${error}`);
143 });
144 return false;
145 }
146
147 if (iconValidation.warnings.length > 0) {
148 console.log("\nIcon validation warnings:\n");
149 iconValidation.warnings.forEach((warning) => {
150 console.log(` - ${warning}`);
151 });
152 }
153 }
154
155 return true;
156 } else {
157 console.log("ERROR: Manifest validation failed:\n");
158 result.error.issues.forEach((issue) => {
159 const path = issue.path.join(".");
160 console.log(` - ${path ? `${path}: ` : ""}${issue.message}`);
161 });
162 return false;
163 }
164 } catch (error) {
165 if (error instanceof Error) {
166 if (error.message.includes("ENOENT")) {
167 console.error(`ERROR: File not found: ${inputPath}`);
168 if (

Callers 2

packExtensionFunction · 0.85
cli.tsFile · 0.85

Calls 2

validateIconFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…