get_cash_flow
Retrieves net cash flow from buy and sell transactions to track your financial position.
Instructions
Get the user's cash flow (money in vs money out from BUY/SELL transactions). Premium-gated. Requires IWMM_API_KEY.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/portfolio.ts:35-41 (handler)The `getCashFlowTool` object defines the tool's handler function, which calls `apiFetch({ path: '/api/v1/portfolio/cash-flow', authenticated: true })` to fetch cash flow data from the IWMM API.
export const getCashFlowTool = { name: "get_cash_flow", description: "Get the user's cash flow (money in vs money out from BUY/SELL transactions). Premium-gated. Requires IWMM_API_KEY.", inputSchema: z.object({}), handler: () => apiFetch({ path: "/api/v1/portfolio/cash-flow", authenticated: true }), }; - src/tools/portfolio.ts:39-39 (schema)The input schema for get_cash_flow uses Zod validation with an empty object (`z.object({})`), meaning the tool accepts no parameters.
inputSchema: z.object({}), - src/tools/index.ts:74-77 (registration)The tool is registered in the `tools` array (line 74) and also accessible via `toolsByName` (line 90-92), which maps tool names to their definitions.
getCashFlowTool, getRealizedGainsTool, getPortfolioBreakdownTool, refreshPortfolioTool, - src/api-client.ts:26-67 (helper)The `apiFetch` helper function used by the handler to make authenticated HTTP requests to the IWMM API. It adds the Authorization header when `authenticated: true`.
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; }