Repository navigation
Architecture Bootstrap
The bootstrap process initializes a connection to a Magento 2 installation from outside the module system, enabling tool access to Magento's ObjectManager and service layer.
1. MagentoDetector::findRoot()
└── Searches for app/etc/env.php upward from CWD
2. MagentoBootstrap::initialize($rootDir)
├── Register Composer autoloader
├── Set Magento root constants (BP)
├── Initialize ObjectManager
├── Record sentinel file mtimes
└── Return ObjectManager instance
3. RequiresMagento (on each tool call)
├── Check sentinel mtimes (staleness)
├── If stale → reinitialize ObjectManager
└── Proceed with tool execution
MagentoDetector locates the Magento root by searching for app/etc/env.php starting from the current working directory and walking upward. This supports:
- Standard Magento installations
- Subdirectory-based projects
- Containerized environments where the working directory differs
The bootstrap follows the same pattern as n98-magerun2:
- Requires Magento's
app/bootstrap.php - Creates the
Bootstrapinstance - Obtains the
ObjectManagerfrom the application
This grants full access to Magento's dependency injection container without being registered as a Magento module.
After initialization, Bricklayer records the modification times of sentinel files:
-
app/etc/config.php— Changes when modules are enabled/disabled -
generated/metadata/global.php— Changes aftersetup:di:compile
Before every tool call, RequiresMagento::requireMagento() checks whether these files have changed. If staleness is detected, the ObjectManager is rebuilt automatically. This ensures tools always operate on the current application state after setup:upgrade, setup:di:compile, or module:enable.
AreaEmulator provides area code switching for tools that need specific Magento contexts:
-
adminhtml— Admin panel operations -
frontend— Storefront operations -
webapi_rest— REST API context -
graphql— GraphQL context -
crontab— Cron execution context
The code-runner tool exposes this via its area parameter.
EnvironmentResolver auto-detects containerized environments:
| Environment | Detection Method |
|---|---|
| DDEV |
/.dockerenv + DDEV_HOSTNAME env var |
| Warden |
/.dockerenv + WARDEN_ENV_NAME env var |
| Docker |
/.dockerenv file existence |
| Native | Fallback when no container detected |
The bricklayer-mcp-docker wrapper script adjusts execution paths when running inside containers.
Getting Started
Architecture
Tools Reference
- Overview (84 Tools)
- Introspection
- Catalog
- Orders
- Customers
- Database
- Logs & Diagnostics
- GraphQL
- Development
Configuration
Guidelines & Skills
Code Generation
Diagnostics
Security