Skip to content

AI MCP Connector

Module: Magenx_AiMcp · admin and AI clients only, no storefront part

Serves a Model Context Protocol (MCP) endpoint from Magento, so an AI agent such as Claude can inspect and manage the store backend. It offers about 270 tools across products, categories, orders, invoices, shipments, credit memos, customers, stock, prices, promotions, CMS, attributes, configuration, caches, indexers, logs, reports, and the companion modules (returns, help desk, blog, feeds, GDPR and more).

It is a management surface, disabled by default. Every call needs a Magento integration token, or an admin’s own sign-in through OAuth, and every tool is checked against that integration’s or admin’s role.

  • Store configuration has no stock REST write endpoint, and caches and indexers have no REST API at all.
  • Management power belongs next to the thing managed. Putting admin write access behind the public storefront would turn any storefront bug into a catalog-destruction bug.
noyesnoyesreadwritenoyesnoyes

Tool call

Module
enabled?

404

Role has
AI MCP Server
+ tool's resource?

403 / refused

Writes?

Run

Allow Writes on?

Refused

confirm: true?

Preview only,
nothing changed

Apply + audit log

  1. Module switch: off by default; the endpoint returns 404.
  2. Permissions: the caller’s role needs AI MCP Server to reach the endpoint, plus each tool’s own resource (Magento’s own, such as Catalog > Products).
  3. Write switch: off by default. While off, the endpoint is read-only whatever the role says.
  4. Confirm gate: a write without "confirm": true returns a preview of exactly what it would do, and changes nothing.

An OAuth connection adds a fifth: the admin grants write access per connection.

Configuration writes have two more limits: secret-looking paths (*password*, *secret*, *token*, admin/*, oauth/*, crypt/*) can never be written, and Allowed Config Paths is empty by default, which denies every configuration write until you list paths. Reading configuration hides secret values.

Every confirmed write appears in the Admin Activity Log with field-level changes, the connector and the role behind it. Every attempted write is also logged to var/log/magenx_ai_mcp.log.

  1. Go to System > Extensions > Integrations > Add New Integration. Give it a name and leave Callback URL and Identity Link URL empty.

  2. On the API tab, grant AI MCP Server plus the resources for the tools you want.

  3. Save, then Activate. Copy the Access Token (not the consumer key or token secret).

  4. Enable the endpoint in Stores > Configuration > Magenx > AI MCP Server. Leave writes off until you have watched it read.

  5. Route /magenx-mcp/ to Magento in nginx (below).

  6. Connect your client, for example Claude Code:

    Terminal window
    claude mcp add --transport http magento \
    https://your-magento-host/magenx-mcp/server \
    --header "Authorization: Bearer <access token>"

Use an integration token, not an admin-user token: admin tokens expire after 4 hours, mid-session. Integration tokens never expire, so rotate them: Platform Overview shows each token’s age.

Set up with OAuth (claude.ai, Claude Desktop, mobile)

Section titled “Set up with OAuth (claude.ai, Claude Desktop, mobile)”

With OAuth on, admins connect as themselves:

  1. System > Extensions > AI MCP Connections > Create Client. The secret is shown once.
  2. In Claude, Settings > Connectors > Add custom connector with URL https://your-host/magenx-mcp/server. Under Advanced settings, enter the client ID and secret.
  3. Sign in to the Magento admin in the tab that opens (password and two-factor), choose the tool areas and whether to allow writes, and approve.
AI MCP Connections page: client and connection counts, the Create Client form and client list, the Connector Key section with Replace Key and Remove Key, and the Connections table with each admin's client, access, last use, expiry and a Revoke button
System > Extensions > AI MCP Connections.

The connection then acts as you: your role decides every tool, the audit log names you, and it ends when your admin account is deactivated, locked or deleted. Dynamic client registration is off by default; only clients created under AI MCP Connections can connect.

location /magenx-mcp/ {
# Optional edge allowlist; drop it for Claude Code on the web, which has no stable address.
allow 160.79.104.0/21; # Anthropic's published egress range
deny all;
# Same upstream and fastcgi wiring as your existing `location /graphql`.
try_files $uri $uri/ /index.php$is_args$args;
}

With OAuth on, also send /.well-known/oauth-protected-resource and /.well-known/oauth-authorization-server to Magento, ahead of any /.well-known/ block for the storefront. Check the route:

Terminal window
curl -sS -o /dev/null -w '%{http_code} %{redirect_url}\n' -X POST https://your-host/magenx-mcp/server

404 means it reaches Magento with the module off. 307 means it still hits the storefront.

Enabled Domains and Disabled Tools decide which tools a client is shown, not what it may do: permissions and the write switch still decide that. A full tool list takes a lot of an agent’s context; offering only the areas a task needs helps it plan. Both are empty by default, which means everything.

Terminal window
bin/magento magenx:mcp:check --admin=alice
bin/magento magenx:mcp:check --integration="Reporting"

Prints how many tools that caller gets and how many write, the switches and rate limits, and fails with the reason when the caller can’t use the endpoint. Run it after changing a role.

  • Tool calls are rate-limited per caller: 120 a minute, and confirmed writes 30 a minute.
  • invalidate_indexers marks indexers invalid for cron to rebuild; it doesn’t reindex within the request.
  • set_config refreshes Magento’s configuration cache, not the storefront’s. Refresh that through cache invalidation.
  • Allowed IPs checks the connecting address. Behind a proxy it only works if nginx sets the real client address.

Connect with an integration token

  1. An admin creates an integration with the endpoint permission and the permissions it needs, and copies its token.
  2. The agent is configured with the endpoint address and token, optionally narrowed to a profile.
  3. The handshake succeeds only with the endpoint permission; discovery lists only tools the integration may use.

Connect a hosted assistant with OAuth

  1. With OAuth on, an admin creates a client; its secret is shown once.
  2. The user adds the store as a custom connector in the assistant with that client.
  3. The assistant opens the store; the admin signs in with password and second factor and sees a consent page naming the client, where the code goes, the tool areas to grant and a write checkbox.
  4. On approval the assistant receives tokens and acts as that admin with that admin's permissions.

Read

  1. The agent calls a read tool; permissions, rate limit and toolset filters are checked; results come back (lists in a standard paged envelope).

Write

  1. The agent calls a write tool without confirmation and receives an exact preview.
  2. It calls again with confirmation; if writes are on, the caller's permissions allow it and (for OAuth) the connection may write, the change is applied, attributed in the admin audit trail and logged.

Place an order for a customer

  1. The agent creates a cart for a named store view, adds items by SKU and quantity, estimates shipping, sets addresses and shipping method together, picks an offline payment method and places the order, which needs its own permission.

Operate

  1. The agent checks caches, indexes, background jobs and installed features, reads masked log tails, and marks indexes for rebuild by the background scheduler.

These always hold:

  • A caller can never do through the endpoint what their admin permissions do not allow in the admin.
  • No write happens while writes are off, without confirmation, or (OAuth) without the connection's write grant.
  • No tool returns a secret, a file's contents or an arbitrary path.
  • A setting or address parameter can only remove tools, never add them.
  • Agents never set prices or order statuses directly.
  • Visible tools = all tools ∩ permitted ∩ store domains − disabled tools ∩ client / connection areas ∩ address slice.
  • Rate limits count per caller per minute; an admin counts once across all their connections.
  • Revoking an admin, integration, client or connection stops access on the next call.
  • A store that has not switched the endpoint on reveals nothing.
SituationWhat happens
Caller without endpoint permission starts the handshake.Forbidden.
Agent changes a payment API key setting while allow pattern is "everything".Refused by the deny list.
Write without confirmation.Preview; nothing changed.
Log read with ../ in the name.Unknown log.
Refresh token reused.Connection revoked.
Authorization code replayed.Everything it issued revoked.
Online payment method chosen for an agent order.Refused when chosen.
Erasure approved with the wrong email.Refused.
Customer group with members deleted.Refused, naming the count.
Address allow list set behind a proxy that hides the real address.Fails closed; refusal logged with the observed address.
Browser request from an unlisted origin.Forbidden.
Settings leave no tools at all.Logged as a warning.
  • Integrations and admins with the endpoint permission, on stores where the endpoint is on.
  • Online card payments for agent-created orders (offline payment methods only).
  • Setting customer passwords, raw order statuses or arbitrary prices.
  • Disabling the configuration cache or running a full reindex inside a request.
  • Returning file contents (attachments, media) or reading arbitrary paths.
  • Streaming responses or batched protocol requests.
  • Shopper-facing agent features.
Terminal window
composer require magenxcommerce/module-ai-mcp
bin/magento module:enable Magenx_AiMcp
bin/magento setup:upgrade
bin/magento setup:di:compile # production mode only
bin/magento cache:flush

Stores > Configuration > Magenx > AI MCP Server

General

SettingDefaultScopeNotes
Enable MCP Endpoint
magenx_ai_mcp/general/enabled
NoGlobalYes/No. Serves the Model Context Protocol endpoint at /magenx-mcp/server. While disabled the endpoint returns 404 and advertises nothing. Requires a Magento Integration whose ACL role includes "AI MCP Server".

Security

SettingDefaultScopeNotes
Allow Write Tools
magenx_ai_mcp/security/allow_writes
NoGlobalYes/No. Shown when magenx_ai_mcp/general/enabled = Yes. When No, tools that change data are not listed and cannot be called; the endpoint is read-only. This is independent of the integration's ACL — both must permit the write.
Allowed IP Addresses
magenx_ai_mcp/security/allowed_ips
emptyGlobalText area. Shown when magenx_ai_mcp/general/enabled = Yes. Comma or newline separated. Plain addresses (203.0.113.7) and CIDR ranges (10.0.0.0/8) are supported. Leave empty to accept any source address that presents a valid token. Behind a reverse proxy this compares against REMOTE_ADDR, which is the proxy's own address unless nginx's real_ip module is rewriting it (set_real_ip_from / real_ip_header). Without that, filling this in locks the endpoint out entirely. Refusals are recorded with the observed address in var/log/magenx_ai_mcp.log.
Allowed Browser Origins
magenx_ai_mcp/security/allowed_origins
emptyGlobalText area. Shown when magenx_ai_mcp/general/enabled = Yes. Comma or newline separated, e.g. https://app.example.com. The MCP transport requires the Origin header to be validated against DNS-rebinding attacks. Requests that send no Origin — curl, Claude Code, every ordinary MCP client — are unaffected by this setting. Requests that send one are refused unless it is listed here, so empty means "no browser may call this endpoint".
Writable Configuration Paths
magenx_ai_mcp/security/allowed_config_paths
emptyGlobalText area. Shown when magenx_ai_mcp/general/enabled = Yes. Comma or newline separated glob patterns, e.g. magenx_*/* or catalog/frontend/*. Empty denies every configuration write. Secret-bearing paths (keys, passwords, tokens, encrypted values) are refused regardless of what is listed here.
Tool Calls per Minute
magenx_ai_mcp/security/rate_limit
120GlobalText. Shown when magenx_ai_mcp/general/enabled = Yes. Per caller: one integration, or one admin across all their OAuth connections. A call over the limit is answered with an error the agent can read and wait on, and the first refusal in each minute is logged. 0 disables the limit.
Write Calls per Minute
magenx_ai_mcp/security/write_rate_limit
30GlobalText. Shown when magenx_ai_mcp/general/enabled = Yes. Confirmed write-tool calls per caller, counted on top of the limit above. Previews (a write called without confirm) count only towards the limit above. 0 disables the limit.
Audit Reads
magenx_ai_mcp/security/audit_reads
offGlobalDropdown. Shown when magenx_ai_mcp/general/enabled = Yes. Writes are always recorded in var/log/magenx_ai_mcp.log. This adds successful reads to the same file: the tool, the integration, the arguments and the ids of the records returned &mdash; never the records themselves. "Personal data only" covers customers, orders and their documents, carts, returns, help desk tickets, GDPR requests and admin users.

OAuth

Lets claude.ai, Claude Desktop and other MCP clients connect with an admin's own sign-in instead of an integration token. The admin approves each connection on a consent page behind the normal admin login and two-factor check, and the client acts with that admin's role. Clients are created, connections listed and revoked, and the optional connector key generated under System > Extensions > AI MCP Connections. See the README for the nginx locations this needs.

SettingDefaultScopeNotes
Enable OAuth
magenx_ai_mcp/oauth/enabled
NoGlobalYes/No. Shown when magenx_ai_mcp/general/enabled = Yes. Publishes /.well-known/oauth-protected-resource and /.well-known/oauth-authorization-server, and accepts OAuth access tokens on the MCP endpoint. Integration tokens keep working either way.
Allow Dynamic Client Registration
magenx_ai_mcp/oauth/allow_dynamic_registration
NoGlobalYes/No. Shown when magenx_ai_mcp/general/enabled = Yes, magenx_ai_mcp/oauth/enabled = Yes. Leave this off. Create a client under System > Extensions > AI MCP Connections instead, and enter its client ID and secret in the connector's advanced settings ("Use your own OAuth client"). When on, anyone can register a client and start a flow: that reveals the admin URL to them, and lets them send an admin a consent link that would connect their Claude account to the admin's role.
Allowed Redirect URIs
magenx_ai_mcp/oauth/allowed_redirect_uris
https://claude.ai/api/mcp/auth_callback https://claude.com/api/mcp/auth_callbackGlobalText area. Shown when magenx_ai_mcp/general/enabled = Yes, magenx_ai_mcp/oauth/enabled = Yes. One per line, matched exactly. A client can only be created or registered with, and only ever receive an authorization code at, a URI listed here. The default is claude.ai's callback. Add other clients' callbacks only for services you trust with an admin's access.
Allow Loopback Redirects
magenx_ai_mcp/oauth/allow_loopback_redirects
NoGlobalYes/No. Shown when magenx_ai_mcp/general/enabled = Yes, magenx_ai_mcp/oauth/enabled = Yes. Accept http://localhost, http://127.0.0.1 and http://[::1] callbacks on any port, for clients that run on the admin's own machine (Claude Code, MCP Inspector). Any program on that machine can then complete a flow the admin approves.
Access Token Lifetime (minutes)
magenx_ai_mcp/oauth/access_token_lifetime
60GlobalText. Shown when magenx_ai_mcp/general/enabled = Yes, magenx_ai_mcp/oauth/enabled = Yes. 5 to 1440. The client renews it with its refresh token without asking the admin.
Connection Lifetime (days)
magenx_ai_mcp/oauth/refresh_token_lifetime
30GlobalText. Shown when magenx_ai_mcp/general/enabled = Yes, magenx_ai_mcp/oauth/enabled = Yes. 1 to 90, counted from approval and never extended by use. When it runs out the admin has to sign in, and pass two-factor authentication, again.
Public Base URL
magenx_ai_mcp/oauth/public_base_url
emptyGlobalText. Shown when magenx_ai_mcp/general/enabled = Yes, magenx_ai_mcp/oauth/enabled = Yes. The origin clients reach the MCP endpoint on, e.g. https://www.example.com, when that is not the default store's secure base URL. It becomes part of the issuer and of every token's audience, so changing it ends every existing connection.

Tools

These narrow what a client is shown, not what it is permitted to do. The integration's ACL role and the write switch still decide that, and a tool withheld here is withheld from every integration.

SettingDefaultScopeNotes
Enabled Tool Domains
magenx_ai_mcp/tools/enabled_domains
emptyGlobalMultiple select. Shown when magenx_ai_mcp/general/enabled = Yes. Select nothing to offer every domain, which is the default. Selecting some offers only those: the whole tool list is a large part of a client's context window, and an agent given only the domains its task needs plans better within it. A tool outside the selection is not listed and cannot be called.
Disabled Tools
magenx_ai_mcp/tools/disabled_tools
emptyGlobalText area. Shown when magenx_ai_mcp/general/enabled = Yes. Comma or newline separated tool names, e.g. delete_product, delete_category. Applied after the domain selection above, so a name listed here is withheld even if its domain is enabled. A name no tool answers to is refused when you save rather than accepted and ignored.
  • Magento_Integration::system_extensions > AI MCP Connections

Grant these under System > Permissions > User Roles > Role Resources:

ResourceUnderID
AI MCP ServerMagenx_AiMcp::server
AI MCP Server DiagnosticsAI MCP ServerMagenx_AiMcp::ops
AI MCP Server ReportsAI MCP ServerMagenx_AiMcp::reports
AI MCP Server LogsAI MCP ServerMagenx_AiMcp::logs
Approve AI Client ConnectionsAI MCP ServerMagenx_AiMcp::oauth_grant
Manage AI Client ConnectionsAI MCP ServerMagenx_AiMcp::oauth_manage
AI MCP Server SectionStores > Settings > ConfigurationMagenx_AiMcp::config
JobGroupDefault scheduleChange it at
magenx_aimcp_oauth_purgedefault17 * * * *Fixed
TermMeaning
ToolA named operation with input schema, description, hints and, for some reads, an output schema.
Read tool / write toolA tool that does not / does change data or a live system.
CallerAn integration (token) or an admin (OAuth connection).
Endpoint permissionThe admin permission needed to reach the endpoint at all.
Write switchStore setting that allows write tools.
Confirm stepA write without confirm: true returns a preview and changes nothing.
DomainA group of tools by business area (catalog, sales, content, returns, operations…).
ProfileA named set of domains: analytics, catalog, content, support, operations.
ConnectionOne admin's approval of one OAuth client, with chosen tool areas and an optional write grant.
ClientAn OAuth client created by an administrator.
Audit logThe endpoint's own record of attempted writes (and of reads when configured).
Personal-data toolA read that returns information about people.