chase_rewards
Retrieve your Chase Ultimate Rewards points and cash back balance.
Instructions
Get Ultimate Rewards points and cash back balance.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:144-152 (registration)Registration of the chase_rewards tool in the ListToolsRequestSchema handler, defining the tool name, description, and empty input schema.
{ name: "chase_rewards", description: "Get Ultimate Rewards points and cash back balance.", inputSchema: { type: "object", properties: {}, }, }, - src/index.ts:362-373 (handler)Handler for the chase_rewards tool in the CallToolRequestSchema switch statement. It calls getRewards() and returns the result.
case "chase_rewards": { const result = await getRewards(); return { content: [ { type: "text", text: JSON.stringify(result), }, ], isError: !result.success, }; } - src/browser.ts:445-475 (helper)The actual implementation of getRewards(), which uses Playwright/Patchright to scrape Ultimate Rewards points balance, cash back balance, and tier from the Chase dashboard page.
export async function getRewards(): Promise<{ success: boolean; rewards?: RewardsInfo; error?: string }> { try { const p = await getPage(); await p.goto(`${CHASE_BASE_URL}/web/auth/dashboard`, { waitUntil: "networkidle" }); await p.waitForTimeout(2000); const rewards = await p.evaluate(() => { const pointsEl = document.querySelector('.points-balance, .ultimate-rewards, [data-testid="points"]'); const cashBackEl = document.querySelector('.cash-back-balance, [data-testid="cashback"]'); const tierEl = document.querySelector('.rewards-tier, .membership-level'); const pointsText = pointsEl?.textContent?.trim() || '0'; const cashBackText = cashBackEl?.textContent?.trim() || '0'; return { pointsBalance: parseInt(pointsText.replace(/[^0-9]/g, '')) || 0, cashBackBalance: parseFloat(cashBackText.replace(/[$,]/g, '')) || 0, pendingRewards: 0, tier: tierEl?.textContent?.trim() || undefined, }; }); return { success: true, rewards }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : "Failed to get rewards", }; } } - src/browser.ts:65-70 (schema)Type definition for RewardsInfo, the data structure returned by getRewards().
export interface RewardsInfo { pointsBalance: number; cashBackBalance: number; pendingRewards: number; tier?: string; }