diff --git a/CITATION.cff b/CITATION.cff
index 5b8fb724c..773fdcdae 100644
--- a/CITATION.cff
+++ b/CITATION.cff
@@ -13,7 +13,7 @@ abstract: >
server that turns REST/OpenAPI, SOAP/WSDL and GraphQL APIs, SQL/NoSQL
databases and other MCP servers into tools for AI clients such as Claude,
ChatGPT, Google Gemini, GitHub Copilot and Cursor, without writing code.
- It ships 976 pre-built adapters, with a focus on ERP and e-commerce
+ It ships 977 pre-built adapters, with a focus on ERP and e-commerce
systems (SAP Business One, Odoo, Xentral, JTL-Wawi, weclapp, Shopware,
WooCommerce, Amazon Seller, Kaufland, OTTO, etc.), a per-workspace
knowledge graph served over MCP, File Search over company file servers
diff --git a/README.de.md b/README.de.md
index 30aca4378..439022fe4 100644
--- a/README.de.md
+++ b/README.de.md
@@ -1,5 +1,5 @@
-
+
AnythingMCP: das Open-Source-MCP-Gateway, das zum Gehirn deines Unternehmens wird
@@ -55,7 +55,7 @@ Ein Gateway reicht Aufrufe weiter. Ein Firmengehirn weiß außerdem, wo deine Do
| | Was es macht | Edition |
|---|---|---|
-| **Jedes System, ein Endpunkt** | 976 Connectors aus dem Katalog oder deine eigene REST-/OpenAPI-, SOAP-, GraphQL-, OData-, SQL-, IMAP/SMTP- oder MCP-Quelle. Tools werden zur Laufzeit registriert. [Connectors](#connect-any-api-soap-service-or-database) | Alle |
+| **Jedes System, ein Endpunkt** | 977 Connectors aus dem Katalog oder deine eigene REST-/OpenAPI-, SOAP-, GraphQL-, OData-, SQL-, IMAP/SMTP- oder MCP-Quelle. Tools werden zur Laufzeit registriert. [Connectors](#connect-any-api-soap-service-or-database) | Alle |
| **File Search** | Indexiert SFTP, FTP/FTPS, WebDAV (Nextcloud, NAS), S3 oder eine Netzwerkfreigabe: jede PDF-Seite, Excel-Zeilen mit ihren Spaltennamen, Word, PowerPoint, Outlook-Mails mit Anhängen. Die KI antwortet mit Datei, Seite und Datum. [File Search](docs/connectors/file-search.md) | Cloud; selbst gehostet Enterprise |
| **File Share** | Befristete Download-Links für Dateien aus deinen Ordnern oder für Dateien, die die KI erstellt (einen CSV-Export, einen Bericht), intern oder öffentlich, mit Ablaufdatum und Widerruf. [File Share](docs/connectors/file-search.md) | Cloud; selbst gehostet Enterprise |
| **Firmengedächtnis** | Fakten und Vorlieben, in einem KI-Client gespeichert und in jedem anderen wiedergefunden: einmal in Claude gesagt, von Copilot genutzt. Persönlicher und firmenweiter Bereich, mit Ordnern und Rollengrenzen. [Gedächtnis](docs/memory.md) | Enterprise |
@@ -140,7 +140,7 @@ Tools werden zur Laufzeit registriert, ohne Neustart. `{{VAR}}`-Werte pro Connec
## Connector-Katalog
-976 Adapter mit über 12.000 Tools. Zu jedem gibt es eine Einrichtungsanleitung auf [anythingmcp.com/de/guides](https://anythingmcp.com/de/guides), in sieben Sprachen.
+977 Adapter mit über 12.000 Tools. Zu jedem gibt es eine Einrichtungsanleitung auf [anythingmcp.com/de/guides](https://anythingmcp.com/de/guides), in sieben Sprachen.
| Kategorie | Beispiele |
|---|---|
diff --git a/README.ja.md b/README.ja.md
index e16737a34..0d4e65df0 100644
--- a/README.ja.md
+++ b/README.ja.md
@@ -1,5 +1,5 @@
AnythingMCP: the open-source MCP gateway that becomes your company brain
@@ -21,7 +21,7 @@
AnythingMCP is an open-source, self-hosted MCP gateway that connects Claude, ChatGPT, Copilot and Gemini to the software your company runs and to the documents on your file servers, without writing an MCP server.
On top of the gateway it keeps your company brain: a knowledge graph of how your systems connect, AI skills and company memory, shared by every AI client and limited by each user's role.
- 976 ready connectors with 12,000+ tools, among them SAP, Odoo, weclapp and Amazon Seller; 57 need no API key.
+ 977 ready connectors with 12,000+ tools, among them SAP, Odoo, weclapp and Amazon Seller; 57 need no API key.
@@ -131,7 +131,7 @@ Tools register at runtime, without a restart. Per-connector `{{VAR}}` values are
## Connector catalog
-976 adapters, exposing 12,000+ tools. Every one has a setup guide on [anythingmcp.com/guides](https://anythingmcp.com/guides), in seven languages. The [full catalog by category](docs/catalog/README.md) lists every Cloud connector with links to its guides for Claude, ChatGPT, Copilot, Cursor and Gemini, and the [connector marketplace](https://anythingmcp.com/marketplace) has a page for each one.
+977 adapters, exposing 12,000+ tools. Every one has a setup guide on [anythingmcp.com/guides](https://anythingmcp.com/guides), in seven languages. The [full catalog by category](docs/catalog/README.md) lists every Cloud connector with links to its guides for Claude, ChatGPT, Copilot, Cursor and Gemini, and the [connector marketplace](https://anythingmcp.com/marketplace) has a page for each one.
| Category | Examples |
|---|---|
diff --git a/README.zh-CN.md b/README.zh-CN.md
index 6a1e6753a..ecede2136 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -1,5 +1,5 @@
@@ -140,7 +140,7 @@ docker compose up -d
## 连接器目录
-共 976 个适配器,提供 12,000 多个工具。每个适配器都在 [anythingmcp.com/zh/guides](https://anythingmcp.com/zh/guides) 上提供七种语言的配置指南。
+共 977 个适配器,提供 12,000 多个工具。每个适配器都在 [anythingmcp.com/zh/guides](https://anythingmcp.com/zh/guides) 上提供七种语言的配置指南。
| 类别 | 示例 |
|---|---|
diff --git a/docs/connectors/login-token-auth.md b/docs/connectors/login-token-auth.md
index d03bfb13f..cbd5d7d78 100644
--- a/docs/connectors/login-token-auth.md
+++ b/docs/connectors/login-token-auth.md
@@ -124,6 +124,7 @@ The token cache is keyed by `connectorId` (when available) or by `loginUrl|usern
"tokenJsonPath": "data.signIn.jwtToken.token", // or a list; empty, absent or "." = the whole body
"expiryJsonPath": "data.signIn.jwtToken.expiredAt",
"audJsonPath": "data.signIn.jwtToken.aud", // optional — overrides authConfig.aud
+ "audSecret": false, // true = the second value is a credential: cached encrypted
"expiryFormat": "iso8601", // iso8601 | unix | ttl_seconds
"tokenTTLSeconds": 2592000, // fallback when expiry is absent (30 days)
@@ -302,11 +303,20 @@ behaves exactly as before.
(`headerName` and `headerTemplate` are not used; `extraHeaders` still are).
The token is the placeholder `${loginToken}` in a tool's
`endpointMapping.bodyTemplate`: XML-escaped with `bodyEncoding: "xml"`,
- JSON-escaped in a JSON template. The engine's value always wins: a tool
- argument named `loginToken` cannot replace it. A body that carries the token
- is not sent again to another origin after a redirect. Fixed values the body
- needs next to the token (a partner id, a shop id) are ordinary connector
- variables: `{{PARTNER_ID}}` in the template.
+ JSON-escaped in a JSON template. A `bodyMapping` can name it `$loginToken`
+ instead, which leaves out any other field the caller did not pass. The
+ engine's value always wins: a tool argument named `loginToken` cannot
+ replace it. A second value from the login, read with `audJsonPath` (or the
+ static `aud`), is `${loginAud}` in a template and `$loginAud` in a
+ `bodyMapping`. Use it when the login returns two fields every later call
+ sends, such as SkuVault's TenantToken and UserToken. When that second
+ value is a credential, set `"audSecret": true`: it is then encrypted with
+ `ENCRYPTION_KEY` in the cached login row (like the token), decrypted when
+ the row is read, and never logged. Without the flag it is cached as a plain
+ value, and a row cached before the flag was set still reads. A body that
+ carries the token is not sent again to another origin after a redirect. Fixed
+ values the body needs next to the token (a partner id, a shop id) are
+ ordinary connector variables: `{{PARTNER_ID}}` in the template.
```json
"endpointMapping": {
diff --git a/glama.json b/glama.json
index bd150b17f..d976f125b 100644
--- a/glama.json
+++ b/glama.json
@@ -3,5 +3,5 @@
"maintainers": [
"helpcodeai"
],
- "description": "Self-hosted MCP gateway and company brain for AI agents. Turn any REST/OpenAPI, SOAP/WSDL, GraphQL, OData or SQL API into MCP tools for Claude, ChatGPT and Copilot, no code: 976 pre-built adapters for ERP and e-commerce (SAP S/4HANA, SAP Business One, Odoo, Xentral, JTL-Wawi, weclapp, Shopware, WooCommerce, Amazon Seller, Kaufland, OTTO\u2026) and more. File Search over SFTP/WebDAV/S3 file servers, company memory, AI skills and a knowledge graph shared by every AI client. Per-tool response mapping, OAuth2/RBAC/SSO/SCIM, audit log. Open source under AGPL-3.0."
+ "description": "Self-hosted MCP gateway and company brain for AI agents. Turn any REST/OpenAPI, SOAP/WSDL, GraphQL, OData or SQL API into MCP tools for Claude, ChatGPT and Copilot, no code: 977 pre-built adapters for ERP and e-commerce (SAP S/4HANA, SAP Business One, Odoo, Xentral, JTL-Wawi, weclapp, Shopware, WooCommerce, Amazon Seller, Kaufland, OTTO\u2026) and more. File Search over SFTP/WebDAV/S3 file servers, company memory, AI skills and a knowledge graph shared by every AI client. Per-tool response mapping, OAuth2/RBAC/SSO/SCIM, audit log. Open source under AGPL-3.0."
}
diff --git a/llms-full.txt b/llms-full.txt
index 8025812ee..a7b85b701 100644
--- a/llms-full.txt
+++ b/llms-full.txt
@@ -1,6 +1,6 @@
# AnythingMCP
-> Turn any REST/OpenAPI, SOAP/WSDL, GraphQL, OData or SQL API into MCP tools for Claude, ChatGPT and Copilot, no code. 976 pre-built adapters for ERP, e-commerce and more (SAP S/4HANA, SAP Business One, Odoo, Xentral, JTL-Wawi, Shopware, WooCommerce, Amazon Seller). Self-hosted, open source (AGPL-3.0).
+> Turn any REST/OpenAPI, SOAP/WSDL, GraphQL, OData or SQL API into MCP tools for Claude, ChatGPT and Copilot, no code. 977 pre-built adapters for ERP, e-commerce and more (SAP S/4HANA, SAP Business One, Odoo, Xentral, JTL-Wawi, Shopware, WooCommerce, Amazon Seller). Self-hosted, open source (AGPL-3.0).
---
@@ -93,7 +93,7 @@ Tools register at runtime, without a restart. Per-connector `{{VAR}}` values are
## Connector catalog
-976 adapters, exposing 12,000+ tools. Every one has a setup guide on [anythingmcp.com/guides](), in seven languages. The [full catalog by category]() lists every Cloud connector with links to its guides for Claude, ChatGPT, Copilot, Cursor and Gemini, and the [connector marketplace]() has a page for each one.
+977 adapters, exposing 12,000+ tools. Every one has a setup guide on [anythingmcp.com/guides](), in seven languages. The [full catalog by category]() lists every Cloud connector with links to its guides for Claude, ChatGPT, Copilot, Cursor and Gemini, and the [connector marketplace]() has a page for each one.
| Category | Examples |
|---|---|
@@ -2186,6 +2186,7 @@ The token cache is keyed by `connectorId` (when available) or by `loginUrl|usern
"tokenJsonPath": "data.signIn.jwtToken.token", // or a list; empty, absent or "." = the whole body
"expiryJsonPath": "data.signIn.jwtToken.expiredAt",
"audJsonPath": "data.signIn.jwtToken.aud", // optional — overrides authConfig.aud
+ "audSecret": false, // true = the second value is a credential: cached encrypted
"expiryFormat": "iso8601", // iso8601 | unix | ttl_seconds
"tokenTTLSeconds": 2592000, // fallback when expiry is absent (30 days)
@@ -2364,11 +2365,20 @@ behaves exactly as before.
(`headerName` and `headerTemplate` are not used; `extraHeaders` still are).
The token is the placeholder `${loginToken}` in a tool's
`endpointMapping.bodyTemplate`: XML-escaped with `bodyEncoding: "xml"`,
- JSON-escaped in a JSON template. The engine's value always wins: a tool
- argument named `loginToken` cannot replace it. A body that carries the token
- is not sent again to another origin after a redirect. Fixed values the body
- needs next to the token (a partner id, a shop id) are ordinary connector
- variables: `{{PARTNER_ID}}` in the template.
+ JSON-escaped in a JSON template. A `bodyMapping` can name it `$loginToken`
+ instead, which leaves out any other field the caller did not pass. The
+ engine's value always wins: a tool argument named `loginToken` cannot
+ replace it. A second value from the login, read with `audJsonPath` (or the
+ static `aud`), is `${loginAud}` in a template and `$loginAud` in a
+ `bodyMapping`. Use it when the login returns two fields every later call
+ sends, such as SkuVault's TenantToken and UserToken. When that second
+ value is a credential, set `"audSecret": true`: it is then encrypted with
+ `ENCRYPTION_KEY` in the cached login row (like the token), decrypted when
+ the row is read, and never logged. Without the flag it is cached as a plain
+ value, and a row cached before the flag was set still reads. A body that
+ carries the token is not sent again to another origin after a redirect. Fixed
+ values the body needs next to the token (a partner id, a shop id) are
+ ordinary connector variables: `{{PARTNER_ID}}` in the template.
```json
"endpointMapping": {
diff --git a/llms.txt b/llms.txt
index e35563023..b767e8245 100644
--- a/llms.txt
+++ b/llms.txt
@@ -1,6 +1,6 @@
# AnythingMCP
-> Turn any REST/OpenAPI, SOAP/WSDL, GraphQL, OData or SQL API into MCP tools for Claude, ChatGPT and Copilot, no code. 976 pre-built adapters for ERP, e-commerce and more (SAP S/4HANA, SAP Business One, Odoo, Xentral, JTL-Wawi, Shopware, WooCommerce, Amazon Seller). Self-hosted, open source (AGPL-3.0).
+> Turn any REST/OpenAPI, SOAP/WSDL, GraphQL, OData or SQL API into MCP tools for Claude, ChatGPT and Copilot, no code. 977 pre-built adapters for ERP, e-commerce and more (SAP S/4HANA, SAP Business One, Odoo, Xentral, JTL-Wawi, Shopware, WooCommerce, Amazon Seller). Self-hosted, open source (AGPL-3.0).
## Getting started
diff --git a/package.json b/package.json
index 9174353ff..fa12ddb11 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "anythingmcp",
"version": "0.55.22",
- "description": "Turn any REST/OpenAPI, SOAP/WSDL, GraphQL, OData or SQL API into MCP tools for Claude, ChatGPT and Copilot, no code. 976 pre-built adapters for ERP, e-commerce and more (SAP S/4HANA, SAP Business One, Odoo, Xentral, JTL-Wawi, Shopware, WooCommerce, Amazon Seller). Self-hosted, open source (AGPL-3.0).",
+ "description": "Turn any REST/OpenAPI, SOAP/WSDL, GraphQL, OData or SQL API into MCP tools for Claude, ChatGPT and Copilot, no code. 977 pre-built adapters for ERP, e-commerce and more (SAP S/4HANA, SAP Business One, Odoo, Xentral, JTL-Wawi, Shopware, WooCommerce, Amazon Seller). Self-hosted, open source (AGPL-3.0).",
"private": true,
"license": "AGPL-3.0-only",
"engines": {
diff --git a/packages/backend/src/adapters/catalog.spec.ts b/packages/backend/src/adapters/catalog.spec.ts
index 545c75644..924a3d831 100644
--- a/packages/backend/src/adapters/catalog.spec.ts
+++ b/packages/backend/src/adapters/catalog.spec.ts
@@ -546,6 +546,14 @@ describe('adapter catalog', () => {
| undefined) ?? {},
),
);
+ // LOGIN_TOKEN with the token in the body fills these itself
+ // (`$loginToken` / `$loginAud`, or `${loginToken}` / `${loginAud}`).
+ // They are not tool parameters. A caller-supplied value cannot replace them.
+ const authCfg = adapter.connector.authConfig as { tokenPlacement?: string } | undefined;
+ const engineParams =
+ adapter.connector.authType === 'LOGIN_TOKEN' && authCfg?.tokenPlacement === 'body'
+ ? new Set(['loginToken', 'loginAud'])
+ : new Set();
for (const field of ['queryParams', 'bodyMapping', 'headers']) {
const strings: Array<{ path: string; value: string }> = [];
collectStrings(em[field], field, strings);
@@ -554,13 +562,19 @@ describe('adapter catalog', () => {
// unless it's $$ (escape) or an env-var-style reference (UPPER_SNAKE_CASE,
// resolved at runtime from connector.envVars populated at import time).
const full = /^\$([\w$]+)$/.exec(value);
- if (full && !value.startsWith('$$') && !/^[A-Z][A-Z0-9_]*$/.test(full[1])) {
+ if (
+ full &&
+ !value.startsWith('$$') &&
+ !/^[A-Z][A-Z0-9_]*$/.test(full[1]) &&
+ !engineParams.has(full[1])
+ ) {
expect(declaredParams.has(full[1])).toBe(true);
}
// Embedded references: "...${foo}..." — all names must be declared
// (same env-var exemption applies).
for (const match of value.matchAll(/\$\{([\w$]+)\}/g)) {
if (/^[A-Z][A-Z0-9_]*$/.test(match[1])) continue;
+ if (engineParams.has(match[1])) continue;
expect(declaredParams.has(match[1])).toBe(true);
}
}
diff --git a/packages/backend/src/adapters/catalog.ts b/packages/backend/src/adapters/catalog.ts
index e7f0bb1d7..73eee5d04 100644
--- a/packages/backend/src/adapters/catalog.ts
+++ b/packages/backend/src/adapters/catalog.ts
@@ -711,6 +711,7 @@ import * as signnow from './intl/signnow.json';
import * as signwell from './intl/signwell.json';
import * as siigo from './intl/siigo.json';
import * as skroutz from './intl/skroutz.json';
+import * as skuvault from './intl/skuvault.json';
import * as slab from './intl/slab.json';
import * as slack from './intl/slack.json';
import * as smartlead from './intl/smartlead.json';
@@ -2007,6 +2008,7 @@ const RAW_ADAPTERS: AdapterDefinition[] = [
signwell as unknown as AdapterDefinition,
siigo as unknown as AdapterDefinition,
skroutz as unknown as AdapterDefinition,
+ skuvault as unknown as AdapterDefinition,
slab as unknown as AdapterDefinition,
slack as unknown as AdapterDefinition,
smartlead as unknown as AdapterDefinition,
diff --git a/packages/backend/src/adapters/intl/skuvault.json b/packages/backend/src/adapters/intl/skuvault.json
new file mode 100644
index 000000000..0aaa2413b
--- /dev/null
+++ b/packages/backend/src/adapters/intl/skuvault.json
@@ -0,0 +1,369 @@
+{
+ "slug": "skuvault",
+ "name": "SkuVault",
+ "aliases": ["Sku Vault", "Linnworks"],
+ "description": "Read a SkuVault (Linnworks) warehouse: products and quantities, inventory by location, warehouses, and sales waiting to ship. Signs in with the account email and password. Read-only.",
+ "region": "intl",
+ "category": "inventory",
+ "icon": "skuvault",
+ "docsUrl": "https://dev.skuvault.com/",
+ "prerequisites": "A SkuVault account and the email and password of a user who is allowed to call the API. About 2 minutes. A disabled user receives no tokens.",
+ "instructions": "## SkuVault\nThis connector reads one SkuVault warehouse account (now part of Linnworks) through the SkuVault REST API at `https://app.skuvault.com/api`. Every call is a POST with a JSON body. It does not create or change products, stock, or sales.\n\n**Setup**\n1. `SKUVAULT_EMAIL` and `SKUVAULT_PASSWORD` are the email and password of a SkuVault user who may use the API.\n2. The connector calls `POST /gettokens` with that login. SkuVault returns `TenantToken` (one per account) and `UserToken` (one per user). Both go in the JSON body of every later call. The tokens do not expire on their own. The connector keeps them for 30 days, signs in again before that, and signs in again after an HTTP 401.\n3. A wrong email or password makes `gettokens` answer HTTP 200 with both tokens null. The connector reports that the token was null. Check the email and password, and that the user is not disabled.\n\n**Where to start**: `skuvault_get_warehouses` checks the sign-in and returns each warehouse id and code. Then `skuvault_get_products` for the catalog and quantities, `skuvault_get_inventory_by_location` for the bin of each SKU, and `skuvault_get_sales` for orders waiting to ship.\n\n**Products**: `skuvault_get_products` returns products, not kits. With no `product_codes` and no `product_skus`, alternate SKUs come back as their own rows (`is_alternate_sku` true) and each product is listed under its primary code. `page_size` is 1000 to 10000 and defaults to 1000, the smallest page SkuVault accepts. `page_number` starts at 0. Pass `modified_after` or `modified_before` as UTC, for example `2026-01-15T00:00:00Z`, to read only what changed.\n\n**Locations**: `skuvault_get_inventory_by_location` returns a map. Each key is a SKU, or a product code when `is_return_by_codes` is true, and each value is the locations that hold it: location code, warehouse code, quantity, and whether the location is reserve stock. Filter by SKU only with `is_return_by_codes` false. Filter by product code only with `is_return_by_codes` true. The page size rules match products.\n\n**Warehouses**: id and code. `page_number` starts at 0. This call is limited to 1 per minute, so use it to check the sign-in and then keep the codes.\n\n**Sales**: `skuvault_get_sales` returns up to 10000 sales. `status` is `ReadyToShip` (the default) or `Pending`. `order_ids` (up to 10000) returns those orders and ignores `status`. An order id that came from the API matches only sales that were created through the API. The full SkuVault id matches a sale from any channel. The published request has no page parameter. Money fields are objects with `a` (the amount) and `s` (the currency symbol). Street address, phone, and email are left out of the answer.\n\n**Limits**: `gettokens` allows 200 calls a minute. Products, inventory by location, and sales allow 5 a minute. Warehouses allow 1 a minute. HTTP 429 includes `X-RateLimit-Limit`, `X-RateLimit-Remaining`, and `X-RateLimit-Reset` (milliseconds to wait).\n\n**Errors**: HTTP 401 means the tokens were refused or the user is disabled. HTTP 404 means the tenant or the user was not found. A 200 body whose `Errors` list is not empty is reported as a failed call.\n\n**Reachability**: `app.skuvault.com` is a public HTTPS API. This connector works the same on AnythingMCP Cloud and on a self-hosted instance.\n\n**Out of scope**: creating or editing products, changing quantities, kits, purchase orders, shipments, and every other write.",
+ "requiredEnvVars": ["SKUVAULT_EMAIL", "SKUVAULT_PASSWORD"],
+ "envVarMeta": {
+ "SKUVAULT_EMAIL": {
+ "label": "SkuVault email",
+ "kind": "credential",
+ "help": "Email address of a SkuVault user who may call the API. It is sent only to POST /gettokens.",
+ "example": "warehouse@example.com",
+ "pattern": "^[^@\\s]+@[^@\\s.]+(\\.[^@\\s.]+)+$",
+ "patternMessage": "The email address you sign in to SkuVault with.",
+ "link": "https://dev.skuvault.com/reference/gettokens"
+ },
+ "SKUVAULT_PASSWORD": {
+ "label": "SkuVault password",
+ "kind": "credential",
+ "secret": true,
+ "help": "Password of that SkuVault user. A wrong password makes gettokens return both tokens as null.",
+ "link": "https://dev.skuvault.com/reference/gettokens"
+ }
+ },
+ "verifyHints": {
+ "401": "SkuVault refused the tokens (HTTP 401) or the login returned null tokens. Check the email and password, and that the user is not disabled. The connector signs in again once after a 401.",
+ "404": "SkuVault did not recognize the tenant or the user (HTTP 404). Check the email and password and sign in again.",
+ "400": "SkuVault rejected the request. Page size must be from 1000 to 10000. Filter inventory by SKU with is_return_by_codes false, or by product code with it true.",
+ "rate_limited": "SkuVault throttled this call. Warehouses allow 1 call a minute. Products, inventory by location, and sales allow 5. Wait for the X-RateLimit-Reset header, in milliseconds."
+ },
+ "probe": {
+ "tool": "skuvault_get_warehouses",
+ "params": { "page_number": 0 }
+ },
+ "connector": {
+ "name": "SkuVault API",
+ "type": "REST",
+ "baseUrl": "https://app.skuvault.com/api",
+ "authType": "LOGIN_TOKEN",
+ "authConfig": {
+ "loginUrl": "https://app.skuvault.com/api/gettokens",
+ "loginMethod": "POST",
+ "loginHeaders": {
+ "Content-Type": "application/json",
+ "Accept": "application/json"
+ },
+ "loginBody": {
+ "Email": "${username}",
+ "Password": "${password}"
+ },
+ "username": "{{SKUVAULT_EMAIL}}",
+ "password": "{{SKUVAULT_PASSWORD}}",
+ "tokenJsonPath": "TenantToken",
+ "audJsonPath": "UserToken",
+ "audSecret": true,
+ "tokenTTLSeconds": 2592000,
+ "proactiveRefreshSeconds": 86400,
+ "refreshOn401": true,
+ "tokenPlacement": "body"
+ },
+ "headers": {
+ "Accept": "application/json",
+ "Content-Type": "application/json",
+ "User-Agent": "AnythingMCP"
+ },
+ "config": {
+ "errorWhen": [
+ {
+ "path": "Errors[0]",
+ "matches": ".+",
+ "messagePath": "Errors",
+ "status": 400
+ }
+ ]
+ }
+ },
+ "tools": [
+ {
+ "name": "skuvault_get_products",
+ "description": "List SkuVault products (not kits) with code, SKU, description, prices, brand, supplier, and quantities (on hand, available, on hold, picked, pending, incoming, inbound, in stock). Without product_codes and product_skus, alternate SKUs are separate rows (is_alternate_sku true) and products are returned under the primary code. page_number starts at 0. page_size is 1000 to 10000. Use this to look up a SKU or to see what changed since modified_after.",
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "product_skus": {
+ "type": "array",
+ "description": "Only these SKUs. Leave out, together with product_codes, to page through the catalog. Example: [\"WIDGET-1\"].",
+ "items": { "type": "string" }
+ },
+ "product_codes": {
+ "type": "array",
+ "description": "Only these product codes. Alternate codes must be listed here or the product is returned under its primary code. Example: [\"CODE-1\"].",
+ "items": { "type": "string" }
+ },
+ "modified_after": {
+ "type": "string",
+ "description": "Only products modified after this UTC time, for example 2026-01-15T00:00:00Z. Omit for no lower bound."
+ },
+ "modified_before": {
+ "type": "string",
+ "description": "Only products modified before this UTC time, for example 2026-02-01T00:00:00Z. Omit for no upper bound."
+ },
+ "page_number": {
+ "type": "integer",
+ "minimum": 0,
+ "default": 0,
+ "description": "Page to return. The first page is 0."
+ },
+ "page_size": {
+ "type": "integer",
+ "minimum": 1000,
+ "maximum": 10000,
+ "default": 1000,
+ "description": "Products per page, from 1000 to 10000. Default 1000, which is the smallest page SkuVault accepts."
+ }
+ }
+ },
+ "endpointMapping": {
+ "method": "POST",
+ "path": "/products/getProducts",
+ "bodyMapping": {
+ "TenantToken": "$loginToken",
+ "UserToken": "$loginAud",
+ "ProductSKUs": "$product_skus",
+ "ProductCodes": "$product_codes",
+ "ModifiedAfterDateTimeUtc": "$modified_after",
+ "ModifiedBeforeDateTimeUtc": "$modified_before",
+ "PageNumber": "$page_number",
+ "PageSize": "$page_size"
+ }
+ },
+ "responseMapping": {
+ "transform": {
+ "mode": "select",
+ "maxBytes": 1200000,
+ "select": {
+ "errors": "Errors",
+ "products": {
+ "$from": "$.Products",
+ "$select": {
+ "id": "Id",
+ "code": "Code",
+ "sku": "Sku",
+ "primary_sku": "PrimarySku",
+ "part_number": "PartNumber",
+ "description": "Description",
+ "cost": "Cost",
+ "retail_price": "RetailPrice",
+ "sale_price": "SalePrice",
+ "brand": "Brand",
+ "supplier": "Supplier",
+ "classification": "Classification",
+ "quantity_on_hand": "QuantityOnHand",
+ "quantity_available": "QuantityAvailable",
+ "quantity_on_hold": "QuantityOnHold",
+ "quantity_picked": "QuantityPicked",
+ "quantity_pending": "QuantityPending",
+ "quantity_incoming": "QuantityIncoming",
+ "quantity_inbound": "QuantityInbound",
+ "quantity_in_stock": "QuantityInStock",
+ "created_at": "CreatedDateUtc",
+ "modified_at": "ModifiedDateUtc",
+ "variation_parent_sku": "VariationParentSku",
+ "is_alternate_sku": "IsAlternateSKU",
+ "is_alternate_code": "IsAlternateCode",
+ "statuses": "Statuses"
+ }
+ }
+ }
+ }
+ },
+ "annotations": { "readOnlyHint": true }
+ },
+ {
+ "name": "skuvault_get_inventory_by_location",
+ "description": "Stock of SkuVault products by warehouse location. Returns items, a map whose key is the SKU (or the product code when is_return_by_codes is true) and whose value is the locations holding it: location code, warehouse code, quantity, and reserve (true when that location is held back from sale). Filter by SKU with is_return_by_codes false, or by product code with it true. page_number starts at 0 and page_size is 1000 to 10000. Use after skuvault_get_warehouses when you need the bin, not just the total quantity.",
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "product_skus": {
+ "type": "array",
+ "description": "Only these SKUs. Requires is_return_by_codes false. Example: [\"WIDGET-1\"].",
+ "items": { "type": "string" }
+ },
+ "product_codes": {
+ "type": "array",
+ "description": "Only these product codes. Requires is_return_by_codes true. Example: [\"CODE-1\"].",
+ "items": { "type": "string" }
+ },
+ "is_return_by_codes": {
+ "type": "boolean",
+ "default": false,
+ "description": "false (default): keys of items are SKUs. true: keys are product codes. Match this to the filter you send."
+ },
+ "page_number": {
+ "type": "integer",
+ "minimum": 0,
+ "default": 0,
+ "description": "Page to return. The first page is 0. SkuVault returns up to page_size products per page."
+ },
+ "page_size": {
+ "type": "integer",
+ "minimum": 1000,
+ "maximum": 10000,
+ "default": 1000,
+ "description": "Products per page, from 1000 to 10000. Default 1000."
+ }
+ }
+ },
+ "endpointMapping": {
+ "method": "POST",
+ "path": "/inventory/getInventoryByLocation",
+ "bodyMapping": {
+ "TenantToken": "$loginToken",
+ "UserToken": "$loginAud",
+ "ProductSKUs": "$product_skus",
+ "ProductCodes": "$product_codes",
+ "IsReturnByCodes": "$is_return_by_codes",
+ "PageNumber": "$page_number",
+ "PageSize": "$page_size"
+ }
+ },
+ "responseMapping": {
+ "transform": {
+ "mode": "select",
+ "maxBytes": 1200000,
+ "select": {
+ "errors": "Errors",
+ "items": "Items"
+ }
+ }
+ },
+ "annotations": { "readOnlyHint": true }
+ },
+ {
+ "name": "skuvault_get_warehouses",
+ "description": "List the regular SkuVault warehouses as id and code. No filter other than page_number, which starts at 0. Call this first to check the sign-in and to learn the warehouse codes used by skuvault_get_inventory_by_location. Limited to 1 call per minute.",
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "page_number": {
+ "type": "integer",
+ "minimum": 0,
+ "default": 0,
+ "description": "Page to return. The first page is 0."
+ }
+ }
+ },
+ "endpointMapping": {
+ "method": "POST",
+ "path": "/inventory/getWarehouses",
+ "bodyMapping": {
+ "TenantToken": "$loginToken",
+ "UserToken": "$loginAud",
+ "PageNumber": "$page_number"
+ }
+ },
+ "responseMapping": {
+ "transform": {
+ "mode": "select",
+ "maxBytes": 200000,
+ "select": {
+ "warehouses": {
+ "$from": "$.Warehouses",
+ "$select": {
+ "id": "Id",
+ "code": "Code"
+ }
+ }
+ }
+ }
+ },
+ "annotations": { "readOnlyHint": true }
+ },
+ {
+ "name": "skuvault_get_sales",
+ "description": "List SkuVault sales, up to 10000 per call, with id, seller sale id, marketplace, status, sale date, line items (SKU, quantity, unit price, tax), kits, shipping cost and charge, ship-to city, region, country and postal code, contact name and company, carrier, class, notes, charges, and promotions. status is ReadyToShip (default) or Pending. order_ids returns those orders and ignores status; an API order id matches only API sales, while the full SkuVault id matches any channel. Money amounts are objects {a, s}. Street address, phone, and email are omitted. The published request has no page parameter.",
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "status": {
+ "type": "string",
+ "enum": ["ReadyToShip", "Pending"],
+ "default": "ReadyToShip",
+ "description": "Which sales to list when order_ids is omitted. ReadyToShip (default) or Pending."
+ },
+ "order_ids": {
+ "type": "array",
+ "maxItems": 10000,
+ "description": "Only these order ids, up to 10000. When set, SkuVault ignores status. Example: [\"10001\"].",
+ "items": { "type": "string" }
+ }
+ }
+ },
+ "endpointMapping": {
+ "method": "POST",
+ "path": "/sales/getSales",
+ "bodyMapping": {
+ "TenantToken": "$loginToken",
+ "UserToken": "$loginAud",
+ "Status": "$status",
+ "OrderIds": "$order_ids"
+ }
+ },
+ "responseMapping": {
+ "transform": {
+ "mode": "select",
+ "maxBytes": 1200000,
+ "select": {
+ "sales": {
+ "$from": "$.Sales",
+ "$select": {
+ "id": "Id",
+ "seller_sale_id": "SellerSaleId",
+ "marketplace_id": "MarketplaceId",
+ "channel_id": "ChannelId",
+ "status": "Status",
+ "sale_date": "SaleDate",
+ "marketplace": "Marketplace",
+ "shipping_carrier": "ShippingCarrier",
+ "shipping_class": "ShippingClass",
+ "shipping_cost": "ShippingCost",
+ "shipping_charge": "ShippingCharge",
+ "notes": "Notes",
+ "printed_status": "PrintedStatus",
+ "charges": "Charges",
+ "promotions": "Promotions",
+ "shipping": {
+ "city": "ShippingInfo.City",
+ "region": "ShippingInfo.Region",
+ "country": "ShippingInfo.Country",
+ "postal_code": "ShippingInfo.PostalCode"
+ },
+ "contact": {
+ "first_name": "ContactInfo.FirstName",
+ "last_name": "ContactInfo.LastName",
+ "company": "ContactInfo.Company"
+ },
+ "items": {
+ "$from": "SaleItems",
+ "$select": {
+ "sku": "Sku",
+ "quantity": "Quantity",
+ "unit_price": "UnitPrice",
+ "taxes": "Taxes"
+ }
+ },
+ "kits": {
+ "$from": "SaleKits",
+ "$select": {
+ "sku": "Sku",
+ "quantity": "Quantity",
+ "unit_price": "UnitPrice"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "annotations": { "readOnlyHint": true }
+ }
+ ]
+}
diff --git a/packages/backend/src/adapters/intl/skuvault.live.spec.ts b/packages/backend/src/adapters/intl/skuvault.live.spec.ts
new file mode 100644
index 000000000..168e34682
--- /dev/null
+++ b/packages/backend/src/adapters/intl/skuvault.live.spec.ts
@@ -0,0 +1,447 @@
+import axios from 'axios';
+import { existsSync } from 'fs';
+import { join } from 'path';
+import { ConfigService } from '@nestjs/config';
+import * as adapter from './skuvault.json';
+import { RestEngine } from '../../connectors/engines/rest.engine';
+import { OAuth2TokenService } from '../../connectors/engines/oauth2-token.service';
+import { LoginTokenService } from '../../connectors/engines/login-token.service';
+import { deriveToolAnnotations } from '../../mcp-server/tool-annotations';
+import { applySchemaDefaults } from '../../common/schema-defaults.util';
+import { interpolateDeep } from '../../common/env-interpolation.util';
+import { applyResponseTransform } from '../../connectors/response-transform.util';
+import { assertNoResponseBodyError } from '../../connectors/engines/response-error.util';
+import { describeAdapterEnvVars } from '../env-var-meta';
+import { getAdapter, listAdapters } from '../catalog';
+
+/**
+ * SkuVault (Linnworks) read-only adapter.
+ *
+ * Static checks always run. They pin the login at
+ * POST https://app.skuvault.com/api/gettokens (Email + Password, TenantToken
+ * and UserToken) and the four read calls against the published reference
+ * (https://dev.skuvault.com/reference/):
+ * POST /products/getProducts
+ * POST /inventory/getInventoryByLocation
+ * POST /inventory/getWarehouses
+ * POST /sales/getSales
+ * Both tokens are sent in the JSON body. Calls run through the real
+ * RestEngine and LoginTokenService with axios mocked.
+ *
+ * Live checks run only with RUN_SKUVAULT_LIVE=1. Without SKUVAULT_EMAIL and
+ * SKUVAULT_PASSWORD they confirm gettokens still answers HTTP 200 with both
+ * tokens null for a bad login, which is what the public API did on
+ * 2026-11-23. With both variables set they sign in and read warehouses
+ * (one call; that endpoint allows 1 request per minute):
+ *
+ * RUN_SKUVAULT_LIVE=1 SKUVAULT_EMAIL=... SKUVAULT_PASSWORD=... \
+ * npx jest src/adapters/intl/skuvault.live.spec.ts
+ */
+
+jest.mock('axios', () => {
+ const actual = jest.requireActual('axios');
+ const mocked = jest.fn();
+ return {
+ __esModule: true,
+ default: Object.assign(mocked, actual.default, { __actual: actual.default }),
+ AxiosError: actual.AxiosError,
+ AxiosHeaders: actual.AxiosHeaders,
+ };
+});
+const mockedAxios = axios as unknown as jest.Mock & { __actual: typeof axios };
+
+type Tool = {
+ name: string;
+ description: string;
+ parameters: {
+ properties?: Record;
+ required?: string[];
+ };
+ endpointMapping: {
+ method: string;
+ path: string;
+ bodyMapping?: Record;
+ };
+ responseMapping?: Record;
+ annotations?: Record;
+};
+
+const a = adapter as unknown as {
+ slug: string;
+ name: string;
+ description: string;
+ category: string;
+ icon: string;
+ instructions: string;
+ requiredEnvVars: string[];
+ envVarMeta: Record;
+ verifyHints: Record;
+ probe: { tool: string; params?: Record };
+ connector: {
+ baseUrl: string;
+ authType: string;
+ authConfig: Record;
+ headers: Record;
+ config?: { errorWhen?: unknown };
+ };
+ tools: Tool[];
+};
+
+const tool = (name: string) => {
+ const found = a.tools.find((entry) => entry.name === name);
+ if (!found) throw new Error(`missing tool ${name}`);
+ return found;
+};
+
+const annotationsOf = (entry: Tool) =>
+ deriveToolAnnotations({
+ name: entry.name,
+ connectorType: 'REST',
+ endpointMapping: entry.endpointMapping,
+ annotations: entry.annotations,
+ });
+
+const ENV = {
+ SKUVAULT_EMAIL: 'warehouse@example.com',
+ SKUVAULT_PASSWORD: 'warehouse-password',
+};
+const TENANT = 'tenant-token';
+const USER = 'user-token';
+const config = { get: () => 'test-encryption-key-32-chars-ok!' } as unknown as ConfigService;
+const fakeBundle = async () => ({ token: TENANT, aud: USER, expiresAt: Date.now() + 2_592_000_000 });
+const stubLogin = { getToken: fakeBundle, forceRelogin: fakeBundle } as unknown as LoginTokenService;
+
+const call = (name: string, params: Record) =>
+ new RestEngine({} as OAuth2TokenService, stubLogin).execute(
+ {
+ baseUrl: a.connector.baseUrl,
+ authType: a.connector.authType,
+ authConfig: interpolateDeep(a.connector.authConfig, ENV),
+ headers: a.connector.headers,
+ } as never,
+ tool(name).endpointMapping,
+ { ...applySchemaDefaults(tool(name).parameters as never, params), ...ENV },
+ ) as Promise<{ body: unknown }>;
+
+const sent = () => mockedAxios.mock.calls.at(-1)![0];
+
+describe('skuvault adapter: static contract', () => {
+ beforeEach(() => mockedAxios.mockReset());
+
+ it('signs in with email and password and sends both tokens in the body', () => {
+ expect(a.slug).toBe('skuvault');
+ expect(a.category).toBe('inventory');
+ expect(a.icon).toBe('skuvault');
+ expect(a.connector.baseUrl).toBe('https://app.skuvault.com/api');
+ expect(a.connector.authType).toBe('LOGIN_TOKEN');
+ expect(a.requiredEnvVars).toEqual(['SKUVAULT_EMAIL', 'SKUVAULT_PASSWORD']);
+ const auth = a.connector.authConfig;
+ expect(auth.loginUrl).toBe('https://app.skuvault.com/api/gettokens');
+ expect(auth.loginMethod).toBe('POST');
+ expect(auth.loginBody).toEqual({ Email: '${username}', Password: '${password}' });
+ expect(auth.username).toBe('{{SKUVAULT_EMAIL}}');
+ expect(auth.password).toBe('{{SKUVAULT_PASSWORD}}');
+ expect(auth.tokenJsonPath).toBe('TenantToken');
+ expect(auth.audJsonPath).toBe('UserToken');
+ expect(auth.tokenPlacement).toBe('body');
+ expect(auth.tokenTTLSeconds).toBe(2592000);
+ expect(auth.refreshOn401).toBe(true);
+ expect(auth.headerName).toBeUndefined();
+ expect(auth.headerTemplate).toBeUndefined();
+ const described = describeAdapterEnvVars(a as never);
+ expect(described.map((entry) => entry.name)).toEqual(a.requiredEnvVars);
+ expect(described.find((entry) => entry.name === 'SKUVAULT_PASSWORD')).toMatchObject({
+ kind: 'credential',
+ secret: true,
+ required: true,
+ });
+ expect(existsSync(join(__dirname, '../../../../frontend/public/logos/connectors/skuvault.svg'))).toBe(true);
+ });
+
+ it('accepts an email and refuses a blank or a URL', () => {
+ const email = new RegExp(a.envVarMeta.SKUVAULT_EMAIL.pattern!);
+ expect(email.test('warehouse@example.com')).toBe(true);
+ for (const bad of ['', 'warehouse', 'warehouse@', 'not an email', 'https://app.skuvault.com']) {
+ expect(email.test(bad)).toBe(false);
+ }
+ });
+
+ it('reads TenantToken and UserToken, and treats null tokens as a refused login', async () => {
+ const auth = interpolateDeep(a.connector.authConfig, ENV) as never;
+ mockedAxios.mockResolvedValueOnce({
+ data: { TenantToken: TENANT, UserToken: USER },
+ headers: {},
+ });
+ const bundle = await new LoginTokenService({} as never, config).getToken(auth);
+ const login = sent();
+ expect(login.method).toBe('POST');
+ expect(login.url).toBe('https://app.skuvault.com/api/gettokens');
+ expect(login.data).toEqual({ Email: ENV.SKUVAULT_EMAIL, Password: ENV.SKUVAULT_PASSWORD });
+ expect(bundle.token).toBe(TENANT);
+ expect(bundle.aud).toBe(USER);
+ expect(bundle.expiresAt - Date.now()).toBeGreaterThan(2_500_000_000);
+ expect(bundle.expiresAt - Date.now()).toBeLessThanOrEqual(2_592_000_000);
+
+ mockedAxios.mockResolvedValueOnce({
+ data: { TenantToken: null, UserToken: null },
+ headers: {},
+ });
+ await expect(new LoginTokenService({} as never, config).getToken(auth, 'other-connector')).rejects.toThrow(
+ /the token at "TenantToken" was null/,
+ );
+ });
+
+ it('probes warehouses and explains 401, 404, 400, and throttling', () => {
+ expect(a.probe).toEqual({ tool: 'skuvault_get_warehouses', params: { page_number: 0 } });
+ expect(tool('skuvault_get_warehouses').parameters.required ?? []).toEqual([]);
+ for (const status of ['400', '401', '404', 'rate_limited']) expect(a.verifyHints[status]).toBeTruthy();
+ });
+
+ it('keeps the four read tools on the documented paths and sends no writes', () => {
+ expect(a.tools.map((entry) => entry.name)).toEqual([
+ 'skuvault_get_products',
+ 'skuvault_get_inventory_by_location',
+ 'skuvault_get_warehouses',
+ 'skuvault_get_sales',
+ ]);
+ expect(tool('skuvault_get_products').endpointMapping).toMatchObject({
+ method: 'POST',
+ path: '/products/getProducts',
+ });
+ expect(tool('skuvault_get_inventory_by_location').endpointMapping.path).toBe(
+ '/inventory/getInventoryByLocation',
+ );
+ expect(tool('skuvault_get_warehouses').endpointMapping.path).toBe('/inventory/getWarehouses');
+ expect(tool('skuvault_get_sales').endpointMapping.path).toBe('/sales/getSales');
+ for (const entry of a.tools) {
+ expect(entry.endpointMapping.method).toBe('POST');
+ expect(entry.endpointMapping.bodyMapping).toMatchObject({
+ TenantToken: '$loginToken',
+ UserToken: '$loginAud',
+ });
+ expect(annotationsOf(entry).readOnlyHint).toBe(true);
+ expect(annotationsOf(entry).destructiveHint).toBe(false);
+ expect(entry.description.length).toBeGreaterThanOrEqual(60);
+ for (const property of Object.values(entry.parameters.properties ?? {})) {
+ expect(property.description).toBeTruthy();
+ }
+ }
+ });
+
+ it('prefixes every tool with skuvault_ and shares no tool name', () => {
+ const mine = new Set(a.tools.map((entry) => entry.name));
+ expect(mine.size).toBe(a.tools.length);
+ for (const name of mine) expect(name).toMatch(/^skuvault_[a-z_]+$/);
+ for (const meta of listAdapters()) {
+ if (meta.slug === a.slug) continue;
+ for (const other of getAdapter(meta.slug)!.tools) expect(mine.has(other.name)).toBe(false);
+ }
+ });
+
+ it('names every tool in the instructions and writes no em dash', () => {
+ for (const entry of a.tools) expect(a.instructions).toContain(entry.name);
+ expect(a.instructions).not.toMatch(/—/);
+ expect(a.instructions.length).toBeGreaterThanOrEqual(800);
+ expect(a.description.length).toBeGreaterThan(40);
+ });
+
+ it('posts products, locations, warehouses, and sales with the tokens and the defaults', async () => {
+ mockedAxios.mockResolvedValue({ data: {}, headers: {} });
+ await call('skuvault_get_warehouses', {});
+ expect(sent().url).toBe('https://app.skuvault.com/api/inventory/getWarehouses');
+ expect(sent().data).toEqual({ TenantToken: TENANT, UserToken: USER, PageNumber: 0 });
+ expect(sent().headers.Authorization).toBeUndefined();
+
+ await call('skuvault_get_products', { product_skus: ['WIDGET-1'], modified_after: '2026-01-15T00:00:00Z' });
+ expect(sent().url).toBe('https://app.skuvault.com/api/products/getProducts');
+ expect(sent().data).toEqual({
+ TenantToken: TENANT,
+ UserToken: USER,
+ ProductSKUs: ['WIDGET-1'],
+ ModifiedAfterDateTimeUtc: '2026-01-15T00:00:00Z',
+ PageNumber: 0,
+ PageSize: 1000,
+ });
+ expect(sent().data.ProductCodes).toBeUndefined();
+
+ await call('skuvault_get_inventory_by_location', { product_codes: ['CODE-1'], is_return_by_codes: true });
+ expect(sent().data).toEqual({
+ TenantToken: TENANT,
+ UserToken: USER,
+ ProductCodes: ['CODE-1'],
+ IsReturnByCodes: true,
+ PageNumber: 0,
+ PageSize: 1000,
+ });
+
+ await call('skuvault_get_sales', { order_ids: ['10001'] });
+ expect(sent().url).toBe('https://app.skuvault.com/api/sales/getSales');
+ expect(sent().data).toEqual({
+ TenantToken: TENANT,
+ UserToken: USER,
+ Status: 'ReadyToShip',
+ OrderIds: ['10001'],
+ });
+ });
+
+ it('keeps the useful product, location, warehouse, and sale fields and drops the rest', () => {
+ const products = applyResponseTransform(
+ {
+ Products: [
+ {
+ Id: 'p1',
+ Code: 'CODE-1',
+ Sku: 'WIDGET-1',
+ PrimarySku: 'WIDGET-1',
+ Description: 'A widget',
+ LongDescription: '
a very long page
',
+ Cost: 2.5,
+ RetailPrice: 9,
+ SalePrice: 8,
+ Brand: 'Acme',
+ Supplier: 'Mill',
+ QuantityOnHand: 4,
+ QuantityAvailable: 3,
+ IsAlternateSKU: false,
+ Pictures: ['https://example.test/a.jpg'],
+ Attributes: [{ Name: 'Color', Value: 'Red' }],
+ },
+ ],
+ Errors: [],
+ },
+ tool('skuvault_get_products').responseMapping,
+ ).value as { products: Array> };
+ expect(products.products[0]).toMatchObject({
+ id: 'p1',
+ code: 'CODE-1',
+ sku: 'WIDGET-1',
+ description: 'A widget',
+ quantity_available: 3,
+ is_alternate_sku: false,
+ });
+ expect(products.products[0].LongDescription).toBeUndefined();
+ expect(JSON.stringify(products)).not.toContain('very long page');
+ expect(JSON.stringify(products)).not.toContain('example.test');
+
+ const locations = applyResponseTransform(
+ {
+ Errors: [],
+ Items: { 'WIDGET-1': [{ LocationCode: 'A-1', Quantity: 3, Reserve: false, WarehouseCode: 'MAIN' }] },
+ },
+ tool('skuvault_get_inventory_by_location').responseMapping,
+ ).value;
+ expect(locations).toEqual({
+ errors: [],
+ items: { 'WIDGET-1': [{ LocationCode: 'A-1', Quantity: 3, Reserve: false, WarehouseCode: 'MAIN' }] },
+ });
+
+ const warehouses = applyResponseTransform(
+ { Warehouses: [{ Id: '9', Code: 'MAIN', Name: 'Main floor' }] },
+ tool('skuvault_get_warehouses').responseMapping,
+ ).value;
+ expect(warehouses).toEqual({ warehouses: [{ id: '9', code: 'MAIN' }] });
+
+ const sales = applyResponseTransform(
+ {
+ Sales: [
+ {
+ Id: 'sale-1',
+ SellerSaleId: '10001',
+ Status: 'ReadyToShip',
+ Marketplace: 'Shopify',
+ SaleDate: '2026-02-01T00:00:00Z',
+ ShippingCost: { a: 4.5, s: '$' },
+ ShippingInfo: {
+ City: 'Austin',
+ Region: 'TX',
+ Country: 'US',
+ PostalCode: '78701',
+ Address1: '1 Secret St',
+ Address2: 'Apt 2',
+ },
+ ContactInfo: {
+ FirstName: 'Ada',
+ LastName: 'Lovelace',
+ Company: 'Analytical',
+ Phone: '555-0100',
+ Email: 'ada@example.com',
+ },
+ SaleItems: [{ Sku: 'WIDGET-1', Quantity: 2, UnitPrice: { a: 8, s: '$' }, Taxes: 0.6 }],
+ SaleKits: [],
+ Notes: 'leave at dock',
+ },
+ ],
+ },
+ tool('skuvault_get_sales').responseMapping,
+ ).value as { sales: Array> };
+ expect(sales.sales[0]).toMatchObject({
+ id: 'sale-1',
+ seller_sale_id: '10001',
+ status: 'ReadyToShip',
+ marketplace: 'Shopify',
+ shipping_cost: { a: 4.5, s: '$' },
+ shipping: { city: 'Austin', region: 'TX', country: 'US', postal_code: '78701' },
+ contact: { first_name: 'Ada', last_name: 'Lovelace', company: 'Analytical' },
+ items: [{ sku: 'WIDGET-1', quantity: 2, unit_price: { a: 8, s: '$' }, taxes: 0.6 }],
+ notes: 'leave at dock',
+ });
+ const saleText = JSON.stringify(sales);
+ expect(saleText).not.toContain('Secret St');
+ expect(saleText).not.toContain('555-0100');
+ expect(saleText).not.toContain('ada@example.com');
+ });
+
+ it('fails a 200 whose Errors list is not empty, and lets an empty list through', () => {
+ expect(() =>
+ assertNoResponseBodyError({ Errors: ['SKU not found'], Products: [] }, a.connector.config?.errorWhen),
+ ).toThrow(/SKU not found/);
+ expect(() =>
+ assertNoResponseBodyError({ Errors: [], Products: [] }, a.connector.config?.errorWhen),
+ ).not.toThrow();
+ });
+});
+
+const live = process.env.RUN_SKUVAULT_LIVE === '1' ? describe : describe.skip;
+
+live('skuvault adapter: live', () => {
+ const email = process.env.SKUVAULT_EMAIL;
+ const password = process.env.SKUVAULT_PASSWORD;
+
+ it('refuses a bad login, or reads warehouses when credentials are set', async () => {
+ const realAxios = mockedAxios.__actual;
+ if (!email || !password) {
+ const response = await realAxios({
+ method: 'POST',
+ url: 'https://app.skuvault.com/api/gettokens',
+ data: { Email: 'not-a-user@example.com', Password: 'not-the-password' },
+ headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
+ timeout: 20000,
+ validateStatus: () => true,
+ });
+ expect(response.status).toBe(200);
+ expect(response.data).toEqual({ TenantToken: null, UserToken: null });
+ return;
+ }
+
+ mockedAxios.mockImplementation((request: unknown) => realAxios(request as never));
+ const auth = interpolateDeep(a.connector.authConfig, {
+ SKUVAULT_EMAIL: email,
+ SKUVAULT_PASSWORD: password,
+ });
+ const login = new LoginTokenService({} as never, config);
+ const bundle = await login.getToken(auth as never);
+ expect(bundle.token).toEqual(expect.any(String));
+ expect(bundle.aud).toEqual(expect.any(String));
+ const out = (await new RestEngine({} as OAuth2TokenService, login).execute(
+ {
+ baseUrl: a.connector.baseUrl,
+ authType: 'LOGIN_TOKEN',
+ authConfig: auth,
+ headers: a.connector.headers,
+ } as never,
+ tool('skuvault_get_warehouses').endpointMapping,
+ { page_number: 0 },
+ )) as { body: { Warehouses?: unknown } };
+ expect(Array.isArray(out.body?.Warehouses)).toBe(true);
+ });
+});
diff --git a/packages/backend/src/connectors/engines/login-token.service.spec.ts b/packages/backend/src/connectors/engines/login-token.service.spec.ts
index 1a8f14344..048873fc0 100644
--- a/packages/backend/src/connectors/engines/login-token.service.spec.ts
+++ b/packages/backend/src/connectors/engines/login-token.service.spec.ts
@@ -22,7 +22,7 @@ import {
import { generateKeyPairSync, verify } from 'crypto';
import { injectLoginTokenHeaders } from './rest.engine';
import signavio from '../../adapters/intl/sap-signavio.json';
-import { encrypt } from '../../common/crypto/encryption.util';
+import { encrypt, decrypt } from '../../common/crypto/encryption.util';
jest.mock('axios');
const mockedAxios = axios as jest.Mocked;
@@ -191,6 +191,104 @@ describe('LoginTokenService', () => {
expect(mockedAxios as unknown as jest.Mock).not.toHaveBeenCalled();
});
+ describe('audSecret: the second login value is a credential', () => {
+ const USER_TOKEN = 'user-token-SECRET-123';
+ const secretAuth: LoginTokenAuthConfig = {
+ loginUrl: 'https://app.skuvault.example/api/gettokens',
+ username: 'warehouse@example.com',
+ password: 'plain-password',
+ loginBody: { Email: '${username}', Password: '${password}' },
+ tokenJsonPath: 'TenantToken',
+ audJsonPath: 'UserToken',
+ tokenTTLSeconds: 30 * 24 * 60 * 60,
+ tokenPlacement: 'body',
+ audSecret: true,
+ };
+ const answerLogin = () =>
+ (mockedAxios as unknown as jest.Mock).mockResolvedValue({
+ data: { TenantToken: 'tenant-token-1', UserToken: USER_TOKEN },
+ });
+ const storedRow = () => mockPrisma.connectorAuthCache.upsert.mock.calls[0][0];
+
+ it('stores the aud encrypted: no plain UserToken in the cached row', async () => {
+ answerLogin();
+ const bundle = await service.getToken(secretAuth, 'conn-secret-1');
+ expect(bundle.aud).toBe(USER_TOKEN);
+
+ const { create, update } = storedRow();
+ for (const row of [create, update]) {
+ expect(JSON.stringify(row)).not.toContain(USER_TOKEN);
+ expect(row.metadata.aud).toBeUndefined();
+ expect(typeof row.metadata.audEnc).toBe('string');
+ expect(decrypt(row.metadata.audEnc, encryptionKey)).toBe(USER_TOKEN);
+ }
+ });
+
+ it('gives the right aud back from a cached row (round trip)', async () => {
+ answerLogin();
+ await service.getToken(secretAuth, 'conn-secret-2');
+ const { create } = storedRow();
+ mockPrisma.connectorAuthCache.findUnique.mockResolvedValue({
+ token: create.token,
+ metadata: create.metadata,
+ expiresAt: create.expiresAt,
+ });
+ (mockedAxios as unknown as jest.Mock).mockClear();
+
+ // A new service has a cold memory cache, so the row is what answers.
+ const cold = new LoginTokenService(mockPrisma, mockConfig);
+ const bundle = await cold.getToken(secretAuth, 'conn-secret-2');
+ expect(bundle.token).toBe('tenant-token-1');
+ expect(bundle.aud).toBe(USER_TOKEN);
+ expect(bundle.metadata).toBeUndefined();
+ expect(mockedAxios as unknown as jest.Mock).not.toHaveBeenCalled();
+ });
+
+ it('does not rewrite the aud in plain text when a cached secret bundle is stored again', async () => {
+ answerLogin();
+ await service.getToken(secretAuth, 'conn-secret-3');
+ mockPrisma.connectorAuthCache.upsert.mockClear();
+ await service.forceRelogin(secretAuth, 'conn-secret-3');
+ const { create } = storedRow();
+ expect(JSON.stringify(create)).not.toContain(USER_TOKEN);
+ });
+
+ it('still reads an older row that holds a plain aud', async () => {
+ mockPrisma.connectorAuthCache.findUnique.mockResolvedValue({
+ token: encrypt('tenant-token-old', encryptionKey),
+ metadata: { aud: USER_TOKEN },
+ expiresAt: new Date(Date.now() + 10 * 24 * 60 * 60 * 1000),
+ });
+ const bundle = await service.getToken(secretAuth, 'conn-secret-4');
+ expect(bundle.token).toBe('tenant-token-old');
+ expect(bundle.aud).toBe(USER_TOKEN);
+ });
+
+ it('keeps the plain aud row for an adapter without the flag', async () => {
+ answerLogin();
+ await service.getToken({ ...secretAuth, audSecret: undefined }, 'conn-secret-5');
+ const { create } = storedRow();
+ expect(create.metadata).toEqual({ aud: USER_TOKEN });
+ });
+
+ it('keeps the aud out of the logs, including a failed persist', async () => {
+ const logged: string[] = [];
+ for (const level of ['log', 'debug', 'warn', 'error', 'verbose'] as const) {
+ jest
+ .spyOn(Logger.prototype, level)
+ .mockImplementation((...args: unknown[]) => void logged.push(args.map(String).join(' ')));
+ }
+ answerLogin();
+ mockPrisma.connectorAuthCache.upsert.mockRejectedValue(new Error('database is down'));
+ const bundle = await service.getToken(secretAuth, 'conn-secret-6');
+ expect(bundle.aud).toBe(USER_TOKEN);
+ expect(logged.some((line) => /failed to persist token/.test(line))).toBe(true);
+ expect(logged.join('\n')).not.toContain(USER_TOKEN);
+ expect(logged.join('\n')).not.toContain('tenant-token-1');
+ jest.restoreAllMocks();
+ });
+ });
+
it('forceRelogin bypasses cache and re-issues token', async () => {
const salt = bcrypt.genSaltSync(4);
let loginCount = 0;
@@ -397,6 +495,13 @@ describe('LoginTokenService', () => {
expect(bundle.token).toBe('bare-jwt');
});
+ it('reports a null token field as a refused login', async () => {
+ answer({ TenantToken: null, UserToken: null });
+ await expect(
+ service.getToken({ ...listAuth, tokenJsonPath: 'TenantToken', audJsonPath: 'UserToken' }, 'conn-null'),
+ ).rejects.toThrow(/refused the login — the token at "TenantToken" was null/);
+ });
+
it('names every path when none holds a token', async () => {
answer({ ok: true });
await expect(
diff --git a/packages/backend/src/connectors/engines/login-token.service.ts b/packages/backend/src/connectors/engines/login-token.service.ts
index be8fdf6a3..fe2090897 100644
--- a/packages/backend/src/connectors/engines/login-token.service.ts
+++ b/packages/backend/src/connectors/engines/login-token.service.ts
@@ -166,6 +166,15 @@ export interface LoginTokenAuthConfig {
tokenJsonPath?: string | string[];
expiryJsonPath?: string;
audJsonPath?: string;
+ /**
+ * The second login value (`aud` / `audJsonPath`) is half of a credential
+ * pair, not a public audience: SkuVault's UserToken. With `true` it is
+ * encrypted with ENCRYPTION_KEY, like the token, before it is cached in the
+ * database (`connectorAuthCache.metadata.audEnc`) and decrypted when the
+ * row is read; it is never logged. Default false: `aud` stays a plain
+ * value in the cache row. A row written without the flag still reads.
+ */
+ audSecret?: boolean;
expiryFormat?: 'iso8601' | 'unix' | 'ttl_seconds';
tokenTTLSeconds?: number;
@@ -214,6 +223,8 @@ export interface LoginTokenAuthConfig {
export interface LoginTokenBundle {
token: string;
aud?: string;
+ // True when `aud` must not be stored in plain text (authConfig.audSecret).
+ audSecret?: boolean;
expiresAt: number; // epoch ms
// When the login that issued the token happened (epoch ms). Together with
// expiresAt it gives the token's lifetime, which bounds the early-refresh
@@ -557,19 +568,11 @@ export class LoginTokenService {
const paths = tokenJsonPaths(authConfig.tokenJsonPath);
token = readTokenAt(response.data, paths);
if (!token) {
- // Far and away the commonest reason the token is missing is that the
- // login itself was refused — wrong password, 2FA, a locked account.
- // The endpoint answers 200 and puts the reason in the body, so saying
- // "token not found at data.signIn.jwtToken.token" describes our own
- // JSON path and hides the vendor's explanation. Sorare accounted for
- // thirteen failures reported that way.
- const refusal =
- extractLoginRefusal(response.data) ??
- (authConfig.loginResponseFormat === 'xml' ? extractXmlLoginRefusal(response.data) : null);
+ // No token means the login is rejected. missingTokenMessage only
+ // chooses the sentence. A field in the body cannot skip the throw
+ // or decide which lookup runs.
throw new Error(
- refusal
- ? `LOGIN_TOKEN: the service refused the login — ${refusal}`
- : tokenNotFoundMessage(paths, response.data),
+ missingTokenMessage(response.data, paths, authConfig.loginResponseFormat === 'xml'),
);
}
}
@@ -587,7 +590,9 @@ export class LoginTokenService {
aud: aud || undefined,
expiresAt,
obtainedAt,
- metadata: aud ? { aud } : undefined,
+ // A secret aud is written by persist() in encrypted form only.
+ audSecret: authConfig.audSecret === true ? true : undefined,
+ metadata: aud && authConfig.audSecret !== true ? { aud } : undefined,
};
const key = this.cacheKey(authConfig, connectorId);
@@ -710,14 +715,22 @@ export class LoginTokenService {
where: { connectorId },
});
if (!row) return null;
+ // `audEnc` is the encrypted second value of an authConfig.audSecret
+ // login; a plain `aud` is an older row, or an adapter without the flag.
+ const { audEnc, ...rest } = (row.metadata as Record | null) ?? {};
+ const aud =
+ typeof audEnc === 'string'
+ ? decrypt(audEnc, this.encryptionKey)
+ : (rest as { aud?: string }).aud;
return {
token: decrypt(row.token, this.encryptionKey),
expiresAt: row.expiresAt.getTime(),
// persist() writes the row right after the login, so updatedAt is
// when the token was issued.
obtainedAt: row.updatedAt?.getTime(),
- aud: (row.metadata as { aud?: string } | null)?.aud,
- metadata: (row.metadata as Record | null) || undefined,
+ aud,
+ audSecret: typeof audEnc === 'string' ? true : undefined,
+ metadata: Object.keys(rest).length > 0 ? rest : undefined,
};
} catch (err: any) {
this.logger.warn(
@@ -733,7 +746,15 @@ export class LoginTokenService {
): Promise {
try {
const encrypted = encrypt(bundle.token, this.encryptionKey);
- const metadata = bundle.metadata || (bundle.aud ? { aud: bundle.aud } : null);
+ // A secret aud never goes to the database in plain text, neither as
+ // `aud` nor inside bundle.metadata.
+ const { aud: _plainAud, ...otherMetadata } = bundle.metadata ?? {};
+ const metadata = bundle.audSecret
+ ? {
+ ...otherMetadata,
+ ...(bundle.aud ? { audEnc: encrypt(bundle.aud, this.encryptionKey) } : {}),
+ }
+ : bundle.metadata || (bundle.aud ? { aud: bundle.aud } : null);
await this.prisma.connectorAuthCache.upsert({
where: { connectorId },
update: {
@@ -903,6 +924,47 @@ export function readTokenAt(body: unknown, paths: string[]): string | undefined
return undefined;
}
+/**
+ * The error text when a login answer contained no token.
+ *
+ * Far and away the commonest reason is that the login was refused (wrong
+ * password, 2FA, a locked account) and the endpoint still answered 200.
+ * Naming only our JSON path hides the vendor's explanation. Sorare
+ * accounted for thirteen failures reported that way. SkuVault instead
+ * answers 200 with the token field set to null.
+ *
+ * The lookups always run. Their results are read afterwards, in order, and
+ * never decide whether the login is rejected.
+ */
+function missingTokenMessage(body: unknown, paths: string[], xml: boolean): string {
+ const fromJson = extractLoginRefusal(body);
+ const fromXml = extractXmlLoginRefusal(body);
+ const fromNull = nullTokenRefusal(body, paths);
+ const refusal = firstNonEmpty(fromJson, xml ? fromXml : null, fromNull);
+ if (refusal) return `LOGIN_TOKEN: the service refused the login — ${refusal}`;
+ return tokenNotFoundMessage(paths, body);
+}
+
+function firstNonEmpty(...parts: Array): string | null {
+ for (const part of parts) {
+ if (part) return part;
+ }
+ return null;
+}
+
+/**
+ * SkuVault's getTokens, and APIs like it, answer HTTP 200 with the token
+ * field set to null when the login is refused. That is a refusal, not a
+ * path we guessed wrong.
+ */
+function nullTokenRefusal(body: unknown, paths: string[]): string | null {
+ for (const path of paths) {
+ if (isWholeBodyPath(path)) continue;
+ if (jsonPath(body, path) === null) return `the token at "${path}" was null`;
+ }
+ return null;
+}
+
/** Why no token was found, naming the paths (the whole body in words). */
function tokenNotFoundMessage(paths: string[], body: unknown): string {
if (paths.length === 1 && isWholeBodyPath(paths[0])) {
diff --git a/packages/backend/src/connectors/engines/rest.engine.login-token-body.http.spec.ts b/packages/backend/src/connectors/engines/rest.engine.login-token-body.http.spec.ts
index dfe326ba3..ee3be6d9c 100644
--- a/packages/backend/src/connectors/engines/rest.engine.login-token-body.http.spec.ts
+++ b/packages/backend/src/connectors/engines/rest.engine.login-token-body.http.spec.ts
@@ -220,3 +220,58 @@ describe('LOGIN_TOKEN over HTTP: XML login, token in the body, re-login on an ex
}
});
});
+
+describe('LOGIN_TOKEN bodyMapping is not followed to another origin', () => {
+ // The token is in the body for every encoding, so a 307 to another origin
+ // must be refused. The first hop still carries the engine's token, not a
+ // value the caller passed as loginToken.
+ const endpoints = [
+ { name: 'JSON', mapping: { method: 'POST', path: '/q', bodyMapping: { token: '$loginToken', aud: '$loginAud', sku: '$sku' } } },
+ { name: 'form-urlencoded', mapping: { method: 'POST', path: '/q', bodyEncoding: 'form-urlencoded', bodyMapping: { token: '$loginToken', aud: '$loginAud', sku: '$sku' } } },
+ { name: 'form-data', mapping: { method: 'POST', path: '/q', bodyEncoding: 'form-data', bodyMapping: { token: '$loginToken', aud: '$loginAud', sku: '$sku' } } },
+ { name: '__raw', mapping: { method: 'POST', path: '/q', bodyMapping: { __raw: 'token=${loginToken}&aud=${loginAud}&sku=${sku}' } } },
+ ];
+
+ for (const { name, mapping } of endpoints) {
+ it(`does not resend a ${name} bodyMapping that carries $loginToken after a cross-origin 307`, async () => {
+ const seen: string[] = [];
+ let elsewhereHits = 0;
+ const elsewhere = await listen((_req, res) => {
+ elsewhereHits += 1;
+ res.end('nope');
+ });
+ const redirecting = await listen((_req, res, body) => {
+ seen.push(body);
+ res.statusCode = 307;
+ res.setHeader('Location', `${elsewhere.url}/q`);
+ res.end();
+ });
+ try {
+ const login = {
+ getToken: async () => ({ token: 'old-token', aud: 'old-aud', expiresAt: Date.now() + 600_000 }),
+ forceRelogin: async () => ({ token: 'new-token', aud: 'new-aud', expiresAt: Date.now() + 600_000 }),
+ } as unknown as LoginTokenService;
+ await expect(
+ new RestEngine({} as OAuth2TokenService, login).execute(
+ {
+ baseUrl: redirecting.url,
+ authType: 'LOGIN_TOKEN',
+ authConfig: { loginUrl: `${redirecting.url}/auth`, tokenJsonPath: 'token', tokenPlacement: 'body' },
+ connectorId: 'conn-redirect',
+ },
+ mapping,
+ { sku: 'A', loginToken: 'spoofed-token', loginAud: 'spoofed-aud' },
+ ),
+ ).rejects.toThrow(/its body carries credentials and is not sent to another origin/);
+ expect(seen).toHaveLength(1);
+ expect(seen[0]).toContain('old-token');
+ expect(seen[0]).toContain('old-aud');
+ expect(seen[0]).not.toContain('spoofed');
+ expect(elsewhereHits).toBe(0);
+ } finally {
+ await close(redirecting.server);
+ await close(elsewhere.server);
+ }
+ });
+ }
+});
diff --git a/packages/backend/src/connectors/engines/rest.engine.login-token-body.spec.ts b/packages/backend/src/connectors/engines/rest.engine.login-token-body.spec.ts
index 80c91382e..14eb3b8d0 100644
--- a/packages/backend/src/connectors/engines/rest.engine.login-token-body.spec.ts
+++ b/packages/backend/src/connectors/engines/rest.engine.login-token-body.spec.ts
@@ -1,4 +1,5 @@
import axios, { AxiosError } from 'axios';
+import FormData from 'form-data';
import { ConfigService } from '@nestjs/config';
import { RestEngine, bodyReports401, renderXmlBodyTemplate } from './rest.engine';
import { OAuth2TokenService } from './oauth2-token.service';
@@ -126,6 +127,102 @@ describe('RestEngine: LOGIN_TOKEN with the token in the request body', () => {
expect(headerNames(sentAt(0))).not.toContain('authorization');
});
+ it('puts ${loginAud} in a JSON bodyTemplate and ignores a caller-supplied value', async () => {
+ const login = loginStub(['tenant-1', 'tenant-2']);
+ mockedAxios.mockResolvedValueOnce({ status: 200, data: { ok: true }, headers: {} });
+ await new RestEngine({} as OAuth2TokenService, login).execute(
+ { baseUrl: BASE, authType: 'LOGIN_TOKEN', authConfig: authConfig({ audJsonPath: 'UserToken' }) },
+ {
+ method: 'POST',
+ path: '/q',
+ bodyTemplate: '{"TenantToken":"${loginToken}","UserToken":"${loginAud}","PageNumber":${page}}',
+ },
+ { page: 0, loginToken: 'spoofed', loginAud: 'also-spoofed' },
+ );
+ expect(sentAt(0).data).toEqual({ TenantToken: 'tenant-1', UserToken: 'S1', PageNumber: 0 });
+ expect(headerNames(sentAt(0))).not.toContain('authorization');
+ });
+
+ it('puts $loginToken and $loginAud in a JSON bodyMapping and drops omitted fields', async () => {
+ const login = {
+ getToken: jest.fn().mockResolvedValue({ token: 'tenant-1', aud: 'user-1', expiresAt: Date.now() + 600_000 }),
+ forceRelogin: jest.fn().mockResolvedValue({ token: 'tenant-2', aud: 'user-2', expiresAt: Date.now() + 600_000 }),
+ };
+ mockedAxios
+ .mockRejectedValueOnce(httpError(401, { Warehouses: [] }, { 'content-type': 'application/json' }))
+ .mockResolvedValueOnce({ status: 200, data: { Warehouses: [] }, headers: {} });
+ await new RestEngine({} as OAuth2TokenService, login as unknown as LoginTokenService).execute(
+ {
+ baseUrl: BASE,
+ authType: 'LOGIN_TOKEN',
+ authConfig: authConfig({ refreshOn401: true }),
+ connectorId: 'conn-1',
+ },
+ {
+ method: 'POST',
+ path: '/inventory/getWarehouses',
+ bodyMapping: {
+ TenantToken: '$loginToken',
+ UserToken: '$loginAud',
+ PageNumber: '$page_number',
+ ProductCodes: '$product_codes',
+ },
+ },
+ { page_number: 0, loginToken: 'spoofed', loginAud: 'spoofed' },
+ );
+ expect(sentAt(0).data).toEqual({ TenantToken: 'tenant-1', UserToken: 'user-1', PageNumber: 0 });
+ expect(sentAt(0).data.ProductCodes).toBeUndefined();
+ expect(login.forceRelogin).toHaveBeenCalledTimes(1);
+ expect(sentAt(1).data).toEqual({ TenantToken: 'tenant-2', UserToken: 'user-2', PageNumber: 0 });
+ });
+
+ // JSON sets renderTokenBody already. __raw, form-urlencoded and form-data
+ // must do the same: the retry after a re-login carries the new token, not
+ // the one from the refused call. A caller-supplied loginToken is ignored.
+ const bodyText = (data: unknown): string => {
+ if (data instanceof FormData) return data.getBuffer().toString('utf8');
+ return typeof data === 'string' ? data : JSON.stringify(data);
+ };
+ const carried = [
+ ['JSON', { method: 'POST', path: '/q', bodyMapping: { token: '$loginToken', aud: '$loginAud', sku: '$sku' } }],
+ ['form-urlencoded', { method: 'POST', path: '/q', bodyEncoding: 'form-urlencoded', bodyMapping: { token: '$loginToken', aud: '$loginAud', sku: '$sku' } }],
+ ['form-data', { method: 'POST', path: '/q', bodyEncoding: 'form-data', bodyMapping: { token: '$loginToken', aud: '$loginAud', sku: '$sku' } }],
+ ['__raw', { method: 'POST', path: '/q', bodyMapping: { __raw: 'token=${loginToken}&aud=${loginAud}&sku=${sku}' } }],
+ ] as const;
+ for (const [encoding, endpoint] of carried) {
+ it(`retries a ${encoding} bodyMapping that carries $loginToken with the new token`, async () => {
+ const login = {
+ getToken: jest.fn().mockResolvedValue({ token: 'old-token', aud: 'old-aud', expiresAt: Date.now() + 600_000 }),
+ forceRelogin: jest.fn().mockResolvedValue({ token: 'new-token', aud: 'new-aud', expiresAt: Date.now() + 600_000 }),
+ };
+ mockedAxios
+ .mockRejectedValueOnce(httpError(401, { error: 'expired' }, { 'content-type': 'application/json' }))
+ .mockResolvedValueOnce({ status: 200, data: { ok: true }, headers: {} });
+ await new RestEngine({} as OAuth2TokenService, login as unknown as LoginTokenService).execute(
+ {
+ baseUrl: BASE,
+ authType: 'LOGIN_TOKEN',
+ authConfig: authConfig({ refreshOn401: true }),
+ connectorId: 'conn-1',
+ },
+ endpoint,
+ { sku: 'A', loginToken: 'spoofed-token', loginAud: 'spoofed-aud' },
+ );
+ const first = bodyText(sentAt(0).data);
+ const second = bodyText(sentAt(1).data);
+ expect(first).toContain('old-token');
+ expect(first).toContain('old-aud');
+ expect(first).not.toContain('spoofed');
+ expect(second).toContain('new-token');
+ expect(second).toContain('new-aud');
+ expect(second).not.toContain('old-token');
+ expect(second).toContain('sku');
+ expect(login.forceRelogin).toHaveBeenCalledTimes(1);
+ expect(headerNames(sentAt(0))).not.toContain('authorization');
+ expect(headerNames(sentAt(1))).not.toContain('authorization');
+ });
+ }
+
it('without tokenPlacement the token goes in the header and ${loginToken} is an ordinary, missing parameter', async () => {
mockedAxios.mockResolvedValueOnce({ status: 200, data: offers, headers: XML });
await new RestEngine({} as OAuth2TokenService, loginStub()).execute(
diff --git a/packages/backend/src/connectors/engines/rest.engine.ts b/packages/backend/src/connectors/engines/rest.engine.ts
index ae6f9a286..97e1488fa 100644
--- a/packages/backend/src/connectors/engines/rest.engine.ts
+++ b/packages/backend/src/connectors/engines/rest.engine.ts
@@ -440,10 +440,12 @@ export class RestEngine {
? loginTokenHeaderCollision(axiosConfig.headers, config.authConfig as unknown as LoginTokenAuthConfig)
: undefined;
// Set only for LOGIN_TOKEN with `tokenPlacement: "body"`: the token is
- // then `${loginToken}` in the tool's bodyTemplate instead of a header.
- const loginBodyToken = await this.injectAuth(axiosConfig, config);
+ // then `${loginToken}` in the tool's bodyTemplate (or `$loginToken` in
+ // bodyMapping) instead of a header. `aud` is `${loginAud}` / `$loginAud`,
+ // for a login that returns a second value the later calls also send.
+ const loginBodyAuth = await this.injectAuth(axiosConfig, config);
// Renders the body again with a new token, for the retry after a re-login.
- let renderTokenBody: ((token: string) => unknown) | undefined;
+ let renderTokenBody: ((token: string, aud?: string) => unknown) | undefined;
// Headers that carry the connector's credentials stay behind when a
// redirect leaves the origin: whatever auth added, plus the connector's
// own headers and templated ones, which often hold a key.
@@ -500,11 +502,12 @@ export class RestEngine {
if (REQUEST_BODY_METHODS.has(httpMethod)) {
if (endpointMapping.bodyTemplate && xmlBody) {
const template = endpointMapping.bodyTemplate;
- if (loginBodyToken === undefined) {
+ if (loginBodyAuth === undefined) {
axiosConfig.data = renderXmlBodyTemplate(template, params);
} else {
- renderTokenBody = (token) => renderXmlBodyTemplate(template, params, { loginToken: token });
- axiosConfig.data = renderTokenBody(loginBodyToken);
+ renderTokenBody = (token, aud) =>
+ renderXmlBodyTemplate(template, params, { loginToken: token, loginAud: aud ?? '' });
+ axiosConfig.data = renderTokenBody(loginBodyAuth.token, loginBodyAuth.aud);
}
} else if (endpointMapping.bodyTemplate) {
const template = endpointMapping.bodyTemplate;
@@ -532,11 +535,12 @@ export class RestEngine {
assertNoPrototypePollution(parsed);
return parsed;
};
- if (loginBodyToken === undefined) {
+ if (loginBodyAuth === undefined) {
axiosConfig.data = renderJson(params);
} else {
- renderTokenBody = (token) => renderJson({ ...params, loginToken: token });
- axiosConfig.data = renderTokenBody(loginBodyToken);
+ renderTokenBody = (token, aud) =>
+ renderJson({ ...params, loginToken: token, loginAud: aud ?? '' });
+ axiosConfig.data = renderTokenBody(loginBodyAuth.token, loginBodyAuth.aud);
}
} else if (endpointMapping.bodyMapping) {
let bodyMapping = endpointMapping.bodyMapping;
@@ -550,16 +554,31 @@ export class RestEngine {
bodyMapping = expanded.template;
bodyParams = { ...params, ...expanded.values };
}
+ // `$loginToken` / `$loginAud` in a bodyMapping. The engine's values
+ // win over anything the caller passed under those names. Every
+ // encoding (JSON, __raw, form-urlencoded, form-data) rebuilds the
+ // body with them after a re-login, and that body is marked as
+ // carrying credentials so a cross-origin redirect is refused.
+ const paramsBeforeToken = bodyParams;
+ const withLoginToken = (token: string, aud?: string): Record => ({
+ ...paramsBeforeToken,
+ loginToken: token,
+ loginAud: aud ?? '',
+ });
+ if (loginBodyAuth) {
+ bodyParams = withLoginToken(loginBodyAuth.token, loginBodyAuth.aud);
+ }
// Handle __raw body mapping (non-JSON body, e.g. XML/SOAP)
if ('__raw' in bodyMapping) {
// Resolved on its own rather than through mapParams so an XML body
// can escape what `${param}` puts into it. A whole-value `$param`
// is the caller's own body and goes out as given.
- axiosConfig.data = this.resolveValue(
- bodyMapping['__raw'],
- bodyParams,
- xmlBody ? escapeXmlValue : undefined,
- );
+ const raw = bodyMapping['__raw'];
+ const escape = xmlBody ? escapeXmlValue : undefined;
+ axiosConfig.data = this.resolveValue(raw, bodyParams, escape);
+ if (loginBodyAuth) {
+ renderTokenBody = (token, aud) => this.resolveValue(raw, withLoginToken(token, aud), escape);
+ }
} else {
const mapped = this.mapParams(bodyMapping, bodyParams);
// `{ "__json": … }`: the field goes out as the JSON text of its
@@ -584,9 +603,9 @@ export class RestEngine {
);
}
- if (encoding === 'form-urlencoded') {
+ const encodeUrlForm = (mappedBody: Record): string => {
const urlParams = new URLSearchParams();
- for (const [k, v] of spreadFormEntries(mapped)) {
+ for (const [k, v] of spreadFormEntries(mappedBody)) {
if (isFileMarker(v)) {
throw new Error(
`bodyMapping.${k} uses the __file marker, but this tool's ` +
@@ -596,7 +615,18 @@ export class RestEngine {
}
appendFormParam((key, val) => urlParams.append(key, val), k, v);
}
- axiosConfig.data = urlParams.toString();
+ return urlParams.toString();
+ };
+ if (encoding === 'form-urlencoded') {
+ axiosConfig.data = encodeUrlForm(mapped);
+ if (loginBodyAuth) {
+ const mapping = bodyMapping;
+ renderTokenBody = (token, aud) => {
+ const remapped = this.mapParams(mapping, withLoginToken(token, aud));
+ stringifyJsonMarkers(remapped, mapping);
+ return encodeUrlForm(remapped);
+ };
+ }
// URLSearchParams percent-encodes UTF-8 bytes, but the charset of a
// form body is not implied by the media type: a server that assumes
// latin-1 reads "Bev%C3%B6lkerung" as mojibake and, in the Destatis
@@ -610,7 +640,7 @@ export class RestEngine {
};
}
} else if (encoding === 'form-data') {
- const plainEntries: Array<[string, unknown]> = [];
+ let plainEntries: Array<[string, unknown]> = [];
const fileEntries: Array<{ key: string; file: FetchedFile }> = [];
for (const [k, v] of spreadFormEntries(mapped)) {
if (isFileMarker(v)) {
@@ -665,6 +695,24 @@ export class RestEngine {
axiosConfig.data = form;
axiosConfig.headers = withFormDataHeaders(axiosConfig.headers, form);
buildBody = buildForm;
+ if (loginBodyAuth) {
+ const mapping = bodyMapping;
+ // The retry after a re-login calls this, then rebuildBody, which
+ // reads buildBody. Updating the entries the builder closes over
+ // is what puts the new token on that second stream. Files stay
+ // as fetched on the first build.
+ renderTokenBody = (token, aud) => {
+ const remapped = this.mapParams(mapping, withLoginToken(token, aud));
+ stringifyJsonMarkers(remapped, mapping);
+ const nextPlain: Array<[string, unknown]> = [];
+ for (const [k, v] of spreadFormEntries(remapped)) {
+ if (isFileMarker(v)) continue;
+ nextPlain.push([k, v]);
+ }
+ plainEntries = nextPlain;
+ return buildForm();
+ };
+ }
} else if (encoding === 'binary') {
// `bodyEncoding: 'binary'`: the body is the bytes of one file and
// nothing else, for APIs that take neither multipart nor JSON
@@ -698,6 +746,14 @@ export class RestEngine {
);
} else {
axiosConfig.data = mapped;
+ if (loginBodyAuth) {
+ const mapping = bodyMapping;
+ renderTokenBody = (token, aud) => {
+ const remapped = this.mapParams(mapping, withLoginToken(token, aud));
+ stringifyJsonMarkers(remapped, mapping);
+ return remapped;
+ };
+ }
}
}
}
@@ -851,7 +907,7 @@ export class RestEngine {
{ proxyUrl: config.proxyUrl, connectorHeaders: Object.keys(config.headers ?? {}) },
);
injectLoginTokenHeaders(axiosConfig, authConfig, bundle.token, bundle.aud);
- if (renderTokenBody) axiosConfig.data = renderTokenBody(bundle.token);
+ if (renderTokenBody) axiosConfig.data = renderTokenBody(bundle.token, bundle.aud);
rebuildBody(axiosConfig, buildBody);
const retryResponse = await outboundRequest(axiosConfig, outbound);
return withMeta(retryResponse);
@@ -1218,7 +1274,7 @@ export class RestEngine {
proxyUrl?: string;
headers?: Record;
},
- ): Promise {
+ ): Promise<{ token: string; aud?: string } | undefined> {
if (!config.authConfig) return undefined;
switch (config.authType) {
@@ -1310,8 +1366,11 @@ export class RestEngine {
);
if (replaced) this.warnLoginHeaderCollision(config.connectorId, replaced);
// `tokenPlacement: "body"`: the caller renders the token into the
- // tool's bodyTemplate as `${loginToken}`.
- if (config.authConfig.tokenPlacement === 'body') return bundle.token;
+ // tool's body as `${loginToken}` / `$loginToken`, and `aud` as
+ // `${loginAud}` / `$loginAud`.
+ if (config.authConfig.tokenPlacement === 'body') {
+ return { token: bundle.token, aud: bundle.aud };
+ }
break;
}
case 'OAUTH1':
diff --git a/packages/frontend/public/logos/connectors/skuvault.svg b/packages/frontend/public/logos/connectors/skuvault.svg
new file mode 100644
index 000000000..c3073c2cf
--- /dev/null
+++ b/packages/frontend/public/logos/connectors/skuvault.svg
@@ -0,0 +1,5 @@
+
diff --git a/scripts/validate-adapters.mjs b/scripts/validate-adapters.mjs
index 361ff31dd..91d5312fd 100644
--- a/scripts/validate-adapters.mjs
+++ b/scripts/validate-adapters.mjs
@@ -154,18 +154,33 @@ export function loginBasicAuthProblems(connector) {
* engine would run without doing what the adapter meant.
*/
const LOGIN_TOKEN_PLACEHOLDER = '$' + '{loginToken}';
+const LOGIN_AUD_PLACEHOLDER = '$' + '{loginAud}';
+const LOGIN_TOKEN_MAPPING = '"$' + 'loginToken"';
+const LOGIN_AUD_MAPPING = '"$' + 'loginAud"';
+
+/** True when a tool body template or bodyMapping carries `needle`. */
+function bodyCarries(tools, needle) {
+ return tools.some((tool) => {
+ const mapping = tool?.endpointMapping;
+ const template = typeof mapping?.bodyTemplate === 'string' ? mapping.bodyTemplate : '';
+ const body = mapping?.bodyMapping === undefined ? '' : JSON.stringify(mapping.bodyMapping);
+ return template.includes(needle) || body.includes(needle);
+ });
+}
+
export function loginTokenXmlProblems(adapter) {
const connector = adapter?.connector;
const cfg = connector?.authConfig;
const tools = Array.isArray(adapter?.tools) ? adapter.tools : [];
- const templates = tools.map((t) => t?.endpointMapping?.bodyTemplate).filter((t) => typeof t === 'string');
- const usesLoginToken = templates.some((t) => t.includes(LOGIN_TOKEN_PLACEHOLDER));
+ const usesLoginToken = bodyCarries(tools, LOGIN_TOKEN_PLACEHOLDER) || bodyCarries(tools, LOGIN_TOKEN_MAPPING);
+ const usesLoginAud = bodyCarries(tools, LOGIN_AUD_PLACEHOLDER) || bodyCarries(tools, LOGIN_AUD_MAPPING);
const problems = [];
const fields = ['loginBodyFormat', 'loginResponseFormat', 'tokenPlacement', 'refreshOnBody401'];
const set = cfg && typeof cfg === 'object' ? fields.filter((f) => cfg[f] !== undefined) : [];
if (connector?.authType !== 'LOGIN_TOKEN') {
for (const f of set) problems.push(`${f} only applies to LOGIN_TOKEN authentication`);
if (usesLoginToken) problems.push(`${LOGIN_TOKEN_PLACEHOLDER} in a bodyTemplate needs LOGIN_TOKEN authentication with tokenPlacement: "body"`);
+ if (usesLoginAud) problems.push(`${LOGIN_AUD_PLACEHOLDER} in a body needs LOGIN_TOKEN authentication with tokenPlacement: "body"`);
return problems;
}
if (!cfg || typeof cfg !== 'object') return problems;
@@ -175,15 +190,27 @@ export function loginTokenXmlProblems(adapter) {
}
if (cfg.loginResponseFormat !== undefined && cfg.loginResponseFormat !== 'xml') problems.push('loginResponseFormat must be "xml"');
if (cfg.tokenPlacement !== undefined && !['header', 'body'].includes(cfg.tokenPlacement)) problems.push('tokenPlacement must be "header" or "body"');
+ if (cfg.audSecret !== undefined) {
+ if (typeof cfg.audSecret !== 'boolean') problems.push('audSecret must be true or false');
+ else if (cfg.audSecret && !(typeof cfg.audJsonPath === 'string' && cfg.audJsonPath.trim()) && !(typeof cfg.aud === 'string' && cfg.aud.trim())) {
+ problems.push('audSecret: true protects the second login value, so authConfig.audJsonPath or authConfig.aud must name it');
+ }
+ }
if (cfg.tokenPlacement === 'body') {
if (connector.type !== 'REST') problems.push('tokenPlacement: "body" is only supported by REST connectors');
- if (!usesLoginToken) problems.push(`tokenPlacement: "body" sends no token header, so at least one tool's bodyTemplate must contain ${LOGIN_TOKEN_PLACEHOLDER}`);
+ if (!usesLoginToken) problems.push(`tokenPlacement: "body" sends no token header, so at least one tool's bodyTemplate must contain ${LOGIN_TOKEN_PLACEHOLDER} (or its bodyMapping $loginToken)`);
+ if (usesLoginAud && !(typeof cfg.audJsonPath === 'string' && cfg.audJsonPath.trim()) && !(typeof cfg.aud === 'string' && cfg.aud.trim())) {
+ problems.push('a body that sends loginAud needs authConfig.audJsonPath or authConfig.aud, the second value from the login');
+ }
for (const f of ['headerName', 'headerTemplate']) {
if (cfg[f] !== undefined) problems.push(`${f} is not sent with tokenPlacement: "body"; remove it`);
}
} else if (usesLoginToken && (cfg.tokenPlacement === undefined || cfg.tokenPlacement === 'header')) {
problems.push(`${LOGIN_TOKEN_PLACEHOLDER} in a bodyTemplate renders empty without authConfig.tokenPlacement: "body"`);
}
+ if (usesLoginAud && cfg.tokenPlacement !== 'body') {
+ problems.push(`${LOGIN_AUD_PLACEHOLDER} in a body renders empty without authConfig.tokenPlacement: "body"`);
+ }
if (cfg.refreshOnBody401 !== undefined) {
if (typeof cfg.refreshOnBody401 !== 'boolean') problems.push('refreshOnBody401 must be true or false');
else if (cfg.refreshOnBody401) {
diff --git a/scripts/validate-adapters.test.mjs b/scripts/validate-adapters.test.mjs
index 46ec8c772..5ecaab17f 100644
--- a/scripts/validate-adapters.test.mjs
+++ b/scripts/validate-adapters.test.mjs
@@ -295,6 +295,34 @@ test('LOGIN_TOKEN for XML APIs: login formats, the token in the body and the re-
assert.equal(other.length, 5);
assert.ok(other.slice(0, 4).every((m) => /only applies to LOGIN_TOKEN authentication/.test(m)));
assert.match(other[4], /needs LOGIN_TOKEN authentication with tokenPlacement: "body"/);
+
+ const audTool = {
+ name: 'good_lookup',
+ description: 'x'.repeat(60),
+ parameters: { type: 'object', properties: {} },
+ endpointMapping: {
+ method: 'POST',
+ path: '/q',
+ bodyMapping: { TenantToken: '$loginToken', UserToken: '$loginAud', PageNumber: '$page_number' },
+ },
+ };
+ const audErrors = (authConfig) => check({
+ authConfig: { loginBodyFormat: undefined, loginResponseFormat: undefined, refreshOnBody401: undefined, loginBody: {}, ...authConfig },
+ tools: [audTool],
+ });
+ const audText = (authConfig) => audErrors(authConfig).map((entry) => entry.message).join('\n');
+ assert.deepEqual(audErrors({ tokenPlacement: 'body', audJsonPath: 'UserToken' }), []);
+ assert.match(audText({ tokenPlacement: 'body' }), /needs authConfig.audJsonPath or authConfig.aud/);
+ assert.match(audText({ tokenPlacement: 'header', headerName: 'X-Token' }), /loginAud/);
+
+ // audSecret keeps the second login value encrypted in the cache row.
+ assert.deepEqual(audErrors({ tokenPlacement: 'body', audJsonPath: 'UserToken', audSecret: true }), []);
+ assert.deepEqual(audErrors({ tokenPlacement: 'body', aud: 'static', audSecret: true }), []);
+ assert.match(audText({ tokenPlacement: 'body', audJsonPath: 'UserToken', audSecret: 'yes' }), /audSecret must be true or false/);
+ assert.match(
+ audText({ tokenPlacement: 'header', headerName: 'X-Token', audSecret: true }),
+ /audSecret: true protects the second login value/,
+ );
});
test('optional and repeated blocks in an XML bodyTemplate are named, closed and only in XML bodies', () => {
diff --git a/server.json b/server.json
index c40a6bbd7..91405e3f0 100644
--- a/server.json
+++ b/server.json
@@ -2,7 +2,7 @@
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
"name": "io.github.HelpCode-ai/anythingmcp",
"title": "AnythingMCP",
- "description": "MCP gateway and company brain: 976 connectors (SAP, ERP, SQL), file search, memory and skills.",
+ "description": "MCP gateway and company brain: 977 connectors (SAP, ERP, SQL), file search, memory and skills.",
"repository": {
"url": "https://github.com/HelpCode-ai/anythingmcp",
"source": "github"