@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/index.mjs CHANGED
@@ -154,7 +154,26 @@ import {
154
154
  getDescriptionContent, isHtmlDescription,
155
155
  getProductMetafieldValue, getProductCustomizationFields,
156
156
  } from 'brainerce';
157
- \`\`\``;
157
+ \`\`\`
158
+
159
+ ### Available features \u2014 request each topic for full docs
160
+
161
+ | Topic | What it covers |
162
+ |-------|----------------|
163
+ | \`products\` | Catalog listing, search, PDP, variants, swatches, stock, attributes |
164
+ | \`cart\` | Guest + logged-in cart, add/remove/update, reservations |
165
+ | \`checkout\` | Guest + customer checkout, shipping, address |
166
+ | \`payment\` | Payment providers, intents, status polling, confirmation |
167
+ | \`auth\` | Customer sign-up, login, OAuth, email verification |
168
+ | \`discounts\` | Coupons, banners, nudges |
169
+ | \`recommendations\` | Cross-sell / upsell grids |
170
+ | \`reviews\` | Product reviews & ratings |
171
+ | \`inventory\` | Stock badges, reservation countdown |
172
+ | \`inquiries\` | Contact / custom forms |
173
+ | \`i18n\` | Multi-language, RTL |
174
+ | \`admin\` | Server-to-server admin API (products, orders, customers) |
175
+ | \`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. |
176
+ | \`content\` | Blog, articles, static pages |`;
158
177
  }
159
178
  function getCheckoutFlowSection(_currency) {
160
179
  return `## \u26A0\uFE0F CHECKOUT FLOW (CRITICAL \u2014 READ CAREFULLY!)
@@ -703,7 +722,7 @@ const growProvider = providers.find(p => p.provider === 'grow');
703
722
  const paypalProvider = providers.find(p => p.provider === 'paypal');
704
723
  \`\`\`
705
724
 
706
- Each provider has: \`id\`, \`provider\` (flexible string \u2014 \`'stripe'\`, \`'grow'\`, \`'paypal'\`, \`'cardcom'\`, \`'sandbox'\`, and future providers), \`name\`, \`publicKey\`, \`stripeAccountId\` (Stripe only), \`supportedMethods\`, \`testMode\`, \`isDefault\`.
725
+ 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\`.
707
726
 
708
727
  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**:
709
728
 
@@ -1876,8 +1895,8 @@ function getTaxDisplaySection(_currency) {
1876
1895
  | Product Page | \u274C No | "Price excludes tax" (optional note) |
1877
1896
  | Cart Page | \u26A0\uFE0F "Calculated at checkout" | No address yet |
1878
1897
  | Checkout (before address) | \u26A0\uFE0F "Enter address to calculate" | Waiting for location |
1879
- | Checkout (after address) | \u2705 **REQUIRED** | \`checkout.taxAmount\` |
1880
- | Order Confirmation | \u2705 **REQUIRED** | \`order.taxAmount\` |
1898
+ | Checkout (after address) | \u2705 **REQUIRED** | \`checkout.taxAmount\` (0 in VAT mode \u2192 \`checkout.taxBreakdown.totalTax\`) |
1899
+ | Order Confirmation | \u2705 **REQUIRED** | \`order.taxAmount\` (0 in VAT mode \u2192 \`order.taxBreakdown.totalTax\`) |
1881
1900
 
1882
1901
  ### Cart Page \u2014 Partial Display
1883
1902
 
@@ -1929,7 +1948,13 @@ const totals = getCartTotals(cart);
1929
1948
  <div className="flex justify-between text-green-600"><span>Discount</span><span>-{formatPrice(order.discountAmount, { currency: order.currency })}</span></div>
1930
1949
  )}
1931
1950
  <div className="flex justify-between"><span>Shipping</span><span>{formatPrice(order.shippingAmount, { currency: order.currency })}</span></div>
1932
- <div className="flex justify-between"><span>Tax</span><span>{formatPrice(order.taxAmount, { currency: order.currency })}</span></div>
1951
+ {/* Inclusive (VAT) stores keep taxAmount="0" \u2014 the real VAT is on taxBreakdown.totalTax. */}
1952
+ {(() => {
1953
+ const tax = parseFloat(order.taxAmount || '0') || order.taxBreakdown?.totalTax || 0;
1954
+ if (tax <= 0) return null;
1955
+ const incl = order.taxBreakdown?.pricesIncludeTax;
1956
+ return <div className="flex justify-between"><span>{incl ? 'Tax (incl.)' : 'Tax'}</span><span>{formatPrice(tax, { currency: order.currency })}</span></div>;
1957
+ })()}
1933
1958
  <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>
1934
1959
  </div>
1935
1960
  \`\`\``;
@@ -2058,7 +2083,7 @@ A useful order card includes ALL of the following when the data is present. Each
2058
2083
  | **Tracking** | \`order.trackingNumber\`, \`order.trackingUrl\`, \`order.carrier\`, \`order.shippedAt\`, \`order.deliveredAt\` | Link out to \`trackingUrl\` when set. |
2059
2084
  | **Payment** | \`order.paymentMethod\`, \`order.financialStatus\` | Badge \`financialStatus\` (paid / pending / refunded / partially_refunded). |
2060
2085
  | Downloads | \`order.hasDownloads\` \u2192 \`client.getOrderDownloads(id)\` | Separate call; returns \`OrderDownloadLink[]\`. |
2061
- | Financial summary | \`order.subtotal\`, \`order.appliedDiscounts\`, \`order.couponCode\` + \`couponDiscount\`, \`order.shippingAmount\`, \`order.taxAmount\`, \`order.totalAmount\` | Breakdown rows + final total. |
2086
+ | 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.)". |
2062
2087
 
2063
2088
  #### Rendering \`order.items[i].customizations\` by type
2064
2089
 
@@ -2362,6 +2387,67 @@ Read \`storeInfo.i18n.supportedLocales\` and render a switcher in the header
2362
2387
  that navigates to \`/{otherLocale}/{currentPathWithoutLocale}\`. The middleware
2363
2388
  handles the canonical redirect when the user picks the default locale.`;
2364
2389
  }
2390
+ function getMultilingualSeoSection() {
2391
+ return `## Multilingual SEO
2392
+
2393
+ ### Slugs per locale (IMPORTANT)
2394
+
2395
+ Brainerce stores per-locale slugs in \`Product.translations[locale].slug\`.
2396
+ The API exposes them as \`product.localeSlugs\` \u2014 a flat \`Record<string, string>\`.
2397
+
2398
+ \`\`\`typescript
2399
+ // product.localeSlugs = { he: '\u05DE\u05D6\u05E8\u05DF-\u05D9\u05D5\u05D2\u05D4', en: 'yoga-mattress', ar: '\u062D\u0635\u064A\u0631\u0629-\u064A\u0648\u063A\u0627' }
2400
+ const locSlug = product.localeSlugs?.[locale] ?? product.slug;
2401
+ \`\`\`
2402
+
2403
+ Use AI translation (\`translateEntities\` / the AI Translate button in the admin) to populate
2404
+ locale-specific slugs automatically. Until translated, all locales fall back to the base slug
2405
+ (which Google still accepts \u2014 it resolves to the correct locale content via Accept-Language).
2406
+
2407
+ ### hreflang tags
2408
+
2409
+ Every product page in a multi-locale store MUST emit bidirectional hreflang tags or Google
2410
+ ignores them entirely. The scaffolded template generates them automatically when
2411
+ \`NEXT_PUBLIC_BRAINERCE_LOCALES=he,en\` is set.
2412
+
2413
+ \`\`\`html
2414
+ <!-- Example output for /en/products/yoga-mattress -->
2415
+ <link rel="alternate" hreflang="he" href="https://store.com/products/\u05DE\u05D6\u05E8\u05DF-\u05D9\u05D5\u05D2\u05D4" />
2416
+ <link rel="alternate" hreflang="en" href="https://store.com/en/products/yoga-mattress" />
2417
+ <link rel="alternate" hreflang="x-default" href="https://store.com/products/\u05DE\u05D6\u05E8\u05DF-\u05D9\u05D5\u05D2\u05D4" />
2418
+ \`\`\`
2419
+
2420
+ If building a custom storefront, add to \`generateMetadata()\`:
2421
+ \`\`\`typescript
2422
+ alternates: {
2423
+ canonical: locale === defaultLoc ? \`/products/\${slug}\` : \`/\${locale}/products/\${slug}\`,
2424
+ languages: {
2425
+ he: \`\${baseUrl}/products/\${localeSlugs.he ?? baseSlug}\`,
2426
+ en: \`\${baseUrl}/en/products/\${localeSlugs.en ?? baseSlug}\`,
2427
+ 'x-default': \`\${baseUrl}/products/\${localeSlugs[defaultLoc] ?? baseSlug}\`,
2428
+ },
2429
+ },
2430
+ \`\`\`
2431
+
2432
+ ### URL structure
2433
+
2434
+ Google-recommended for headless storefronts:
2435
+ - Default locale: \`/products/\u05DE\u05D6\u05E8\u05DF-\u05D9\u05D5\u05D2\u05D4\` (no prefix)
2436
+ - Other locales: \`/en/products/yoga-mattress\` (prefixed)
2437
+ - \u274C Never: \`?locale=he\` query params (Google rates these as "Not recommended")
2438
+
2439
+ ### Sitemap
2440
+
2441
+ The scaffolded \`sitemap.ts\` generates per-locale entries automatically:
2442
+ \`\`\`
2443
+ /products/\u05DE\u05D6\u05E8\u05DF-\u05D9\u05D5\u05D2\u05D4 (he \u2014 default, no prefix)
2444
+ /en/products/yoga-mattress (en)
2445
+ /ar/products/\u062D\u0635\u064A\u0631\u0629-\u064A\u0648\u063A\u0627 (ar)
2446
+ \`\`\`
2447
+
2448
+ Hebrew, Arabic, and other non-Latin slugs are fully supported \u2014 Google recommends
2449
+ using the audience's language in URLs and indexes non-ASCII characters correctly.`;
2450
+ }
2365
2451
  function getAdminApiSection() {
2366
2452
  return `## Admin API (v0.19.0+)
2367
2453
 
@@ -2445,6 +2531,20 @@ await admin.mergeTaxClasses(food.id, standardClassId);
2445
2531
  Storefront (public, no apiKey \u2014 \`storeId\` mode): \`getStoreTaxClasses()\` lists
2446
2532
  the store's classes (storefront-safe fields only) for a transparency badge.
2447
2533
 
2534
+ For a buyer-facing tax preview on PDP / PLP / cart, \`estimateTax({ country,
2535
+ subtotal })\` returns the tax portion at the Standard rate for the buyer's
2536
+ country. **Non-binding** \u2014 the authoritative tax still runs at checkout with
2537
+ the full shipping address (state / postal / per-class). Always render with an
2538
+ "Estimate" affordance.
2539
+
2540
+ \`\`\`typescript
2541
+ const { estimatedTax, rate, currency, note } = await store.estimateTax({
2542
+ country: 'IT', subtotal: 100,
2543
+ });
2544
+ // \u2192 { appliesTax: true, rate: 22, estimatedTax: 22, currency: 'EUR',
2545
+ // note: 'Estimate \u2014 final tax calculated at checkout\u2026' }
2546
+ \`\`\`
2547
+
2448
2548
  ### Regions (multi-currency / per-region providers)
2449
2549
 
2450
2550
  A region binds countries \u2192 currency + tax-display mode + enabled payment
@@ -2475,6 +2575,19 @@ const { data: regions } = await store.getStoreRegions();
2475
2575
  const region = await store.getStoreRegion(regions[0].id);
2476
2576
  \`\`\`
2477
2577
 
2578
+ For a single round trip, \`getAutoRegion(country)\` resolves a buyer's country
2579
+ to a region server-side. Brainerce does NOT derive the country from the request
2580
+ IP (the storefront server is what reaches the backend, not the end-customer) \u2014
2581
+ your storefront extracts the country from its edge runtime (Cloudflare
2582
+ \`CF-IPCountry\`, Vercel \`request.geo?.country\`, Fastly \`client-geo-country\`,
2583
+ etc.) and forwards it. Returns \`matched=true\` on explicit country hit, \`false\`
2584
+ when falling back to the default region.
2585
+
2586
+ \`\`\`typescript
2587
+ const country = headers.get('cf-ipcountry') ?? 'US';
2588
+ const { region, matched } = await store.getAutoRegion(country);
2589
+ \`\`\`
2590
+
2478
2591
  A shipping zone can be limited to regions via \`regionIds\` \u2014 the zone is then
2479
2592
  only offered to checkouts that resolved to one of those regions. Empty/omitted =
2480
2593
  available for any region (default); each id must belong to the same store.
@@ -2938,6 +3051,146 @@ entries \u2014 pick a descriptive slug (\`'shipping'\`, \`'returns'\`, \`'about'
2938
3051
  - \`get-type-definitions\` with \`domain: 'content'\` for the TypeScript
2939
3052
  interfaces.`;
2940
3053
  }
3054
+ function getBlogSection() {
3055
+ return `## Blog
3056
+
3057
+ Merchants write and schedule blog posts in **Content \u2192 Blog** in the dashboard.
3058
+ Storefronts choose their own URL scheme \u2014 render posts at \`/blog/[slug]\`,
3059
+ \`/articles/[slug]\`, or whatever fits the brand.
3060
+
3061
+ Public reads carry \`Cache-Control: public, max-age=300, stale-while-revalidate=60\`.
3062
+
3063
+ **Scheduling:** A post is visible once \`status === 'PUBLISHED'\` and
3064
+ \`publishedAt <= now()\`. Set a future \`publishedAt\` while publishing to
3065
+ schedule \u2014 no cron needed; visibility is computed at query time.
3066
+
3067
+ ### Reading posts (any SDK mode)
3068
+
3069
+ \`\`\`typescript
3070
+ // List published posts
3071
+ const { data: posts, meta } = await client.blog.getPosts({ page: 1, limit: 10 });
3072
+
3073
+ // Filter by category or tag
3074
+ const { data: news } = await client.blog.getPosts({ category: 'news' });
3075
+ const { data: tips } = await client.blog.getPosts({ tag: 'tutorial' });
3076
+
3077
+ // Fetch one by slug (returns null on 404)
3078
+ const post = await client.blog.getPost('my-first-post');
3079
+ if (post) {
3080
+ console.log(post.title); // string
3081
+ console.log(post.content); // HTML string from rich-text editor
3082
+ console.log(post.excerpt); // optional short summary
3083
+ console.log(post.tags); // string[]
3084
+ console.log(post.coverImageUrl, post.coverImageAlt);
3085
+ console.log(post.publishedAt); // ISO 8601 or undefined
3086
+ }
3087
+ \`\`\`
3088
+
3089
+ ### BlogPost fields
3090
+
3091
+ | Field | Type | Notes |
3092
+ | ----------------- | ----------- | ------------------------------------- |
3093
+ | \`id\` | string | |
3094
+ | \`title\` | string | |
3095
+ | \`slug\` | string | Unique per store, URL-safe |
3096
+ | \`category\` | string? | Free-form (e.g. \`'news'\`) |
3097
+ | \`content\` | string | HTML from rich-text editor |
3098
+ | \`excerpt\` | string? | Short summary for listing cards |
3099
+ | \`coverImageUrl\` | string? | |
3100
+ | \`coverImageAlt\` | string? | |
3101
+ | \`author\` | string? | |
3102
+ | \`tags\` | string[] | |
3103
+ | \`publishedAt\` | string? | ISO 8601; null = publish immediately |
3104
+ | \`seoTitle\` | string? | |
3105
+ | \`seoDescription\`| string? | |
3106
+ | \`ogImageUrl\` | string? | |
3107
+
3108
+ ### Rendering blog content
3109
+
3110
+ \`\`\`tsx
3111
+ // app/blog/[slug]/page.tsx
3112
+ import DOMPurify from 'isomorphic-dompurify';
3113
+
3114
+ const post = await brainerce.blog.getPost(params.slug);
3115
+ if (!post) notFound();
3116
+
3117
+ // Always sanitize before rendering HTML \u2014 treat external-origin content as untrusted
3118
+ const safeHtml = DOMPurify.sanitize(post.content);
3119
+ return <div dangerouslySetInnerHTML={{ __html: safeHtml }} className="prose" />;
3120
+ \`\`\`
3121
+
3122
+ The \`content\` field is HTML produced by the Lexical rich-text editor.
3123
+ **Always sanitize with DOMPurify (or equivalent) before rendering via
3124
+ \`dangerouslySetInnerHTML\`** \u2014 even though the content originates from your
3125
+ own editor, defense-in-depth prevents any stored-XSS path if content is ever
3126
+ migrated or imported from an external source.
3127
+ Apply a \`prose\` class (Tailwind Typography) for automatic styling.
3128
+
3129
+ ### REST endpoints
3130
+
3131
+ | Method | Path | Returns |
3132
+ |--------|------|---------|
3133
+ | GET | \`/api/stores/:storeId/blog/posts\` | \`BlogPostListResponse\` |
3134
+ | GET | \`/api/stores/:storeId/blog/posts/:slug\` | \`BlogPost\` or 404 |
3135
+ | GET | \`/api/vc/:connectionId/blog/posts\` | Same, channel-scoped |
3136
+ | GET | \`/api/vc/:connectionId/blog/posts/:slug\` | \`BlogPost\` or 404 |
3137
+ `;
3138
+ }
3139
+ function getStorefrontBotSection(connectionId) {
3140
+ return `## Storefront Bot (AI chat widget)
3141
+
3142
+ The store's AI shopping assistant. ALL configuration (name, avatar, colors,
3143
+ greeting, starter questions, capabilities, guardrails) lives in the merchant
3144
+ dashboard \u2014 the embed never decides behavior, and the widget renders nothing
3145
+ until the merchant switches the bot Live.
3146
+
3147
+ ### Zero-code embed (any site)
3148
+
3149
+ \`\`\`html
3150
+ <script src="https://cdn.brainerce.com/bot.js" data-connection-id="${connectionId}" defer></script>
3151
+ \`\`\`
3152
+
3153
+ Keep the tag exactly this bare \u2014 do NOT add \`integrity\` or \`crossorigin\`
3154
+ (the bootstrap is intentionally mutable; it is origin-pinned by CSP instead).
3155
+
3156
+ ### SDK mount (React / Next.js / any bundler)
3157
+
3158
+ \`\`\`ts
3159
+ import { BrainerceBot } from 'brainerce/bot';
3160
+
3161
+ // client-side only (e.g. in a useEffect) \u2014 mounts a floating chat bubble
3162
+ const bot = await BrainerceBot.mount({ connectionId: '${connectionId}' });
3163
+ bot?.destroy(); // optional teardown
3164
+ \`\`\`
3165
+
3166
+ \`mount\` resolves to \`null\` when the bot is disabled (FREE plan, switched
3167
+ off, or unconfigured) \u2014 safe to call unconditionally. Options: \`connectionId\`
3168
+ (required), \`baseUrl\` (API origin override), \`target\` (mount element),
3169
+ \`onAddToCart\` (\`({ productId, variantId, quantity }) => boolean | Promise<boolean>\`
3170
+ \u2014 route the widget's cart adds through the site's own cart; \`variantId\` is
3171
+ null for simple products; return false to fall back to the product page).
3172
+
3173
+ Behavior: persists an anonymous session in localStorage, restores the
3174
+ conversation on revisit, streams answers, and shows product recommendation
3175
+ cards (image, price, add-to-cart / view). Multi-variant products get an
3176
+ in-card variant picker; shoppers can also ask the assistant to add an item
3177
+ and it goes through the same cart chain. Zero-result searches feed the
3178
+ merchant's "unmet demand" analytics. Aside from shopper-initiated cart adds,
3179
+ the bot is read-only.
3180
+
3181
+ Add-to-cart resolution chain: \`onAddToCart\` option \u2192 cancelable
3182
+ \`brainerce:bot:add-to-cart\` CustomEvent on window
3183
+ (\`detail: { productId, variantId, quantity, connectionId }\`; call
3184
+ preventDefault() after handling) \u2192 navigate to the product page.
3185
+
3186
+ Rules:
3187
+ - Mount once per page; do not pass any visual config \u2014 the dashboard owns it.
3188
+ - Do not wrap or restyle the widget; it renders in its own Shadow DOM.
3189
+ - Product card links expect the conventional \`/products/<slug>\` route.
3190
+ - Wire \`onAddToCart\` to the site's cart (see the cart section) so the header
3191
+ count updates when the bot adds items.
3192
+ `;
3193
+ }
2941
3194
  function getSectionByTopic(topic, connectionId, currency) {
2942
3195
  const cid = connectionId || "vc_YOUR_CONNECTION_ID";
2943
3196
  const cur = currency || "USD";
@@ -2976,6 +3229,10 @@ function getSectionByTopic(topic, connectionId, currency) {
2976
3229
  return getTaxDisplaySection(cur);
2977
3230
  case "i18n":
2978
3231
  return getI18nSection();
3232
+ case "multilingual-seo":
3233
+ case "hreflang":
3234
+ case "seo-i18n":
3235
+ return getMultilingualSeoSection();
2979
3236
  case "critical-rules":
2980
3237
  return getCriticalRulesSection() + "\n\n" + getTypeQuickReference();
2981
3238
  case "type-reference":
@@ -2986,6 +3243,10 @@ function getSectionByTopic(topic, connectionId, currency) {
2986
3243
  return getContactInquiriesSection();
2987
3244
  case "content":
2988
3245
  return getContentSection();
3246
+ case "blog":
3247
+ return getBlogSection();
3248
+ case "storefront-bot":
3249
+ return getStorefrontBotSection(cid);
2989
3250
  case "all":
2990
3251
  return [
2991
3252
  "# Brainerce SDK \u2014 full topic dump",
@@ -3070,6 +3331,10 @@ function getSectionByTopic(topic, connectionId, currency) {
3070
3331
  "",
3071
3332
  "---",
3072
3333
  "",
3334
+ getMultilingualSeoSection(),
3335
+ "",
3336
+ "---",
3337
+ "",
3073
3338
  getAdminApiSection(),
3074
3339
  "",
3075
3340
  "---",
@@ -3078,10 +3343,18 @@ function getSectionByTopic(topic, connectionId, currency) {
3078
3343
  "",
3079
3344
  "---",
3080
3345
  "",
3081
- getContentSection()
3346
+ getContentSection(),
3347
+ "",
3348
+ "---",
3349
+ "",
3350
+ getBlogSection(),
3351
+ "",
3352
+ "---",
3353
+ "",
3354
+ getStorefrontBotSection(cid)
3082
3355
  ].join("\n");
3083
3356
  default:
3084
- 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`;
3357
+ 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`;
3085
3358
  }
3086
3359
  }
3087
3360
 
@@ -3110,6 +3383,7 @@ var GET_SDK_DOCS_SCHEMA = {
3110
3383
  "admin",
3111
3384
  "inquiries",
3112
3385
  "content",
3386
+ "storefront-bot",
3113
3387
  "all"
3114
3388
  ]).describe("The SDK documentation topic to retrieve"),
3115
3389
  salesChannelId: z.string().optional().describe("Sales channel ID (starts with vc_). Used to personalize setup code."),
@@ -3147,6 +3421,12 @@ interface Product {
3147
3421
  priceMin?: string | null; // Lowest variant price (VARIABLE products) \u2014 same as basePrice for VARIABLE, kept for back-compat and JSON-LD range display.
3148
3422
  priceMax?: string | null; // Highest variant price (VARIABLE products). Use with priceMin for "\u20AA49 \u2013 \u20AA199" range.
3149
3423
  priceVaries?: boolean; // true when variant prices differ \u2014 show "\u20AA49 \u2013 \u20AA199" range.
3424
+ // 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.
3425
+ displayPrice?: string; // basePrice \xD7 daily FX rate, in displayCurrency.
3426
+ displaySalePrice?: string; // salePrice \xD7 rate (if salePrice present).
3427
+ displayPriceMin?: string; // priceMin \xD7 rate (VARIABLE products).
3428
+ displayPriceMax?: string; // priceMax \xD7 rate (VARIABLE products).
3429
+ displayCurrency?: string; // ISO 4217 of the region \u2014 e.g. "EUR".
3150
3430
  status: string;
3151
3431
  type: 'SIMPLE' | 'VARIABLE';
3152
3432
  isDownloadable?: boolean;
@@ -3190,6 +3470,10 @@ interface ProductVariant {
3190
3470
  name?: string | null;
3191
3471
  price?: string | null;
3192
3472
  salePrice?: string | null;
3473
+ // FX DISPLAY overlay (PRD \xA723) \u2014 same semantics as on the parent Product.
3474
+ displayPrice?: string;
3475
+ displaySalePrice?: string;
3476
+ displayCurrency?: string;
3193
3477
  attributes?: Record<string, string> | null;
3194
3478
  options?: Array<{ name: string; value: string }>;
3195
3479
  inventory?: InventoryInfo | null;
@@ -3502,6 +3786,8 @@ interface Order {
3502
3786
  totalAmount: string; // ALWAYS use this, not .total
3503
3787
  total?: string; // optional alias
3504
3788
  currency?: string;
3789
+ taxAmount?: string | null; // 0 in inclusive (VAT) mode \u2014 read taxBreakdown.totalTax
3790
+ taxBreakdown?: TaxBreakdown | null; // carries the included VAT when prices include tax
3505
3791
  customer?: OrderCustomer | null;
3506
3792
  items: OrderItem[];
3507
3793
  itemCount?: number;
@@ -4319,6 +4605,15 @@ interface PublicRegionDetail extends PublicRegion {
4319
4605
  }
4320
4606
  // getStoreRegions(): { data: PublicRegion[] } \u2014 active regions, default first.
4321
4607
  // getStoreRegion(regionId): PublicRegionDetail \u2014 one region + its providers.
4608
+ interface AutoRegionResponse {
4609
+ region: PublicRegion | null;
4610
+ matched: boolean; // true=country was in a region's list; false=fell back to default
4611
+ country: string; // upper-cased ISO-3166-1 alpha-2; '' when caller omitted it
4612
+ }
4613
+ // getAutoRegion(country): AutoRegionResponse \u2014 server-side resolution in one
4614
+ // round trip. Pair with the country your edge runtime extracts
4615
+ // (CF-IPCountry / request.geo.country / etc.) \u2014 Brainerce does NOT derive the
4616
+ // country from the request IP server-side (storefront != end-customer).
4322
4617
 
4323
4618
  // ---- Tax Classes ---- (scopes: tax-classes:read / tax-classes:write)
4324
4619
  // Charge differential rates by product type. A TaxRate may target a class via
@@ -4350,7 +4645,25 @@ interface AssignTaxClassDto { productIds?: string[]; variantIds?: string[]; cate
4350
4645
  // getRegionCompatibleProviders(id), detectRegion(country, regions)
4351
4646
  // Tax classes: getTaxClasses(), getTaxClass(id), createTaxClass(dto), updateTaxClass(id, dto),
4352
4647
  // deleteTaxClass(id), setDefaultTaxClass(id), assignTaxClass(id, dto),
4353
- // mergeTaxClasses(id, targetId)`;
4648
+ // mergeTaxClasses(id, targetId)
4649
+ //
4650
+ // SDK methods (storefront, public \u2014 storeId mode, no apiKey):
4651
+ // getStoreRegions(), getStoreRegion(id), getAutoRegion(country)
4652
+ // getStoreTaxClasses(), estimateTax({ country?, subtotal })
4653
+ //
4654
+ // estimateTax returns:
4655
+ interface TaxEstimateResponse {
4656
+ appliesTax: boolean;
4657
+ rate: number | null; // percent (18 = 18%) \u2014 null when no matching rule
4658
+ rateName: string | null;
4659
+ estimatedTax: number; // tax portion of subtotal in store currency
4660
+ pricesIncludeTax: boolean;
4661
+ currency: string; // store currency (cart/order currency)
4662
+ note: string; // disclaimer \u2014 preview is non-binding
4663
+ }
4664
+ // Non-binding by design: the authoritative tax runs at checkout against the
4665
+ // full shipping address. The country comes from your edge runtime
4666
+ // (CF-IPCountry / request.geo.country / etc.), NOT the request IP.`;
4354
4667
  var TYPES_BY_DOMAIN = {
4355
4668
  products: PRODUCTS_TYPES,
4356
4669
  cart: CART_TYPES,
package/package.json CHANGED
@@ -1,53 +1,53 @@
1
- {
2
- "name": "@brainerce/mcp-server",
3
- "version": "3.9.0",
4
- "description": "Framework-agnostic domain knowledge API for Brainerce. Provides SDK docs, types, business flows, critical rules, and store capabilities to AI tools like Lovable, Cursor, Bolt, v0, and Claude Code. Does NOT provide framework-specific boilerplate — clients build in whatever framework fits.",
5
- "bin": {
6
- "brainerce-mcp": "dist/bin/stdio.js"
7
- },
8
- "main": "dist/index.js",
9
- "module": "dist/index.mjs",
10
- "types": "dist/index.d.ts",
11
- "exports": {
12
- ".": {
13
- "types": "./dist/index.d.ts",
14
- "require": "./dist/index.js",
15
- "import": "./dist/index.mjs"
16
- }
17
- },
18
- "files": [
19
- "dist",
20
- "README.md"
21
- ],
22
- "scripts": {
23
- "build": "tsup",
24
- "dev": "tsup --watch",
25
- "start:stdio": "node dist/bin/stdio.js",
26
- "start:http": "node dist/bin/http.js",
27
- "prepublishOnly": "npm run build"
28
- },
29
- "dependencies": {
30
- "@modelcontextprotocol/sdk": "^1.27.1",
31
- "zod": "^3.24.0"
32
- },
33
- "devDependencies": {
34
- "@types/node": "^22.0.0",
35
- "tsup": "^8.0.0",
36
- "typescript": "^5.3.0"
37
- },
38
- "engines": {
39
- "node": ">=18"
40
- },
41
- "keywords": [
42
- "brainerce",
43
- "mcp",
44
- "model-context-protocol",
45
- "ai",
46
- "ecommerce",
47
- "lovable",
48
- "cursor",
49
- "claude-code",
50
- "vibe-coding"
51
- ],
52
- "license": "MIT"
53
- }
1
+ {
2
+ "name": "@brainerce/mcp-server",
3
+ "version": "3.11.1",
4
+ "description": "Framework-agnostic domain knowledge API for Brainerce. Provides SDK docs, types, business flows, critical rules, and store capabilities to AI tools like Lovable, Cursor, Bolt, v0, and Claude Code. Does NOT provide framework-specific boilerplate — clients build in whatever framework fits.",
5
+ "bin": {
6
+ "brainerce-mcp": "dist/bin/stdio.js"
7
+ },
8
+ "main": "dist/index.js",
9
+ "module": "dist/index.mjs",
10
+ "types": "dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "require": "./dist/index.js",
15
+ "import": "./dist/index.mjs"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "README.md"
21
+ ],
22
+ "scripts": {
23
+ "build": "tsup",
24
+ "dev": "tsup --watch",
25
+ "start:stdio": "node dist/bin/stdio.js",
26
+ "start:http": "node dist/bin/http.js",
27
+ "prepublishOnly": "npm run build"
28
+ },
29
+ "dependencies": {
30
+ "@modelcontextprotocol/sdk": "^1.27.1",
31
+ "zod": "^3.24.0"
32
+ },
33
+ "devDependencies": {
34
+ "@types/node": "^22.0.0",
35
+ "tsup": "^8.0.0",
36
+ "typescript": "^5.3.0"
37
+ },
38
+ "engines": {
39
+ "node": ">=18"
40
+ },
41
+ "keywords": [
42
+ "brainerce",
43
+ "mcp",
44
+ "model-context-protocol",
45
+ "ai",
46
+ "ecommerce",
47
+ "lovable",
48
+ "cursor",
49
+ "claude-code",
50
+ "vibe-coding"
51
+ ],
52
+ "license": "MIT"
53
+ }