@hiberus-magento/magento-rest 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +511 -2
- package/THIRD-PARTY-NOTICES.txt +18 -0
- package/dist/cli.js +21555 -0
- package/dist/mcp.js +51019 -0
- package/package.json +59 -3
- package/server.json +56 -0
package/README.md
CHANGED
|
@@ -1,3 +1,512 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @hiberus-magento/magento-rest
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
An MCP (Model Context Protocol) server, and a companion operator CLI, for the
|
|
4
|
+
**Magento 2 / Adobe Commerce REST API** of one instance — catalog, orders,
|
|
5
|
+
customers, stock, content and store configuration — with the write tools
|
|
6
|
+
switched off unless you turn them on.
|
|
7
|
+
|
|
8
|
+
> **This is not EDS, ACS or ACO, and not the Magento Cloud CLI.** Adjacent names
|
|
9
|
+
> that are routinely confused:
|
|
10
|
+
>
|
|
11
|
+
> - **`magento-rest`** — the REST API of a running Magento instance. **This package.**
|
|
12
|
+
> - [`@hiberus-magento/magento-cloud`](https://npmjs.com/package/@hiberus-magento/magento-cloud) —
|
|
13
|
+
> wraps the `magento-cloud` CLI for Cloud projects, environments and database.
|
|
14
|
+
> - **EDS** — Edge Delivery Services, the publishing platform, served by
|
|
15
|
+
> [`@hiberus-magento/eds`](https://npmjs.com/package/@hiberus-magento/eds).
|
|
16
|
+
> - **ACS** — Adobe Commerce Storefront: a commerce storefront built on EDS.
|
|
17
|
+
> - **ACO** — Adobe Commerce Optimizer, served by
|
|
18
|
+
> [`@hiberus-magento/aco`](https://npmjs.com/package/@hiberus-magento/aco).
|
|
19
|
+
|
|
20
|
+
Single bundled file, zero runtime dependencies, so `npx` runs it with nothing
|
|
21
|
+
installed first.
|
|
22
|
+
|
|
23
|
+
Its tool surface follows the functional scope of
|
|
24
|
+
`magento2-mcp`, rebuilt on this repository's safety primitives: bounded lists,
|
|
25
|
+
field allowlists on every result, encoded paths, and no way to disable TLS
|
|
26
|
+
verification.
|
|
27
|
+
|
|
28
|
+
## The two binaries
|
|
29
|
+
|
|
30
|
+
| Binary | What it is |
|
|
31
|
+
| --- | --- |
|
|
32
|
+
| `hiberus-magento-rest-mcp` | The **MCP server**. By default it speaks JSON-RPC over stdio: this is what you put in an MCP client's configuration. With `MAGENTO_REST_HTTP_PORT` set it serves HTTP instead (see [Running over HTTP](#running-over-http)). |
|
|
33
|
+
| `hiberus-magento-rest` | The **operator CLI**, for a human at a terminal. It stores the token (`auth token set`, from stdin) and checks it (`auth status`). It has no command that reads or writes catalog data. |
|
|
34
|
+
|
|
35
|
+
With two binaries declared, `npx` has to be told which one to run
|
|
36
|
+
(`npx -y --package @hiberus-magento/magento-rest hiberus-magento-rest-mcp`); the
|
|
37
|
+
bare `npx -y @hiberus-magento/magento-rest` form exits with `could not determine
|
|
38
|
+
executable to run`.
|
|
39
|
+
|
|
40
|
+
<!-- package:start -->
|
|
41
|
+
|
|
42
|
+
## Tools
|
|
43
|
+
|
|
44
|
+
- `magentorest_get_product_by_sku` (read-only) — Use this to read one product by its SKU: name, price, status, visibility, type, timestamps, catalog attributes and category links.
|
|
45
|
+
- `magentorest_search_products` (read-only) — Use this to find products whose name contains a phrase. Returns a bounded page of summaries (id, sku, name, price, status, type) and the total count.
|
|
46
|
+
- `magentorest_advanced_product_search` (read-only) — Use this to filter products on one field with a chosen comparison (eq, like, gt, gteq, lt, lteq, in, ...) and sort the result. Returns a bounded page of summaries and the total count.
|
|
47
|
+
- `magentorest_create_product` — Use this to create a new product. Adds a catalog record; the SKU must be unique. Does not touch stock or categories. Without website_ids it goes to the default website only: the website of store_code's store view, or the store's only website; with several websites and no store_code it refuses and asks for website_ids (magentorest_get_websites lists them).
|
|
48
|
+
- `magentorest_update_product` — Use this to change fields of an existing product. Only the fields you pass are sent; at least one is required. Overwrites the current values.
|
|
49
|
+
- `magentorest_update_product_attribute` — Use this to set ONE attribute of a product by code (name, price, status, description, a custom attribute, ...). Overwrites the current value. The identity attributes sku, id, entity_id and type_id are refused.
|
|
50
|
+
- `magentorest_delete_product` — Use this to permanently delete a product by SKU. Irreversible: the product, its images and its URL rewrites are removed.
|
|
51
|
+
- `magentorest_assign_product_to_category` — Use this to add a product to a category at a position. Adds a link; it does not move the product out of other categories.
|
|
52
|
+
- `magentorest_remove_product_from_category` — Use this to remove a product from one category. The product itself and its other category links are kept.
|
|
53
|
+
- `magentorest_get_store_configs` (read-only) — Use this to read each store view's configuration: code, locale, base currency, timezone, weight unit and base URLs.
|
|
54
|
+
- `magentorest_get_store_views` (read-only) — Use this to list every store view with its code, name, website, store group and whether it is active.
|
|
55
|
+
- `magentorest_get_websites` (read-only) — Use this to list every website with its code, name and default store group.
|
|
56
|
+
- `magentorest_get_store_groups` (read-only) — Use this to list every store group with its website, root category and default store view.
|
|
57
|
+
- `magentorest_get_countries` (read-only) — Use this to list the countries Magento knows, with ISO codes, English names and their regions.
|
|
58
|
+
- `magentorest_get_currency_info` (read-only) — Use this to read the base and display currency, the available currency codes and the exchange rates.
|
|
59
|
+
- `magentorest_get_category_tree` (read-only) — Use this to read the category structure under a root category as a flat list: each node has its id, parent_id, name, level, position, product count and whether it is active. Capped at 500 nodes; truncated says when the cap cut it short.
|
|
60
|
+
- `magentorest_get_category_by_id` (read-only) — Use this to read one category by its numeric ID: name, parent, level, position, product count, children, URL path and catalog attributes.
|
|
61
|
+
- `magentorest_list_categories` (read-only) — Use this to find categories, optionally by parent, by a phrase in the name, or by active status. Returns a bounded page and the total count.
|
|
62
|
+
- `magentorest_get_products_in_category` (read-only) — Use this to list the products assigned to one category. Returns a bounded page of product summaries (id, sku, name, price, status, type) and the total count.
|
|
63
|
+
- `magentorest_create_category` — Use this to create a category under a parent. Adds a record; it does not assign any product to it.
|
|
64
|
+
- `magentorest_update_category` — Use this to change fields of an existing category. Only the fields you pass are sent; at least one is required. Overwrites the current values.
|
|
65
|
+
- `magentorest_delete_category` — Use this to permanently delete a category and its subcategories by ID. Irreversible; the products stay in the catalog but lose the assignment.
|
|
66
|
+
- `magentorest_move_category` — Use this to move a category under a different parent, optionally right after a sibling. Changes the category tree and the URL paths below it.
|
|
67
|
+
- `magentorest_get_customer_by_id` (read-only) — Use this to read one customer by numeric ID: group, website, store and the default address IDs, plus name and email only when the server runs with MAGENTO_REST_CUSTOMER_DATA=true. Date of birth, tax number and the address book are not returned.
|
|
68
|
+
- `magentorest_search_customers` (read-only) — Use this to find customers by part of the email or name, by group or website, or by creation date range (YYYY-MM-DD). Filters are combined with AND. Returns a bounded page of summaries and the total count.
|
|
69
|
+
- `magentorest_get_customer_groups` (read-only) — Use this to list the customer groups with their code and tax class.
|
|
70
|
+
- `magentorest_get_customer_addresses` (read-only) — Use this to list a customer's addresses by location: country, region and which is the default billing or shipping address, plus city and postcode only when the server runs with MAGENTO_REST_CUSTOMER_DATA=true. Street, telephone and the addressee are not returned.
|
|
71
|
+
- `magentorest_create_customer` — Use this to create a customer account from an email and a name. It takes no password: Magento's own password-reset flow is how the customer sets one. Adds a record; the email must not already exist on the website.
|
|
72
|
+
- `magentorest_update_customer` — Use this to change a customer's email, name or group. Only the fields you pass change; at least one is required. Overwrites the current values.
|
|
73
|
+
- `magentorest_delete_customer` — Use this to permanently delete a customer account by ID. Irreversible: the account and its address book are removed; past orders keep their own copy of the details.
|
|
74
|
+
- `magentorest_get_order_by_id` (read-only) — Use this to read one order by entity ID: status, state, totals, currency and the order lines; who placed it (customer ID, name, email) only when the server runs with MAGENTO_REST_CUSTOMER_DATA=true. Billing and shipping addresses and payment details are not returned.
|
|
75
|
+
- `magentorest_get_order_by_increment_id` (read-only) — Use this to read one order by its order number (increment ID), the one a customer quotes. Same fields as reading by entity ID. A number with no order is reported as not-found.
|
|
76
|
+
- `magentorest_search_orders` (read-only) — Use this to find orders by status, customer email or ID, creation date range (YYYY-MM-DD, whole days) and grand-total range. Filters are combined with AND. Newest first unless you sort otherwise. Returns a bounded page of summaries and the total count.
|
|
77
|
+
- `magentorest_get_order_items` (read-only) — Use this to list the lines of one order: SKU, name, quantities ordered, shipped, invoiced and refunded, price and row total, tax and discount.
|
|
78
|
+
- `magentorest_get_order_comments` (read-only) — Use this to read an order's status history: each entry's status, comment text, date and whether the customer was notified or can see it.
|
|
79
|
+
- `magentorest_add_order_comment` — Use this to add a comment to an order's history, optionally moving it to another status. Silent and hidden from the customer unless you say otherwise: setting is_customer_notified to true makes Magento EMAIL the customer.
|
|
80
|
+
- `magentorest_cancel_order` — Use this to cancel an order that has not been invoiced. Changes its state to canceled and releases the reserved stock; it cannot be undone from here.
|
|
81
|
+
- `magentorest_hold_order` — Use this to put an order on hold, which stops it being invoiced or shipped until it is released with magentorest_unhold_order.
|
|
82
|
+
- `magentorest_unhold_order` — Use this to release an order from hold so it can be invoiced and shipped again.
|
|
83
|
+
- `magentorest_get_invoice_by_id` (read-only) — Use this to read one invoice by its numeric ID: state, totals, currency and the invoiced lines.
|
|
84
|
+
- `magentorest_search_invoices` (read-only) — Use this to find invoices by order, state and creation date range (YYYY-MM-DD, whole days). Filters are combined with AND. Returns a bounded page of summaries and the total count.
|
|
85
|
+
- `magentorest_get_shipment_by_id` (read-only) — Use this to read one shipment by its numeric ID: quantities, weight, the shipped lines and the tracking entries.
|
|
86
|
+
- `magentorest_search_shipments` (read-only) — Use this to find shipments by order and creation date range (YYYY-MM-DD, whole days). Filters are combined with AND. Returns a bounded page of summaries and the total count.
|
|
87
|
+
- `magentorest_get_creditmemo_by_id` (read-only) — Use this to read one credit memo (refund) by its numeric ID: state, totals, adjustments, currency and the refunded lines.
|
|
88
|
+
- `magentorest_search_creditmemos` (read-only) — Use this to find credit memos (refunds) by order, state and creation date range (YYYY-MM-DD, whole days). Filters are combined with AND. Returns a bounded page of summaries and the total count.
|
|
89
|
+
- `magentorest_create_invoice` — Use this to invoice an order, whole or by line. With capture set to true Magento CAPTURES the payment — the customer is charged; the default is false, which only records the invoice. Setting notify_customer to true emails the customer. Returns the new invoice ID.
|
|
90
|
+
- `magentorest_create_shipment` — Use this to record a shipment for an order, whole or by line, optionally with tracking numbers. Setting notify_customer to true emails the customer. Returns the new shipment ID. Shipping deducts stock from the product's source: if a product has none there, Magento answers only "Could not save a shipment" (its log says the quantity is not available), so check stock first with magentorest_get_source_items.
|
|
91
|
+
- `magentorest_add_shipment_tracking` — Use this to add a tracking number to an existing shipment. Adds an entry; it does not change the shipment's lines or notify the customer.
|
|
92
|
+
- `magentorest_create_creditmemo` — Use this to REFUND an order, whole or by line, with optional shipping and manual adjustments. Money goes back to the customer; it cannot be undone from here. Setting notify_customer to true emails the customer. Returns the new credit memo ID.
|
|
93
|
+
- `magentorest_get_product_stock` (read-only) — Use this to read the stock item of one product by SKU: quantity, in-stock flag, whether stock is managed, sale quantity limits and backorder setting. With multi-source inventory enabled (the usual setup now) this legacy stock item mirrors only the default source, so it can show a null or zero quantity for a product held in other sources: use magentorest_get_source_items for every source.
|
|
94
|
+
- `magentorest_get_low_stock_products` (read-only) — Use this to list stock items at or below a quantity threshold, for one stock scope. Items already at zero are included. Returns a bounded page and the total count. With multi-source inventory enabled (the usual setup now) this legacy stock item mirrors only the default source, so it can show a null or zero quantity for a product held in other sources: use magentorest_get_source_items for every source.
|
|
95
|
+
- `magentorest_get_inventory_sources` (read-only) — Use this to list the inventory sources (warehouses) of multi-source inventory: code, name, whether enabled, country, region, city, postcode and priority. Street, phone, email and contact person are not returned.
|
|
96
|
+
- `magentorest_get_inventory_stocks` (read-only) — Use this to list the inventory stocks of multi-source inventory with the sales channels (websites) each one serves.
|
|
97
|
+
- `magentorest_get_source_items` (read-only) — Use this to read a product's quantity and status in each inventory source, by SKU.
|
|
98
|
+
- `magentorest_update_product_stock` — Use this to set a product's stock quantity on the default stock. The in-stock flag follows the quantity (in stock when above zero) unless you set it. Overwrites the current quantity. With multi-source inventory enabled this changes the quantity of the default source (observed on a live store) and no other source; magentorest_get_source_items reads every source, and nothing here writes the others.
|
|
99
|
+
- `magentorest_get_cart_by_id` (read-only) — Use this to read one cart by ID: activity, item count and quantity, currency and the cart lines; the customer's identity (id, name, email, group) only when the server runs with MAGENTO_REST_CUSTOMER_DATA=true. Addresses are not returned.
|
|
100
|
+
- `magentorest_search_carts` (read-only) — Use this to find carts by customer email or ID, active status and creation date range (YYYY-MM-DD, whole days). Filters are combined with AND. Returns a bounded page of summaries and the total count.
|
|
101
|
+
- `magentorest_get_cart_items` (read-only) — Use this to list the lines of one cart: SKU, name, quantity, price and product type.
|
|
102
|
+
- `magentorest_get_abandoned_carts` (read-only) — Use this to find abandoned carts: active, non-empty carts not updated for at least a number of days, most recently updated first. Each entry gives the item count and the dates, and names the owner (or Guest) only when the server runs with MAGENTO_REST_CUSTOMER_DATA=true. Returns a bounded page, the total count and the cutoff used.
|
|
103
|
+
- `magentorest_get_cms_block_by_id` (read-only) — Use this to read one CMS block by ID, including its content (HTML), title, identifier, dates and whether it is active.
|
|
104
|
+
- `magentorest_search_cms_blocks` (read-only) — Use this to find CMS blocks by identifier (exact), part of the title, or active status. Filters are combined with AND. Returns a bounded page of summaries WITHOUT the content, and the total count; read one by ID for its content.
|
|
105
|
+
- `magentorest_update_cms_block` — Use this to change a CMS block's identifier, title, content or active flag. Only the fields you pass change; at least one is required. Overwrites the current values on the live storefront. The block ends up assigned to all store views: Magento resets a block's store assignment on every REST update.
|
|
106
|
+
- `magentorest_delete_cms_block` — Use this to permanently delete a CMS block by ID. Irreversible: it disappears from the storefront immediately.
|
|
107
|
+
- `magentorest_get_cms_page_by_id` (read-only) — Use this to read one CMS page by ID, including its content (HTML), title, identifier, dates and whether it is active.
|
|
108
|
+
- `magentorest_search_cms_pages` (read-only) — Use this to find CMS pages by identifier (exact), part of the title, or active status. Filters are combined with AND. Returns a bounded page of summaries WITHOUT the content, and the total count; read one by ID for its content.
|
|
109
|
+
- `magentorest_update_cms_page` — Use this to change a CMS page's identifier, title, content or active flag. Only the fields you pass change; at least one is required. Overwrites the current values on the live storefront. The page keeps its store assignment.
|
|
110
|
+
- `magentorest_delete_cms_page` — Use this to permanently delete a CMS page by ID. Irreversible: it disappears from the storefront immediately.
|
|
111
|
+
- `magentorest_create_cms_block` — Use this to create a CMS block. Adds a block for all store views (Magento's REST body takes no store assignment) that is active unless you say otherwise.
|
|
112
|
+
- `magentorest_create_cms_page` — Use this to create a CMS page at a URL key. Adds a page for all store views (Magento's REST body takes no store assignment) that is active, with a one-column layout, unless you say otherwise.
|
|
113
|
+
- `magentorest_get_product_attribute` (read-only) — Use this to read one product attribute by code: its input type, scope, flags (required, searchable, filterable, comparable), options and store labels.
|
|
114
|
+
- `magentorest_search_product_attributes` (read-only) — Use this to find product attributes by part of the code, input type (text, select, multiselect, boolean, ...), or the searchable and filterable flags. Filters are combined with AND. Returns a bounded page of summaries and the total count.
|
|
115
|
+
- `magentorest_get_attribute_options` (read-only) — Use this to list the options of a select or multiselect attribute as label and value pairs.
|
|
116
|
+
- `magentorest_get_attribute_sets` (read-only) — Use this to list the product attribute sets with their ID, name and sort order. Returns a bounded page and the total count.
|
|
117
|
+
- `magentorest_get_attribute_set_attributes` (read-only) — Use this to list the attributes that belong to one attribute set, as summaries (code, input type, label, required, searchable, filterable).
|
|
118
|
+
- `magentorest_add_attribute_option` — Use this to add an option to a select or multiselect attribute. Adds an option that is not the default; it does not assign it to any product. **Not verified against a live service** — this tool has not been run against a real Magento instance; its request shape and response projection are covered by unit tests against a test double and by the conformance suite.
|
|
119
|
+
- `magentorest_get_product_media` (read-only) — Use this to list a product's media entries (images and videos): ID, type, label, position, whether hidden, the roles it plays and its file path.
|
|
120
|
+
- `magentorest_get_product_media_entry` (read-only) — Use this to read one media entry of a product by its entry ID.
|
|
121
|
+
- `magentorest_add_product_image` — Use this to add an image to a product from base64 data (at most 2,000,000 characters, JPEG, PNG, GIF or WebP). Adds a media entry; it does not remove existing ones. Returns the new entry ID.
|
|
122
|
+
- `magentorest_update_product_media` — Use this to change a media entry's label, position, roles or hidden flag. Only the fields you pass change; at least one is required. Overwrites the current values.
|
|
123
|
+
- `magentorest_delete_product_media` — Use this to permanently delete one media entry of a product. Irreversible: the image stops showing on the storefront.
|
|
124
|
+
- `magentorest_get_sales_rules` (read-only) — Use this to list the cart price rules (promotions): name, dates, whether active, discount type and amount, coupon type, usage limits, websites and customer groups. Returns a bounded page and the total count. **Not verified against a live service** — this tool has not been run against a real Magento instance; its request shape and response projection are covered by unit tests against a test double and by the conformance suite.
|
|
125
|
+
- `magentorest_get_sales_rule_by_id` (read-only) — Use this to read one cart price rule by ID: its dates, discount, coupon type, usage limits, websites and customer groups. **Not verified against a live service** — this tool has not been run against a real Magento instance; its request shape and response projection are covered by unit tests against a test double and by the conformance suite.
|
|
126
|
+
- `magentorest_search_coupons` (read-only) — Use this to find coupons by part of the code and by the rule they belong to. Filters are combined with AND. Returns a bounded page and the total count; each coupon shows its code, limits, times used and expiry. **Not verified against a live service** — this tool has not been run against a real Magento instance; its request shape and response projection are covered by unit tests against a test double and by the conformance suite.
|
|
127
|
+
- `magentorest_get_coupon_by_id` (read-only) — Use this to read one coupon by ID: its code, rule, limits, times used and expiry. **Not verified against a live service** — this tool has not been run against a real Magento instance; its request shape and response projection are covered by unit tests against a test double and by the conformance suite.
|
|
128
|
+
- `magentorest_delete_coupon` — Use this to permanently delete one coupon by ID. Irreversible: customers holding that code can no longer redeem it. **Not verified against a live service** — this tool has not been run against a real Magento instance; its request shape and response projection are covered by unit tests against a test double and by the conformance suite.
|
|
129
|
+
- `magentorest_get_tax_rates` (read-only) — Use this to list the tax rates: code, rate, country, region and postcode (or postcode range). Returns a bounded page and the total count.
|
|
130
|
+
- `magentorest_get_tax_rules` (read-only) — Use this to list the tax rules: code, priority, and the customer tax classes, product tax classes and tax rates each one combines. Returns a bounded page and the total count. **Not verified against a live service** — this tool has not been run against a real Magento instance; its request shape and response projection are covered by unit tests against a test double and by the conformance suite.
|
|
131
|
+
- `magentorest_get_tax_classes` (read-only) — Use this to list the tax classes, optionally only the CUSTOMER or only the PRODUCT ones. Returns one page of up to 100 and the total count.
|
|
132
|
+
- `magentorest_get_revenue` (read-only) — Use this to total the revenue of a period: revenue, currency, order count, average order value and tax. Computed from the orders in the period; it returns no order details. Reads at most max_pages pages of 100 orders and says when the result is partial. With no status it leaves out canceled and closed orders. Amounts in different currencies are never added together: when the orders span several, the totals are null and by_currency gives each currency's own totals.
|
|
133
|
+
- `magentorest_get_order_count` (read-only) — Use this to count the orders of a period, optionally by status. The count is Magento's own total, so it is exact and is never partial.
|
|
134
|
+
- `magentorest_get_product_sales` (read-only) — Use this to see what sold in a period: orders, items, units, revenue, and the ten best-selling products by quantity with their revenue. Optionally for one country (billing or shipping). Computed from the orders; it returns no order details. Reads at most max_pages pages of 100 orders and says when the result is partial. With no status it leaves out canceled and closed orders. Amounts in different currencies are never added together: when the orders span several, the revenue figures are null and by_currency gives each currency's own revenue and order count.
|
|
135
|
+
- `magentorest_get_revenue_by_country` (read-only) — Use this to total the revenue of a period for one country (orders billed or shipped there): revenue, currency, order count, average order value and tax. Computed from the orders; it returns no order details. Reads at most max_pages pages of 100 orders and says when the result is partial. With no status it leaves out canceled and closed orders. Amounts in different currencies are never added together: when the orders span several, the totals are null and by_currency gives each currency's own totals.
|
|
136
|
+
- `magentorest_get_customer_ordered_products_by_email` (read-only) — Use this to list every order of one customer, found by exact email, with each order's lines (SKU, name, price, quantity). Returns the customer's id, name and email only when the server runs with MAGENTO_REST_CUSTOMER_DATA=true, never their addresses. For a product's own detail use magentorest_get_product_by_sku. Reads at most max_pages pages of 100 orders and says when the result is partial.
|
|
137
|
+
- `magentorest_db_status` (read-only) — Use this to check that the database connection works: returns the server version, the database name, that the session is read-only, and whether database writes are enabled. Run it first when a database tool fails. **Not verified against a live service** — this tool has not been run against a real Magento instance; its request shape and response projection are covered by unit tests against a test double and by the conformance suite.
|
|
138
|
+
- `magentorest_db_list_tables` (read-only) — Use this to list the tables of the Magento database, optionally only those whose name contains a fragment (e.g. `sales_order`). Returns each table's name, engine and approximate row count (an estimate, not a count: use magentorest_db_stats or a COUNT(*) for exact figures). **Not verified against a live service** — this tool has not been run against a real Magento instance; its request shape and response projection are covered by unit tests against a test double and by the conformance suite.
|
|
139
|
+
- `magentorest_db_describe_table` (read-only) — Use this to see the columns of one table: name, type, whether it can be NULL, key, default and extra. Refuses the tables that hold credentials (administrators, OAuth tokens, integrations). **Not verified against a live service** — this tool has not been run against a real Magento instance; its request shape and response projection are covered by unit tests against a test double and by the conformance suite.
|
|
140
|
+
- `magentorest_db_query` (read-only) — Use this for a question the other tools cannot answer: runs ONE read-only SELECT and returns its columns and rows. Name the columns (SELECT * and TABLE are refused; COUNT(*) and a * b are fine), pass values as ? placeholders in params (?? identifier placeholders are refused; a literal in the SQL must be single-quoted, without backslashes, never double-quoted), and expect at most max_rows rows (default 100, at most 500): a LIMIT above that is refused, and LIMIT max_rows is added when the statement has none. No comments, no second statement, no INTO, no locking reads, no credential tables (administrators, OAuth tokens, integrations, sessions, ACL; table prefixes included), and no column named like a password, hash or token anywhere in the statement; values of such columns that reach the result anyway (a view, an alias), and of secret configuration rows, come back as [redacted]. **Not verified against a live service** — this tool has not been run against a real Magento instance; its request shape and response projection are covered by unit tests against a test double and by the conformance suite.
|
|
141
|
+
- `magentorest_db_magento_tables` (read-only) — Use this to see the well-known Magento 2 tables grouped by what they hold (products, categories, customers, orders, quotes, invoices, shipments, CMS, EAV, URL rewrites, store), each marked with whether it exists in this database. Table prefixes are not applied. **Not verified against a live service** — this tool has not been run against a real Magento instance; its request shape and response projection are covered by unit tests against a test double and by the conformance suite.
|
|
142
|
+
- `magentorest_db_product_by_sku` (read-only) — Use this for a quick look at one product straight from the database: id, SKU, type, created and updated dates, quantity and in-stock flag (legacy stock table). For the full product use magentorest_get_product_by_sku. **Not verified against a live service** — this tool has not been run against a real Magento instance; its request shape and response projection are covered by unit tests against a test double and by the conformance suite.
|
|
143
|
+
- `magentorest_db_recent_orders` (read-only) — Use this to see the latest orders straight from the database: id, increment id, status, state, customer email and name, totals, currency and dates. Newest first; limit defaults to 10, at most 100. Never returns addresses or payment data. **Not verified against a live service** — this tool has not been run against a real Magento instance; its request shape and response projection are covered by unit tests against a test double and by the conformance suite.
|
|
144
|
+
- `magentorest_db_stats` (read-only) — Use this to count the rows of the key tables in one call: products, categories, customers, orders, order items, quotes, CMS pages and blocks. A table that does not exist says so. **Not verified against a live service** — this tool has not been run against a real Magento instance; its request shape and response projection are covered by unit tests against a test double and by the conformance suite.
|
|
145
|
+
- `magentorest_db_execute` — Use this ONLY when no other tool can make the change: runs ONE INSERT, UPDATE or DELETE (UPDATE and DELETE need a WHERE) in a transaction. It bypasses Magento's own validation, indexing and events, so a change made here may not show on the storefront until a reindex and cache flush. Try it first with dry_run=true: the statement runs and is rolled back, and you see how many rows it would change. It rolls back by itself, changing nothing, if more than max_affected rows (default 100, at most 10000) would change. No DDL (DROP, ALTER, TRUNCATE), no REPLACE, no comments, no credential tables. Irreversible once committed. **Not verified against a live service** — this tool has not been run against a real Magento instance; its request shape and response projection are covered by unit tests against a test double and by the conformance suite.
|
|
146
|
+
|
|
147
|
+
## Environment
|
|
148
|
+
|
|
149
|
+
- `MAGENTO_REST_BASE_URL` (required) — The Magento REST root every magentorest_* tool addresses, e.g. https://<host>/rest/V1 (or /rest/<store-code>/V1 for one store view). Resolved on the first tool call and refused without it; tools/list still works. Must be https — plain http is accepted only for localhost.
|
|
150
|
+
- `MAGENTO_REST_TOKEN` (optional) — A Magento integration access token or admin token, sent as a Bearer. Every tool call needs one, but it may come from this variable OR from the credential file written by `hiberus-magento-rest auth token set`, so neither source is required on its own.
|
|
151
|
+
- `MAGENTO_REST_FIELDS_FILE` (optional) — Path to a JSON file that adjusts the fields a resource exposes, e.g. {"product":{"add":["cost"],"remove":["weight"]}}. A resource may carry only `add` and `remove`, so a file can widen or narrow the shipped list but never replace it — and credential and payment fields (passwords, hashes, tokens, secrets, card and payment data) can never be added. Read once at startup; a file that cannot be read or does not validate stops the server with exit code 1 rather than starting with a half-applied configuration.
|
|
152
|
+
- `MCP_WRITES_ENABLED` (optional) — The write switch an MCP host sets itself. Exactly `true` registers the write tools (create, update, delete, cancel, invoice, refund, ...); any other value, `false` included, registers read tools only, and then MAGENTO_REST_ALLOW_WRITES is ignored. Unset, MAGENTO_REST_ALLOW_WRITES decides. Read once at startup.
|
|
153
|
+
- `MAGENTO_REST_ALLOW_WRITES` (optional) — The write switch for standalone use, read only when MCP_WRITES_ENABLED is unset. Set to exactly `true` to register the write tools (create, update, delete, cancel, invoice, refund, ...). Unset, or any other value, and the server registers read tools only — a write tool is then absent from tools/list, not merely refused. Read once at startup.
|
|
154
|
+
- `MAGENTO_REST_CUSTOMER_DATA` (optional) — Set to exactly `true` to include customer personal data in REST tool results: an order's customer ID, name and email, a cart's customer, a customer's name and email, and the city and postcode of their addresses. Unset, or any other value, and every REST tool result leaves them out, and a MAGENTO_REST_FIELDS_FILE cannot add them back. Off by default so a host that must keep personal data out of a model's context (GDPR) gets that without setting anything. The database tools (MAGENTO_REST_DATABASE_CONNECTION) are not filtered: they return what the SQL selects.
|
|
155
|
+
- `MAGENTO_REST_GROUPS` (optional) — Comma-separated tool groups to load, e.g. `products,customers`, so a project registers only the tools it needs instead of every one. Groups: `products`, `store`, `categories`, `customers`, `orders`, `sales-documents`, `stock`, `carts`, `cms`, `attributes`, `media`, `promotions`, `tax`, `analytics`, `database` (only with MAGENTO_REST_DATABASE_CONNECTION; naming it without one stops the server). Case-insensitive; blanks and repeats are ignored. Unset or empty loads every group (`database` too, when a connection is configured). A name that is not a group stops the server with exit code 1, listing the valid ones. The write switch (MCP_WRITES_ENABLED, or MAGENTO_REST_ALLOW_WRITES when it is unset) still decides whether the write tools of a loaded group are registered. Read once at startup.
|
|
156
|
+
- `MAGENTO_REST_DATABASE_CONNECTION` (optional) — Adds the `database` tool group (magentorest_db_*): direct, read-only access to the Magento database. A URL with NO password, e.g. `mysql://reader@127.0.0.1:3306/magento`; a password in it stops the server. A host that is not this machine uses verified TLS unless you write `?ssl=false`. Unset, there are no database tools. Use a database user with the narrowest grants you can: SELECT only unless you also enable writes. The URL is validated at startup (exit code 1 if it is invalid); the password is only needed when a tool is called.
|
|
157
|
+
- `MAGENTO_REST_DATABASE_PASSWORD` (optional) — The password of the database user, used by the database tools. It may come from this variable OR from the credential file written by `hiberus-magento-rest auth db-password set` (read from stdin, mode 0600), so neither source is required on its own. Resolved on every connection, so a stored password applies without a restart.
|
|
158
|
+
- `MAGENTO_REST_DATABASE_ALLOW_WRITES` (optional) — Set to exactly `true` to register magentorest_db_execute (one INSERT, UPDATE or DELETE per call, in a transaction, with a dry run and a cap on rows changed). A switch of its own: MAGENTO_REST_ALLOW_WRITES does not enable it. Unset, or any other value, and the tool is absent from tools/list. Without MAGENTO_REST_DATABASE_CONNECTION it stops the server with exit code 1. Read once at startup.
|
|
159
|
+
- `MAGENTO_REST_HTTP_PORT` (optional) — Set to serve MCP over HTTP instead of stdio, for callers that cannot own a child process (for example a PHP middleware or a queue consumer). Opt-in: unset or blank and the server speaks stdio exactly as before. `0` picks a free port, which is logged to stderr as `magento-rest: listening on http://<host>:<port>/mcp`. Stateless: one POST per call, no session, JSON replies. Requires MAGENTO_REST_HTTP_TOKEN. Read once at startup. Headers, examples and status codes: docs/http-mode.md.
|
|
160
|
+
- `MAGENTO_REST_HTTP_TOKEN` (optional) — Bearer token the HTTP caller must send as `Authorization: Bearer <token>`. Required when MAGENTO_REST_HTTP_PORT is set; at least 32 characters (generate one with `openssl rand -hex 32`), otherwise the server stops with exit code 1. Read from the environment only, never from argv, and never logged or echoed. Rotating it means restarting the server.
|
|
161
|
+
- `MAGENTO_REST_HTTP_HOST` (optional) — Interface the HTTP endpoint binds to. Default `127.0.0.1` (loopback only). Set it to `0.0.0.0` or a container address only when the server must be reached from another host, and then list the names callers use in MAGENTO_REST_HTTP_ALLOWED_HOSTS.
|
|
162
|
+
- `MAGENTO_REST_HTTP_ALLOWED_HOSTS` (optional) — Comma-separated extra `Host` header values the HTTP endpoint accepts, for example `magento-rest:3000`, beyond loopback with the bound port. A request with any other Host is refused with 403 (DNS rebinding protection).
|
|
163
|
+
- `MAGENTO_REST_HTTP_ALLOWED_ORIGINS` (optional) — Comma-separated `Origin` values the HTTP endpoint accepts. Unset, any request that carries an Origin header is refused with 403: this server is for backends, not browsers.
|
|
164
|
+
|
|
165
|
+
## Configure in an MCP client
|
|
166
|
+
|
|
167
|
+
Pin the exact version; pass secrets as environment variable references, never literal values:
|
|
168
|
+
|
|
169
|
+
```json
|
|
170
|
+
{
|
|
171
|
+
"mcpServers": {
|
|
172
|
+
"hiberus-magento-rest-mcp": {
|
|
173
|
+
"command": "npx",
|
|
174
|
+
"args": [
|
|
175
|
+
"-y",
|
|
176
|
+
"--package",
|
|
177
|
+
"@hiberus-magento/magento-rest@0.2.0",
|
|
178
|
+
"hiberus-magento-rest-mcp"
|
|
179
|
+
],
|
|
180
|
+
"env": {
|
|
181
|
+
"MAGENTO_REST_BASE_URL": "${MAGENTO_REST_BASE_URL}"
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
<!-- package:end -->
|
|
189
|
+
|
|
190
|
+
## Running over HTTP
|
|
191
|
+
|
|
192
|
+
For a caller that cannot launch a child process (a PHP middleware, a queue consumer), set a port and a
|
|
193
|
+
token and the server listens on `http://127.0.0.1:<port>/mcp` instead of stdio:
|
|
194
|
+
|
|
195
|
+
```sh
|
|
196
|
+
export MAGENTO_REST_BASE_URL=https://demo-host.example-domain/rest/V1
|
|
197
|
+
export MAGENTO_REST_HTTP_PORT=3200
|
|
198
|
+
export MAGENTO_REST_HTTP_TOKEN="$(openssl rand -hex 32)"
|
|
199
|
+
npx -y --package @hiberus-magento/magento-rest hiberus-magento-rest-mcp
|
|
200
|
+
|
|
201
|
+
curl -s http://127.0.0.1:3200/mcp \
|
|
202
|
+
-H "Authorization: Bearer $MAGENTO_REST_HTTP_TOKEN" \
|
|
203
|
+
-H "Content-Type: application/json" \
|
|
204
|
+
-H "Accept: application/json, text/event-stream" \
|
|
205
|
+
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"magentorest_get_store_configs","arguments":{}}}'
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
`MAGENTO_REST_HTTP_TOKEN` is the secret HTTP callers send; it is not the Magento token, which still comes
|
|
209
|
+
from `MAGENTO_REST_TOKEN` or the stored file (see [Credentials](#credentials)). Each call is one `POST` with
|
|
210
|
+
a JSON-RPC body: no `initialize`, no session. All three headers are required; without that `Accept` value
|
|
211
|
+
the reply is `406`. A tool that fails answers HTTP `200` with `"isError": true`. The
|
|
212
|
+
[HTTP mode guide](https://github.com/hiberus-magento/mcp-servers/blob/main/docs/http-mode.md) has the
|
|
213
|
+
status codes, the setup for reaching it from another container, and its limits (one store per process, the
|
|
214
|
+
integration's identity on every call).
|
|
215
|
+
|
|
216
|
+
## Credentials
|
|
217
|
+
|
|
218
|
+
A Magento **integration Access Token** (or an admin token), sent as a Bearer. It
|
|
219
|
+
comes from `MAGENTO_REST_TOKEN`, or from `$XDG_CONFIG_HOME/hiberus/magento-rest.json`
|
|
220
|
+
at file mode `0600` — an alternative to putting a secret in any config file or
|
|
221
|
+
shell variable:
|
|
222
|
+
|
|
223
|
+
```sh
|
|
224
|
+
echo "$MAGENTO_TOKEN" | npx -y --package @hiberus-magento/magento-rest hiberus-magento-rest auth token set
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
There is no `--token` flag: it is absent, not rejected, so a token cannot reach
|
|
228
|
+
shell history. A stored file with group or world permissions is refused, not
|
|
229
|
+
warned about, and the message names the file. With no token the call fails at
|
|
230
|
+
once with the command, the variable and the path it looked at — it never waits
|
|
231
|
+
for input. The token is read on every call, so adding or replacing one takes
|
|
232
|
+
effect without a restart.
|
|
233
|
+
|
|
234
|
+
## Read-only by default
|
|
235
|
+
|
|
236
|
+
With `MCP_WRITES_ENABLED` and `MAGENTO_REST_ALLOW_WRITES` unset, or set to anything
|
|
237
|
+
but the exact string `true`, the server registers **read tools only**. An MCP host
|
|
238
|
+
sets `MCP_WRITES_ENABLED` itself; when it is present it decides alone, and
|
|
239
|
+
`MAGENTO_REST_ALLOW_WRITES` (the switch for standalone use) is ignored. A write tool is then absent from
|
|
240
|
+
`tools/list`, not merely refused when called. The choice is made once at
|
|
241
|
+
startup. Reads that hit a `429` or `5xx` are retried with backoff; a write is
|
|
242
|
+
sent exactly once, because replaying an invoice or a refund after an ambiguous
|
|
243
|
+
failure could capture or refund twice. Use a separate, narrowly scoped
|
|
244
|
+
integration for the configuration that enables writes.
|
|
245
|
+
|
|
246
|
+
### Store scope of writes
|
|
247
|
+
|
|
248
|
+
Through `/rest/V1`, Magento runs a request as the **default store view**. A
|
|
249
|
+
product or category saved that way gets values for that one store view, and a
|
|
250
|
+
CMS block or page saved without a store assignment is assigned to that one
|
|
251
|
+
store view. So:
|
|
252
|
+
|
|
253
|
+
- the catalog writes (`create_product`, `update_product`,
|
|
254
|
+
`update_product_attribute`, `add_product_image`, `update_product_media`,
|
|
255
|
+
`create_category`, `update_category`) run in the **`all`** scope by default:
|
|
256
|
+
they change the global values every store view inherits. A store view that
|
|
257
|
+
already has its own value keeps it. Pass `store_code` to change one store
|
|
258
|
+
view's own value instead;
|
|
259
|
+
- `create_product` always sends the website: `website_ids` when given, else the
|
|
260
|
+
**default website only** — the website of the `store_code` store view, or the
|
|
261
|
+
store's only website. Magento's REST API does not say which website is the
|
|
262
|
+
default, so with several websites and no `store_code` the tool refuses and asks
|
|
263
|
+
for `website_ids` (left alone, Magento would put a product created in the
|
|
264
|
+
global scope on every website);
|
|
265
|
+
- the CMS creates and updates always run in `all`, so a new block or page is on
|
|
266
|
+
all store views. A page update keeps the page's store assignment. A **block**
|
|
267
|
+
update does not: Magento resets a block's assignment on every REST update
|
|
268
|
+
(here, to all store views), and its REST interface can neither read nor set
|
|
269
|
+
one, so change a block that belongs to some store views only in the admin;
|
|
270
|
+
- reads, and writes with no store-scoped values (orders, invoices, stock,
|
|
271
|
+
deletes, category moves), use `MAGENTO_REST_BASE_URL` as configured.
|
|
272
|
+
|
|
273
|
+
The scoped URL is built from the base URL, `/rest/<scope>/V1`, so a store-scoped
|
|
274
|
+
write needs a base URL ending in `/rest/V1` or `/rest/<store-code>/V1`. An
|
|
275
|
+
unknown `store_code` is answered as not found. Checked against the Magento
|
|
276
|
+
2.4.5–2.4.8 source, not yet against a live multi-store instance.
|
|
277
|
+
|
|
278
|
+
### A SKU that contains `/`
|
|
279
|
+
|
|
280
|
+
A SKU is sent as one URL path segment, so a `/` in it travels encoded as `%2F`.
|
|
281
|
+
Apache with its default `AllowEncodedSlashes Off` answers **404** to such a
|
|
282
|
+
URL before Magento sees it, and the tool reports the product as not found.
|
|
283
|
+
This affects every tool that takes a SKU in the path, writes included. If your
|
|
284
|
+
SKUs contain `/` and the store runs behind Apache, set
|
|
285
|
+
`AllowEncodedSlashes NoDecode` on the virtual host. Without that, only finding
|
|
286
|
+
the product works: `magentorest_advanced_product_search` with `field: sku`
|
|
287
|
+
returns its summary, because the SKU then travels in the query string. Not
|
|
288
|
+
checked against a live Apache.
|
|
289
|
+
|
|
290
|
+
## What a read returns
|
|
291
|
+
|
|
292
|
+
Every read tool declares an `outputSchema` and answers with `structuredContent`,
|
|
293
|
+
mirrored exactly as JSON text:
|
|
294
|
+
|
|
295
|
+
```json
|
|
296
|
+
{
|
|
297
|
+
"result": { "increment_id": "000000042", "status": "processing", "grand_total": 59.9 },
|
|
298
|
+
"provenance": {
|
|
299
|
+
"endpoint": "GET /rest/V1/orders/42",
|
|
300
|
+
"api_version": "V1",
|
|
301
|
+
"read_at": "2026-11-23T10:00:00.000Z",
|
|
302
|
+
"store_view": "default"
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
`result` is the projected answer (its fields are the tool's allowlist, so the
|
|
308
|
+
schema is derived from it). `provenance` says where and when the data was read:
|
|
309
|
+
`endpoint` is the method and path from `/rest` on, with no host, query string or
|
|
310
|
+
token; `endpoints` lists each distinct one when a tool used several; `read_at` is
|
|
311
|
+
when Magento answered; `store_view` appears when the URL named one. `all` is the
|
|
312
|
+
global scope, not a store view, so a base URL of `https://<host>/rest/all/V1`
|
|
313
|
+
(useful where only `/rest/all/V*` bypasses a CDN) gives no `store_view`. A result whose
|
|
314
|
+
JSON is over 100,000 bytes is refused with an error: ask for fewer records. Write
|
|
315
|
+
tools answer with text, as before.
|
|
316
|
+
|
|
317
|
+
## Customer data is off by default
|
|
318
|
+
|
|
319
|
+
Results carry **no customer personal data** unless the server runs with
|
|
320
|
+
`MAGENTO_REST_CUSTOMER_DATA=true`: no names, email, phone, street, date of birth,
|
|
321
|
+
tax number, gender or IP, no `customer_*` identity on an order, no `customer` on a
|
|
322
|
+
cart, and no city or postcode on a customer's addresses. An order still has its
|
|
323
|
+
number, status, totals and lines. A `MAGENTO_REST_FIELDS_FILE` cannot add these
|
|
324
|
+
fields back while the switch is off. The database tools are not filtered: they
|
|
325
|
+
return what their SQL selects.
|
|
326
|
+
|
|
327
|
+
## Using it from an MCP host (`server.json`)
|
|
328
|
+
|
|
329
|
+
The package ships a `server.json` (the MCP registry's server manifest, schema
|
|
330
|
+
`2025-12-11`) in its root, and `package.json` carries the matching `mcpName`
|
|
331
|
+
(`io.github.hiberus-magento/magento-rest`). A host that builds its configuration
|
|
332
|
+
form from it sees four variables: `MAGENTO_REST_BASE_URL` and `MAGENTO_REST_TOKEN`
|
|
333
|
+
(required, the token secret), `MAGENTO_REST_GROUPS`, and `MCP_WRITES_ENABLED`
|
|
334
|
+
(boolean, default `false`). The standalone write switch, customer data, the field
|
|
335
|
+
file and the database are deliberately not declared, so a host's form cannot turn
|
|
336
|
+
them on.
|
|
337
|
+
|
|
338
|
+
## Tool groups
|
|
339
|
+
|
|
340
|
+
A Magento project rarely needs every tool, and each tool an agent is shown costs
|
|
341
|
+
context. `MAGENTO_REST_GROUPS` loads only the groups you name; unset or empty
|
|
342
|
+
loads all of them (the `database` group too, but only when a database is
|
|
343
|
+
configured — see [Database access](#database-access)).
|
|
344
|
+
|
|
345
|
+
```json
|
|
346
|
+
"MAGENTO_REST_GROUPS": "products,customers"
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
Names are separated by commas, are case-insensitive, and blanks and repeats are
|
|
350
|
+
ignored. A name that is not a group stops the server at startup with exit code 1
|
|
351
|
+
and the list of valid groups, so a typo never leaves a tool set out silently.
|
|
352
|
+
It is read once at startup, like the write switch, and the two are independent:
|
|
353
|
+
a group loads its read tools always, and its write tools (marked `*`) only with
|
|
354
|
+
`MAGENTO_REST_ALLOW_WRITES=true`. The exception is `database`, whose one write tool
|
|
355
|
+
answers to its own switch (below). Naming `database` without a connection stops the
|
|
356
|
+
server, because the tools it names cannot exist.
|
|
357
|
+
|
|
358
|
+
| Group | Covers | Tools (`*` = write) |
|
|
359
|
+
|---|---|---|
|
|
360
|
+
| `products` | Catalog products: read, search, create, update, delete, category assignment | get_product_by_sku, search_products, advanced_product_search, create_product*, update_product*, update_product_attribute*, delete_product*, assign_product_to_category*, remove_product_from_category* |
|
|
361
|
+
| `store` | Store configuration: store views, websites, store groups, countries, currency | get_store_configs, get_store_views, get_websites, get_store_groups, get_countries, get_currency_info |
|
|
362
|
+
| `categories` | Category tree and the products in a category | get_category_tree, get_category_by_id, list_categories, get_products_in_category, create_category*, update_category*, delete_category*, move_category* |
|
|
363
|
+
| `customers` | Customers, their groups and addresses | get_customer_by_id, search_customers, get_customer_groups, get_customer_addresses, create_customer*, update_customer*, delete_customer* |
|
|
364
|
+
| `orders` | Orders and their comments, cancel and hold | get_order_by_id, get_order_by_increment_id, search_orders, get_order_items, get_order_comments, add_order_comment*, cancel_order*, hold_order*, unhold_order* |
|
|
365
|
+
| `sales-documents` | Invoices, shipments and credit memos | get_invoice_by_id, search_invoices, get_shipment_by_id, search_shipments, get_creditmemo_by_id, search_creditmemos, create_invoice*, create_shipment*, add_shipment_tracking*, create_creditmemo* |
|
|
366
|
+
| `stock` | Stock and inventory (MSI sources and stocks) | get_product_stock, get_low_stock_products, get_inventory_sources, get_inventory_stocks, get_source_items, update_product_stock* |
|
|
367
|
+
| `carts` | Carts, including abandoned ones (read-only) | get_cart_by_id, search_carts, get_cart_items, get_abandoned_carts |
|
|
368
|
+
| `cms` | CMS blocks and pages | get_cms_block_by_id, search_cms_blocks, get_cms_page_by_id, search_cms_pages, create_cms_block*, update_cms_block*, delete_cms_block*, create_cms_page*, update_cms_page*, delete_cms_page* |
|
|
369
|
+
| `attributes` | Product attributes, options and attribute sets | get_product_attribute, search_product_attributes, get_attribute_options, get_attribute_sets, get_attribute_set_attributes, add_attribute_option* |
|
|
370
|
+
| `media` | Product images | get_product_media, get_product_media_entry, add_product_image*, update_product_media*, delete_product_media* |
|
|
371
|
+
| `promotions` | Cart price rules and coupons | get_sales_rules, get_sales_rule_by_id, search_coupons, get_coupon_by_id, delete_coupon* |
|
|
372
|
+
| `tax` | Tax rates, rules and classes (read-only) | get_tax_rates, get_tax_rules, get_tax_classes |
|
|
373
|
+
| `analytics` | Revenue, order counts and sales figures computed from orders (read-only) | get_revenue, get_order_count, get_product_sales, get_revenue_by_country, get_customer_ordered_products_by_email |
|
|
374
|
+
| `database` | Direct access to the Magento database; needs `MAGENTO_REST_DATABASE_CONNECTION` | db_status, db_list_tables, db_describe_table, db_query, db_magento_tables, db_product_by_sku, db_recent_orders, db_stats, db_execute* |
|
|
375
|
+
|
|
376
|
+
## Database access
|
|
377
|
+
|
|
378
|
+
The REST API cannot answer every question cheaply — a count, a join, a table's
|
|
379
|
+
columns. `MAGENTO_REST_DATABASE_CONNECTION` adds nine tools that read the Magento
|
|
380
|
+
database directly (the `database` group). They are a second choice: for anything the
|
|
381
|
+
`magentorest_get_*` tools can answer, use those, because they go through Magento's own
|
|
382
|
+
rules and return only reviewed fields.
|
|
383
|
+
|
|
384
|
+
```json
|
|
385
|
+
"MAGENTO_REST_DATABASE_CONNECTION": "mysql://reader@127.0.0.1:3306/magento"
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
**The connection has no password, on purpose.** The string is committed with the project,
|
|
389
|
+
so a password in it stops the server (and is never printed). Give the password with
|
|
390
|
+
`MAGENTO_REST_DATABASE_PASSWORD`, or store it once, from stdin, in a file only you can read:
|
|
391
|
+
|
|
392
|
+
```sh
|
|
393
|
+
printf '%s' "$DB_PASSWORD" | hiberus-magento-rest auth db-password set
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
A host that is not this machine uses TLS with certificate verification; write `?ssl=false`
|
|
397
|
+
to say, explicitly, that it does not. The URL is checked at startup; the password is only
|
|
398
|
+
needed when a tool is called.
|
|
399
|
+
|
|
400
|
+
**Reads** (eight tools) run in a `READ ONLY` session, with a 15 second timeout and a cap on
|
|
401
|
+
rows. `db_query` takes one `SELECT`: name the columns (`SELECT *` is refused under any
|
|
402
|
+
modifier, and so is `TABLE t`; `COUNT(*)` and `a * b` are fine), pass values as `?`
|
|
403
|
+
parameters, expect at most `max_rows` (default 100, at most 500). Values are bound by the
|
|
404
|
+
database server as a prepared statement, never pasted into the SQL text. A literal written in
|
|
405
|
+
the SQL must be single-quoted and contain no backslash; double quotes are refused, because
|
|
406
|
+
what they and a backslash mean depends on the server's SQL mode.
|
|
407
|
+
A `LIMIT` above `max_rows` is refused; a statement without one gets `LIMIT max_rows` added.
|
|
408
|
+
It refuses comments, a second statement, `INTO`, locking reads (`FOR UPDATE`, `FOR SHARE`,
|
|
409
|
+
`LOCK IN SHARE MODE`), `??` identifier placeholders, and the functions that read files or
|
|
410
|
+
stall the server. It will not touch the tables that hold credentials (administrators, OAuth
|
|
411
|
+
tokens, integrations, two-factor settings, sessions, ACL roles and rules — also under a table
|
|
412
|
+
prefix, so `mg_admin_user` is refused like `admin_user`) or the `mysql` schema, and it refuses
|
|
413
|
+
any column named like a password, hash or token wherever it is written (selected, aliased,
|
|
414
|
+
inside an expression or in a `WHERE`). The value of such a column that reaches the result
|
|
415
|
+
anyway (through a view or an alias, judged by the column's original name), and of a
|
|
416
|
+
configuration value whose path is a secret, is not in the result, or may belong to another
|
|
417
|
+
row (the configuration table joined to itself), comes back as `[redacted]`. The other seven tools use fixed statements.
|
|
418
|
+
|
|
419
|
+
**Writes** are a separate switch. `MAGENTO_REST_ALLOW_WRITES` does not enable them:
|
|
420
|
+
|
|
421
|
+
```json
|
|
422
|
+
"MAGENTO_REST_DATABASE_ALLOW_WRITES": "true"
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
Only the exact text `true` registers `db_execute`; without a connection it stops the server.
|
|
426
|
+
It runs **one** `INSERT`, `UPDATE` or `DELETE` per call (the last two need a `WHERE`), in a
|
|
427
|
+
transaction. `dry_run: true` runs it and rolls back, so you see how many rows it would
|
|
428
|
+
change; if more than `max_affected` (default 100, at most 10000) would change, it rolls back
|
|
429
|
+
by itself. No `DROP`, `ALTER`, `TRUNCATE`, `REPLACE` or `LOAD`, and the same rules on
|
|
430
|
+
values and literals as `db_query` (`?` parameters, single quotes, no backslashes). A change made this way skips
|
|
431
|
+
Magento's validation, indexing and events, so it may not show on the storefront until a
|
|
432
|
+
reindex and a cache flush.
|
|
433
|
+
|
|
434
|
+
**These rules make a mistake cheap; they are not the security boundary.** They are a
|
|
435
|
+
best-effort check on the text of a statement, and a check on text can have holes (an
|
|
436
|
+
expression such as `CONCAT(value)`, a derived table or a UNION hides which table a column
|
|
437
|
+
came from, so a configuration value read that way is not redacted). The boundary is
|
|
438
|
+
the database user. Create one for this server with `SELECT` only, without access to the
|
|
439
|
+
credential tables above, and add `INSERT`/`UPDATE`/`DELETE` on the tables you mean to change
|
|
440
|
+
only if you enable writes. Table prefixes
|
|
441
|
+
(`db.table_prefix`) are not applied to the fixed statements. Text is decoded as UTF-8
|
|
442
|
+
(`utf8mb4`); a column in another character set must be converted in the query.
|
|
443
|
+
|
|
444
|
+
## Showing more fields
|
|
445
|
+
|
|
446
|
+
Point `MAGENTO_REST_FIELDS_FILE` at a JSON file, kept in your project and
|
|
447
|
+
reviewed like code:
|
|
448
|
+
|
|
449
|
+
```json
|
|
450
|
+
{ "product": { "add": ["cost", "extension_attributes.stock_item.qty"] } }
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
The keys are resources — a kind of record, such as `product`, `order`,
|
|
454
|
+
`customer`, `cart` or `cms_page` — so one entry widens every tool that returns
|
|
455
|
+
that kind of record. The full list is in the onboarding guide, and an unknown
|
|
456
|
+
name is an error that lists them. The file only adds; a
|
|
457
|
+
credential or payment path (password, hash, token, secret, API key, card or
|
|
458
|
+
payment data, IBAN, private key) is refused at any depth. It is read once at
|
|
459
|
+
startup, and an invalid file stops the server with exit code 1 and the reason.
|
|
460
|
+
See the [onboarding guide](https://github.com/hiberus-magento/mcp-servers/blob/main/docs/magento-rest-onboarding.md).
|
|
461
|
+
|
|
462
|
+
## What this server deliberately does not do
|
|
463
|
+
|
|
464
|
+
- **No database access unless you configure it.** Without
|
|
465
|
+
`MAGENTO_REST_DATABASE_CONNECTION` the `database` group does not exist; with it,
|
|
466
|
+
reads run in a `READ ONLY` session and `db_execute` needs its own switch,
|
|
467
|
+
`MAGENTO_REST_DATABASE_ALLOW_WRITES`. See [Database access](#database-access).
|
|
468
|
+
- **No chat proxy and no embedded model client.** It is an MCP server, nothing
|
|
469
|
+
else.
|
|
470
|
+
- **No way to turn TLS verification off.** There is no option and no honoured
|
|
471
|
+
environment variable. For a private certificate authority, make Node trust it
|
|
472
|
+
with `NODE_EXTRA_CA_CERTS`.
|
|
473
|
+
- **No plain `http`** except for `localhost`: a Bearer over plain http is a
|
|
474
|
+
Bearer on the wire.
|
|
475
|
+
- **No unbounded output.** `page_size` is 1 to 100; a multi-page walk stops at a
|
|
476
|
+
hard cap and reports `truncated: true`.
|
|
477
|
+
- **No raw responses.** Every read returns an allowlist of fields, so whatever
|
|
478
|
+
an instance's modules add (extension attributes, payment blocks, address
|
|
479
|
+
books) cannot reach the model. An operator can **add** fields with
|
|
480
|
+
`MAGENTO_REST_FIELDS_FILE` (see below) but never remove from the list, never
|
|
481
|
+
use a wildcard, and never add a credential or payment field.
|
|
482
|
+
- **No shipping-methods or payment-methods tool.** The original called
|
|
483
|
+
`/shipping-methods` and `/payment-methods`, which are not standard Magento REST
|
|
484
|
+
endpoints (the methods are per cart), and the first fell back to returning the
|
|
485
|
+
store configuration — an answer to a different question.
|
|
486
|
+
- **No store assignment when creating a CMS block or page.** A live Magento refuses
|
|
487
|
+
a `store_id` in that body; the write runs in the `all` scope, so the record is on
|
|
488
|
+
all store views (see "Store scope of writes").
|
|
489
|
+
- **No URL-rewrite search.** The original called `/url-rewrite`, which is not a
|
|
490
|
+
core Magento endpoint: a stock 2.4.8 answers 404.
|
|
491
|
+
- **No order-statuses tool.** The original called `/orders/statuses`, which is not
|
|
492
|
+
a route: a live Magento reads it as `/orders/{id}` with an id of "statuses" and
|
|
493
|
+
answers 400.
|
|
494
|
+
- **No customer password.** `magentorest_create_customer` takes none: a
|
|
495
|
+
credential must not pass through the model; Magento's password-reset flow is
|
|
496
|
+
how a new customer sets one.
|
|
497
|
+
- **No unbounded report.** The analytics tools read at most 50 pages of 100
|
|
498
|
+
orders (10 by default), report how many orders they covered, and say when a
|
|
499
|
+
result is partial.
|
|
500
|
+
- **No set-the-identity tool.** `magentorest_update_product_attribute` refuses
|
|
501
|
+
`sku`, `id`, `entity_id` and `type_id`.
|
|
502
|
+
|
|
503
|
+
## Documentation
|
|
504
|
+
|
|
505
|
+
- [Repository](https://github.com/hiberus-magento/mcp-servers) — source, issues, and the other servers in this family.
|
|
506
|
+
- [Magento REST onboarding](https://github.com/hiberus-magento/mcp-servers/blob/main/docs/magento-rest-onboarding.md) — creating a least-privilege integration, the base URL, the write switch, and what the failures mean.
|
|
507
|
+
- [HTTP mode](https://github.com/hiberus-magento/mcp-servers/blob/main/docs/http-mode.md) — running it as an HTTP service for a backend: the headers, curl examples, status codes, containers, and its limits.
|
|
508
|
+
- [Team setup guide](https://github.com/hiberus-magento/mcp-servers/blob/main/docs/team-setup.md) — where MCP client configuration lives, and which file must never hold a secret.
|
|
509
|
+
|
|
510
|
+
## License
|
|
511
|
+
|
|
512
|
+
Apache-2.0. See [LICENSE](https://github.com/hiberus-magento/mcp-servers/blob/main/LICENSE).
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Third-Party Notices
|
|
2
|
+
====================
|
|
3
|
+
|
|
4
|
+
This package is distributed as a single bundled file with no runtime
|
|
5
|
+
dependencies of its own. It statically bundles the following third-party
|
|
6
|
+
packages:
|
|
7
|
+
|
|
8
|
+
- @modelcontextprotocol/sdk@1.30.0 — MIT
|
|
9
|
+
- content-type@1.0.5 — MIT
|
|
10
|
+
- generate-function@2.3.1 — MIT
|
|
11
|
+
- is-property@1.0.2 — MIT
|
|
12
|
+
- long@5.3.2 — Apache-2.0
|
|
13
|
+
- lru.min@1.1.5 — MIT
|
|
14
|
+
- mysql2@3.24.6 — MIT
|
|
15
|
+
- named-placeholders@1.1.6 — MIT
|
|
16
|
+
- sql-escaper@1.5.2 — MIT
|
|
17
|
+
- zod@4.5.4 — MIT
|
|
18
|
+
- zod-to-json-schema@3.25.2 — ISC
|