MJML MCP Server
Enables creation and management of professional email templates using MJML markup language. Provides compilation to responsive HTML, template generation, validation, and component documentation for building email campaigns.
README
MJML MCP Server
A comprehensive Model Context Protocol (MCP) server for MJML email template generation, compilation, and validation. This server provides powerful tools for creating professional email templates using the MJML markup language.
Features
- MJML Compilation: Compile MJML to responsive HTML with advanced options
- Template Generation: Pre-built templates for common email types
- Validation: Validate MJML syntax and structure with configurable levels
- Component Reference: Get documentation and examples for MJML components
- File Support: Work with both MJML strings and files
- Robust Error Handling: Comprehensive error reporting and logging
Tools
1. compile_mjml
Compile MJML content to responsive HTML email.
Parameters:
input(required): MJML content or file pathfilePath(optional): Treat input as file path (default: false)beautify(optional): Beautify output HTML (default: true)minify(optional): Minify output HTML (default: false)validationLevel(optional): Validation level - "skip", "soft", "strict" (default: "soft")keepComments(optional): Keep comments in output (default: false)fonts(optional): Custom fonts configurationoutputPath(optional): Save compiled HTML to file path
2. validate_mjml
Validate MJML syntax and structure.
Parameters:
input(required): MJML content or file pathfilePath(optional): Treat input as file path (default: false)validationLevel(optional): Validation level - "skip", "soft", "strict" (default: "strict")
3. generate_template
Generate pre-built email templates.
Parameters:
template(required): Template type - "newsletter", "welcome", "promotional", "transactional", "password-reset", "verification", "announcement", "invitation"variables(optional): Template variables to replacecustomColors(optional): Custom color schemecustomFonts(optional): Custom fontsoutputPath(optional): Save template to file path
4. get_component_info
Get MJML component reference and documentation.
Parameters:
component(optional): Specific component namecategory(optional): Component category - "all", "standard", "advanced", "structural" (default: "all")
Installation
- Clone or create the project directory
- Install dependencies:
npm install
Usage
Start the Server
npm start
Development Mode
npm run dev
Running Tests
npm test
Template Variables
When generating templates, you can use these variables:
company_name: Your company namecompany_logo: URL to company logouser_name: Recipient's namenewsletter_date: Date for newslettermain_title: Main title/headingmain_subtitle: Main subtitlefeatured_image: Featured image URLfeatured_title: Featured article titlefeatured_content: Featured article contentfeatured_link: Featured article linkupdate1_title,update1_content: First updateupdate2_title,update2_content: Second updatediscount_percentage: Discount percentage for promotionstime_remaining: Time remaining for promotionsproduct_name,product_image,product_description: Product detailsoriginal_price,sale_price: Pricing informationshop_url: Shopping URLdashboard_url: Dashboard URLsupport_email: Support email addressunsubscribe_url: Unsubscribe linkwebsite_url: Website URLfacebook_url,twitter_url,instagram_url: Social media URLscurrent_year: Current year (automatically filled)
Example Usage
Compile MJML from String
{
"name": "compile_mjml",
"arguments": {
"input": "<mjml><mj-body><mj-section><mj-column><mj-text>Hello World!</mj-text></mj-column></mj-section></mj-body></mjml>",
"beautify": true,
"validationLevel": "soft"
}
}
Generate Welcome Template
{
"name": "generate_template",
"arguments": {
"template": "welcome",
"variables": {
"company_name": "Acme Corp",
"user_name": "John Doe",
"support_email": "support@acme.com"
},
"customColors": {
"primary": "#007bff",
"success": "#28a745"
},
"outputPath": "./welcome-email.mjml"
}
}
Validate MJML File
{
"name": "validate_mjml",
"arguments": {
"input": "./templates/newsletter.mjml",
"filePath": true,
"validationLevel": "strict"
}
}
Get Component Information
{
"name": "get_component_info",
"arguments": {
"component": "mj-button"
}
}
Error Handling
The server provides comprehensive error handling with detailed error messages:
- File access errors
- MJML syntax errors
- Validation failures
- Configuration issues
Logging
The server includes structured logging with different levels:
INFO: General informationWARN: WarningsERROR: Error messagesDEBUG: Debug information (enable with DEBUG environment variable)
Enable debug logging:
DEBUG=1 npm start
Configuration
The server supports various MJML options:
- Custom fonts configuration
- Validation levels
- Output formatting options
- File input/output handling
Dependencies
@modelcontextprotocol/sdk: MCP SDK for server implementationmjml: MJML compiler and validatorzod: Schema validationfs-extra: Enhanced file system operations
License
MIT License
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
Support
For issues and questions, please open an issue in the project repository.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。