Download the PHP package hryvinskyi/magento2-mcp-server without Composer

On this page you can find all versions of the php package hryvinskyi/magento2-mcp-server. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package magento2-mcp-server

MCP Server for Adobe Commerce (Magento 2)

Lets AI clients that speak the Model Context Protocol work with your store. The client finds and runs the operations of the store's Web API and GraphQL schema, as the admin user or integration it authenticates with.

What it does

Requirements

Installation

Via Composer (recommended)

Manual Installation

  1. Download the module from GitHub.
  2. Place it in app/code/Hryvinskyi/McpServer.
  3. Run:

setup:upgrade creates three tables: hryvinskyi_mcp_session, hryvinskyi_mcp_confirmation and hryvinskyi_mcp_ability_override.

Configuration

Go to Stores > Configuration > MCP Server > MCP Server. All options are set in the default scope only.

Group General:

Option Description Default
Enable MCP Server While it is off, the endpoint refuses every message No
Read-only Mode Clients may only call abilities that read data. Abilities that write or delete are blocked Yes
Expose Anonymous Abilities Lets clients call abilities that any guest may call through the REST API, such as account creation or guest checkout. Through MCP, the CAPTCHA and rate limits set for each REST route do not apply, so these abilities are denied while this is No. Yes also lets every GraphQL ability run, because they all run as a guest. To keep them off, set Enable GraphQL Abilities to No No

The server is off after install. Turning it on is your step.

Group GraphQL:

Option Path Description Default
Enable GraphQL Abilities hryvinskyi_mcp_server/graphql/enabled Offers the query fields of the store's GraphQL schema as abilities. They are still denied until Expose Anonymous Abilities is Yes Yes
Expose GraphQL Mutations hryvinskyi_mcp_server/graphql/expose_mutations Also offers the mutation fields as abilities. Mutations write data, so read-only mode blocks them No
GraphQL Endpoint URL hryvinskyi_mcp_server/graphql/endpoint_url An absolute http(s) URL ending in /graphql, for a server that cannot reach its own public host name. Empty means the secure base URL of the store view below, followed by graphql. That default is refused, and no GraphQL ability is listed, when the stored base URL is a placeholder such as {{base_url}}: Magento fills it in from the host of each request. Set this URL then Empty
Store View hryvinskyi_mcp_server/graphql/store_code The store view the GraphQL abilities run in, sent as the Store header. Empty means the default store view Empty

See GraphQL abilities for what these settings do.

Calling the endpoint

The URL is https://<host>/rest/all/V1/mcp.

Tokens

Integration token (recommended).

  1. Go to System > Extensions > Integrations and add an integration.
  2. On its API tab, give it the resource Use the MCP endpoint, plus whatever resources the abilities it will run need.
  3. Activate the integration and copy its Access Token.
  4. Magento accepts an integration's access token as a Bearer token only when Stores > Configuration > Services > OAuth > Consumer Settings > Allow OAuth Access Tokens to be used as standalone Bearer tokens is Yes. It is off by default (oauth/consumer/enable_integration_as_bearer).

Admin token. POST /rest/V1/integration/admin/token returns a token for an admin user. It expires after Admin Token Lifetime (hours) (oauth/access_token_lifetime/admin, default 4). With two-factor authentication enabled, that endpoint refuses to issue a token. Use an integration instead.

Client configuration

Cursor (.cursor/mcp.json, a remote server with headers):

Claude Desktop (claude_desktop_config.json) starts local commands only. A remote server with a Bearer header goes through the mcp-remote bridge, which needs Node.js. Keep Authorization:${AUTH_HEADER} without a space, as mcp-remote documents:

Protocol

Sessions

Limits

Limit Value Answer when it is exceeded
Request body 1 MB (1048576 bytes) HTTP 400, error -32600, id: null
Messages in a batch 20 HTTP 400, error -32600, id: null
JSON nesting depth 64 levels HTTP 400, error -32600, id: null
Live sessions per caller 20 The least recently used sessions are ended

A developer can change the body size, the batch size and the session count in etc/di.xml: the arguments maxBodyBytes of Hryvinskyi\McpServer\Model\Protocol\Server, maxBatchSize of Hryvinskyi\McpServer\Model\Protocol\MessageParser and maxSessionsPerCaller of Hryvinskyi\McpServer\Model\Session\DbSessionStore. The nesting depth is fixed.

Using stdio

For a client that runs on the same machine as the store, and starts a command instead of calling a URL. The command acts as an admin user. It needs Magento_User and Magento_Security, which Magento ships with.

Client configuration

Pass display_errors=stderr to PHP, so that a PHP error never lands in the answers.

Claude Desktop (claude_desktop_config.json):

With DDEV, the same command runs in the container. If the client does not start in the project directory, add "-p", "<project>" after "exec":

How it runs

The three tools

Abilities are not listed as tools. A client finds one, reads its arguments, then runs it.

discover_abilities

Searches the abilities. All arguments are optional.

Argument Description
query Words to find in the ability name, title or category. The search is case-insensitive. Empty lists every ability
category Only abilities of this category: a Magento module name, for example Magento_Catalog, or GraphQL
access read, write or delete
limit 1 to 100. Default 25
offset 0 or more. Default 0

The answer is {total, abilities: [{name, title, category, access, exposure}]}, sorted by name. Every ability is listed, whatever the caller's role allows.

get_ability_info

Takes name. The answer is {name, title, description, category, source, access, aclResources, exposure, allowedForYou, inputSchema}, plus denialReason when no client may call the ability: deny_list, read_only_mode, anonymous_ability or another rule's code.

inputSchema is a JSON Schema built from Magento's Web API metadata. Data types nest at most six levels in it. allowedForYou tells whether the caller's role holds every resource in aclResources.

execute_ability

Runs an ability.

Argument Description
name The ability name. Required
arguments An object keyed by argument name, as inputSchema describes. Default {}
confirmationToken The token that the -32004 error of this same call carried, sent once the user confirmed. Optional

The old confirm argument is gone. A call that sends it gets a tool error that explains the token.

On success, the tool result holds the value as JSON text and as structuredContent. A scalar or a list is wrapped as {"result": ...}.

Case Answer
Unknown ability, or arguments the service cannot take A tool result with isError: true and a message, so the model can correct itself
The service fails A tool result with isError: true. A message meant for users is passed on. Any other error is masked and logged
Denied JSON-RPC error -32003, with data: {ability, reason}. See the reasons below
The ability needs a confirmation and the call has no valid token JSON-RPC error -32004, with data: {ability, confirmationToken}. Ask the user, then call again with the same name and arguments plus that token
The ability must be called over HTTPS and the request was not A tool result with isError: true

The reasons of a -32003 error:

Reason Why the call was denied
deny_list The ability is on the built-in deny-list or has the deny override
read_only_mode Read-only mode is on and the ability writes or deletes
anonymous_ability The ability is open to guests and Expose Anonymous Abilities is No
acl The caller's role lacks an ACL resource of the ability
argument_guard A guard refused the arguments of this call

A module that adds an exposure rule can report a reason of its own (see Extending).

Confirmation tokens

An ability with the confirm override does not run on the first call. The error -32004 carries a confirmationToken. The client asks the user, then calls execute_ability again with the same name and arguments and that token.

A token proves that the client made a second, explicit call for exactly these arguments. It does not prove that a person approved the call. A client that sends the token on its own, with no question to the user, gets the same result.

JSON-RPC errors that answer a parsed request come with HTTP 200 and the request's id. Input that cannot be parsed (-32700, or an invalid envelope -32600) is HTTP 400 with id: null.

Abilities

Abilities come from three sources: the modules that register them in di.xml (source pool), the Web API (webapi) and the GraphQL schema (graphql). get_ability_info names the source. This section is about the Web API abilities; the others have their own sections below.

A Web API ability is one service method that a webapi.xml route calls.

The input schemas are cached in the MCP Server cache type. Cleaning or flushing that cache type rebuilds them.

GraphQL abilities

Every query field of the store's GraphQL schema is an ability. The module reads the schema by introspection, from the store's own /graphql.

Who runs them

Calling one

inputSchema has one property for each argument of the field. A field whose result is an object, an interface, a union or a list of them also takes a required selection. It is the selection set of the result:

Setup

Exposure

Every ability has one exposure. When several rules apply, the strictest wins, in this order:

Order Exposure When
1 denied The ability is on the built-in deny-list, has the deny override, or is open to guests while Expose Anonymous Abilities is No
2 read_only_blocked Read-only mode is on and the ability is write or delete
3 needs_confirmation The ability has the confirm override
4 exposed None of the above

A call that is denied changes nothing. The exposure, the caller's ACL, the confirmation and the argument guards are all checked before the ability runs.

Read-only mode

It is on after install. Turn it off in the configuration to let clients run abilities that write or delete. Do this only with a token whose role holds just the resources you want a client to use.

Built-in deny-list

These abilities are always denied, whatever the overrides say:

Pattern What it covers
integration.* Integrations, and the services that issue admin and customer tokens
jwt_user_token.* JWT user tokens
two_factor_auth.* Two-factor authentication, including its token endpoints
login_as_customer*.* Login as customer
customer.account_management.*password* Customer password reset and change
graphql.mutation.*token* GraphQL mutations that issue, revoke, exchange or delete a token, such as a customer token or a stored payment token
graphql.mutation.*password* GraphQL mutations that set, change or reset a password

The patterns are fnmatch patterns in etc/di.xml, in the patterns argument of Hryvinskyi\McpServer\Model\Exposure\Rule\BuiltInDenyListRule. Another module can add patterns there. The list cannot be changed in the configuration.

Overrides

A per-ability override is a row in hryvinskyi_mcp_ability_override: ability, deny and confirm. Overrides only add restrictions. They cannot lift read-only mode or the built-in deny-list. The Hryvinskyi\McpServer\Api\AbilityOverrideRepositoryInterface reads and saves overrides; the MCP Server page edits them (see The admin page).

Anonymous abilities

An ability whose only ACL resource is anonymous can be called by a guest through REST. Through MCP, the CAPTCHA and rate limits of each REST route do not apply. So these abilities are denied with the reason anonymous_ability, until you set Expose Anonymous Abilities to Yes. Turn it on only when you accept that. Every GraphQL ability is one of them.

Argument guards

A guard looks at the arguments of one call and may refuse it. Guards run after the confirmation check and before the ability runs. A refusal is a -32003 error with the reason argument_guard.

The module ships one guard. It refuses customer.customer_repository.save when the arguments hold a passwordHash. Passwords are never set through MCP that way.

ACL

The caller's role is never used to hide an ability. discover_abilities lists all of them, and get_ability_info says what each needs. The ACL decides only when a call runs.

The module adds these ACL resources:

The admin page

Stores › Settings › MCP Server (Hryvinskyi_McpServer::view):

Extending

Registering an ability

A module adds an ability by implementing Hryvinskyi\McpServer\Api\PoolAbilityInterface and adding the class to the abilities argument of Hryvinskyi\McpServer\Model\Source\Pool\PoolAbilitySource. The item's key must be the ability's name.

The module keeps no log of calls. Errors go to the PSR logger.

Privacy and security

Limits of this version

Author

Volodymyr Hryvinskyi

License

This module is licensed under the MIT License.

Support

For issues, feature requests, or questions, please contact the author or submit an issue on GitHub.


All versions of magento2-mcp-server with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
hryvinskyi/magento2-base Version ^2.2
magento/framework Version *
magento/module-authorization Version *
magento/module-backend Version *
magento/module-config Version *
magento/module-cron Version *
magento/module-integration Version *
magento/module-security Version *
magento/module-store Version *
magento/module-ui Version *
magento/module-user Version *
magento/module-webapi Version *
psr/log Version ^1 || ^2 || ^3
symfony/console Version ^5.4 || ^6.0 || ^7.0
symfony/process Version ^5.4 || ^6.0 || ^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package hryvinskyi/magento2-mcp-server contains the following files

Loading the files please wait ...