( manifestJson: unknown, )
| 11 | * closures out of the startup heap for sessions that never touch .dxt/.mcpb. |
| 12 | */ |
| 13 | export async function validateManifest( |
| 14 | manifestJson: unknown, |
| 15 | ): Promise<McpbManifest> { |
| 16 | const { McpbManifestSchema } = await import('@anthropic-ai/mcpb') |
| 17 | const parseResult = McpbManifestSchema.safeParse(manifestJson) |
| 18 | |
| 19 | if (!parseResult.success) { |
| 20 | const errors = parseResult.error.flatten() |
| 21 | const errorMessages = [ |
| 22 | ...Object.entries(errors.fieldErrors).map( |
| 23 | ([field, errs]) => `${field}: ${errs?.join(', ')}`, |
| 24 | ), |
| 25 | ...(errors.formErrors || []), |
| 26 | ] |
| 27 | .filter(Boolean) |
| 28 | .join('; ') |
| 29 | |
| 30 | throw new Error(`Invalid manifest: ${errorMessages}`) |
| 31 | } |
| 32 | |
| 33 | return parseResult.data |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Parses and validates a DXT manifest from raw text data. |
no test coverage detected