@hiberus-magento/magento-rest 0.0.0-stage → 0.1.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/README.md CHANGED
@@ -1,3 +1,428 @@
1
- # Temporary Holding Version
1
+ # @hiberus-magento/magento-rest
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
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 **stdio MCP server**. This is what you put in an MCP client's configuration. It speaks JSON-RPC on stdout and nothing else. |
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: name, email, group, website, store and the default address IDs. 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, city, postcode and which is the default billing or shipping address. 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, the customer as the order records it, and the order lines. 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, the customer's identity (id, name, email, group) and the cart lines. 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 names the owner (or Guest), the item count and the dates. 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, 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
+ - `MAGENTO_REST_ALLOW_WRITES` (optional) — 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.
153
+ - `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. MAGENTO_REST_ALLOW_WRITES still decides whether the write tools of a loaded group are registered. Read once at startup.
154
+ - `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.
155
+ - `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.
156
+ - `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.
157
+
158
+ ## Configure in an MCP client
159
+
160
+ Pin the exact version; pass secrets as environment variable references, never literal values:
161
+
162
+ ```json
163
+ {
164
+ "mcpServers": {
165
+ "hiberus-magento-rest-mcp": {
166
+ "command": "npx",
167
+ "args": [
168
+ "-y",
169
+ "--package",
170
+ "@hiberus-magento/magento-rest@0.0.0",
171
+ "hiberus-magento-rest-mcp"
172
+ ],
173
+ "env": {
174
+ "MAGENTO_REST_BASE_URL": "${MAGENTO_REST_BASE_URL}"
175
+ }
176
+ }
177
+ }
178
+ }
179
+ ```
180
+
181
+ <!-- package:end -->
182
+
183
+ ## Credentials
184
+
185
+ A Magento **integration Access Token** (or an admin token), sent as a Bearer. It
186
+ comes from `MAGENTO_REST_TOKEN`, or from `$XDG_CONFIG_HOME/hiberus/magento-rest.json`
187
+ at file mode `0600` — an alternative to putting a secret in any config file or
188
+ shell variable:
189
+
190
+ ```sh
191
+ echo "$MAGENTO_TOKEN" | npx -y --package @hiberus-magento/magento-rest hiberus-magento-rest auth token set
192
+ ```
193
+
194
+ There is no `--token` flag: it is absent, not rejected, so a token cannot reach
195
+ shell history. A stored file with group or world permissions is refused, not
196
+ warned about, and the message names the file. With no token the call fails at
197
+ once with the command, the variable and the path it looked at — it never waits
198
+ for input. The token is read on every call, so adding or replacing one takes
199
+ effect without a restart.
200
+
201
+ ## Read-only by default
202
+
203
+ With `MAGENTO_REST_ALLOW_WRITES` unset, or set to anything but the exact string
204
+ `true`, the server registers **read tools only**: a write tool is absent from
205
+ `tools/list`, not merely refused when called. The choice is made once at
206
+ startup. Reads that hit a `429` or `5xx` are retried with backoff; a write is
207
+ sent exactly once, because replaying an invoice or a refund after an ambiguous
208
+ failure could capture or refund twice. Use a separate, narrowly scoped
209
+ integration for the configuration that enables writes.
210
+
211
+ ### Store scope of writes
212
+
213
+ Through `/rest/V1`, Magento runs a request as the **default store view**. A
214
+ product or category saved that way gets values for that one store view, and a
215
+ CMS block or page saved without a store assignment is assigned to that one
216
+ store view. So:
217
+
218
+ - the catalog writes (`create_product`, `update_product`,
219
+ `update_product_attribute`, `add_product_image`, `update_product_media`,
220
+ `create_category`, `update_category`) run in the **`all`** scope by default:
221
+ they change the global values every store view inherits. A store view that
222
+ already has its own value keeps it. Pass `store_code` to change one store
223
+ view's own value instead;
224
+ - `create_product` always sends the website: `website_ids` when given, else the
225
+ **default website only** — the website of the `store_code` store view, or the
226
+ store's only website. Magento's REST API does not say which website is the
227
+ default, so with several websites and no `store_code` the tool refuses and asks
228
+ for `website_ids` (left alone, Magento would put a product created in the
229
+ global scope on every website);
230
+ - the CMS creates and updates always run in `all`, so a new block or page is on
231
+ all store views. A page update keeps the page's store assignment. A **block**
232
+ update does not: Magento resets a block's assignment on every REST update
233
+ (here, to all store views), and its REST interface can neither read nor set
234
+ one, so change a block that belongs to some store views only in the admin;
235
+ - reads, and writes with no store-scoped values (orders, invoices, stock,
236
+ deletes, category moves), use `MAGENTO_REST_BASE_URL` as configured.
237
+
238
+ The scoped URL is built from the base URL, `/rest/<scope>/V1`, so a store-scoped
239
+ write needs a base URL ending in `/rest/V1` or `/rest/<store-code>/V1`. An
240
+ unknown `store_code` is answered as not found. Checked against the Magento
241
+ 2.4.5–2.4.8 source, not yet against a live multi-store instance.
242
+
243
+ ### A SKU that contains `/`
244
+
245
+ A SKU is sent as one URL path segment, so a `/` in it travels encoded as `%2F`.
246
+ Apache with its default `AllowEncodedSlashes Off` answers **404** to such a
247
+ URL before Magento sees it, and the tool reports the product as not found.
248
+ This affects every tool that takes a SKU in the path, writes included. If your
249
+ SKUs contain `/` and the store runs behind Apache, set
250
+ `AllowEncodedSlashes NoDecode` on the virtual host. Without that, only finding
251
+ the product works: `magentorest_advanced_product_search` with `field: sku`
252
+ returns its summary, because the SKU then travels in the query string. Not
253
+ checked against a live Apache.
254
+
255
+ ## Tool groups
256
+
257
+ A Magento project rarely needs every tool, and each tool an agent is shown costs
258
+ context. `MAGENTO_REST_GROUPS` loads only the groups you name; unset or empty
259
+ loads all of them (the `database` group too, but only when a database is
260
+ configured — see [Database access](#database-access)).
261
+
262
+ ```json
263
+ "MAGENTO_REST_GROUPS": "products,customers"
264
+ ```
265
+
266
+ Names are separated by commas, are case-insensitive, and blanks and repeats are
267
+ ignored. A name that is not a group stops the server at startup with exit code 1
268
+ and the list of valid groups, so a typo never leaves a tool set out silently.
269
+ It is read once at startup, like the write switch, and the two are independent:
270
+ a group loads its read tools always, and its write tools (marked `*`) only with
271
+ `MAGENTO_REST_ALLOW_WRITES=true`. The exception is `database`, whose one write tool
272
+ answers to its own switch (below). Naming `database` without a connection stops the
273
+ server, because the tools it names cannot exist.
274
+
275
+ | Group | Covers | Tools (`*` = write) |
276
+ |---|---|---|
277
+ | `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* |
278
+ | `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 |
279
+ | `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* |
280
+ | `customers` | Customers, their groups and addresses | get_customer_by_id, search_customers, get_customer_groups, get_customer_addresses, create_customer*, update_customer*, delete_customer* |
281
+ | `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* |
282
+ | `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* |
283
+ | `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* |
284
+ | `carts` | Carts, including abandoned ones (read-only) | get_cart_by_id, search_carts, get_cart_items, get_abandoned_carts |
285
+ | `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* |
286
+ | `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* |
287
+ | `media` | Product images | get_product_media, get_product_media_entry, add_product_image*, update_product_media*, delete_product_media* |
288
+ | `promotions` | Cart price rules and coupons | get_sales_rules, get_sales_rule_by_id, search_coupons, get_coupon_by_id, delete_coupon* |
289
+ | `tax` | Tax rates, rules and classes (read-only) | get_tax_rates, get_tax_rules, get_tax_classes |
290
+ | `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 |
291
+ | `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* |
292
+
293
+ ## Database access
294
+
295
+ The REST API cannot answer every question cheaply — a count, a join, a table's
296
+ columns. `MAGENTO_REST_DATABASE_CONNECTION` adds nine tools that read the Magento
297
+ database directly (the `database` group). They are a second choice: for anything the
298
+ `magentorest_get_*` tools can answer, use those, because they go through Magento's own
299
+ rules and return only reviewed fields.
300
+
301
+ ```json
302
+ "MAGENTO_REST_DATABASE_CONNECTION": "mysql://reader@127.0.0.1:3306/magento"
303
+ ```
304
+
305
+ **The connection has no password, on purpose.** The string is committed with the project,
306
+ so a password in it stops the server (and is never printed). Give the password with
307
+ `MAGENTO_REST_DATABASE_PASSWORD`, or store it once, from stdin, in a file only you can read:
308
+
309
+ ```sh
310
+ printf '%s' "$DB_PASSWORD" | hiberus-magento-rest auth db-password set
311
+ ```
312
+
313
+ A host that is not this machine uses TLS with certificate verification; write `?ssl=false`
314
+ to say, explicitly, that it does not. The URL is checked at startup; the password is only
315
+ needed when a tool is called.
316
+
317
+ **Reads** (eight tools) run in a `READ ONLY` session, with a 15 second timeout and a cap on
318
+ rows. `db_query` takes one `SELECT`: name the columns (`SELECT *` is refused under any
319
+ modifier, and so is `TABLE t`; `COUNT(*)` and `a * b` are fine), pass values as `?`
320
+ parameters, expect at most `max_rows` (default 100, at most 500). Values are bound by the
321
+ database server as a prepared statement, never pasted into the SQL text. A literal written in
322
+ the SQL must be single-quoted and contain no backslash; double quotes are refused, because
323
+ what they and a backslash mean depends on the server's SQL mode.
324
+ A `LIMIT` above `max_rows` is refused; a statement without one gets `LIMIT max_rows` added.
325
+ It refuses comments, a second statement, `INTO`, locking reads (`FOR UPDATE`, `FOR SHARE`,
326
+ `LOCK IN SHARE MODE`), `??` identifier placeholders, and the functions that read files or
327
+ stall the server. It will not touch the tables that hold credentials (administrators, OAuth
328
+ tokens, integrations, two-factor settings, sessions, ACL roles and rules — also under a table
329
+ prefix, so `mg_admin_user` is refused like `admin_user`) or the `mysql` schema, and it refuses
330
+ any column named like a password, hash or token wherever it is written (selected, aliased,
331
+ inside an expression or in a `WHERE`). The value of such a column that reaches the result
332
+ anyway (through a view or an alias, judged by the column's original name), and of a
333
+ configuration value whose path is a secret, is not in the result, or may belong to another
334
+ row (the configuration table joined to itself), comes back as `[redacted]`. The other seven tools use fixed statements.
335
+
336
+ **Writes** are a separate switch. `MAGENTO_REST_ALLOW_WRITES` does not enable them:
337
+
338
+ ```json
339
+ "MAGENTO_REST_DATABASE_ALLOW_WRITES": "true"
340
+ ```
341
+
342
+ Only the exact text `true` registers `db_execute`; without a connection it stops the server.
343
+ It runs **one** `INSERT`, `UPDATE` or `DELETE` per call (the last two need a `WHERE`), in a
344
+ transaction. `dry_run: true` runs it and rolls back, so you see how many rows it would
345
+ change; if more than `max_affected` (default 100, at most 10000) would change, it rolls back
346
+ by itself. No `DROP`, `ALTER`, `TRUNCATE`, `REPLACE` or `LOAD`, and the same rules on
347
+ values and literals as `db_query` (`?` parameters, single quotes, no backslashes). A change made this way skips
348
+ Magento's validation, indexing and events, so it may not show on the storefront until a
349
+ reindex and a cache flush.
350
+
351
+ **These rules make a mistake cheap; they are not the security boundary.** They are a
352
+ best-effort check on the text of a statement, and a check on text can have holes (an
353
+ expression such as `CONCAT(value)`, a derived table or a UNION hides which table a column
354
+ came from, so a configuration value read that way is not redacted). The boundary is
355
+ the database user. Create one for this server with `SELECT` only, without access to the
356
+ credential tables above, and add `INSERT`/`UPDATE`/`DELETE` on the tables you mean to change
357
+ only if you enable writes. Table prefixes
358
+ (`db.table_prefix`) are not applied to the fixed statements. Text is decoded as UTF-8
359
+ (`utf8mb4`); a column in another character set must be converted in the query.
360
+
361
+ ## Showing more fields
362
+
363
+ Point `MAGENTO_REST_FIELDS_FILE` at a JSON file, kept in your project and
364
+ reviewed like code:
365
+
366
+ ```json
367
+ { "product": { "add": ["cost", "extension_attributes.stock_item.qty"] } }
368
+ ```
369
+
370
+ The keys are resources — a kind of record, such as `product`, `order`,
371
+ `customer`, `cart` or `cms_page` — so one entry widens every tool that returns
372
+ that kind of record. The full list is in the onboarding guide, and an unknown
373
+ name is an error that lists them. The file only adds; a
374
+ credential or payment path (password, hash, token, secret, API key, card or
375
+ payment data, IBAN, private key) is refused at any depth. It is read once at
376
+ startup, and an invalid file stops the server with exit code 1 and the reason.
377
+ See the [onboarding guide](https://github.com/hiberus-magento/mcp-servers/blob/main/docs/magento-rest-onboarding.md).
378
+
379
+ ## What this server deliberately does not do
380
+
381
+ - **No database access.** The server this one replaces also exposed MySQL tools
382
+ (`db_query` and others). Those are not here; direct SQL needs its own design
383
+ (a read-only database user and session, a statement timeout) and is not part
384
+ of this package.
385
+ - **No chat proxy and no embedded model client.** It is an MCP server, nothing
386
+ else.
387
+ - **No way to turn TLS verification off.** There is no option and no honoured
388
+ environment variable. For a private certificate authority, make Node trust it
389
+ with `NODE_EXTRA_CA_CERTS`.
390
+ - **No plain `http`** except for `localhost`: a Bearer over plain http is a
391
+ Bearer on the wire.
392
+ - **No unbounded output.** `page_size` is 1 to 100; a multi-page walk stops at a
393
+ hard cap and reports `truncated: true`.
394
+ - **No raw responses.** Every read returns an allowlist of fields, so whatever
395
+ an instance's modules add (extension attributes, payment blocks, address
396
+ books) cannot reach the model. An operator can **add** fields with
397
+ `MAGENTO_REST_FIELDS_FILE` (see below) but never remove from the list, never
398
+ use a wildcard, and never add a credential or payment field.
399
+ - **No shipping-methods or payment-methods tool.** The original called
400
+ `/shipping-methods` and `/payment-methods`, which are not standard Magento REST
401
+ endpoints (the methods are per cart), and the first fell back to returning the
402
+ store configuration — an answer to a different question.
403
+ - **No store assignment when creating a CMS block or page.** A live Magento refuses
404
+ a `store_id` in that body; the write runs in the `all` scope, so the record is on
405
+ all store views (see "Store scope of writes").
406
+ - **No URL-rewrite search.** The original called `/url-rewrite`, which is not a
407
+ core Magento endpoint: a stock 2.4.8 answers 404.
408
+ - **No order-statuses tool.** The original called `/orders/statuses`, which is not
409
+ a route: a live Magento reads it as `/orders/{id}` with an id of "statuses" and
410
+ answers 400.
411
+ - **No customer password.** `magentorest_create_customer` takes none: a
412
+ credential must not pass through the model; Magento's password-reset flow is
413
+ how a new customer sets one.
414
+ - **No unbounded report.** The analytics tools read at most 50 pages of 100
415
+ orders (10 by default), report how many orders they covered, and say when a
416
+ result is partial.
417
+ - **No set-the-identity tool.** `magentorest_update_product_attribute` refuses
418
+ `sku`, `id`, `entity_id` and `type_id`.
419
+
420
+ ## Documentation
421
+
422
+ - [Repository](https://github.com/hiberus-magento/mcp-servers) — source, issues, and the other servers in this family.
423
+ - [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.
424
+ - [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.
425
+
426
+ ## License
427
+
428
+ Apache-2.0. See [LICENSE](https://github.com/hiberus-magento/mcp-servers/blob/main/LICENSE).
@@ -0,0 +1,17 @@
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
+ - generate-function@2.3.1 — MIT
10
+ - is-property@1.0.2 — MIT
11
+ - long@5.3.2 — Apache-2.0
12
+ - lru.min@1.1.5 — MIT
13
+ - mysql2@3.24.6 — MIT
14
+ - named-placeholders@1.1.6 — MIT
15
+ - sql-escaper@1.5.2 — MIT
16
+ - zod@4.5.4 — MIT
17
+ - zod-to-json-schema@3.25.2 — ISC