rightcard-mcp 0.1.14 → 0.1.15

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/engine.d.ts CHANGED
@@ -25,6 +25,10 @@ export interface Recommendation {
25
25
  /** The winning rotating quarter's limit and who wins after it (app: CapInfo). */
26
26
  capLimit?: string | null;
27
27
  afterLimit?: string | null;
28
+ /** The store's register refuses every card in the wallet (Costco takes Visa
29
+ * only and none is a Visa). Then `caveat` is set by the engine and wins
30
+ * over the directory's caveat. Mirrors RecommendationContext. */
31
+ walletRefusedAtRegister?: boolean;
28
32
  }
29
33
  export interface RecommendInput {
30
34
  cards: CreditCard[];
@@ -43,6 +47,8 @@ export interface RecommendInput {
43
47
  }
44
48
  /** Where the quarter is turned on. Mirrors MerchantYieldEngine.activationApp. */
45
49
  export declare function activationApp(issuer: string): string;
50
+ /** A card network as people write it (mirrors MerchantYieldEngine.networkName). */
51
+ export declare function networkName(raw: string): string;
46
52
  export declare function formatPercent(v: number): string;
47
53
  export declare function formatMultiplier(v: number): string;
48
54
  /** MerchantYieldEngine.recommend — base-rate mode (offers: []) */
package/dist/engine.js CHANGED
@@ -1,18 +1,37 @@
1
1
  // Mirrors MerchantYieldEngine (BASE-RATE mode only — offers live on the phone, never here).
2
- import { CATEGORY_DISPLAY, capCovers, isPermanentMerchantBenefit, multiplier, overrideIsActive, rotatingCap, standingCaps, storeTypes, } from "./model.js";
2
+ import { CATEGORY_DISPLAY, capCovers, categoryStoreTypes, isPermanentMerchantBenefit, multiplier, overrideIsActive, rotatingCap, standingCaps, storeTypes, } from "./model.js";
3
3
  import { merchantMatchesCoBrandBenefit, offerMatches } from "./matching.js";
4
4
  import { specFor } from "./configurable.js";
5
- import { basisLabel, cashOutCPP, centsPerPoint, earnUnitLabel, effectiveProgram, fmt1, valuesPointsAboveCash, withPooling, } from "./valuation.js";
5
+ import { basisLabel, cashOutCPP, centsPerPoint, earnUnitLabel, effectiveProgram, fmt1, fmtRate, valuesPointsAboveCash, withPooling, } from "./valuation.js";
6
6
  /** Where the quarter is turned on. Mirrors MerchantYieldEngine.activationApp. */
7
7
  export function activationApp(issuer) {
8
8
  return issuer.toLowerCase().includes("discover") ? "Capital One or Discover" : issuer;
9
9
  }
10
10
  // ── formatting (Swift twins) ──
11
+ /** A card network as people write it (mirrors MerchantYieldEngine.networkName). */
12
+ export function networkName(raw) {
13
+ switch (raw.toLowerCase()) {
14
+ case "visa": return "Visa";
15
+ case "mastercard": return "Mastercard";
16
+ case "amex":
17
+ case "american express": return "American Express";
18
+ case "discover": return "Discover";
19
+ default: return raw.charAt(0).toUpperCase() + raw.slice(1);
20
+ }
21
+ }
22
+ /** "A", "A and B", "A, B, and C" (en ListFormatter). */
23
+ function listJoin(items) {
24
+ if (items.length <= 1)
25
+ return items.join("");
26
+ if (items.length === 2)
27
+ return `${items[0]} and ${items[1]}`;
28
+ return `${items.slice(0, -1).join(", ")}, and ${items[items.length - 1]}`;
29
+ }
11
30
  export function formatPercent(v) {
12
- return v === Math.round(v) ? `${Math.round(v)}%` : `${fmt1(v)}%`;
31
+ return v === Math.round(v) ? `${Math.round(v)}%` : `${fmtRate(v)}%`;
13
32
  }
14
33
  export function formatMultiplier(v) {
15
- return v === Math.round(v) ? `${Math.round(v)}x` : `${fmt1(v)}x`;
34
+ return v === Math.round(v) ? `${Math.round(v)}x` : `${fmtRate(v)}x`;
16
35
  }
17
36
  /** shortName: trim issuer/boilerplate so a card name fits a one-line note. */
18
37
  function shortName(name) {
@@ -124,8 +143,19 @@ function appliedRate(card, category, subKey, merchantQuery, overrides, cardConfi
124
143
  else if (storeTypes(o)) {
125
144
  // A store-type quarter (Discover's entertainment): only a store the
126
145
  // directory files under one of its types.
127
- if (!merchantType || !storeTypes(o).includes(merchantType.toLowerCase()))
128
- continue;
146
+ // A category tap has no store: it matches when the category IS that
147
+ // kind of store (mirrors MerchantYieldEngine, Oct 24 2026).
148
+ const types = storeTypes(o);
149
+ if (merchantType) {
150
+ if (!types.includes(merchantType.toLowerCase()))
151
+ continue;
152
+ }
153
+ else {
154
+ if (merchantQuery && merchantQuery !== "")
155
+ continue;
156
+ if (!categoryStoreTypes(category).some((t) => types.includes(t)))
157
+ continue;
158
+ }
129
159
  matches = true;
130
160
  }
131
161
  else {
@@ -285,10 +315,10 @@ function rateContext(card, earn, valueCents, override, configured, v, category,
285
315
  if (card.rewardCurrency !== null && card.rewardCurrency !== "cashback") {
286
316
  lines.push(category === "general"
287
317
  ? `Base rate: ${formatMultiplier(earn)} ${earnUnitLabel(v, card)} → ${valueStr}`
288
- : `Base ${cat} earn: ${formatMultiplier(earn)} ${earnUnitLabel(v, card)} → ${valueStr}`);
318
+ : `Rate on ${cat}: ${formatMultiplier(earn)} ${earnUnitLabel(v, card)} → ${valueStr}`);
289
319
  }
290
320
  else {
291
- lines.push(category === "general" ? `Base rate: ${valueStr}` : `Base ${cat} earn: ${valueStr}`);
321
+ lines.push(category === "general" ? `Base rate: ${valueStr}` : `Rate on ${cat}: ${valueStr}`);
292
322
  }
293
323
  }
294
324
  let caption = configured ? "your bonus category · value per $1"
@@ -319,6 +349,8 @@ function subcategoryBreakdown(cards, category, overrides, cardConfigs, v, now) {
319
349
  subs = [["in_store", "In a store"], ["online", "Online / delivery"]];
320
350
  else if (category === "travel")
321
351
  subs = [["flight", "Flights"], ["hotel", "Hotels"], [null, "Other travel"]];
352
+ else if (category === "phone_internet")
353
+ subs = [["phone", "Phone plans"], ["internet", "Internet & cable"]];
322
354
  else
323
355
  return [];
324
356
  const rows = [];
@@ -344,6 +376,7 @@ export function recommend(input) {
344
376
  // caveat carries the register story. Unknown (null) network never gates.
345
377
  const accepted = input.acceptedNetworks;
346
378
  let refusedAtRegister = [];
379
+ let walletRefused = false;
347
380
  if (accepted && accepted.size > 0) {
348
381
  const eligible = cards.filter((c) => {
349
382
  const net = c.network?.toLowerCase();
@@ -353,6 +386,9 @@ export function recommend(input) {
353
386
  refusedAtRegister = cards.filter((c) => !eligible.includes(c));
354
387
  cards = eligible;
355
388
  }
389
+ else {
390
+ walletRefused = true;
391
+ }
356
392
  }
357
393
  const v = withPooling(input.valuation, cards);
358
394
  const cardConfigs = input.cardConfigs ?? {};
@@ -373,6 +409,15 @@ export function recommend(input) {
373
409
  ctx.reason = `${w.card.displayName} is your best card that works at the ${merchantName} register: ${formatPercent(w.valueCents)} per dollar.`;
374
410
  }
375
411
  }
412
+ // Every card is refused at the register: say so instead of headlining a
413
+ // card that won't swipe (mirrors MerchantYieldEngine, Oct 24 2026).
414
+ if (merchantName && walletRefused && accepted) {
415
+ const nets = listJoin([...accepted].sort().map(networkName));
416
+ ctx.walletRefusedAtRegister = true;
417
+ ctx.reason = `None of your cards works at the ${merchantName} register. Online, ${w.card.displayName} earns ${formatPercent(w.valueCents)} per dollar.`;
418
+ ctx.caveat = `None of your cards works at the ${merchantName} register. It takes ${nets} only. Online, this is your best card.`;
419
+ ctx.tieNote = null;
420
+ }
376
421
  // Rotating limit (mirrors MerchantYieldEngine.capInfo): re-answer without
377
422
  // this card's capped quarter rows to name who wins after the limit.
378
423
  const o = w.override;
package/dist/model.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type SpendCategory = "dining" | "grocery" | "travel" | "gas" | "online" | "drugstore" | "transit" | "streaming" | "general";
1
+ export type SpendCategory = "dining" | "grocery" | "travel" | "gas" | "online" | "drugstore" | "transit" | "streaming" | "entertainment" | "phone_internet" | "office_supply" | "general";
2
2
  export declare const ALL_CATEGORIES: SpendCategory[];
3
3
  export declare const CATEGORY_DISPLAY: Record<SpendCategory, string>;
4
4
  export type RewardCurrency = "points" | "miles" | "cashback";
@@ -39,6 +39,10 @@ export interface Override {
39
39
  * merchant_type values they cover (Discover Q4 2026 entertainment/utilities).
40
40
  * Mirrors SupabaseOverride.storeTypeCategories in the app. */
41
41
  export declare const STORE_TYPE_CATEGORIES: Record<string, string[]>;
42
+ /** The directory store types a category stands for (mirrors
43
+ * MerchantYieldEngine.storeTypes(for:), Oct 24 2026): a category tap uses a
44
+ * quarter written as a store type, e.g. Discover's entertainment. */
45
+ export declare function categoryStoreTypes(category: SpendCategory): string[];
42
46
  /** The store types a row applies to, or null for a category/merchant row. */
43
47
  export declare function storeTypes(o: Override): string[] | null;
44
48
  /** A card's rotating limit (mirrors RotatingCap in the app): Chase and Discover
package/dist/model.js CHANGED
@@ -1,9 +1,12 @@
1
1
  // Mirrors Models/CreditCard.swift, Models/SpendCategory.swift, SupabaseModels.swift.
2
2
  // Every rule here has a Swift twin; parity is enforced by test/parity.test.ts.
3
- export const ALL_CATEGORIES = ["dining", "grocery", "travel", "gas", "online", "drugstore", "transit", "streaming", "general"];
3
+ export const ALL_CATEGORIES = ["dining", "grocery", "travel", "gas", "online", "drugstore", "transit", "streaming",
4
+ "entertainment", "phone_internet", "office_supply", "general"];
4
5
  export const CATEGORY_DISPLAY = {
5
6
  dining: "Dining", grocery: "Grocery", travel: "Travel", gas: "Gas", online: "Online",
6
- drugstore: "Drugstores", transit: "Transit", streaming: "Streaming", general: "General",
7
+ drugstore: "Drugstores", transit: "Transit", streaming: "Streaming",
8
+ entertainment: "Entertainment", phone_internet: "Phone & internet", office_supply: "Office supplies",
9
+ general: "General",
7
10
  };
8
11
  export const CURRENCY_DISPLAY = {
9
12
  points: "points", miles: "miles", cashback: "cash back",
@@ -86,6 +89,16 @@ export const STORE_TYPE_CATEGORIES = {
86
89
  entertainment: ["entertainment"],
87
90
  utilities: ["telecom", "utility"],
88
91
  };
92
+ /** The directory store types a category stands for (mirrors
93
+ * MerchantYieldEngine.storeTypes(for:), Oct 24 2026): a category tap uses a
94
+ * quarter written as a store type, e.g. Discover's entertainment. */
95
+ export function categoryStoreTypes(category) {
96
+ if (category === "entertainment")
97
+ return ["entertainment"];
98
+ if (category === "phone_internet")
99
+ return ["telecom"];
100
+ return [];
101
+ }
89
102
  /** The store types a row applies to, or null for a category/merchant row. */
90
103
  export function storeTypes(o) {
91
104
  if (o.merchant && o.merchant !== "")
@@ -130,9 +143,10 @@ export function standingCaps(cardId) {
130
143
  case "chase_southwest_premier":
131
144
  return [{ id: "combined", categories: ["grocery", "dining"], limit: 8000, period: "cardYear", after: 1 }];
132
145
  case "chase_ink_business_preferred_credit_card":
133
- return [{ id: "combined", categories: ["travel", "transit"], limit: 150000, period: "cardYear", after: 1 }];
146
+ return [{ id: "combined", categories: ["travel", "transit", "phone_internet"], limit: 150000, period: "cardYear", after: 1 }];
134
147
  case "chase_ink_business_cash_credit_card":
135
- return [{ id: "combined", categories: ["gas", "dining"], limit: 25000, period: "cardYear", after: 1 }];
148
+ return [{ id: "essentials", categories: ["office_supply", "phone_internet"], limit: 25000, period: "cardYear", after: 1 },
149
+ { id: "combined", categories: ["gas", "dining"], limit: 25000, period: "cardYear", after: 1 }];
136
150
  case "discover_discover_it_chrome":
137
151
  case "discover_discover_it_student_chrome":
138
152
  return [{ id: "combined", categories: ["gas", "dining"], limit: 1000, period: "quarter", after: 1 }];
package/dist/search.d.ts CHANGED
@@ -9,7 +9,10 @@ export interface SearchForms {
9
9
  raw: string;
10
10
  norm: string;
11
11
  compact: string;
12
+ body: string;
12
13
  }
14
+ /** Merchant.droppingWebEnding: "emirates.com" → "emirates". Anything with a space comes back unchanged. */
15
+ export declare function droppingWebEnding(raw: string): string;
13
16
  export declare const searchForms: (raw: string) => SearchForms;
14
17
  /** Merchant.matchScore(queryNorm:queryCompact:rawQuery:candidates:) */
15
18
  export declare function matchScore(q: string, qc: string, rawQuery: string, candidates: SearchForms[]): number | null;
package/dist/search.js CHANGED
@@ -68,9 +68,21 @@ export function withinOneEdit(aStr, bStr) {
68
68
  }
69
69
  return true;
70
70
  }
71
+ /** Merchant.droppingWebEnding: "emirates.com" → "emirates". Anything with a space comes back unchanged. */
72
+ export function droppingWebEnding(raw) {
73
+ const s = raw.trim();
74
+ const dot = s.indexOf(".");
75
+ if (s.includes(" ") || dot < 0)
76
+ return raw;
77
+ const after = s.slice(dot + 1).toLowerCase();
78
+ const endings = ["com", "co.uk", "co", "uk", "ca", "net", "org", "us", "io", "app", "shop", "store"];
79
+ if (!endings.some((e) => after === e || after.startsWith(e + "/") || after.startsWith(e + ".")))
80
+ return raw;
81
+ return s.slice(0, dot);
82
+ }
71
83
  export const searchForms = (raw) => {
72
84
  const norm = searchNormalized(raw);
73
- return { raw, norm, compact: compactForm(norm) };
85
+ return { raw, norm, compact: compactForm(norm), body: searchNormalized(droppingWebEnding(raw)) };
74
86
  };
75
87
  /** Merchant.matchScore(queryNorm:queryCompact:rawQuery:candidates:) */
76
88
  export function matchScore(q, qc, rawQuery, candidates) {
@@ -100,7 +112,9 @@ export function matchScore(q, qc, rawQuery, candidates) {
100
112
  // character query matching mid-word is noise: "LG" returned Algenist,
101
113
  // Bulgari, Trafalgar and the glued alias "naturalgrocers.com" and no LG
102
114
  // (user report, Sep 17 2026). Mirrors Merchant.matchScore in the app.
103
- if ([...q].length >= 4 && n.includes(q))
115
+ // The mid-word tier reads the name without its web ending, so "tesco"
116
+ // can't match inside "emiratesCOm" (Oct 26 2026).
117
+ if ([...q].length >= 4 && c.body.includes(q))
104
118
  best = Math.max(best, 55);
105
119
  if (best < 45 && merchantMatches(c.raw, rawQuery))
106
120
  best = Math.max(best, 45);
package/dist/tools.js CHANGED
@@ -40,7 +40,9 @@ function resolveMerchant(catalog, name) {
40
40
  }
41
41
  function shapeAnswer(r, merchant, mode, unverified) {
42
42
  const caveats = [];
43
- if (merchant) {
43
+ if (r.walletRefusedAtRegister && r.caveat)
44
+ caveats.push(r.caveat);
45
+ else if (merchant) {
44
46
  const cv = exclusionCaveat(merchant);
45
47
  if (cv)
46
48
  caveats.push(cv);
@@ -28,4 +28,9 @@ export declare function basisLabel(v: Valuation, card: CreditCard): string;
28
28
  * "1.6" where Swift prints "1.7" (Delta Biz Platinum transit 1.5x @ 1.1¢).
29
29
  * toFixed(20) is the exact decimal expansion of the double, so a tie is a
30
30
  * tie only when the digits past the tenths are literally 5000…0. */
31
+ /** Swift `LocalNumber.decimal` for the US: up to two decimals, trailing
32
+ * zeros dropped ("2.7", "1.25"). Oct 27 2026: one decimal turned a
33
+ * bank-stated 1.25% into "1.2%". Ties round half-to-even on the double's
34
+ * exact decimal expansion, the same way printf("%.2f") does (see fmt1). */
35
+ export declare function fmtRate(x: number): string;
31
36
  export declare function fmt1(x: number): string;
package/dist/valuation.js CHANGED
@@ -12,7 +12,7 @@ export const TRAVEL_CPP = {
12
12
  // Sep 2026: median of TPG / Frequent Miler / Upgraded Points / OMAAT, rounded
13
13
  // down, never above (mirrors Swift RewardProgram.travelCPP).
14
14
  cash: 1.0, amexMR: 1.8, chaseUR: 1.8, capOneMiles: 1.7, citiTYP: 1.6, wellsFargo: 1.5, bilt: 1.8,
15
- tdRewards: 0.5, scenePlus: 1.0, rbcAvion: 1.5, bmoRewards: 0.7,
15
+ tdRewards: 0.5, scenePlus: 1.0, rbcAvion: 1.8, bmoRewards: 0.6, // Oct 2026 CA medians (the MCP serves US cards only)
16
16
  hyatt: 1.4, marriott: 0.7, ihg: 0.5, choice: 0.6, hilton: 0.4,
17
17
  delta: 1.1, united: 1.2, american: 1.4, southwest: 1.2, jetBlue: 1.3, alaska: 1.4, avios: 1.2, aeroplan: 1.3,
18
18
  fixedValue: 1.0, genericPoints: 2.0, genericMiles: 1.5,
@@ -25,6 +25,9 @@ export function cashOutCPP(p) {
25
25
  case "citiTYP":
26
26
  case "scenePlus": return 1.0;
27
27
  case "amexMR": return 0.6;
28
+ case "bmoRewards": return 0.6;
29
+ case "rbcAvion": return 0.58;
30
+ case "tdRewards": return 0.25;
28
31
  default: return 0.5;
29
32
  }
30
33
  }
@@ -183,6 +186,26 @@ export function basisLabel(v, card) {
183
186
  * "1.6" where Swift prints "1.7" (Delta Biz Platinum transit 1.5x @ 1.1¢).
184
187
  * toFixed(20) is the exact decimal expansion of the double, so a tie is a
185
188
  * tie only when the digits past the tenths are literally 5000…0. */
189
+ /** Swift `LocalNumber.decimal` for the US: up to two decimals, trailing
190
+ * zeros dropped ("2.7", "1.25"). Oct 27 2026: one decimal turned a
191
+ * bank-stated 1.25% into "1.2%". Ties round half-to-even on the double's
192
+ * exact decimal expansion, the same way printf("%.2f") does (see fmt1). */
193
+ export function fmtRate(x) {
194
+ const exact = Math.abs(x).toFixed(20);
195
+ const [ip, fp] = exact.split(".");
196
+ let s;
197
+ if (/^[0-9]{2}50{17}$/.test(fp)) {
198
+ let n = parseInt(ip, 10) * 100 + parseInt(fp.slice(0, 2), 10);
199
+ if (n % 2 !== 0)
200
+ n += 1;
201
+ s = (n / 100).toFixed(2);
202
+ }
203
+ else {
204
+ s = Math.abs(x).toFixed(2);
205
+ }
206
+ s = s.replace(/0+$/, "").replace(/\.$/, "");
207
+ return x < 0 ? "-" + s : s;
208
+ }
186
209
  export function fmt1(x) {
187
210
  const exact = Math.abs(x).toFixed(20);
188
211
  const [ip, fp] = exact.split(".");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rightcard-mcp",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "mcpName": "ai.rightcard/mcp",
5
5
  "description": "RightCard MCP — the card-selection oracle for agents. Which of your credit cards to use at any store, from verified data. No bank login.",
6
6
  "type": "module",