rightcard-mcp 0.1.11 → 0.1.13

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 CHANGED
@@ -58,8 +58,11 @@ function tieNote(winner, runnerUp, value, v) {
58
58
  if (v.mode === "cash" && centsPerPoint(smart, runnerUp) > 1.0) {
59
59
  return `${other} also earns ${rate} here. Its points can be worth more for travel, so try Points & miles.`;
60
60
  }
61
- const why = v.mode === "smart" ? "transfer flexibility" : "guaranteed cash back";
62
- return `${other} also earns ${rate} here. We picked ${win} for ${why}.`;
61
+ if (v.mode === "smart")
62
+ return `${other} also earns ${rate} here. We picked ${win} for transfer flexibility.`;
63
+ return winner.rewardCurrency === "cashback"
64
+ ? `${other} also earns ${rate} here. We picked ${win} for guaranteed cash back.`
65
+ : `${other} also earns ${rate} here. We picked ${win} because its rewards cash out for more.`;
63
66
  }
64
67
  if (premiumRank(winner) > premiumRank(runnerUp)) {
65
68
  return `${other} also earns ${rate} here. We picked ${win} for its purchase protection.`;
@@ -133,6 +136,12 @@ function appliedRate(card, category, subKey, merchantQuery, overrides, cardConfi
133
136
  winningOverride = o;
134
137
  winningConfig = null;
135
138
  }
139
+ else if (matches && o.bonusRate === rate && merchantQuery && o.merchant && winningOverride?.merchant
140
+ && closerBenefit(o.merchant, winningOverride.merchant, merchantQuery)) {
141
+ // Same rate, closer name: "Marriott" names Marriott, not TownePlace
142
+ // Suites by Marriott. Mirrors MerchantYieldEngine (Oct 21 2026).
143
+ winningOverride = o;
144
+ }
136
145
  }
137
146
  const spec = specFor(card);
138
147
  if (spec && spec.eligible.includes(category) && cardConfigs[card.id]?.has(category) && spec.bonusRate > rate) {
@@ -154,6 +163,20 @@ function appliedRate(card, category, subKey, merchantQuery, overrides, cardConfi
154
163
  }
155
164
  return { rate, override: winningOverride, configured: winningConfig };
156
165
  }
166
+ /** MerchantYieldEngine.benefitCloseness: exact name first, then the fewest
167
+ * words, the shortest, then A–Z. True when `a` is closer than `b`. */
168
+ function closerBenefit(a, b, query) {
169
+ const plain = (s) => s.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter((t) => t.length > 0).join(" ");
170
+ const key = (n) => {
171
+ const p = plain(n);
172
+ return [p === plain(query) ? 0 : 1, p.split(" ").length, [...p].length, p];
173
+ };
174
+ const x = key(a), y = key(b);
175
+ for (let i = 0; i < 3; i++)
176
+ if (x[i] !== y[i])
177
+ return x[i] < y[i];
178
+ return x[3] < y[3];
179
+ }
157
180
  function bestBaseCard(cards, category, subKey, merchantQuery, overrides, cardConfigs, v, now, strict, merchantType = null, usedUp = NO_CAPS) {
158
181
  const candidates = cards.map((card) => {
159
182
  const a = appliedRate(card, category, subKey, merchantQuery, overrides, cardConfigs, now, strict, merchantType, usedUp);
@@ -162,7 +185,22 @@ function bestBaseCard(cards, category, subKey, merchantQuery, overrides, cardCon
162
185
  if (candidates.length === 0)
163
186
  return null;
164
187
  const maxValue = Math.max(...candidates.map((c) => c.value));
188
+ // A card with NO spending limit on this rate beats one that stops paying it
189
+ // after $X (mirrors MerchantYieldEngine.rateIsCapped, Oct 22 2026).
190
+ const capped = (c) => {
191
+ if (c.override) {
192
+ return c.override.requiresActivation && !isPermanentMerchantBenefit(c.override, now) && rotatingCap(c.card.id) !== null;
193
+ }
194
+ const cap = standingCaps(c.card.id).find((x) => capCovers(x, category, !!c.configured));
195
+ if (!cap)
196
+ return false;
197
+ const after = cap.after ?? multiplier(c.card, "general", null);
198
+ return !usedUp.has(`${c.card.id}|std|${cap.id}`) && after < c.earn - 0.0001;
199
+ };
165
200
  const tied = candidates.filter((c) => Math.abs(c.value - maxValue) < 0.0001).sort((a, b) => {
201
+ const ca = capped(a), cb = capped(b);
202
+ if (ca !== cb)
203
+ return ca ? 1 : -1;
166
204
  const ra = optionalityRank(a.card, v), rb = optionalityRank(b.card, v);
167
205
  if (ra !== rb)
168
206
  return rb - ra;
@@ -174,7 +212,10 @@ function bestBaseCard(cards, category, subKey, merchantQuery, overrides, cardCon
174
212
  const w = tied[0];
175
213
  if (!w)
176
214
  return null;
177
- const note = tied.length >= 2 ? tieNote(w.card, tied[1].card, w.value, v) : null;
215
+ const note = tied.length < 2 ? null
216
+ : (!capped(w) && capped(tied[1]))
217
+ ? `${shortName(tied[1].card.displayName)} also earns ${formatPercent(w.value)} here, but only up to a spending limit. We picked ${shortName(w.card.displayName)} because it has no limit.`
218
+ : tieNote(w.card, tied[1].card, w.value, v);
178
219
  return { card: w.card, earn: w.earn, valueCents: w.value, override: w.override, configured: w.configured, tieNote: note };
179
220
  }
180
221
  function rateContext(card, earn, valueCents, override, configured, v, category, now, chosenCategoryCount, storeName = null) {
@@ -250,7 +291,9 @@ function rateContext(card, earn, valueCents, override, configured, v, category,
250
291
  lines.push(category === "general" ? `Base rate: ${valueStr}` : `Base ${cat} earn: ${valueStr}`);
251
292
  }
252
293
  }
253
- let caption = configured ? "your bonus category · value per $1" : override ? "rotating bonus · value per $1" : "value per $1";
294
+ let caption = configured ? "your bonus category · value per $1"
295
+ : override && isPermanentMerchantBenefit(override, now) ? "card benefit · value per $1"
296
+ : override ? "rotating bonus · value per $1" : "value per $1";
254
297
  let valueMath = null;
255
298
  let valueMathShort = null;
256
299
  if (pointsAbove) {
@@ -297,13 +340,16 @@ export function recommend(input) {
297
340
  // full wallet answers (works on the merchant's site) and the warehouse
298
341
  // caveat carries the register story. Unknown (null) network never gates.
299
342
  const accepted = input.acceptedNetworks;
343
+ let refusedAtRegister = [];
300
344
  if (accepted && accepted.size > 0) {
301
345
  const eligible = cards.filter((c) => {
302
346
  const net = c.network?.toLowerCase();
303
347
  return net == null || accepted.has(net);
304
348
  });
305
- if (eligible.length > 0)
349
+ if (eligible.length > 0) {
350
+ refusedAtRegister = cards.filter((c) => !eligible.includes(c));
306
351
  cards = eligible;
352
+ }
307
353
  }
308
354
  const v = withPooling(input.valuation, cards);
309
355
  const cardConfigs = input.cardConfigs ?? {};
@@ -316,6 +362,14 @@ export function recommend(input) {
316
362
  return null;
317
363
  const ctx = rateContext(w.card, w.earn, w.valueCents, w.override, w.configured, v, category, now, cardConfigs[w.card.id]?.size ?? 0, merchantName);
318
364
  ctx.tieNote = w.tieNote;
365
+ // A better card set aside because the register won't take it: say so
366
+ // (mirrors MerchantYieldEngine, Oct 22 2026).
367
+ if (merchantName && refusedAtRegister.length > 0) {
368
+ const refused = bestBaseCard(refusedAtRegister, category, subKey, query, overrides, cardConfigs, v, now, strict, input.merchantType ?? null);
369
+ if (refused && refused.valueCents > w.valueCents + 0.0001) {
370
+ ctx.reason = `${w.card.displayName} is your best card that works at the ${merchantName} register: ${formatPercent(w.valueCents)} per dollar.`;
371
+ }
372
+ }
319
373
  // Rotating limit (mirrors MerchantYieldEngine.capInfo): re-answer without
320
374
  // this card's capped quarter rows to name who wins after the limit.
321
375
  const o = w.override;
package/dist/model.js CHANGED
@@ -199,14 +199,14 @@ export function merchantFromRow(r) {
199
199
  export function exclusionCaveat(m) {
200
200
  switch (m.merchantType) {
201
201
  case "superstore":
202
- return `${m.displayName} usually codes as a superstore (not a supermarket), so grocery bonuses often don't post. This is your best guaranteed card.`;
202
+ return `Card rewards usually don't count ${m.displayName} as a grocery store, so a grocery bonus often won't apply. This card earns its rate here either way.`;
203
203
  case "warehouse_club": {
204
- const base = `${m.displayName} codes as a warehouse club, so category bonuses usually don't post. This is your best guaranteed card.`;
204
+ const base = `Card rewards usually don't count ${m.displayName} as a grocery store or any bonus category, so most bonuses won't apply. This card earns its rate here either way.`;
205
205
  // Costco alone is also NETWORK-locked: warehouse registers take Visa
206
206
  // only (Costco.com takes other networks). Mirrors the Swift engine —
207
207
  // keep both sides identical or the parity gate fails.
208
208
  if (m.displayName.toLowerCase().includes("costco")) {
209
- return base + " Note: Costco warehouses take Visa only at the register; other networks work on Costco.com.";
209
+ return "Costco only takes Visa at the register. Other cards work on Costco.com. " + base;
210
210
  }
211
211
  return base;
212
212
  }
package/dist/tools.js CHANGED
@@ -73,7 +73,7 @@ export function buildServer(getCatalog) {
73
73
  wallet: z.array(z.string()).min(1).describe("Card ids the person holds (from search_cards)."),
74
74
  merchant: z.string().optional().describe("Store name, e.g. 'Costco', 'Whole Foods', 'Uber'. Use this OR category."),
75
75
  category: CategorySchema.optional().describe("Spend category when there is no specific store."),
76
- valuation: z.enum(["cash", "points"]).default("cash").describe("'cash' counts every point at 1¢ (default). 'points' values points per program at conservative travel values."),
76
+ valuation: z.enum(["cash", "points"]).default("cash").describe("'cash' counts each point at up to 1¢, and hotel/airline points at their lower value (default). 'points' values points per program at conservative travel values."),
77
77
  on: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional().describe("Date (YYYY-MM-DD, UTC) for rotating windows; defaults to today."),
78
78
  chosen_categories: z.record(z.string(), z.array(CategorySchema)).optional().describe("For choose-your-category cards (Citi Custom Cash, BofA Customized, Venmo): card id → the categories the person set."),
79
79
  },
@@ -194,7 +194,7 @@ export function buildServer(getCatalog) {
194
194
  return { contents: [{ uri: uri.href, mimeType: "application/json", text: JSON.stringify(catalog.cards.map(cardSummary)) }] };
195
195
  });
196
196
  server.registerResource("valuation", "rightcard://valuation", { title: "How points are valued", mimeType: "application/json" }, async (uri) => ({
197
- contents: [{ uri: uri.href, mimeType: "application/json", text: JSON.stringify({ mode_cash: "every point = 1¢", mode_points_travel_cents_per_point: TRAVEL_CPP, source: "Conservative blended baselines (The Points Guy, Bankrate, Frequent Miler), Q2 2026." }) }],
197
+ contents: [{ uri: uri.href, mimeType: "application/json", text: JSON.stringify({ mode_cash: "each point = min(1¢, its points value)", mode_points_travel_cents_per_point: TRAVEL_CPP, source: "Conservative blended baselines (The Points Guy, Bankrate, Frequent Miler), Q2 2026." }) }],
198
198
  }));
199
199
  server.registerPrompt("which-card", {
200
200
  title: "Which card should I use here?",
package/dist/valuation.js CHANGED
@@ -155,7 +155,10 @@ export function effectiveProgram(v, card) {
155
155
  return v.pooledPrograms[card.id] ?? inferProgram(card.issuer, card.id, card.rewardCurrency);
156
156
  }
157
157
  export function centsPerPoint(v, card) {
158
- return v.mode === "cash" ? 1.0 : TRAVEL_CPP[effectiveProgram(v, card)];
158
+ // Cash mode: at most 1¢, and never more than the program is worth
159
+ // (hotel/airline points under a cent). Mirrors RewardValuation.centsPerPoint.
160
+ const program = TRAVEL_CPP[effectiveProgram(v, card)];
161
+ return v.mode === "cash" ? Math.min(1.0, program) : program;
159
162
  }
160
163
  export function valuesPointsAboveCash(v, card) {
161
164
  return centsPerPoint(v, card) !== 1.0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rightcard-mcp",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
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",