Provides coding patterns and validation rules for Alpine.js components, specifically used as a modern alternative to jQuery in Magento themes like Hyva.
Enforces Magento-specific CSS and LESS styling standards, including validation for theme-specific rules and frontend conventions.
Provides specialized coding standards and validation rules for implementing GraphQL features within the Magento 2 framework.
Validates JavaScript code against Magento standards, covering RequireJS modules, UI Components, and Magento-specific widget patterns.
Identifies deprecated jQuery methods and provides modern replacements to help developers transition away from legacy frontend patterns in Magento.
Enforces 19 specific rules for LESS styling, including proper usage of the Magento UI Library and theme-specific variables.
Offers comprehensive validation for PHP code, covering security rules, discouraged functions, and framework-compliant architectural patterns.
Supports the definition of custom coding standards and validation rules for React-based implementations in specialized Magento theme configurations.
Assists with migrating restricted Zend Framework classes to their modern Laminas equivalents as required by current Magento standards.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Magento 2 Coding Standards MCP ServerShow me the correct way to read a file in Magento 2"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Magento 2 Coding Standards MCP Server
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.
Why This Exists
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:
Ask for a "jQuery widget" with Hyva theme active → get Alpine.js component instead
Paste PHP code → get instant validation with line numbers and fix suggestions
Ask "how to read a file" → get
DriverInterfacepattern, notfile_get_contents()
Features
83+ Coding Standard Rules — Security, Legacy, PHP, Functions, Templates, LESS/CSS, GraphQL, HTML, Framework, Exceptions, and more
150+ Discouraged Functions — Every PHP function Magento wants you to avoid, with the correct replacement
50+ Restricted Classes — Zend Framework → Laminas migrations, deprecated class replacements
25+ jQuery Deprecations — Deprecated jQuery methods with modern replacements
19 LESS/CSS Rules — Frontend styling standards
7 MCP Tools — Pattern lookup, code validation, security checking, rule explanations, theme management
4 Built-in Theme Presets — Hyva, Luma, Breeze, Porto with full validation rules and pattern overrides
Custom Theme Support — Add your own theme standards via JSON files
Multi-Platform — Works with every major AI coding tool
Quick Start
1. Clone and Build
2. Connect to Your AI Tool
Pick your platform below and add the MCP server:
Claude Code (CLI)
Claude Desktop
Add to your claude_desktop_config.json:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Cursor IDE
Add to .cursor/mcp.json in your project root:
VS Code Copilot
Add to .vscode/mcp.json in your project root:
Gemini CLI
Add to ~/.gemini/settings.json:
Continue.dev
Add to ~/.continue/config.json:
Windsurf
Add to Windsurf MCP settings:
Augment Code
Add in Augment Code settings:
Note: Replace
/path/to/with your actual installation path. On Windows, use forward slashes:C:/Users/name/magento-coding-standard-mcp/dist/index.js
Available Tools
1. get_magento_pattern
Get the correct Magento 2 way to accomplish a task. Returns the proper pattern, code example, what to avoid, and why.
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).
2. validate_code
Validate code against Magento coding standards. Returns violations with severity, line numbers, rule names, and fix suggestions.
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.
3. check_security
Security-focused validation checking for:
XSS vulnerabilities (unescaped output)
SQL injection risks (raw queries)
Insecure functions (exec, eval, shell_exec, etc.)
Superglobal usage ($_GET, $_POST direct access)
Object injection (serialize/unserialize)
4. explain_rule
Get detailed explanation of any rule with reasoning, bad/good examples, related rules, and documentation links.
Also supports theme-specific rules (e.g., Hyva.JS.NoJQuery).
5. list_rules
List all rules with optional filtering:
category: Security, Legacy, PHP, Functions, Templates, Less, GraphQL, etc.
minSeverity: 1-10 (10 = most critical)
searchTerm: Search in rule names and descriptions
When a theme is active, theme rules are included in the listing.
6. get_rules_summary
Get a summary of all rules grouped by category with counts of errors and warnings.
7. manage_theme
Manage theme-specific coding standards that layer on top of base Magento rules.
Action | Description | Example |
| Show all available themes |
|
| Activate a theme |
|
| Deactivate theme |
|
| Show theme details |
|
Theme-Specific Standards
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.
Built-in Presets
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 |
How Themes Work
Activate a theme: The AI calls
manage_theme({ action: "set", themeId: "hyva" })Validation is enhanced:
validate_codenow flags jQuery, RequireJS, KnockoutJS usage as errorsPatterns are overridden:
get_magento_pattern({ task: "jquery widget" })returns Alpine.js component insteadRules are extended:
list_rulesincludes Hyva-specific rules likeHyva.JS.NoJQuery
Theme Details
Hyva Theme
USE: Alpine.js (x-data, x-show, x-on), TailwindCSS, vanilla JS, ViewModelRegistry,
$escaperAVOID: jQuery
$(), KnockoutJSdata-bind, RequireJSdefine()/require(), LESS,data-mage-init5 pattern overrides with full code examples for requirejs modules, jquery widgets, template structure, escaping, UI components
Luma/Blank Theme
USE: RequireJS AMD, jQuery, KnockoutJS, LESS with Magento UI Library,
$.widget(),data-mage-initAVOID: Global variables, inline scripts, ES modules, Alpine.js
5 pattern overrides for requirejs modules, jquery widgets, UI components, template structure, LESS/CSS
Breeze Theme
USE: Vanilla JS, Breeze component API (
$.widget,$.view), lightweight LESS,fetch()APIAVOID: RequireJS, heavy jQuery, KnockoutJS, uiComponent
3 pattern overrides for requirejs modules, jquery widgets, template structure
Porto Theme
USE: Luma conventions + Porto widgets, Porto LESS variables, child theme pattern
AVOID: Modifying core Porto files, hardcoded colors/fonts
3 pattern overrides for template structure, LESS/CSS, requirejs modules
Custom Themes
Create your own theme standards by placing JSON files in ~/.magento-mcp/themes/:
Override the directory with the MAGENTO_MCP_THEME_DIR environment variable.
See src/themes/custom/README.md for full JSON schema documentation.
Knowledge Base Coverage
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... |
Severity Levels
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 |
Project Structure
Development
Requirements
Node.js >= 18.0.0
npm >= 8.0.0
Tech Stack
TypeScript with ESM modules
@modelcontextprotocol/sdkfor MCP protocolzodfor input validationZero runtime dependencies beyond MCP SDK and Zod
How It Works
You connect this MCP server to your AI tool (Claude, Cursor, Gemini, etc.)
The AI automatically uses the tools when writing Magento code
Before generating code, it calls
get_magento_patternto get the correct approachAfter generating code, it calls
validate_codeto check for violationsTheme standards layer on top — set your theme once and all suggestions adapt
The AI doesn't need special prompting. The MCP tools are described clearly enough that AI assistants naturally call them when working on Magento projects.
Contributing
Contributions are welcome! Areas that could use help:
Additional theme presets (e.g., Magezon, Amasty, custom frameworks)
More validation rules for edge cases
Integration tests
Performance optimizations for large codebases
Documentation improvements
Adding a New Theme Preset
Create
src/themes/presets/my-theme.tsfollowing theThemeStandardinterfaceExport it from
src/themes/presets/index.tsAdd to
THEME_PRESETSrecordRun
npm run build— zero errors required
License
MIT - see LICENSE for details.