magento-sql-mcp-server
Provides read-only access to a Magento 2 / Adobe Commerce MySQL database, enabling AI assistants to query and diagnose data across orders, catalog, customers, CMS, store configuration, EAV, MSI, B2B, staging, cron, indexers, and more. Supports SELECT/SHOW/DESCRIBE/EXPLAIN queries with automatic limits and connection profile management for local, cloud, and remote databases.
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-sql-mcp-servershow me orders placed in the last 7 days with their statuses"
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 SQL MCP Server
An MCP (Model Context Protocol) server that provides AI assistants with read-only access to a Magento 2 / Adobe Commerce MySQL database. It auto-detects local DDEV environments, connects to Adobe Commerce Cloud via CLI tunnels, and ships 50+ tools for orders, catalog, customers, CMS, config, indexers, and diagnostics.
Complementary MCP: Documentation MCPs (see Related MCPs) cover official Adobe Commerce docs. This package covers your live database.
Features
50+ read-only tools for orders, products, customers, CMS, config, EAV, MSI, B2B, staging, cron, and indexers
Read-only by design — blocks INSERT/UPDATE/DELETE/DDL; masks password, token, and credit-card columns
Multi-environment profiles — local DDEV, Adobe Commerce Cloud (staging/production), direct remote DB, SSH tunnel
Zero-config local dev — reads
app/etc/env.php, auto-detects DDEV MySQL port (cached 120s)Commerce-aware — detects staging (
updated_in), MSI, B2B; EAV joins userow_idon CommerceCMS helpers —
get_cms_page,audit_cms_page_blocksParameter aliases —
querytosql,pathtopathPattern,entity_typetoentity_type_codePer-call profile override — pass
profile: "staging"on any tool without restarting MCPMCP standards — Zod schemas, structured output, tool annotations, server instructions
Resources and prompts — table reference, EAV cheatsheet, order-debug and MSI-troubleshoot workflows
Dual transport — stdio (default) and optional HTTP for LibreChat / remote hosts
Related MCP server: Magento MCP Server
Quick setup for Cursor
Prerequisites
Requirement | Notes |
Node.js 18+ |
|
Magento project | Must contain |
DDEV | Optional; auto-detected for local profiles |
Adobe Commerce Cloud CLI | Required for Cloud staging/production tunnels |
Option A: npx (recommended)
Open Cursor → Settings → MCP → Add new MCP server
Configure:
Field | Value |
Name |
|
Type |
|
Command |
|
Set environment variables:
Variable | Required | Example |
| Yes |
|
| No |
|
Restart Cursor. Verify with:
Call get_connection_status
Option B: Project config (.cursor/mcp.json)
Create in your Magento project root:
{
"mcpServers": {
"magento-sql": {
"command": "npx",
"args": ["-y", "magento-sql-mcp-server"],
"env": {
"MAGENTO_ROOT": "/absolute/path/to/magento",
"MAGENTO_SQL_PROFILE": "local"
}
}
}
}Run from source (development):
{
"mcpServers": {
"magento-sql": {
"command": "node",
"args": ["/absolute/path/to/magento-sql-mcp-server/dist/index.js"],
"env": {
"MAGENTO_ROOT": "/absolute/path/to/magento",
"MAGENTO_SQL_PROFILE": "local"
}
}
}
}Option C: Init profile scaffold
npx magento-sql-mcp-server --initCreates .cursor/magento-sql-mcp.json from examples/magento-sql-mcp.example.json.
Profiles named default, local, or dev auto-fallback to DDEV/env.php detection without a config file.
Setup for other tools
Claude Desktop
OS | Config path |
macOS |
|
Windows |
|
Linux |
|
Use the same mcpServers JSON as Cursor.
VS Code / GitHub Copilot
.vscode/mcp.json — same env vars; use "servers" key instead of "mcpServers".
Windsurf
~/.codeium/windsurf/mcp_config.json — same structure as Claude Desktop.
Connection profiles
Profile file
Create .cursor/magento-sql-mcp.json in your Magento project (see examples/magento-sql-mcp.example.json):
{
"defaultProfile": "local",
"profiles": {
"local": { "mode": "auto" },
"staging": {
"mode": "direct",
"database": {
"host": "127.0.0.1",
"port": 30000,
"dbname": "your_project_stg",
"username": "your_project_stg",
"password": "${MAGENTO_STAGING_DB_PASSWORD}"
}
},
"production": {
"mode": "direct",
"database": {
"host": "127.0.0.1",
"port": 30000,
"dbname": "your_project_id",
"username": "your_project_id",
"password": "${MAGENTO_PRODUCTION_DB_PASSWORD}"
}
}
}
}Set passwords in MCP env (never commit credentials):
"env": {
"MAGENTO_STAGING_DB_PASSWORD": "from-tunnel-info",
"MAGENTO_PRODUCTION_DB_PASSWORD": "from-tunnel-info",
"MAGENTO_SQL_PROFILE": "local"
}Global shared profiles: ~/.config/magento-sql-mcp/config.json
Connection modes
Mode | Use case |
| Local dev: reads |
| Same as |
| Connect to host:port (Cloud tunnel on |
| MCP opens SSH port forward (non-Cloud hosts with standard SSH keys) |
Config values support ${ENV_VAR} references for secrets.
Per-tool override: pass profile on any tool call without changing MAGENTO_SQL_PROFILE.
Adobe Commerce Cloud setup
Cloud MySQL runs on database.internal:3306 inside the environment. It is not reachable from the public internet. Use an SSH tunnel (same approach as DBeaver with SSH enabled).
Laptop Cloud environment
127.0.0.1:30000 --SSH--> database.internal:3306Step 1: Install and authenticate Cloud CLI
Documentation: Adobe Commerce Cloud CLI
magento-cloud login
magento-cloud auth:info
magento-cloud project:list
magento-cloud environments -p YOUR_PROJECT_IDNon-interactive auth: magento-cloud auth:api-token-login or export MAGENTO_CLOUD_CLI_TOKEN=...
Step 2: Open tunnel
# Staging
magento-cloud tunnel:open -p YOUR_PROJECT_ID -e staging
# Production
magento-cloud tunnel:open -p YOUR_PROJECT_ID -e productionExample output:
SSH tunnel opened to database at: mysql://user:pass@127.0.0.1:30000/dbname?compression=1Default ports (single environment open):
Port | Service |
30000 | MySQL (primary) |
30001 | MySQL slave / MBI |
30002+ | OpenSearch, Valkey, etc. |
Note: Staging and production both use port 30000. Close the current tunnel before opening another:
magento-cloud tunnel:close
magento-cloud tunnel:open -p YOUR_PROJECT_ID -e stagingStep 3: Get credentials
magento-cloud tunnel:info -p YOUR_PROJECT_ID -e staging
magento-cloud tunnel:info -P databaseOn the remote container (SSH):
echo $MAGENTO_CLOUD_RELATIONSHIPS | base64 -d | json_ppCLI reference: Cloud CLI reference
Step 4: Configure MCP profiles
Cloud profiles use direct mode to 127.0.0.1:30000. The tunnel must remain open while MCP is connected.
Add .cursor/mcp.json and .cursor/magento-sql-mcp.json to .gitignore.
Step 5: Switch environments
Target | Steps |
Local |
|
Staging |
|
Production |
|
Step 6: Verify connection
magento-cloud tunnelsMCP tools:
get_connection_status(withprofile: "staging"or"production")detect_magento_environment
Check | Staging | Production |
Database name | Often | Usually project ID |
Cloud URL |
|
|
Order volume (7d) | Typically low | Active traffic |
magento-cloud url -p YOUR_PROJECT_ID -e stagingStep 7: Close tunnel
magento-cloud tunnel:closeCloud config URLs vs storefront URLs
core_config_data base URLs (web/unsecure/base_url, web/secure/base_url) on staging often still show the production domain (DB cloned from production). Actual storefront URLs are set by Cloud routes and Fastly.
Timezone-aware order queries
Store timezone: general/locale/timezone in core_config_data. Order created_at is stored in UTC. Convert store-local date ranges to UTC before querying sales_order. Use get_magento_config with pathPattern: "general/locale/%" to read the timezone.
Tools
Call list_available_tools for the full catalog with edition tags (OSS / MSI / B2B / Commerce).
Connection and environment
Tool | Description |
| List configured DB profiles |
| Test connectivity, host, database, latency |
| Detect OSS vs Commerce, MSI, B2B, staging columns |
| Snapshot: connection, indexers, crons, queue backlog |
SQL and schema
Tool | Parameters | Description |
|
| Read-only SELECT/SHOW/DESCRIBE/EXPLAIN (auto LIMIT 100) |
|
| Validate SQL safety without executing |
|
| EXPLAIN plan for a SELECT |
|
| List tables (optional SQL LIKE pattern) |
|
| Column definitions from INFORMATION_SCHEMA |
|
| Find tables containing a column name |
|
| Index details |
|
| Foreign key relationships |
|
| Row count for one table |
|
| Top tables by storage size |
Catalog and products
Tool | Tag | Description |
| OSS | Product entity + stock + websites |
| OSS | Name, price, status, visibility, url_key |
| OSS | Configurable to simple child SKUs |
| OSS | Category assignments with names |
| OSS | Attribute metadata + join hints |
| OSS | Indexed catalog rule price |
| MSI | Physical qty, reservations, salable qty |
| Commerce | Future staging campaigns for a SKU |
Sales and customers
Tool | Description |
| Order header + line items |
| Exact email only + order stats |
| Firstname/lastname LIKE search |
| Most recent active cart |
| Quote line items with parent-child nesting |
| Shipment tracking numbers |
| Tax rates applied to an order |
| B2B negotiable quotes (optional |
Operations, CMS, and config
Tool | Description |
|
|
| CMS page by identifier + embedded block IDs |
| CMS block by identifier or |
| Active/inactive audit of blocks in a page |
|
|
| Recent cron entries |
| Failed/stuck crons (24h) |
| Queue backlog (sampled on large DBs) |
| Websites, store groups, store views |
| Installed module versions |
| URL rewrite lookup |
| Flag plaintext secrets in config |
| Oversized log/visitor tables |
| Meta-tool: categorized tool catalog |
Edition-specific tools return a clear error if required tables are missing.
Resources
URI | Description |
| Common Magento tables by domain |
| Table group index (JSON) |
| Tables in a group (catalog, sales, customer, eav, msi, ...) |
| EAV entity types, attribute codes, value tables |
| Full tool catalog markdown |
| Server version and capabilities |
| Live connection status (JSON) |
Prompts
Prompt | Arguments | Description |
|
| Investigate order, items, addresses, status history |
|
| Product entity, EAV, stock, URL rewrite |
|
| Customer account, group, recent orders |
|
| Read store configuration paths |
| Review indexer and mview health | |
|
| Trace quote to order conversion |
|
| Diagnose MSI salable qty issues |
|
| Audit B2B company and quotes |
|
| View upcoming staging campaigns |
Usage examples
What you ask | What happens |
"How many orders yesterday and total revenue?" | Timezone-aware query on |
"Debug order 1000203870" |
|
"What is the store timezone?" |
|
"Check Fastly config on staging" |
|
"Audit CMS blocks on the home page" |
|
"Is this Commerce with MSI?" |
|
"Why is salable qty 0 for SKU X?" |
|
"Show indexer and failed cron status" |
|
How it works
+-------------+ +---------------------------+ +-----------------------------+
| AI Client |---->| MCP Server (stdio/HTTP) |---->| MySQL (read-only) |
| Cursor, |<----| 50+ Tools |<----| Magento / Adobe Commerce |
| Claude, | | 7 Resources, 9 Prompts | +-----------------------------+
| VS Code | +---------------------------+
+-------------+
|
+-- Profile: MAGENTO_SQL_PROFILE -> config JSON
+-- auto mode: env.php + DDEV port (cached 120s)
+-- Cloud: magento-cloud tunnel -> 127.0.0.1:30000
+-- Query validation: read-only only
+-- Auto LIMIT 100 (max 1000)
+-- Sensitive column masking
+-- Commerce staging: updated_in = 2147483647MCP host starts the server with
MAGENTO_ROOTpointing at your Magento projectresolveConnection()loads profile from.cursor/magento-sql-mcp.jsonor auto-detectsFor local DDEV: reads
app/etc/env.php, runsddev describe -jonce (cached)Tools run validated read-only SQL or canned queries with Magento-aware joins
Results return as structured JSON with Zod schemas
HTTP transport
npx magento-sql-mcp-server --http
# listens on http://localhost:3100 (override with MCP_HTTP_PORT)LibreChat librechat.yaml:
mcpServers:
magento-sql:
type: streamable-http
url: http://localhost:3100
initTimeout: 30000Configuration
Environment variables
Variable | Description |
| Magento project root (must contain |
| Active profile ( |
| Override mode: |
| DB host override |
| DB port override |
| Database name override |
| DB username override |
| DB password override |
| Staging password for profile |
| Production password for profile |
| SSH tunnel host override |
| SSH tunnel user override |
| HTTP transport port (default: |
Per-tool overrides: magentoRoot and profile arguments on most tools.
Troubleshooting
MCP server failed to start
Verify Node.js 18+:
node --versionTest manually:
npx magento-sql-mcp-server(should print "running on stdio")Ensure
MAGENTO_ROOTpoints to a directory withapp/etc/env.php
Profile local not found
v2.4.0+ auto-fallbacks local/default/dev to auto-detect. Upgrade or run:
npx magento-sql-mcp-server --initConnection refused on Cloud (port 30000)
Tunnel not running:
magento-cloud tunnel:open -p PROJECT_ID -e stagingWrong environment:
magento-cloud tunnelsthen close and reopenTunnel dropped after reboot: re-run
tunnel:open
Connected to wrong environment
Run get_connection_status and check database. Staging names often end in _stg; production matches project ID.
Missing password environment variable
Copy password from magento-cloud tunnel:info into MCP env. Do not commit it.
DDEV connection refused / wrong port
Ensure DDEV is running:
ddev startDDEV port is cached for 120s after first discovery
Tool parameter errors
Use | Instead of |
|
|
|
|
|
|
Slow queue / health check tools
On large databases, queue backlog uses sampled counts. Check sampled: true in results.
Green dot does not appear in Cursor
Restart Cursor
Refresh MCP server in settings
Check Output panel for errors
Security
All queries validated as read-only before execution
Auto LIMIT (default 100, max 1000) on SELECT without explicit LIMIT
Password, token, and credit-card columns masked in results
Customer/admin password hashes never exposed
Use read-only MySQL users for Cloud profiles when available
Never commit credentials; use MCP
envor${ENV_VAR}in config JSONClose Cloud tunnels when finished; avoid heavy full-table scans on production
Development
Run from source
git clone https://github.com/jigarkkarangiya/magento-sql-mcp-server.git
cd magento-sql-mcp-server
npm install
npm run build
MAGENTO_ROOT=/path/to/magento npm startTests
npm test
MAGENTO_ROOT=/path/to/magento npm run test:live
MAGENTO_ROOT=/path/to/magento npm run test:scenariosProject structure
magento-sql-mcp-server/
├── src/ # MCP server source
├── scripts/ # live-tool-smoke.ts, scenario-benchmark.ts
├── tests/ # unit tests
├── examples/ # magento-sql-mcp.example.json
└── dist/ # compiled JS (npm run build)Requirements
Requirement | Required for |
Node.js 18+ | All modes |
PHP CLI |
|
DDEV CLI | Optional; local auto-detect |
Adobe Commerce Cloud CLI | Cloud staging/production tunnels |
OpenSSH client |
|
MySQL read access | All modes |
Find this MCP
Registry | Link |
npm | |
GitHub |
Related MCPs
Documentation MCPs for Adobe Commerce and related platforms. Install alongside this server for docs + database coverage.
Package | npm | Description |
Merchant, admin, cloud, operations docs (Experience League) | ||
Developer docs (developer.adobe.com/commerce) | ||
Support Knowledge Base, patches, troubleshooting | ||
App Builder, I/O Runtime, Commerce extensibility | ||
API Mesh, GraphQL gateway | ||
I/O Events, webhooks | ||
AEM / Edge Delivery Services (aem.live) | ||
Odoo documentation |
Combined Cursor config:
{
"mcpServers": {
"magento-sql": {
"command": "npx",
"args": ["-y", "magento-sql-mcp-server"],
"env": {
"MAGENTO_ROOT": "/absolute/path/to/magento",
"MAGENTO_SQL_PROFILE": "local"
}
},
"adobe-commerce-docs": {
"command": "npx",
"args": ["-y", "adobe-commerce-docs-mcp"]
},
"adobe-commerce-dev-docs": {
"command": "npx",
"args": ["-y", "adobe-commerce-dev-docs-mcp"]
},
"adobe-commerce-kb": {
"command": "npx",
"args": ["-y", "adobe-commerce-kb-mcp"]
}
}
}All MCP packages: github.com/jigarkkarangiya?tab=repositories&q=mcp
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with MySQL databases through natural language for schema introspection, safe SQL execution, and full CRUD operations. It provides built-in tools for managing users, products, and orders while ensuring security through parameterized queries and read-only SQL checks.
- AlicenseBqualityCmaintenanceEnables AI assistants to manage Adobe Commerce and Magento 2 instances through business-level tools for catalog, promotions, CMS, and SEO. It features secure OAuth 1.0 authentication, safety guardrails for bulk operations, and built-in diagnostic reports for store health.38111MIT
- AlicenseAqualityBmaintenanceEnables AI assistants to inspect and query a MySQL database through safe, structured tools, including schema discovery and read-only queries.989MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to securely interact with MySQL databases, including listing tables, viewing schemas, and executing read-only SQL queries through natural language.6
Related MCP Connectors
Read-only bank access for your AI agent. Connects Claude, ChatGPT, Cursor, Gemini, Codex.
Manage your Savanto store from your AI: catalog, content, prompts, and analytics, by chat.
Persistent memory and knowledge management for AI agents with semantic search and 50+ tools.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/jigarkkarangiya/magento-sql-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server