@brainerce/mcp-server 3.9.0 → 3.11.1
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/dist/bin/http.js +322 -9
- package/dist/bin/stdio.js +322 -9
- package/dist/index.d.mts +0 -3
- package/dist/index.d.ts +0 -3
- package/dist/index.js +322 -9
- package/dist/index.mjs +322 -9
- package/package.json +53 -53
package/dist/bin/stdio.js
CHANGED
|
@@ -160,7 +160,26 @@ import {
|
|
|
160
160
|
getDescriptionContent, isHtmlDescription,
|
|
161
161
|
getProductMetafieldValue, getProductCustomizationFields,
|
|
162
162
|
} from 'brainerce';
|
|
163
|
-
|
|
163
|
+
\`\`\`
|
|
164
|
+
|
|
165
|
+
### Available features \u2014 request each topic for full docs
|
|
166
|
+
|
|
167
|
+
| Topic | What it covers |
|
|
168
|
+
|-------|----------------|
|
|
169
|
+
| \`products\` | Catalog listing, search, PDP, variants, swatches, stock, attributes |
|
|
170
|
+
| \`cart\` | Guest + logged-in cart, add/remove/update, reservations |
|
|
171
|
+
| \`checkout\` | Guest + customer checkout, shipping, address |
|
|
172
|
+
| \`payment\` | Payment providers, intents, status polling, confirmation |
|
|
173
|
+
| \`auth\` | Customer sign-up, login, OAuth, email verification |
|
|
174
|
+
| \`discounts\` | Coupons, banners, nudges |
|
|
175
|
+
| \`recommendations\` | Cross-sell / upsell grids |
|
|
176
|
+
| \`reviews\` | Product reviews & ratings |
|
|
177
|
+
| \`inventory\` | Stock badges, reservation countdown |
|
|
178
|
+
| \`inquiries\` | Contact / custom forms |
|
|
179
|
+
| \`i18n\` | Multi-language, RTL |
|
|
180
|
+
| \`admin\` | Server-to-server admin API (products, orders, customers) |
|
|
181
|
+
| \`storefront-bot\` | **AI chat widget** \u2014 add Brainerce's AI shopping assistant to any page with one script tag or \`BrainerceBot.mount()\`. Answers product questions, shows recommendation cards, handles cart adds, opens escalation form. |
|
|
182
|
+
| \`content\` | Blog, articles, static pages |`;
|
|
164
183
|
}
|
|
165
184
|
function getCheckoutFlowSection(_currency) {
|
|
166
185
|
return `## \u26A0\uFE0F CHECKOUT FLOW (CRITICAL \u2014 READ CAREFULLY!)
|
|
@@ -709,7 +728,7 @@ const growProvider = providers.find(p => p.provider === 'grow');
|
|
|
709
728
|
const paypalProvider = providers.find(p => p.provider === 'paypal');
|
|
710
729
|
\`\`\`
|
|
711
730
|
|
|
712
|
-
Each provider has: \`id\`, \`provider\` (flexible string \u2014 \`'stripe'\`, \`'grow'\`, \`'paypal'\`, \`'cardcom'\`, \`'sandbox'\`, and future providers), \`name\`, \`publicKey\`, \`stripeAccountId\` (Stripe only), \`supportedMethods\`, \`testMode\`, \`isDefault\`.
|
|
731
|
+
Each provider has: \`id\`, \`provider\` (flexible string \u2014 \`'stripe'\`, \`'grow'\`, \`'paypal'\`, \`'cardcom'\`, \`'morning'\`, \`'takbull'\`, \`'sandbox'\`, and future providers), \`name\`, \`publicKey\`, \`stripeAccountId\` (Stripe only), \`supportedMethods\`, \`testMode\`, \`isDefault\`.
|
|
713
732
|
|
|
714
733
|
The payment intent returned from \`createPaymentIntent()\` includes a \`clientSdk\` object whose \`renderType\` tells you exactly how to render \u2014 **branch on THAT, not on the provider name**:
|
|
715
734
|
|
|
@@ -1882,8 +1901,8 @@ function getTaxDisplaySection(_currency) {
|
|
|
1882
1901
|
| Product Page | \u274C No | "Price excludes tax" (optional note) |
|
|
1883
1902
|
| Cart Page | \u26A0\uFE0F "Calculated at checkout" | No address yet |
|
|
1884
1903
|
| Checkout (before address) | \u26A0\uFE0F "Enter address to calculate" | Waiting for location |
|
|
1885
|
-
| Checkout (after address) | \u2705 **REQUIRED** | \`checkout.taxAmount\` |
|
|
1886
|
-
| Order Confirmation | \u2705 **REQUIRED** | \`order.taxAmount\` |
|
|
1904
|
+
| Checkout (after address) | \u2705 **REQUIRED** | \`checkout.taxAmount\` (0 in VAT mode \u2192 \`checkout.taxBreakdown.totalTax\`) |
|
|
1905
|
+
| Order Confirmation | \u2705 **REQUIRED** | \`order.taxAmount\` (0 in VAT mode \u2192 \`order.taxBreakdown.totalTax\`) |
|
|
1887
1906
|
|
|
1888
1907
|
### Cart Page \u2014 Partial Display
|
|
1889
1908
|
|
|
@@ -1935,7 +1954,13 @@ const totals = getCartTotals(cart);
|
|
|
1935
1954
|
<div className="flex justify-between text-green-600"><span>Discount</span><span>-{formatPrice(order.discountAmount, { currency: order.currency })}</span></div>
|
|
1936
1955
|
)}
|
|
1937
1956
|
<div className="flex justify-between"><span>Shipping</span><span>{formatPrice(order.shippingAmount, { currency: order.currency })}</span></div>
|
|
1938
|
-
|
|
1957
|
+
{/* Inclusive (VAT) stores keep taxAmount="0" \u2014 the real VAT is on taxBreakdown.totalTax. */}
|
|
1958
|
+
{(() => {
|
|
1959
|
+
const tax = parseFloat(order.taxAmount || '0') || order.taxBreakdown?.totalTax || 0;
|
|
1960
|
+
if (tax <= 0) return null;
|
|
1961
|
+
const incl = order.taxBreakdown?.pricesIncludeTax;
|
|
1962
|
+
return <div className="flex justify-between"><span>{incl ? 'Tax (incl.)' : 'Tax'}</span><span>{formatPrice(tax, { currency: order.currency })}</span></div>;
|
|
1963
|
+
})()}
|
|
1939
1964
|
<div className="flex justify-between font-bold text-lg border-t pt-2"><span>Total Paid</span><span>{formatPrice(order.totalAmount, { currency: order.currency })}</span></div>
|
|
1940
1965
|
</div>
|
|
1941
1966
|
\`\`\``;
|
|
@@ -2064,7 +2089,7 @@ A useful order card includes ALL of the following when the data is present. Each
|
|
|
2064
2089
|
| **Tracking** | \`order.trackingNumber\`, \`order.trackingUrl\`, \`order.carrier\`, \`order.shippedAt\`, \`order.deliveredAt\` | Link out to \`trackingUrl\` when set. |
|
|
2065
2090
|
| **Payment** | \`order.paymentMethod\`, \`order.financialStatus\` | Badge \`financialStatus\` (paid / pending / refunded / partially_refunded). |
|
|
2066
2091
|
| Downloads | \`order.hasDownloads\` \u2192 \`client.getOrderDownloads(id)\` | Separate call; returns \`OrderDownloadLink[]\`. |
|
|
2067
|
-
| Financial summary | \`order.subtotal\`, \`order.appliedDiscounts\`, \`order.couponCode\` + \`couponDiscount\`, \`order.shippingAmount\`, \`order.taxAmount\`, \`order.totalAmount\` | Breakdown rows + final total. |
|
|
2092
|
+
| Financial summary | \`order.subtotal\`, \`order.appliedDiscounts\`, \`order.couponCode\` + \`couponDiscount\`, \`order.shippingAmount\`, \`order.taxAmount\`, \`order.totalAmount\` | Breakdown rows + final total. In VAT-inclusive mode \`taxAmount\` is 0 \u2014 read \`order.taxBreakdown.totalTax\` and label "Tax (incl.)". |
|
|
2068
2093
|
|
|
2069
2094
|
#### Rendering \`order.items[i].customizations\` by type
|
|
2070
2095
|
|
|
@@ -2368,6 +2393,67 @@ Read \`storeInfo.i18n.supportedLocales\` and render a switcher in the header
|
|
|
2368
2393
|
that navigates to \`/{otherLocale}/{currentPathWithoutLocale}\`. The middleware
|
|
2369
2394
|
handles the canonical redirect when the user picks the default locale.`;
|
|
2370
2395
|
}
|
|
2396
|
+
function getMultilingualSeoSection() {
|
|
2397
|
+
return `## Multilingual SEO
|
|
2398
|
+
|
|
2399
|
+
### Slugs per locale (IMPORTANT)
|
|
2400
|
+
|
|
2401
|
+
Brainerce stores per-locale slugs in \`Product.translations[locale].slug\`.
|
|
2402
|
+
The API exposes them as \`product.localeSlugs\` \u2014 a flat \`Record<string, string>\`.
|
|
2403
|
+
|
|
2404
|
+
\`\`\`typescript
|
|
2405
|
+
// product.localeSlugs = { he: '\u05DE\u05D6\u05E8\u05DF-\u05D9\u05D5\u05D2\u05D4', en: 'yoga-mattress', ar: '\u062D\u0635\u064A\u0631\u0629-\u064A\u0648\u063A\u0627' }
|
|
2406
|
+
const locSlug = product.localeSlugs?.[locale] ?? product.slug;
|
|
2407
|
+
\`\`\`
|
|
2408
|
+
|
|
2409
|
+
Use AI translation (\`translateEntities\` / the AI Translate button in the admin) to populate
|
|
2410
|
+
locale-specific slugs automatically. Until translated, all locales fall back to the base slug
|
|
2411
|
+
(which Google still accepts \u2014 it resolves to the correct locale content via Accept-Language).
|
|
2412
|
+
|
|
2413
|
+
### hreflang tags
|
|
2414
|
+
|
|
2415
|
+
Every product page in a multi-locale store MUST emit bidirectional hreflang tags or Google
|
|
2416
|
+
ignores them entirely. The scaffolded template generates them automatically when
|
|
2417
|
+
\`NEXT_PUBLIC_BRAINERCE_LOCALES=he,en\` is set.
|
|
2418
|
+
|
|
2419
|
+
\`\`\`html
|
|
2420
|
+
<!-- Example output for /en/products/yoga-mattress -->
|
|
2421
|
+
<link rel="alternate" hreflang="he" href="https://store.com/products/\u05DE\u05D6\u05E8\u05DF-\u05D9\u05D5\u05D2\u05D4" />
|
|
2422
|
+
<link rel="alternate" hreflang="en" href="https://store.com/en/products/yoga-mattress" />
|
|
2423
|
+
<link rel="alternate" hreflang="x-default" href="https://store.com/products/\u05DE\u05D6\u05E8\u05DF-\u05D9\u05D5\u05D2\u05D4" />
|
|
2424
|
+
\`\`\`
|
|
2425
|
+
|
|
2426
|
+
If building a custom storefront, add to \`generateMetadata()\`:
|
|
2427
|
+
\`\`\`typescript
|
|
2428
|
+
alternates: {
|
|
2429
|
+
canonical: locale === defaultLoc ? \`/products/\${slug}\` : \`/\${locale}/products/\${slug}\`,
|
|
2430
|
+
languages: {
|
|
2431
|
+
he: \`\${baseUrl}/products/\${localeSlugs.he ?? baseSlug}\`,
|
|
2432
|
+
en: \`\${baseUrl}/en/products/\${localeSlugs.en ?? baseSlug}\`,
|
|
2433
|
+
'x-default': \`\${baseUrl}/products/\${localeSlugs[defaultLoc] ?? baseSlug}\`,
|
|
2434
|
+
},
|
|
2435
|
+
},
|
|
2436
|
+
\`\`\`
|
|
2437
|
+
|
|
2438
|
+
### URL structure
|
|
2439
|
+
|
|
2440
|
+
Google-recommended for headless storefronts:
|
|
2441
|
+
- Default locale: \`/products/\u05DE\u05D6\u05E8\u05DF-\u05D9\u05D5\u05D2\u05D4\` (no prefix)
|
|
2442
|
+
- Other locales: \`/en/products/yoga-mattress\` (prefixed)
|
|
2443
|
+
- \u274C Never: \`?locale=he\` query params (Google rates these as "Not recommended")
|
|
2444
|
+
|
|
2445
|
+
### Sitemap
|
|
2446
|
+
|
|
2447
|
+
The scaffolded \`sitemap.ts\` generates per-locale entries automatically:
|
|
2448
|
+
\`\`\`
|
|
2449
|
+
/products/\u05DE\u05D6\u05E8\u05DF-\u05D9\u05D5\u05D2\u05D4 (he \u2014 default, no prefix)
|
|
2450
|
+
/en/products/yoga-mattress (en)
|
|
2451
|
+
/ar/products/\u062D\u0635\u064A\u0631\u0629-\u064A\u0648\u063A\u0627 (ar)
|
|
2452
|
+
\`\`\`
|
|
2453
|
+
|
|
2454
|
+
Hebrew, Arabic, and other non-Latin slugs are fully supported \u2014 Google recommends
|
|
2455
|
+
using the audience's language in URLs and indexes non-ASCII characters correctly.`;
|
|
2456
|
+
}
|
|
2371
2457
|
function getAdminApiSection() {
|
|
2372
2458
|
return `## Admin API (v0.19.0+)
|
|
2373
2459
|
|
|
@@ -2451,6 +2537,20 @@ await admin.mergeTaxClasses(food.id, standardClassId);
|
|
|
2451
2537
|
Storefront (public, no apiKey \u2014 \`storeId\` mode): \`getStoreTaxClasses()\` lists
|
|
2452
2538
|
the store's classes (storefront-safe fields only) for a transparency badge.
|
|
2453
2539
|
|
|
2540
|
+
For a buyer-facing tax preview on PDP / PLP / cart, \`estimateTax({ country,
|
|
2541
|
+
subtotal })\` returns the tax portion at the Standard rate for the buyer's
|
|
2542
|
+
country. **Non-binding** \u2014 the authoritative tax still runs at checkout with
|
|
2543
|
+
the full shipping address (state / postal / per-class). Always render with an
|
|
2544
|
+
"Estimate" affordance.
|
|
2545
|
+
|
|
2546
|
+
\`\`\`typescript
|
|
2547
|
+
const { estimatedTax, rate, currency, note } = await store.estimateTax({
|
|
2548
|
+
country: 'IT', subtotal: 100,
|
|
2549
|
+
});
|
|
2550
|
+
// \u2192 { appliesTax: true, rate: 22, estimatedTax: 22, currency: 'EUR',
|
|
2551
|
+
// note: 'Estimate \u2014 final tax calculated at checkout\u2026' }
|
|
2552
|
+
\`\`\`
|
|
2553
|
+
|
|
2454
2554
|
### Regions (multi-currency / per-region providers)
|
|
2455
2555
|
|
|
2456
2556
|
A region binds countries \u2192 currency + tax-display mode + enabled payment
|
|
@@ -2481,6 +2581,19 @@ const { data: regions } = await store.getStoreRegions();
|
|
|
2481
2581
|
const region = await store.getStoreRegion(regions[0].id);
|
|
2482
2582
|
\`\`\`
|
|
2483
2583
|
|
|
2584
|
+
For a single round trip, \`getAutoRegion(country)\` resolves a buyer's country
|
|
2585
|
+
to a region server-side. Brainerce does NOT derive the country from the request
|
|
2586
|
+
IP (the storefront server is what reaches the backend, not the end-customer) \u2014
|
|
2587
|
+
your storefront extracts the country from its edge runtime (Cloudflare
|
|
2588
|
+
\`CF-IPCountry\`, Vercel \`request.geo?.country\`, Fastly \`client-geo-country\`,
|
|
2589
|
+
etc.) and forwards it. Returns \`matched=true\` on explicit country hit, \`false\`
|
|
2590
|
+
when falling back to the default region.
|
|
2591
|
+
|
|
2592
|
+
\`\`\`typescript
|
|
2593
|
+
const country = headers.get('cf-ipcountry') ?? 'US';
|
|
2594
|
+
const { region, matched } = await store.getAutoRegion(country);
|
|
2595
|
+
\`\`\`
|
|
2596
|
+
|
|
2484
2597
|
A shipping zone can be limited to regions via \`regionIds\` \u2014 the zone is then
|
|
2485
2598
|
only offered to checkouts that resolved to one of those regions. Empty/omitted =
|
|
2486
2599
|
available for any region (default); each id must belong to the same store.
|
|
@@ -2944,6 +3057,146 @@ entries \u2014 pick a descriptive slug (\`'shipping'\`, \`'returns'\`, \`'about'
|
|
|
2944
3057
|
- \`get-type-definitions\` with \`domain: 'content'\` for the TypeScript
|
|
2945
3058
|
interfaces.`;
|
|
2946
3059
|
}
|
|
3060
|
+
function getBlogSection() {
|
|
3061
|
+
return `## Blog
|
|
3062
|
+
|
|
3063
|
+
Merchants write and schedule blog posts in **Content \u2192 Blog** in the dashboard.
|
|
3064
|
+
Storefronts choose their own URL scheme \u2014 render posts at \`/blog/[slug]\`,
|
|
3065
|
+
\`/articles/[slug]\`, or whatever fits the brand.
|
|
3066
|
+
|
|
3067
|
+
Public reads carry \`Cache-Control: public, max-age=300, stale-while-revalidate=60\`.
|
|
3068
|
+
|
|
3069
|
+
**Scheduling:** A post is visible once \`status === 'PUBLISHED'\` and
|
|
3070
|
+
\`publishedAt <= now()\`. Set a future \`publishedAt\` while publishing to
|
|
3071
|
+
schedule \u2014 no cron needed; visibility is computed at query time.
|
|
3072
|
+
|
|
3073
|
+
### Reading posts (any SDK mode)
|
|
3074
|
+
|
|
3075
|
+
\`\`\`typescript
|
|
3076
|
+
// List published posts
|
|
3077
|
+
const { data: posts, meta } = await client.blog.getPosts({ page: 1, limit: 10 });
|
|
3078
|
+
|
|
3079
|
+
// Filter by category or tag
|
|
3080
|
+
const { data: news } = await client.blog.getPosts({ category: 'news' });
|
|
3081
|
+
const { data: tips } = await client.blog.getPosts({ tag: 'tutorial' });
|
|
3082
|
+
|
|
3083
|
+
// Fetch one by slug (returns null on 404)
|
|
3084
|
+
const post = await client.blog.getPost('my-first-post');
|
|
3085
|
+
if (post) {
|
|
3086
|
+
console.log(post.title); // string
|
|
3087
|
+
console.log(post.content); // HTML string from rich-text editor
|
|
3088
|
+
console.log(post.excerpt); // optional short summary
|
|
3089
|
+
console.log(post.tags); // string[]
|
|
3090
|
+
console.log(post.coverImageUrl, post.coverImageAlt);
|
|
3091
|
+
console.log(post.publishedAt); // ISO 8601 or undefined
|
|
3092
|
+
}
|
|
3093
|
+
\`\`\`
|
|
3094
|
+
|
|
3095
|
+
### BlogPost fields
|
|
3096
|
+
|
|
3097
|
+
| Field | Type | Notes |
|
|
3098
|
+
| ----------------- | ----------- | ------------------------------------- |
|
|
3099
|
+
| \`id\` | string | |
|
|
3100
|
+
| \`title\` | string | |
|
|
3101
|
+
| \`slug\` | string | Unique per store, URL-safe |
|
|
3102
|
+
| \`category\` | string? | Free-form (e.g. \`'news'\`) |
|
|
3103
|
+
| \`content\` | string | HTML from rich-text editor |
|
|
3104
|
+
| \`excerpt\` | string? | Short summary for listing cards |
|
|
3105
|
+
| \`coverImageUrl\` | string? | |
|
|
3106
|
+
| \`coverImageAlt\` | string? | |
|
|
3107
|
+
| \`author\` | string? | |
|
|
3108
|
+
| \`tags\` | string[] | |
|
|
3109
|
+
| \`publishedAt\` | string? | ISO 8601; null = publish immediately |
|
|
3110
|
+
| \`seoTitle\` | string? | |
|
|
3111
|
+
| \`seoDescription\`| string? | |
|
|
3112
|
+
| \`ogImageUrl\` | string? | |
|
|
3113
|
+
|
|
3114
|
+
### Rendering blog content
|
|
3115
|
+
|
|
3116
|
+
\`\`\`tsx
|
|
3117
|
+
// app/blog/[slug]/page.tsx
|
|
3118
|
+
import DOMPurify from 'isomorphic-dompurify';
|
|
3119
|
+
|
|
3120
|
+
const post = await brainerce.blog.getPost(params.slug);
|
|
3121
|
+
if (!post) notFound();
|
|
3122
|
+
|
|
3123
|
+
// Always sanitize before rendering HTML \u2014 treat external-origin content as untrusted
|
|
3124
|
+
const safeHtml = DOMPurify.sanitize(post.content);
|
|
3125
|
+
return <div dangerouslySetInnerHTML={{ __html: safeHtml }} className="prose" />;
|
|
3126
|
+
\`\`\`
|
|
3127
|
+
|
|
3128
|
+
The \`content\` field is HTML produced by the Lexical rich-text editor.
|
|
3129
|
+
**Always sanitize with DOMPurify (or equivalent) before rendering via
|
|
3130
|
+
\`dangerouslySetInnerHTML\`** \u2014 even though the content originates from your
|
|
3131
|
+
own editor, defense-in-depth prevents any stored-XSS path if content is ever
|
|
3132
|
+
migrated or imported from an external source.
|
|
3133
|
+
Apply a \`prose\` class (Tailwind Typography) for automatic styling.
|
|
3134
|
+
|
|
3135
|
+
### REST endpoints
|
|
3136
|
+
|
|
3137
|
+
| Method | Path | Returns |
|
|
3138
|
+
|--------|------|---------|
|
|
3139
|
+
| GET | \`/api/stores/:storeId/blog/posts\` | \`BlogPostListResponse\` |
|
|
3140
|
+
| GET | \`/api/stores/:storeId/blog/posts/:slug\` | \`BlogPost\` or 404 |
|
|
3141
|
+
| GET | \`/api/vc/:connectionId/blog/posts\` | Same, channel-scoped |
|
|
3142
|
+
| GET | \`/api/vc/:connectionId/blog/posts/:slug\` | \`BlogPost\` or 404 |
|
|
3143
|
+
`;
|
|
3144
|
+
}
|
|
3145
|
+
function getStorefrontBotSection(connectionId) {
|
|
3146
|
+
return `## Storefront Bot (AI chat widget)
|
|
3147
|
+
|
|
3148
|
+
The store's AI shopping assistant. ALL configuration (name, avatar, colors,
|
|
3149
|
+
greeting, starter questions, capabilities, guardrails) lives in the merchant
|
|
3150
|
+
dashboard \u2014 the embed never decides behavior, and the widget renders nothing
|
|
3151
|
+
until the merchant switches the bot Live.
|
|
3152
|
+
|
|
3153
|
+
### Zero-code embed (any site)
|
|
3154
|
+
|
|
3155
|
+
\`\`\`html
|
|
3156
|
+
<script src="https://cdn.brainerce.com/bot.js" data-connection-id="${connectionId}" defer></script>
|
|
3157
|
+
\`\`\`
|
|
3158
|
+
|
|
3159
|
+
Keep the tag exactly this bare \u2014 do NOT add \`integrity\` or \`crossorigin\`
|
|
3160
|
+
(the bootstrap is intentionally mutable; it is origin-pinned by CSP instead).
|
|
3161
|
+
|
|
3162
|
+
### SDK mount (React / Next.js / any bundler)
|
|
3163
|
+
|
|
3164
|
+
\`\`\`ts
|
|
3165
|
+
import { BrainerceBot } from 'brainerce/bot';
|
|
3166
|
+
|
|
3167
|
+
// client-side only (e.g. in a useEffect) \u2014 mounts a floating chat bubble
|
|
3168
|
+
const bot = await BrainerceBot.mount({ connectionId: '${connectionId}' });
|
|
3169
|
+
bot?.destroy(); // optional teardown
|
|
3170
|
+
\`\`\`
|
|
3171
|
+
|
|
3172
|
+
\`mount\` resolves to \`null\` when the bot is disabled (FREE plan, switched
|
|
3173
|
+
off, or unconfigured) \u2014 safe to call unconditionally. Options: \`connectionId\`
|
|
3174
|
+
(required), \`baseUrl\` (API origin override), \`target\` (mount element),
|
|
3175
|
+
\`onAddToCart\` (\`({ productId, variantId, quantity }) => boolean | Promise<boolean>\`
|
|
3176
|
+
\u2014 route the widget's cart adds through the site's own cart; \`variantId\` is
|
|
3177
|
+
null for simple products; return false to fall back to the product page).
|
|
3178
|
+
|
|
3179
|
+
Behavior: persists an anonymous session in localStorage, restores the
|
|
3180
|
+
conversation on revisit, streams answers, and shows product recommendation
|
|
3181
|
+
cards (image, price, add-to-cart / view). Multi-variant products get an
|
|
3182
|
+
in-card variant picker; shoppers can also ask the assistant to add an item
|
|
3183
|
+
and it goes through the same cart chain. Zero-result searches feed the
|
|
3184
|
+
merchant's "unmet demand" analytics. Aside from shopper-initiated cart adds,
|
|
3185
|
+
the bot is read-only.
|
|
3186
|
+
|
|
3187
|
+
Add-to-cart resolution chain: \`onAddToCart\` option \u2192 cancelable
|
|
3188
|
+
\`brainerce:bot:add-to-cart\` CustomEvent on window
|
|
3189
|
+
(\`detail: { productId, variantId, quantity, connectionId }\`; call
|
|
3190
|
+
preventDefault() after handling) \u2192 navigate to the product page.
|
|
3191
|
+
|
|
3192
|
+
Rules:
|
|
3193
|
+
- Mount once per page; do not pass any visual config \u2014 the dashboard owns it.
|
|
3194
|
+
- Do not wrap or restyle the widget; it renders in its own Shadow DOM.
|
|
3195
|
+
- Product card links expect the conventional \`/products/<slug>\` route.
|
|
3196
|
+
- Wire \`onAddToCart\` to the site's cart (see the cart section) so the header
|
|
3197
|
+
count updates when the bot adds items.
|
|
3198
|
+
`;
|
|
3199
|
+
}
|
|
2947
3200
|
function getSectionByTopic(topic, connectionId, currency) {
|
|
2948
3201
|
const cid = connectionId || "vc_YOUR_CONNECTION_ID";
|
|
2949
3202
|
const cur = currency || "USD";
|
|
@@ -2982,6 +3235,10 @@ function getSectionByTopic(topic, connectionId, currency) {
|
|
|
2982
3235
|
return getTaxDisplaySection(cur);
|
|
2983
3236
|
case "i18n":
|
|
2984
3237
|
return getI18nSection();
|
|
3238
|
+
case "multilingual-seo":
|
|
3239
|
+
case "hreflang":
|
|
3240
|
+
case "seo-i18n":
|
|
3241
|
+
return getMultilingualSeoSection();
|
|
2985
3242
|
case "critical-rules":
|
|
2986
3243
|
return getCriticalRulesSection() + "\n\n" + getTypeQuickReference();
|
|
2987
3244
|
case "type-reference":
|
|
@@ -2992,6 +3249,10 @@ function getSectionByTopic(topic, connectionId, currency) {
|
|
|
2992
3249
|
return getContactInquiriesSection();
|
|
2993
3250
|
case "content":
|
|
2994
3251
|
return getContentSection();
|
|
3252
|
+
case "blog":
|
|
3253
|
+
return getBlogSection();
|
|
3254
|
+
case "storefront-bot":
|
|
3255
|
+
return getStorefrontBotSection(cid);
|
|
2995
3256
|
case "all":
|
|
2996
3257
|
return [
|
|
2997
3258
|
"# Brainerce SDK \u2014 full topic dump",
|
|
@@ -3076,6 +3337,10 @@ function getSectionByTopic(topic, connectionId, currency) {
|
|
|
3076
3337
|
"",
|
|
3077
3338
|
"---",
|
|
3078
3339
|
"",
|
|
3340
|
+
getMultilingualSeoSection(),
|
|
3341
|
+
"",
|
|
3342
|
+
"---",
|
|
3343
|
+
"",
|
|
3079
3344
|
getAdminApiSection(),
|
|
3080
3345
|
"",
|
|
3081
3346
|
"---",
|
|
@@ -3084,10 +3349,18 @@ function getSectionByTopic(topic, connectionId, currency) {
|
|
|
3084
3349
|
"",
|
|
3085
3350
|
"---",
|
|
3086
3351
|
"",
|
|
3087
|
-
getContentSection()
|
|
3352
|
+
getContentSection(),
|
|
3353
|
+
"",
|
|
3354
|
+
"---",
|
|
3355
|
+
"",
|
|
3356
|
+
getBlogSection(),
|
|
3357
|
+
"",
|
|
3358
|
+
"---",
|
|
3359
|
+
"",
|
|
3360
|
+
getStorefrontBotSection(cid)
|
|
3088
3361
|
].join("\n");
|
|
3089
3362
|
default:
|
|
3090
|
-
return `Unknown topic: "${topic}". Available topics: setup, products, cart, checkout, checkout-custom-fields, payment, auth, order-confirmation, inventory, discounts, recommendations, product-customization-fields, tax, i18n, critical-rules, type-reference, admin, inquiries, content, all`;
|
|
3363
|
+
return `Unknown topic: "${topic}". Available topics: setup, products, cart, checkout, checkout-custom-fields, payment, auth, order-confirmation, inventory, discounts, recommendations, product-customization-fields, tax, i18n, critical-rules, type-reference, admin, inquiries, content, blog, all`;
|
|
3091
3364
|
}
|
|
3092
3365
|
}
|
|
3093
3366
|
|
|
@@ -3116,6 +3389,7 @@ var GET_SDK_DOCS_SCHEMA = {
|
|
|
3116
3389
|
"admin",
|
|
3117
3390
|
"inquiries",
|
|
3118
3391
|
"content",
|
|
3392
|
+
"storefront-bot",
|
|
3119
3393
|
"all"
|
|
3120
3394
|
]).describe("The SDK documentation topic to retrieve"),
|
|
3121
3395
|
salesChannelId: import_zod.z.string().optional().describe("Sales channel ID (starts with vc_). Used to personalize setup code."),
|
|
@@ -3153,6 +3427,12 @@ interface Product {
|
|
|
3153
3427
|
priceMin?: string | null; // Lowest variant price (VARIABLE products) \u2014 same as basePrice for VARIABLE, kept for back-compat and JSON-LD range display.
|
|
3154
3428
|
priceMax?: string | null; // Highest variant price (VARIABLE products). Use with priceMin for "\u20AA49 \u2013 \u20AA199" range.
|
|
3155
3429
|
priceVaries?: boolean; // true when variant prices differ \u2014 show "\u20AA49 \u2013 \u20AA199" range.
|
|
3430
|
+
// FX DISPLAY overlay (PRD \xA723). Set only when getProducts({ regionId }) was called AND region.currency !== store.currency. basePrice/salePrice above stay in store currency \u2014 these are additive, display-only. The buyer is still charged in store currency at checkout; payment provider handles customer-side FX.
|
|
3431
|
+
displayPrice?: string; // basePrice \xD7 daily FX rate, in displayCurrency.
|
|
3432
|
+
displaySalePrice?: string; // salePrice \xD7 rate (if salePrice present).
|
|
3433
|
+
displayPriceMin?: string; // priceMin \xD7 rate (VARIABLE products).
|
|
3434
|
+
displayPriceMax?: string; // priceMax \xD7 rate (VARIABLE products).
|
|
3435
|
+
displayCurrency?: string; // ISO 4217 of the region \u2014 e.g. "EUR".
|
|
3156
3436
|
status: string;
|
|
3157
3437
|
type: 'SIMPLE' | 'VARIABLE';
|
|
3158
3438
|
isDownloadable?: boolean;
|
|
@@ -3196,6 +3476,10 @@ interface ProductVariant {
|
|
|
3196
3476
|
name?: string | null;
|
|
3197
3477
|
price?: string | null;
|
|
3198
3478
|
salePrice?: string | null;
|
|
3479
|
+
// FX DISPLAY overlay (PRD \xA723) \u2014 same semantics as on the parent Product.
|
|
3480
|
+
displayPrice?: string;
|
|
3481
|
+
displaySalePrice?: string;
|
|
3482
|
+
displayCurrency?: string;
|
|
3199
3483
|
attributes?: Record<string, string> | null;
|
|
3200
3484
|
options?: Array<{ name: string; value: string }>;
|
|
3201
3485
|
inventory?: InventoryInfo | null;
|
|
@@ -3508,6 +3792,8 @@ interface Order {
|
|
|
3508
3792
|
totalAmount: string; // ALWAYS use this, not .total
|
|
3509
3793
|
total?: string; // optional alias
|
|
3510
3794
|
currency?: string;
|
|
3795
|
+
taxAmount?: string | null; // 0 in inclusive (VAT) mode \u2014 read taxBreakdown.totalTax
|
|
3796
|
+
taxBreakdown?: TaxBreakdown | null; // carries the included VAT when prices include tax
|
|
3511
3797
|
customer?: OrderCustomer | null;
|
|
3512
3798
|
items: OrderItem[];
|
|
3513
3799
|
itemCount?: number;
|
|
@@ -4325,6 +4611,15 @@ interface PublicRegionDetail extends PublicRegion {
|
|
|
4325
4611
|
}
|
|
4326
4612
|
// getStoreRegions(): { data: PublicRegion[] } \u2014 active regions, default first.
|
|
4327
4613
|
// getStoreRegion(regionId): PublicRegionDetail \u2014 one region + its providers.
|
|
4614
|
+
interface AutoRegionResponse {
|
|
4615
|
+
region: PublicRegion | null;
|
|
4616
|
+
matched: boolean; // true=country was in a region's list; false=fell back to default
|
|
4617
|
+
country: string; // upper-cased ISO-3166-1 alpha-2; '' when caller omitted it
|
|
4618
|
+
}
|
|
4619
|
+
// getAutoRegion(country): AutoRegionResponse \u2014 server-side resolution in one
|
|
4620
|
+
// round trip. Pair with the country your edge runtime extracts
|
|
4621
|
+
// (CF-IPCountry / request.geo.country / etc.) \u2014 Brainerce does NOT derive the
|
|
4622
|
+
// country from the request IP server-side (storefront != end-customer).
|
|
4328
4623
|
|
|
4329
4624
|
// ---- Tax Classes ---- (scopes: tax-classes:read / tax-classes:write)
|
|
4330
4625
|
// Charge differential rates by product type. A TaxRate may target a class via
|
|
@@ -4356,7 +4651,25 @@ interface AssignTaxClassDto { productIds?: string[]; variantIds?: string[]; cate
|
|
|
4356
4651
|
// getRegionCompatibleProviders(id), detectRegion(country, regions)
|
|
4357
4652
|
// Tax classes: getTaxClasses(), getTaxClass(id), createTaxClass(dto), updateTaxClass(id, dto),
|
|
4358
4653
|
// deleteTaxClass(id), setDefaultTaxClass(id), assignTaxClass(id, dto),
|
|
4359
|
-
// mergeTaxClasses(id, targetId)
|
|
4654
|
+
// mergeTaxClasses(id, targetId)
|
|
4655
|
+
//
|
|
4656
|
+
// SDK methods (storefront, public \u2014 storeId mode, no apiKey):
|
|
4657
|
+
// getStoreRegions(), getStoreRegion(id), getAutoRegion(country)
|
|
4658
|
+
// getStoreTaxClasses(), estimateTax({ country?, subtotal })
|
|
4659
|
+
//
|
|
4660
|
+
// estimateTax returns:
|
|
4661
|
+
interface TaxEstimateResponse {
|
|
4662
|
+
appliesTax: boolean;
|
|
4663
|
+
rate: number | null; // percent (18 = 18%) \u2014 null when no matching rule
|
|
4664
|
+
rateName: string | null;
|
|
4665
|
+
estimatedTax: number; // tax portion of subtotal in store currency
|
|
4666
|
+
pricesIncludeTax: boolean;
|
|
4667
|
+
currency: string; // store currency (cart/order currency)
|
|
4668
|
+
note: string; // disclaimer \u2014 preview is non-binding
|
|
4669
|
+
}
|
|
4670
|
+
// Non-binding by design: the authoritative tax runs at checkout against the
|
|
4671
|
+
// full shipping address. The country comes from your edge runtime
|
|
4672
|
+
// (CF-IPCountry / request.geo.country / etc.), NOT the request IP.`;
|
|
4360
4673
|
var TYPES_BY_DOMAIN = {
|
|
4361
4674
|
products: PRODUCTS_TYPES,
|
|
4362
4675
|
cart: CART_TYPES,
|
package/dist/index.d.mts
CHANGED
|
@@ -5,9 +5,6 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
|
5
5
|
*/
|
|
6
6
|
declare function createServer(): McpServer;
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* Topic-to-section mapping for the get-sdk-docs tool.
|
|
10
|
-
*/
|
|
11
8
|
declare function getSectionByTopic(topic: string, connectionId?: string, currency?: string): string;
|
|
12
9
|
|
|
13
10
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -5,9 +5,6 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
|
5
5
|
*/
|
|
6
6
|
declare function createServer(): McpServer;
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* Topic-to-section mapping for the get-sdk-docs tool.
|
|
10
|
-
*/
|
|
11
8
|
declare function getSectionByTopic(topic: string, connectionId?: string, currency?: string): string;
|
|
12
9
|
|
|
13
10
|
/**
|