update_price_alert
Update an existing price alert by modifying thresholds or toggling its active state. Pass null to clear thresholds (premium only).
Instructions
Update an existing price alert. Pass null for a threshold to clear it (Premium only - free users must keep exactly one direction). isActive toggles enable/disable without deleting. Requires IWMM_API_KEY.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Alert ID from list_price_alerts. | |
| increasePct | No | ||
| decreasePct | No | ||
| isActive | No |
Implementation Reference
- src/tools/alerts.ts:30-41 (handler)The tool definition and handler for update_price_alert. It accepts id, optional increasePct/decreasePct (nullable to clear), and optional isActive. Handler sends a PATCH request to /api/v1/price-alerts/:id.
export const updateAlertTool = { name: "update_price_alert", description: "Update an existing price alert. Pass null for a threshold to clear it (Premium only - free users must keep exactly one direction). isActive toggles enable/disable without deleting. Requires IWMM_API_KEY.", inputSchema: z.object({ id: z.string().describe("Alert ID from list_price_alerts."), increasePct: z.number().min(0.01).nullable().optional(), decreasePct: z.number().min(0.01).nullable().optional(), isActive: z.boolean().optional(), }), handler: ({ id, ...patch }: { id: string } & Record<string, unknown>) => apiFetch({ path: `/api/v1/price-alerts/${encodeURIComponent(id)}`, method: "PATCH", body: patch, authenticated: true }), - src/tools/alerts.ts:34-38 (schema)Zod input schema for update_price_alert: id (required string), increasePct/decreasePct (nullable optional numbers), isActive (optional boolean).
inputSchema: z.object({ id: z.string().describe("Alert ID from list_price_alerts."), increasePct: z.number().min(0.01).nullable().optional(), decreasePct: z.number().min(0.01).nullable().optional(), isActive: z.boolean().optional(), - src/tools/index.ts:81-81 (registration)The updateAlertTool is registered in the tools array at line 81, making it available for MCP invocation.
updateAlertTool, - src/tools/index.ts:90-92 (registration)toolsByName maps tool names (including 'update_price_alert') to their ToolDefinition for runtime lookup.
export const toolsByName: Record<string, ToolDefinition> = Object.fromEntries( tools.map((t) => [t.name, t]), ); - src/api-client.ts:26-67 (helper)apiFetch helper used by the handler to make authenticated HTTP PATCH 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; }