validate_mjml
Check MJML syntax and structure for errors to ensure valid email templates before deployment.
Instructions
Validate MJML syntax and structure
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input | Yes | MJML content or file path | |
| filePath | No | Treat input as file path | |
| validationLevel | No | Validation level | strict |
Implementation Reference
- index.js:337-365 (handler)The main handler function for the validate_mjml tool. Parses input arguments using the schema, reads MJML content from string or file, validates it using the mjml library with specified validation level, determines if valid based on absence of errors, and returns a structured response with validity status, errors, warnings, and validation level.async handleValidateMjml(args) { const parsed = ValidateMjmlSchema.parse(args); log.info('Validating MJML'); const mjmlContent = await this.readInput(parsed.input, parsed.filePath); const mjmlOptions = { validationLevel: parsed.validationLevel, }; const result = mjml(mjmlContent, mjmlOptions); const isValid = result.errors.length === 0; log.info(`MJML validation ${isValid ? 'passed' : 'failed'}`); return { content: [ { type: 'text', text: JSON.stringify({ valid: isValid, errors: result.errors, warnings: result.warnings, validationLevel: parsed.validationLevel, }, null, 2), }, ], }; }
- index.js:46-50 (schema)Zod schema for validating input parameters to the validate_mjml tool: MJML input (content or path), flag for file path treatment, and validation level.const ValidateMjmlSchema = z.object({ input: z.string().describe('MJML content or file path'), filePath: z.boolean().optional().default(false).describe('Treat input as file path'), validationLevel: z.enum(['skip', 'soft', 'strict']).optional().default('strict').describe('Validation level'), });
- index.js:185-209 (registration)MCP tool registration for validate_mjml, including name, description, and input schema definition for the ListTools response.{ name: 'validate_mjml', description: 'Validate MJML syntax and structure', inputSchema: { type: 'object', properties: { input: { type: 'string', description: 'MJML content or file path', }, filePath: { type: 'boolean', description: 'Treat input as file path', default: false, }, validationLevel: { type: 'string', enum: ['skip', 'soft', 'strict'], description: 'Validation level', default: 'strict', }, }, required: ['input'], }, },
- index.js:271-272 (registration)Dispatch case in the CallToolRequest handler that routes validate_mjml calls to the specific handler method.case 'validate_mjml': return await this.handleValidateMjml(args);