lb_account_get
Retrieve your Listing Bureau account details including email, name, status, and wallet balance to manage your Amazon organic ranking campaigns.
Instructions
Get Listing Bureau account info (email, name, account status, wallet balance)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/account.tools.ts:7-51 (handler)The handler function that registers the 'lb_account_get' tool. It calls two API endpoints (/api/v1/account and /api/v1/wallet) in parallel, derives an account status (Active/Inactive/No funds), and returns a combined result with email, name, account_status, and wallet_balance.
export function registerAccountTools(server: McpServer, client: LBClient) { server.tool( "lb_account_get", "Get Listing Bureau account info (email, name, account status, wallet balance)", {}, { readOnlyHint: true }, async () => { try { const [accountRes, walletRes] = await Promise.all([ client.request<Account>("GET", "/api/v1/account", undefined, undefined, "lb_account_get"), client.request<WalletBalance>("GET", "/api/v1/wallet", undefined, undefined, "lb_account_get"), ]); const account = accountRes.data; const wallet = walletRes.data; // Derive display status let status: string; let note: string | undefined; if (account.account_status === "inactive") { status = "Inactive"; note = "Account disabled. Contact hello@listingbureau.com"; } else if ((wallet.balance_usd - wallet.held_usd) < 1) { status = "No funds"; } else { status = "Active"; } const result: Record<string, unknown> = { email: account.email, name: `${account.first_name} ${account.last_name}`.trim(), account_status: status, wallet_balance: { balance_usd: wallet.balance_usd, held_usd: wallet.held_usd, }, }; if (note) result.note = note; return formatResult(result); } catch (e) { return formatErrorResult(e); } }, ); - src/tools/account.tools.ts:7-51 (registration)Registration of 'lb_account_get' via server.tool() inside registerAccountTools(), which is called from src/index.ts:56.
export function registerAccountTools(server: McpServer, client: LBClient) { server.tool( "lb_account_get", "Get Listing Bureau account info (email, name, account status, wallet balance)", {}, { readOnlyHint: true }, async () => { try { const [accountRes, walletRes] = await Promise.all([ client.request<Account>("GET", "/api/v1/account", undefined, undefined, "lb_account_get"), client.request<WalletBalance>("GET", "/api/v1/wallet", undefined, undefined, "lb_account_get"), ]); const account = accountRes.data; const wallet = walletRes.data; // Derive display status let status: string; let note: string | undefined; if (account.account_status === "inactive") { status = "Inactive"; note = "Account disabled. Contact hello@listingbureau.com"; } else if ((wallet.balance_usd - wallet.held_usd) < 1) { status = "No funds"; } else { status = "Active"; } const result: Record<string, unknown> = { email: account.email, name: `${account.first_name} ${account.last_name}`.trim(), account_status: status, wallet_balance: { balance_usd: wallet.balance_usd, held_usd: wallet.held_usd, }, }; if (note) result.note = note; return formatResult(result); } catch (e) { return formatErrorResult(e); } }, ); - src/utils/response.ts:10-54 (helper)formatResult() helper used by the handler to format successful API responses as MCP CallToolResult.
export function formatResult(data: unknown): CallToolResult { const warnings: string[] = []; let cleaned: Record<string, unknown> | unknown = data; if (data && typeof data === "object") { const obj = { ...(data as Record<string, unknown>) }; // Top-level warning string if ("warning" in obj && typeof obj.warning === "string") { warnings.push(obj.warning); delete obj.warning; } // balance_warning object (independent of warning) if ("balance_warning" in obj && obj.balance_warning && typeof obj.balance_warning === "object") { const bw = obj.balance_warning as Record<string, unknown>; const parts: string[] = []; if (typeof bw.warning === "string" && bw.warning.trim()) parts.push(bw.warning); if (typeof bw.daily_cost_estimate === "number") parts.push(`Daily cost estimate: $${bw.daily_cost_estimate.toFixed(2)}`); if (typeof bw.balance === "number") parts.push(`Balance: $${bw.balance.toFixed(2)}`); if (typeof bw.days_remaining === "number") parts.push(`Days remaining: ${bw.days_remaining.toFixed(1)}`); if (parts.length > 0) warnings.push(parts.join(" | ")); delete obj.balance_warning; } cleaned = obj; } let text = JSON.stringify(cleaned, null, 2); for (const w of warnings) { text += `\n\n⚠️ Warning: ${w}`; } const notice = getUpdateNotice(); if (notice) { text += `\n\n${notice}`; } return { content: [{ type: "text", text }], }; } - src/utils/response.ts:81-86 (helper)formatErrorResult() helper used by the handler to format errors as MCP error results.
export function formatErrorResult(error: unknown): CallToolResult { return { content: [{ type: "text", text: formatError(error) }], isError: true, }; } - src/client/types.ts:48-93 (schema)Type definitions for Account and WalletBalance interfaces used by the tool handler.
export interface Account { email: string; first_name: string; last_name: string; account_status: string; // "active" | "inactive" } export interface Subscription { account_type: string; plan_label: string; use_wallet: boolean; subscription_fee: number; } export interface ServiceRates { atc: number; pgv: number; sfb_service_fee: number; sfb_fee_rate: number; sfb_formula: string; sfb_description: string; sfb_lock_days: number; server_date: string; [key: string]: unknown; } export interface BalanceWarning { warning: string; daily_cost_estimate: number; balance?: number; days_remaining?: number; } export interface CostSummary { total_estimated_cost: number | null; avg_daily_cost: number; num_scheduled_days: number | null; note: string; } // -- Wallet ------------------------------------------------------------------- export interface WalletBalance { balance_usd: number; held_usd: number; }