rightcard-mcp 0.1.17 → 0.1.19
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.js +53 -8
- package/dist/model.d.ts +3 -0
- package/dist/model.js +9 -0
- package/dist/tools.js +6 -5
- package/dist/valuation.d.ts +1 -1
- package/dist/valuation.js +9 -3
- package/package.json +1 -1
package/dist/engine.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Mirrors MerchantYieldEngine (BASE-RATE mode only — offers live on the phone, never here).
|
|
2
|
-
import { CATEGORY_DISPLAY, capCovers, categoryStoreTypes, isPermanentMerchantBenefit, multiplier, overrideIsActive, rotatingCap, standingCaps, storeTypes, } from "./model.js";
|
|
2
|
+
import { ALL_CATEGORIES, CATEGORY_DISPLAY, capCovers, categoryStoreTypes, isPermanentMerchantBenefit, multiplier, requiresApplePay, overrideIsActive, rotatingCap, standingCaps, storeTypes, } from "./model.js";
|
|
3
3
|
import { merchantMatchesCoBrandBenefit, offerMatches } from "./matching.js";
|
|
4
4
|
import { specFor } from "./configurable.js";
|
|
5
5
|
import { basisLabel, cashOutCPP, centsPerPoint, earnUnitLabel, effectiveProgram, fmt1, fmtRate, valuesPointsAboveCash, withPooling, } from "./valuation.js";
|
|
@@ -56,13 +56,39 @@ function optionalityRank(card, v) {
|
|
|
56
56
|
}
|
|
57
57
|
const PREMIUM_NEEDLES = [
|
|
58
58
|
"sapphire reserve", "sapphire preferred", "venture x", "platinum card",
|
|
59
|
-
"gold card", "amex gold", "strata premier", "citi premier", "prestige",
|
|
59
|
+
"gold card", "amex gold", "strata premier", "strata elite", "citi premier", "prestige",
|
|
60
60
|
"ritz-carlton", "aspire", "altitude reserve", "brilliant",
|
|
61
61
|
];
|
|
62
|
+
/** Mirrors MerchantYieldEngine.benefitCategoryFits (Nov 10 2026): a store
|
|
63
|
+
* benefit stored under a category other than "general" pays only on that
|
|
64
|
+
* category there (Costco Anywhere Visa's 5% on gas at Costco). */
|
|
65
|
+
/** Mirrors MerchantYieldEngine.sharesCategoryCap: a category-scoped store
|
|
66
|
+
* benefit shares that category's standing cap (Costco Visa 5% + 4% gas). */
|
|
67
|
+
function sharesCategoryCap(o, now) {
|
|
68
|
+
if (!o)
|
|
69
|
+
return true;
|
|
70
|
+
const key = o.category.trim().toLowerCase();
|
|
71
|
+
return isPermanentMerchantBenefit(o, now) && key !== "general" && ALL_CATEGORIES.includes(key);
|
|
72
|
+
}
|
|
73
|
+
function benefitCategoryFits(o, category) {
|
|
74
|
+
const key = o.category.trim().toLowerCase();
|
|
75
|
+
if (key === "general" || !ALL_CATEGORIES.includes(key))
|
|
76
|
+
return true;
|
|
77
|
+
return key === category;
|
|
78
|
+
}
|
|
62
79
|
function premiumRank(card) {
|
|
63
80
|
const n = card.displayName.toLowerCase();
|
|
64
81
|
return PREMIUM_NEEDLES.some((x) => n.includes(x)) ? 1 : 0;
|
|
65
82
|
}
|
|
83
|
+
/** Mirrors MerchantYieldEngine.premiumFeeOrder (Nov 10 2026): between two
|
|
84
|
+
* premium cards, the higher annual fee wins; an unverified fee counts lowest;
|
|
85
|
+
* null = this rule doesn't decide. */
|
|
86
|
+
function premiumFeeOrder(a, b) {
|
|
87
|
+
if (premiumRank(a) !== 1 || premiumRank(b) !== 1)
|
|
88
|
+
return null;
|
|
89
|
+
const fa = a.annualFee ?? -1, fb = b.annualFee ?? -1;
|
|
90
|
+
return fa === fb ? null : fa > fb;
|
|
91
|
+
}
|
|
66
92
|
function tieNote(winner, runnerUp, value, v) {
|
|
67
93
|
const rate = formatPercent(value);
|
|
68
94
|
const other = shortName(runnerUp.displayName);
|
|
@@ -86,6 +112,9 @@ function tieNote(winner, runnerUp, value, v) {
|
|
|
86
112
|
if (premiumRank(winner) > premiumRank(runnerUp)) {
|
|
87
113
|
return `${other} also earns ${rate} here. We picked ${win} for its purchase protection.`;
|
|
88
114
|
}
|
|
115
|
+
if (premiumFeeOrder(winner, runnerUp) === true) {
|
|
116
|
+
return `${other} also earns ${rate} here. We picked ${win} because its higher annual fee comes with more benefits.`;
|
|
117
|
+
}
|
|
89
118
|
return `${other} also earns ${rate} here. Either one works.`;
|
|
90
119
|
}
|
|
91
120
|
const PORTAL_BONUSES = [
|
|
@@ -137,7 +166,7 @@ function appliedRate(card, category, subKey, merchantQuery, overrides, cardConfi
|
|
|
137
166
|
if (!merchantQuery || merchantQuery === "")
|
|
138
167
|
continue;
|
|
139
168
|
matches = isPermanentMerchantBenefit(o, now)
|
|
140
|
-
? merchantMatchesCoBrandBenefit(o.merchant, merchantQuery)
|
|
169
|
+
? merchantMatchesCoBrandBenefit(o.merchant, merchantQuery) && benefitCategoryFits(o, category)
|
|
141
170
|
: offerMatches(o.merchant, merchantQuery, strict);
|
|
142
171
|
}
|
|
143
172
|
else if (storeTypes(o)) {
|
|
@@ -180,13 +209,14 @@ function appliedRate(card, category, subKey, merchantQuery, overrides, cardConfi
|
|
|
180
209
|
winningOverride = null;
|
|
181
210
|
}
|
|
182
211
|
// A standing cap marked used up pays its "after" rate (mirrors the app).
|
|
183
|
-
if (
|
|
212
|
+
if (sharesCategoryCap(winningOverride, now) && usedUp.size > 0) {
|
|
184
213
|
for (const cap of standingCaps(card.id)) {
|
|
185
214
|
if (usedUp.has(`${card.id}|std|${cap.id}`) && capCovers(cap, category, !!winningConfig)) {
|
|
186
215
|
const after = cap.after ?? multiplier(card, "general", null);
|
|
187
216
|
if (rate > after) {
|
|
188
217
|
rate = after;
|
|
189
218
|
winningConfig = null;
|
|
219
|
+
winningOverride = null;
|
|
190
220
|
}
|
|
191
221
|
}
|
|
192
222
|
}
|
|
@@ -218,7 +248,7 @@ function bestBaseCard(cards, category, subKey, merchantQuery, overrides, cardCon
|
|
|
218
248
|
// A card with NO spending limit on this rate beats one that stops paying it
|
|
219
249
|
// after $X (mirrors MerchantYieldEngine.rateIsCapped, Oct 22 2026).
|
|
220
250
|
const capped = (c) => {
|
|
221
|
-
if (c.override) {
|
|
251
|
+
if (c.override && !sharesCategoryCap(c.override, now)) {
|
|
222
252
|
return c.override.requiresActivation && !isPermanentMerchantBenefit(c.override, now) && rotatingCap(c.card.id) !== null;
|
|
223
253
|
}
|
|
224
254
|
const cap = standingCaps(c.card.id).find((x) => capCovers(x, category, !!c.configured));
|
|
@@ -237,6 +267,9 @@ function bestBaseCard(cards, category, subKey, merchantQuery, overrides, cardCon
|
|
|
237
267
|
const pa = premiumRank(a.card), pb = premiumRank(b.card);
|
|
238
268
|
if (pa !== pb)
|
|
239
269
|
return pb - pa;
|
|
270
|
+
const fee = premiumFeeOrder(a.card, b.card);
|
|
271
|
+
if (fee !== null)
|
|
272
|
+
return fee ? -1 : 1;
|
|
240
273
|
return a.card.displayName.localeCompare(b.card.displayName, "en", { sensitivity: "accent" });
|
|
241
274
|
});
|
|
242
275
|
const w = tied[0];
|
|
@@ -252,9 +285,12 @@ function rateContext(card, earn, valueCents, override, configured, v, category,
|
|
|
252
285
|
const valueStr = formatPercent(valueCents);
|
|
253
286
|
// "everyday purchases", not "general" — mirrors SpendCategory.inSentence
|
|
254
287
|
// in the app (Oct 8 2026).
|
|
255
|
-
|
|
288
|
+
// "online shopping" too: "Rate on online: 2%" read as a typo (Oct 31 2026).
|
|
289
|
+
const cat = category === "general" ? "everyday purchases"
|
|
290
|
+
: category === "online" ? "online shopping" : CATEGORY_DISPLAY[category].toLowerCase();
|
|
256
291
|
const disp = CATEGORY_DISPLAY[category];
|
|
257
292
|
let reason;
|
|
293
|
+
let applePayCaveat = null;
|
|
258
294
|
const lines = [];
|
|
259
295
|
const pointsAbove = valuesPointsAboveCash(v, card) && card.rewardCurrency !== null;
|
|
260
296
|
if (configured) {
|
|
@@ -273,7 +309,15 @@ function rateContext(card, earn, valueCents, override, configured, v, category,
|
|
|
273
309
|
// A store-type quarter reads like a merchant one: "at AMC Theatres".
|
|
274
310
|
const scope = override.merchant ? `at ${override.merchant}`
|
|
275
311
|
: (storeTypes(override) && storeName ? `at ${storeName}` : cat);
|
|
276
|
-
if (isPermanentMerchantBenefit(override, now)) {
|
|
312
|
+
if (isPermanentMerchantBenefit(override, now) && override.merchant && requiresApplePay(override)) {
|
|
313
|
+
// Mirrors the Swift engine (Nov 10 2026): Apple Card's 3% at Uber pays
|
|
314
|
+
// only through Apple Pay, so the reason, the line and the caveat say so.
|
|
315
|
+
const plain = formatPercent(multiplier(card, category) * centsPerPoint(v, card));
|
|
316
|
+
reason = `${card.displayName} earns ${valueStr} ${scope} when you pay with Apple Pay, the most in your wallet here.`;
|
|
317
|
+
lines.push(`${valueStr} ${scope} with Apple Pay · card benefit`);
|
|
318
|
+
applePayCaveat = `Pay with Apple Pay to get ${valueStr}. Paid any other way, ${card.displayName} earns ${plain} here.`;
|
|
319
|
+
}
|
|
320
|
+
else if (isPermanentMerchantBenefit(override, now)) {
|
|
277
321
|
reason = `${card.displayName} earns ${valueStr} ${scope}, the most in your wallet here.`;
|
|
278
322
|
lines.push(`${valueStr} ${scope} · card benefit`);
|
|
279
323
|
}
|
|
@@ -338,6 +382,7 @@ function rateContext(card, earn, valueCents, override, configured, v, category,
|
|
|
338
382
|
cardId: card.id, cardName: card.displayName, rateDisplay: valueStr, valueCaption: caption, reason,
|
|
339
383
|
breakdownLines: lines, loggableRate: valueCents, valueMath, valueMathShort,
|
|
340
384
|
valuationBasis: basisLabel(v, card), valuationMode: v.mode, tieNote: null, portalNote: null, subcategoryBreakdown: [],
|
|
385
|
+
...(applePayCaveat ? { caveat: applePayCaveat } : {}),
|
|
341
386
|
};
|
|
342
387
|
}
|
|
343
388
|
function subcategoryBreakdown(cards, category, overrides, cardConfigs, v, now) {
|
|
@@ -436,7 +481,7 @@ export function recommend(input) {
|
|
|
436
481
|
? `After that: ${next.card.displayName}, ${formatPercent(next.valueCents)}.` : null;
|
|
437
482
|
}
|
|
438
483
|
// Standing category cap (mirrors MerchantYieldEngine.standingCapInfo).
|
|
439
|
-
if (
|
|
484
|
+
if (sharesCategoryCap(o, now)) {
|
|
440
485
|
const chosen = !!w.configured;
|
|
441
486
|
const capRow = standingCaps(w.card.id).find((c) => capCovers(c, category, chosen));
|
|
442
487
|
const afterEarn = capRow ? (capRow.after ?? multiplier(w.card, "general", null)) : 0;
|
package/dist/model.d.ts
CHANGED
|
@@ -77,6 +77,9 @@ export declare function overrideFromRow(r: any): Override;
|
|
|
77
77
|
* golden fixture is exported at noon UTC so parity is unaffected. */
|
|
78
78
|
export declare function utcDay(now: Date): string;
|
|
79
79
|
export declare function overrideIsActive(o: Override, now: Date): boolean;
|
|
80
|
+
/** SupabaseOverride.requiresApplePay: a store benefit that pays only through
|
|
81
|
+
* Apple Pay (Apple Card at Uber; Nov 10 2026). The label says so. */
|
|
82
|
+
export declare function requiresApplePay(o: Override): boolean;
|
|
80
83
|
/** SupabaseOverride.isPermanentMerchantBenefit: merchant-scoped, no activation, ends > 2 years out. */
|
|
81
84
|
export declare function isPermanentMerchantBenefit(o: Override, now: Date): boolean;
|
|
82
85
|
export interface Merchant {
|
package/dist/model.js
CHANGED
|
@@ -192,6 +192,11 @@ export function overrideIsActive(o, now) {
|
|
|
192
192
|
const today = utcDay(now);
|
|
193
193
|
return today >= o.startDate && today <= o.endDate;
|
|
194
194
|
}
|
|
195
|
+
/** SupabaseOverride.requiresApplePay: a store benefit that pays only through
|
|
196
|
+
* Apple Pay (Apple Card at Uber; Nov 10 2026). The label says so. */
|
|
197
|
+
export function requiresApplePay(o) {
|
|
198
|
+
return /apple pay/i.test(o.label ?? "");
|
|
199
|
+
}
|
|
195
200
|
/** SupabaseOverride.isPermanentMerchantBenefit: merchant-scoped, no activation, ends > 2 years out. */
|
|
196
201
|
export function isPermanentMerchantBenefit(o, now) {
|
|
197
202
|
if (!o.merchant || o.merchant === "" || o.requiresActivation)
|
|
@@ -229,6 +234,10 @@ export function exclusionCaveat(m) {
|
|
|
229
234
|
// warehouse's Visa-only registers; their own MCC stays honest (no
|
|
230
235
|
// "bonuses don't post" clause). Mirrors the Swift engine (Sep 2026).
|
|
231
236
|
if (acceptedNetworksAtRegister(m) !== null) {
|
|
237
|
+
// At the pump, mirrors the Swift engine (Nov 10 2026).
|
|
238
|
+
if (m.category === "gas" || m.merchantType === "gas") {
|
|
239
|
+
return "Costco gas stations take Visa only. This is your best card that works at the pump.";
|
|
240
|
+
}
|
|
232
241
|
return "Costco takes Visa only at the register. This is your best card that works in-store. Other networks work on Costco.com.";
|
|
233
242
|
}
|
|
234
243
|
return null;
|
package/dist/tools.js
CHANGED
|
@@ -42,11 +42,12 @@ function shapeAnswer(r, merchant, mode, unverified) {
|
|
|
42
42
|
const caveats = [];
|
|
43
43
|
if (r.walletRefusedAtRegister && r.caveat)
|
|
44
44
|
caveats.push(r.caveat);
|
|
45
|
-
else if (merchant)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
else if (merchant && exclusionCaveat(merchant))
|
|
46
|
+
caveats.push(exclusionCaveat(merchant));
|
|
47
|
+
// The engine's own note (Apple Pay-only store benefits), as in the app:
|
|
48
|
+
// the directory's caveat first, else the engine's.
|
|
49
|
+
else if (r.caveat)
|
|
50
|
+
caveats.push(r.caveat);
|
|
50
51
|
if (r.capLimit)
|
|
51
52
|
caveats.push(r.capLimit + (r.afterLimit ? ` ${r.afterLimit}` : ""));
|
|
52
53
|
if (r.tieNote)
|
package/dist/valuation.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CreditCard } from "./model.js";
|
|
2
2
|
export type ValuationMode = "cash" | "smart";
|
|
3
|
-
export type RewardProgram = "cash" | "amexMR" | "chaseUR" | "capOneMiles" | "citiTYP" | "wellsFargo" | "bilt" | "tdRewards" | "scenePlus" | "rbcAvion" | "bmoRewards" | "hyatt" | "marriott" | "ihg" | "choice" | "hilton" | "delta" | "united" | "american" | "southwest" | "jetBlue" | "alaska" | "avios" | "aeroplan" | "fixedValue" | "genericPoints" | "genericMiles";
|
|
3
|
+
export type RewardProgram = "cash" | "amexMR" | "chaseUR" | "capOneMiles" | "citiTYP" | "wellsFargo" | "bilt" | "tdRewards" | "scenePlus" | "rbcAvion" | "bmoRewards" | "hyatt" | "marriott" | "ihg" | "choice" | "wyndham" | "hilton" | "delta" | "united" | "american" | "southwest" | "jetBlue" | "alaska" | "avios" | "aeroplan" | "fixedValue" | "genericPoints" | "genericMiles";
|
|
4
4
|
export declare const PROGRAM_DISPLAY: Record<RewardProgram, string>;
|
|
5
5
|
export declare const TRAVEL_CPP: Record<RewardProgram, number>;
|
|
6
6
|
/** RewardProgram.cashOutCPP */
|
package/dist/valuation.js
CHANGED
|
@@ -2,7 +2,7 @@ export const PROGRAM_DISPLAY = {
|
|
|
2
2
|
cash: "Cash back", amexMR: "Amex Membership Rewards", chaseUR: "Chase Ultimate Rewards",
|
|
3
3
|
capOneMiles: "Capital One miles", citiTYP: "Citi ThankYou Points", wellsFargo: "Wells Fargo Rewards",
|
|
4
4
|
bilt: "Bilt Rewards", tdRewards: "TD Rewards", scenePlus: "Scene+", rbcAvion: "RBC Avion points",
|
|
5
|
-
bmoRewards: "BMO Rewards", hyatt: "World of Hyatt", marriott: "Marriott Bonvoy", ihg: "IHG One Rewards", choice: "Choice Privileges",
|
|
5
|
+
bmoRewards: "BMO Rewards", hyatt: "World of Hyatt", marriott: "Marriott Bonvoy", ihg: "IHG One Rewards", choice: "Choice Privileges", wyndham: "Wyndham Rewards",
|
|
6
6
|
hilton: "Hilton Honors", delta: "Delta SkyMiles", united: "United MileagePlus",
|
|
7
7
|
american: "American AAdvantage", southwest: "Southwest Rapid Rewards", jetBlue: "JetBlue TrueBlue",
|
|
8
8
|
alaska: "Atmos Rewards", avios: "British Airways Avios", aeroplan: "Air Canada Aeroplan",
|
|
@@ -13,7 +13,7 @@ export const TRAVEL_CPP = {
|
|
|
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
15
|
tdRewards: 0.5, scenePlus: 1.0, rbcAvion: 1.8, bmoRewards: 0.6, // Oct 2026 CA medians (the MCP serves US cards only)
|
|
16
|
-
hyatt: 1.4, marriott: 0.7, ihg: 0.5, choice: 0.6, hilton: 0.4,
|
|
16
|
+
hyatt: 1.4, marriott: 0.7, ihg: 0.5, choice: 0.6, wyndham: 0.5, hilton: 0.4, // wyndham: Nov 11 2026 median 0.585
|
|
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,
|
|
19
19
|
};
|
|
@@ -49,6 +49,10 @@ export function inferProgram(issuer, id, currency) {
|
|
|
49
49
|
// which valued these hotel points at 1.5¢ (mirrors Swift, Sep 24 2026).
|
|
50
50
|
if (has("choice"))
|
|
51
51
|
return "choice";
|
|
52
|
+
// Wyndham Rewards (Barclays): no needle matched, so it fell to the generic
|
|
53
|
+
// 2¢ and the Earner Plus 4x read "8%" (mirrors Swift, Nov 11 2026).
|
|
54
|
+
if (has("wyndham"))
|
|
55
|
+
return "wyndham";
|
|
52
56
|
if (has("delta", "skymiles"))
|
|
53
57
|
return "delta";
|
|
54
58
|
if (has("united", "mileageplus"))
|
|
@@ -131,7 +135,9 @@ export function pooledPrograms(wallet) {
|
|
|
131
135
|
const isTYPUnlock = (c) => {
|
|
132
136
|
const s = hay(c);
|
|
133
137
|
const citi = s.includes("citi") || s.includes("thankyou") || s.includes("strata");
|
|
134
|
-
|
|
138
|
+
// Strata Elite transfers ThankYou points too (mirrors Swift, Nov 11 2026).
|
|
139
|
+
return citi && (s.includes("premier") || s.includes("prestige")
|
|
140
|
+
|| s.includes("strata elite") || s.includes("strata_elite"));
|
|
135
141
|
};
|
|
136
142
|
if (wallet.some(isTYPUnlock)) {
|
|
137
143
|
for (const c of wallet) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rightcard-mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
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",
|