loading…
Search for a command to run...
loading…
Provides comprehensive Magento 2 coding standards, security rules, and theme-specific patterns to help AI assistants write and validate compliant code. It suppo
Provides comprehensive Magento 2 coding standards, security rules, and theme-specific patterns to help AI assistants write and validate compliant code. It supports built-in presets for Hyva, Luma, Breeze, and Porto themes to ensure context-aware development.
An MCP (Model Context Protocol) server that provides comprehensive Magento 2 coding standards knowledge, enabling AI assistants to write Magento-compliant code naturally — vibe coding for Magento.
Works with Claude Code, Claude Desktop, Cursor IDE, VS Code Copilot, Gemini CLI, Continue.dev, Windsurf, Augment Code, and any MCP-compatible client.
Writing Magento 2 code correctly is hard. There are 83+ coding standard rules, 150+ discouraged functions, 50+ restricted classes, theme-specific conventions, and security requirements that developers must follow. AI assistants don't know these rules — they generate code that looks correct but violates Magento standards.
This MCP server teaches AI assistants Magento's rules so they write compliant code from the start:
DriverInterface pattern, not file_get_contents()git clone https://github.com/Midhun-edv/magento-coding-standard-mcp.git
cd magento-coding-standard-mcp
npm install
npm run build
Pick your platform below and add the MCP server:
claude mcp add magento-coding-standard -- node /path/to/magento-coding-standard-mcp/dist/index.js
Add to your claude_desktop_config.json:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"magento-coding-standard": {
"command": "node",
"args": ["/path/to/magento-coding-standard-mcp/dist/index.js"]
}
}
}
Add to .cursor/mcp.json in your project root:
{
"mcpServers": {
"magento-coding-standard": {
"command": "node",
"args": ["/path/to/magento-coding-standard-mcp/dist/index.js"]
}
}
}
Add to .vscode/mcp.json in your project root:
{
"servers": {
"magento-coding-standard": {
"type": "stdio",
"command": "node",
"args": ["/path/to/magento-coding-standard-mcp/dist/index.js"]
}
}
}
Add to ~/.gemini/settings.json:
{
"mcpServers": {
"magento-coding-standard": {
"command": "node",
"args": ["/path/to/magento-coding-standard-mcp/dist/index.js"]
}
}
}
Add to ~/.continue/config.json:
{
"mcpServers": [
{
"name": "magento-coding-standard",
"command": "node",
"args": ["/path/to/magento-coding-standard-mcp/dist/index.js"]
}
]
}
Add to Windsurf MCP settings:
{
"mcpServers": {
"magento-coding-standard": {
"command": "node",
"args": ["/path/to/magento-coding-standard-mcp/dist/index.js"]
}
}
}
Add in Augment Code settings:
{
"mcpServers": {
"magento-coding-standard": {
"command": "node",
"args": ["/path/to/magento-coding-standard-mcp/dist/index.js"]
}
}
}
Note: Replace
/path/to/with your actual installation path. On Windows, use forward slashes:C:/Users/name/magento-coding-standard-mcp/dist/index.js
get_magento_patternGet the correct Magento 2 way to accomplish a task. Returns the proper pattern, code example, what to avoid, and why.
Task: "read a file"
→ Returns: DriverInterface::fileGetContents() with full example, avoidPatterns, explanation
Supported tasks: File operations, Escaping (HTML/URL/JS/CSS), JSON/Serialization, Validation, Templates/ViewModels, HTTP requests, JavaScript (RequireJS, UI Components, Widgets), Translation, Logging, Database queries
When a theme is active, patterns are automatically overridden with theme-specific versions (e.g., "jQuery widget" → Alpine.js component when Hyva is active).
validate_codeValidate code against Magento coding standards. Returns violations with severity, line numbers, rule names, and fix suggestions.
Input: { code: "<?php echo $name; ?>", fileType: "phtml" }
→ Returns: XSS violation at line 1, suggestion to use $escaper->escapeHtml()
Supported file types: php, phtml, js, less, css
When a theme is active, theme-specific validation rules are applied on top of base Magento rules.
check_securitySecurity-focused validation checking for:
explain_ruleGet detailed explanation of any rule with reasoning, bad/good examples, related rules, and documentation links.
Input: { ruleName: "XssTemplate" }
→ Returns: Full explanation with bad code, good code, and related rules
Also supports theme-specific rules (e.g., Hyva.JS.NoJQuery).
list_rulesList all rules with optional filtering:
When a theme is active, theme rules are included in the listing.
get_rules_summaryGet a summary of all rules grouped by category with counts of errors and warnings.
manage_themeManage theme-specific coding standards that layer on top of base Magento rules.
| Action | Description | Example |
|---|---|---|
list |
Show all available themes | { action: "list" } |
set |
Activate a theme | { action: "set", themeId: "hyva" } |
clear |
Deactivate theme | { action: "clear" } |
info |
Show theme details | { action: "info", themeId: "hyva" } |
Different Magento themes use completely different frontend stacks. Code that's correct for Luma is wrong for Hyva and vice versa. This MCP supports 4 built-in theme presets and custom themes.
| Theme | Stack | Rules | Description |
|---|---|---|---|
| hyva | Alpine.js + TailwindCSS | 8 rules | No jQuery, No KnockoutJS, No RequireJS, No LESS |
| luma | jQuery + RequireJS + KnockoutJS + LESS | 4 rules | Default Magento 2 frontend stack |
| breeze | Vanilla JS + Breeze API + LESS | 4 rules | Lightweight, no RequireJS |
| porto | Luma-based + Porto widgets | 4 rules | Always use child theme |
manage_theme({ action: "set", themeId: "hyva" })validate_code now flags jQuery, RequireJS, KnockoutJS usage as errorsget_magento_pattern({ task: "jquery widget" }) returns Alpine.js component insteadlist_rules includes Hyva-specific rules like Hyva.JS.NoJQuery$escaper$(), KnockoutJS data-bind, RequireJS define()/require(), LESS, data-mage-init$.widget(), data-mage-init$.widget, $.view), lightweight LESS, fetch() APICreate your own theme standards by placing JSON files in ~/.magento-mcp/themes/:
{
"id": "my-theme",
"name": "My Custom Theme",
"version": "1.0.0",
"description": "Custom standards for my project",
"technologies": {
"use": ["React", "TailwindCSS"],
"avoid": ["jQuery"]
},
"validationRules": [
{
"pattern": "\\$\\(",
"fileTypes": ["js", "phtml"],
"severity": 8,
"type": "warning",
"message": "jQuery detected. My Theme uses React.",
"rule": "MyTheme.JS.NoJQuery",
"suggestion": "Use React components instead",
"mode": "discourage"
}
],
"patternOverrides": [],
"bestPractices": ["Use React for interactive UI"]
}
Override the directory with the MAGENTO_MCP_THEME_DIR environment variable.
See src/themes/custom/README.md for full JSON schema documentation.
| Category | Count | Examples |
|---|---|---|
| Security | 8 rules | InsecureFunction, XSS, Superglobal, LanguageConstruct |
| Legacy | 13 rules | Zend to Laminas, Mage::, deprecated configs, ObsoleteConnection |
| PHP | 7 rules | FinalImplementation, Goto, ShortEchoSyntax, ReturnValueCheck |
| Functions | 3 rules | DiscouragedFunction, StaticFunction, DeprecatedWithoutArgument |
| Templates | 2 rules | ThisInTemplate, ObjectManager in templates |
| Less/CSS | 19 rules | AvoidId, Indentation, Colors, ZeroUnits, ImportantProperty |
| GraphQL | 5 rules | ValidTypeName, ValidFieldName, ValidEnumValue |
| Html | 4 rules | SelfClosing, VoidTags, Binding, Directive |
| Framework | 4 rules | Copyright, License headers |
| Exceptions | 3 rules | DirectThrow, ThrowCatch, TryProcessSystemResources |
| + more | 15+ rules | Annotation, Commenting, Performance, SQL, Translation |
| Discouraged Functions | 150+ | file_get_contents, curl_*, mysql_*, die, sleep, compact... |
| Restricted Classes | 50+ | Zend_Json, Zend_Db, Zend_Log, Varien_*, Mage_* ... |
| jQuery Deprecations | 25+ | $.bind, $.live, $.size, $.isFunction, $.browser... |
| Level | Type | Description |
|---|---|---|
| 10 | Error | Critical — security vulnerabilities, forbidden patterns |
| 9 | Warning | Security — possible security issues |
| 8 | Warning | Magento-specific — design violations |
| 7 | Warning | General — code quality issues |
| 6 | Warning | Style — formatting issues |
| 5 | Warning | Documentation — PHPDoc issues |
magento-coding-standard-mcp/
src/
index.ts # MCP server entry point (7 tools)
cli.ts # CLI entry point (--help, --version)
knowledge/ # Coding standards knowledge base
index.ts # Central exports + utility functions
insecure-functions.ts # Forbidden functions (exec, eval, etc.)
discouraged-functions.ts # 150+ discouraged functions
restricted-classes.ts # 50+ restricted classes
xss-escape-methods.ts # XSS escape methods
template-patterns.ts # Template/ViewModel patterns
jquery-deprecations.ts # 25+ jQuery deprecations
severity-rules.ts # 83+ rules with severity levels
themes/ # Theme-specific standards
types.ts # ThemeStandard interfaces
index.ts # Public API
theme-manager.ts # Active theme state management
presets/
hyva.ts # Hyva: Alpine.js + TailwindCSS
luma.ts # Luma: jQuery + RequireJS + LESS
breeze.ts # Breeze: Vanilla JS
porto.ts # Porto: Luma-based + Porto widgets
index.ts # THEME_PRESETS registry
custom/
loader.ts # Loads user JSON themes
README.md # JSON schema documentation
tools/ # MCP tool implementations
index.ts # Tool exports
get-magento-pattern.ts # Pattern lookup (theme-aware)
validate-code.ts # Code validation (theme-aware)
check-security.ts # Security validation
explain-rule.ts # Rule explanations (theme-aware)
list-rules.ts # Rule listing (theme-aware)
manage-theme.ts # Theme management tool
examples/
ai-platform-configs.md # Full config examples for 7 platforms
dist/ # Compiled output (generated)
package.json
tsconfig.json
# Install dependencies
npm install
# Build for production
npm run build
# Run in development mode (with hot reload)
npm run dev
# Start the server
npm start
# CLI help
node dist/cli.js --help
# CLI version
node dist/cli.js --version
@modelcontextprotocol/sdk for MCP protocolzod for input validationget_magento_pattern to get the correct approachvalidate_code to check for violationsThe AI doesn't need special prompting. The MCP tools are described clearly enough that AI assistants naturally call them when working on Magento projects.
Contributions are welcome! Areas that could use help:
src/themes/presets/my-theme.ts following the ThemeStandard interfacesrc/themes/presets/index.tsTHEME_PRESETS recordnpm run build — zero errors requiredMIT - see LICENSE for details.
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"magento-2-coding-standards-mcp": {
"command": "npx",
"args": []
}
}
}PRs, issues, code search, CI status
Database, auth and storage
Reference / test server with prompts, resources, and tools.
Secure file operations with configurable access controls.