Skip to main content
Glama

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
NameRequiredDescriptionDefault
inputYesMJML content or file path
filePathNoTreat input as file path
validationLevelNoValidation levelstrict

Implementation Reference

  • 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), }, ], }; }
  • 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);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/shaunie2fly/mjml_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server