list_inventory
Fetch and view your MTG card inventory with paginated results, including quantities, prices, and metadata.
Instructions
List the authenticated user's card inventory, paginated. Requires IWMM_API_KEY. Returns cards with quantities, prices, and metadata.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page | No | ||
| limit | No |
Implementation Reference
- src/tools/inventory.ts:18-23 (handler)The handler function that executes the list_inventory tool logic. Calls apiFetch with GET /api/v1/inventory and passes query params (page, limit). Requires authentication via IWMM_API_KEY.
handler: (input: Record<string, unknown>) => apiFetch({ path: "/api/v1/inventory", query: input as Record<string, string | number | undefined>, authenticated: true, }), - src/tools/inventory.ts:14-17 (schema)Input schema for list_inventory: optional page (int >= 1) and limit (int 1-100) with Zod validation.
inputSchema: z.object({ page: z.number().int().min(1).optional(), limit: z.number().int().min(1).max(100).optional(), }), - src/tools/index.ts:48-92 (registration)The listInventoryTool is registered in the tools array at line 59 and also indexed by name in toolsByName at lines 90-92.
export const tools: ToolDefinition[] = [ // Read-only (no auth) searchCardsTool, getCardTool, getCardPricesTool, getCardPriceHistoryTool, searchSetsTool, getSetTool, listSetCardsTool, getSealedProductsTool, // Inventory (auth) listInventoryTool, getInventoryQuantitiesTool, addInventoryTool, updateInventoryTool, removeInventoryTool, // Transactions (auth) listTransactionsTool, recordTransactionTool, updateTransactionTool, deleteTransactionTool, getCostBasisTool, // Portfolio (auth; most are Premium-gated) getPortfolioSummaryTool, getPortfolioHistoryTool, getCardPerformanceTool, getCashFlowTool, getRealizedGainsTool, getPortfolioBreakdownTool, refreshPortfolioTool, // Price alerts (auth) listAlertsTool, createAlertTool, updateAlertTool, deleteAlertTool, // Notifications (auth) listNotificationsTool, getUnreadCountTool, markNotificationReadTool, markAllNotificationsReadTool, ]; export const toolsByName: Record<string, ToolDefinition> = Object.fromEntries( tools.map((t) => [t.name, t]), ); - src/api-client.ts:26-67 (helper)The apiFetch helper used by the handler to make authenticated HTTP requests to the IWMM API.
export async function apiFetch<T = unknown>(req: ApiRequest): Promise<T> { const url = new URL(req.path, config.baseUrl); if (req.query) { for (const [k, v] of Object.entries(req.query)) { if (v !== undefined && v !== null && v !== "") { url.searchParams.set(k, String(v)); } } } const headers: Record<string, string> = { Accept: "application/json", "User-Agent": "iwantmymtg-mcp/0.0.1", }; if (req.authenticated) { const { requireApiKey } = await import("./config.js"); headers["Authorization"] = `Bearer ${requireApiKey()}`; } if (req.body !== undefined) { headers["Content-Type"] = "application/json"; } const res = await fetch(url, { method: req.method ?? "GET", headers, body: req.body !== undefined ? JSON.stringify(req.body) : undefined, }); if (!res.ok) { const text = await res.text(); throw new ApiError(res.status, text, { limit: res.headers.get("X-RateLimit-Limit") ?? undefined, remaining: res.headers.get("X-RateLimit-Remaining") ?? undefined, reset: res.headers.get("X-RateLimit-Reset") ?? undefined, }); } if (res.status === 204) return undefined as T; return (await res.json()) as T; }