@hiberus-magento/magento-rest 0.1.0 → 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/README.md CHANGED
@@ -29,7 +29,7 @@ verification.
29
29
 
30
30
  | Binary | What it is |
31
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. |
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
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
34
 
35
35
  With two binaries declared, `npx` has to be told which one to run
@@ -64,14 +64,14 @@ executable to run`.
64
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
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
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.
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
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
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.
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
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
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
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.
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
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
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
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.
@@ -96,10 +96,10 @@ executable to run`.
96
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
97
  - `magentorest_get_source_items` (read-only) — Use this to read a product's quantity and status in each inventory source, by SKU.
98
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.
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
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
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.
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
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
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
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.
@@ -133,7 +133,7 @@ executable to run`.
133
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
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
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.
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
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
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
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.
@@ -149,11 +149,18 @@ executable to run`.
149
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
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
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.
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.
154
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.
155
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.
156
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.
157
164
 
158
165
  ## Configure in an MCP client
159
166
 
@@ -167,7 +174,7 @@ Pin the exact version; pass secrets as environment variable references, never li
167
174
  "args": [
168
175
  "-y",
169
176
  "--package",
170
- "@hiberus-magento/magento-rest@0.0.0",
177
+ "@hiberus-magento/magento-rest@0.2.0",
171
178
  "hiberus-magento-rest-mcp"
172
179
  ],
173
180
  "env": {
@@ -180,6 +187,32 @@ Pin the exact version; pass secrets as environment variable references, never li
180
187
 
181
188
  <!-- package:end -->
182
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
+
183
216
  ## Credentials
184
217
 
185
218
  A Magento **integration Access Token** (or an admin token), sent as a Bearer. It
@@ -200,8 +233,10 @@ effect without a restart.
200
233
 
201
234
  ## Read-only by default
202
235
 
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
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
205
240
  `tools/list`, not merely refused when called. The choice is made once at
206
241
  startup. Reads that hit a `429` or `5xx` are retried with backoff; a write is
207
242
  sent exactly once, because replaying an invoice or a refund after an ambiguous
@@ -252,6 +287,54 @@ the product works: `magentorest_advanced_product_search` with `field: sku`
252
287
  returns its summary, because the SKU then travels in the query string. Not
253
288
  checked against a live Apache.
254
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
+
255
338
  ## Tool groups
256
339
 
257
340
  A Magento project rarely needs every tool, and each tool an agent is shown costs
@@ -378,10 +461,10 @@ See the [onboarding guide](https://github.com/hiberus-magento/mcp-servers/blob/m
378
461
 
379
462
  ## What this server deliberately does not do
380
463
 
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.
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).
385
468
  - **No chat proxy and no embedded model client.** It is an MCP server, nothing
386
469
  else.
387
470
  - **No way to turn TLS verification off.** There is no option and no honoured
@@ -421,6 +504,7 @@ See the [onboarding guide](https://github.com/hiberus-magento/mcp-servers/blob/m
421
504
 
422
505
  - [Repository](https://github.com/hiberus-magento/mcp-servers) — source, issues, and the other servers in this family.
423
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.
424
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.
425
509
 
426
510
  ## License
@@ -6,6 +6,7 @@ dependencies of its own. It statically bundles the following third-party
6
6
  packages:
7
7
 
8
8
  - @modelcontextprotocol/sdk@1.30.0 — MIT
9
+ - content-type@1.0.5 — MIT
9
10
  - generate-function@2.3.1 — MIT
10
11
  - is-property@1.0.2 — MIT
11
12
  - long@5.3.2 — Apache-2.0
package/dist/cli.js CHANGED
@@ -7,7 +7,7 @@ var __export = (target, all) => {
7
7
  };
8
8
 
9
9
  // src/cli.ts
10
- import { createHash } from "crypto";
10
+ import { createHash as createHash2 } from "crypto";
11
11
 
12
12
  // ../mcp-core/src/bootstrap/stdout-guard.ts
13
13
  import { Writable } from "stream";
@@ -26,6 +26,10 @@ function isEntryPoint(importMetaUrl, entryPoint = process.argv[1]) {
26
26
  }
27
27
  }
28
28
 
29
+ // ../mcp-core/src/http/http-endpoint.ts
30
+ import { createHash, timingSafeEqual } from "crypto";
31
+ var DEFAULT_MAX_BODY_BYTES = 1024 * 1024;
32
+
29
33
  // ../mcp-core/src/credentials/token-provider.ts
30
34
  function formatRemedyMessage(prefix, remedy) {
31
35
  return `${prefix} for domain "${remedy.domain}".
@@ -19209,7 +19213,7 @@ function normalizeBaseUrl(baseUrl) {
19209
19213
  }
19210
19214
  return baseUrl.replace(/\/+$/, "");
19211
19215
  }
19212
- var SCOPED_BASE = /^(.*\/rest)(?:\/[A-Za-z0-9_]+)?\/V1$/;
19216
+ var SCOPED_BASE = /^(.*\/rest)(?:\/([A-Za-z0-9_]+))?\/V1$/;
19213
19217
  var STORE_CODE = /^[A-Za-z][A-Za-z0-9_]{0,31}$/;
19214
19218
  function scopedBase(restRoot, scope) {
19215
19219
  if (!STORE_CODE.test(scope)) {
@@ -19237,7 +19241,9 @@ function retryAfterMs(response) {
19237
19241
  }
19238
19242
  function createRestTransport(deps) {
19239
19243
  const baseUrl = normalizeBaseUrl(deps.baseUrl);
19240
- const restRoot = SCOPED_BASE.exec(baseUrl)?.[1];
19244
+ const scopedMatch = SCOPED_BASE.exec(baseUrl);
19245
+ const restRoot = scopedMatch?.[1];
19246
+ const baseStoreView = scopedMatch?.[2];
19241
19247
  const random = deps.random ?? Math.random;
19242
19248
  const timeoutMs = deps.timeoutMs ?? DEFAULT_REST_TIMEOUT_MS;
19243
19249
  const rateLimiter = new TokenBucketRateLimiter(REST_PACE, { now: deps.now, sleep: deps.sleep });
@@ -19291,6 +19297,17 @@ function createRestTransport(deps) {
19291
19297
  };
19292
19298
  }
19293
19299
  }
19300
+ function answerFor(request, root) {
19301
+ const pathname = new URL(`${root}${request.path}`).pathname;
19302
+ const fromRest = pathname.indexOf("/rest/");
19303
+ const scope = request.scope ?? baseStoreView;
19304
+ const storeView = scope === "all" ? void 0 : scope;
19305
+ return {
19306
+ endpoint: `${request.method} ${fromRest >= 0 ? pathname.slice(fromRest) : pathname}`,
19307
+ readAt: new Date(deps.now()).toISOString(),
19308
+ ...storeView !== void 0 ? { storeView } : {}
19309
+ };
19310
+ }
19294
19311
  return {
19295
19312
  async request(request) {
19296
19313
  assertPath(request.path);
@@ -19302,6 +19319,7 @@ function createRestTransport(deps) {
19302
19319
  }
19303
19320
  const outcome = await attemptOnce(request, root);
19304
19321
  if ("value" in outcome) {
19322
+ request.onAnswered?.(answerFor(request, root));
19305
19323
  return outcome.value;
19306
19324
  }
19307
19325
  const decision = decideRetry(
@@ -19894,7 +19912,7 @@ function analyticsTools({ readTool }) {
19894
19912
  }),
19895
19913
  readTool({
19896
19914
  name: "magentorest_get_customer_ordered_products_by_email",
19897
- description: "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.",
19915
+ description: "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.",
19898
19916
  input: external_exports.object({ email: external_exports.email().max(254).describe("The customer's email address (exact)."), max_pages: maxPages }).strict(),
19899
19917
  shape: [
19900
19918
  ["customer", ["id", "email", "firstname", "lastname"]],
@@ -20062,7 +20080,7 @@ function cartTools({ readTool, shapes }) {
20062
20080
  return [
20063
20081
  readTool({
20064
20082
  name: "magentorest_get_cart_by_id",
20065
- description: "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.",
20083
+ description: "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.",
20066
20084
  input: external_exports.object({ cart_id: cartId }).strict(),
20067
20085
  shape: shapes.cart,
20068
20086
  run: ({ cart_id }, client) => client.get(restPath`/carts/${cart_id}`)
@@ -20107,7 +20125,7 @@ function cartTools({ readTool, shapes }) {
20107
20125
  }),
20108
20126
  readTool({
20109
20127
  name: "magentorest_get_abandoned_carts",
20110
- description: "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.",
20128
+ description: "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.",
20111
20129
  input: external_exports.object({
20112
20130
  days_old: external_exports.number().int().min(0).max(3650).optional().describe("Minimum days since the cart was last updated (default 7)."),
20113
20131
  page_size: pageSize,
@@ -20451,7 +20469,7 @@ function customerTools({ readTool, writeTool, shapes }) {
20451
20469
  return [
20452
20470
  readTool({
20453
20471
  name: "magentorest_get_customer_by_id",
20454
- description: "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.",
20472
+ description: "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.",
20455
20473
  input: external_exports.object({ customer_id: entityId("customer") }).strict(),
20456
20474
  shape: shapes.customer,
20457
20475
  run: ({ customer_id }, client) => client.get(restPath`/customers/${customer_id}`)
@@ -20500,7 +20518,7 @@ function customerTools({ readTool, writeTool, shapes }) {
20500
20518
  }),
20501
20519
  readTool({
20502
20520
  name: "magentorest_get_customer_addresses",
20503
- description: "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.",
20521
+ description: "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.",
20504
20522
  input: external_exports.object({ customer_id: entityId("customer") }).strict(),
20505
20523
  shape: shapes.customer_address,
20506
20524
  run: async ({ customer_id }, client) => {
@@ -20572,6 +20590,20 @@ function customerTools({ readTool, writeTool, shapes }) {
20572
20590
  ];
20573
20591
  }
20574
20592
 
20593
+ // src/tools/output-schema.ts
20594
+ var primitive = external_exports.union([external_exports.string(), external_exports.number(), external_exports.boolean(), external_exports.null()]);
20595
+ var provenanceSchema = external_exports.object({
20596
+ /** The first request: method and path from `/rest` on, with no host, query string or token. */
20597
+ endpoint: external_exports.string(),
20598
+ /** Each distinct endpoint, in the order first used, when the tool used more than one (a paged walk counts once). */
20599
+ endpoints: external_exports.array(external_exports.string()).optional(),
20600
+ api_version: external_exports.literal("V1"),
20601
+ /** ISO 8601 UTC, when Magento answered the last request. */
20602
+ read_at: external_exports.string(),
20603
+ /** The store view the requests addressed, when the URL named one. */
20604
+ store_view: external_exports.string().optional()
20605
+ });
20606
+
20575
20607
  // src/tools/database-tools.ts
20576
20608
  var SQL_PARAM = external_exports.union([external_exports.string().max(2e3), external_exports.number(), external_exports.boolean(), external_exports.null()]);
20577
20609
  var params = external_exports.array(SQL_PARAM).max(50).optional().describe("Values for the ? placeholders in the statement, in order. Always pass values here instead of writing them into the SQL.");
@@ -20960,7 +20992,7 @@ function orderTools({ readTool, writeTool, shapes }) {
20960
20992
  return [
20961
20993
  readTool({
20962
20994
  name: "magentorest_get_order_by_id",
20963
- description: "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.",
20995
+ description: "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.",
20964
20996
  input: external_exports.object({ order_id: orderId }).strict(),
20965
20997
  shape: shapes.order,
20966
20998
  run: ({ order_id }, client) => client.get(restPath`/orders/${order_id}`)
@@ -21451,7 +21483,7 @@ async function authStatus(deps) {
21451
21483
  } catch (error61) {
21452
21484
  return { exitCode: 1, stderr: redact(error61.message) };
21453
21485
  }
21454
- const fingerprint = createHash("sha256").update(token).digest("hex").slice(0, 8);
21486
+ const fingerprint = createHash2("sha256").update(token).digest("hex").slice(0, 8);
21455
21487
  const lines = [`key fingerprint: ${fingerprint}`];
21456
21488
  try {
21457
21489
  await deps.probe();