rr_get_sku_health
Analyze SKU-level inventory health by identifying risk counts and alert counts to prevent stockouts and optimize inventory management.
Instructions
Quick SKU-level health summary (risk counts, alert counts)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:86-100 (handler)The generic tool request handler passes the request to callApi. The specific tool name 'rr_get_sku_health' is passed to the remote API.
server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; try { const result = await callApi(name, (args as Record<string, unknown>) || {}); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; } catch (error) { const message = error instanceof Error ? error.message : String(error); return { content: [{ type: 'text', text: `Error: ${message}` }], isError: true, }; } }); - src/index.ts:42-42 (registration)Definition of the tool in the TOOLS array.
{ name: 'rr_get_sku_health', description: 'Quick SKU-level health summary (risk counts, alert counts)', inputSchema: { type: 'object' as const, properties: {} } }, - src/index.ts:57-74 (helper)The implementation of callApi which proxies tool execution to the ReplenishRadar REST API.
async function callApi(toolName: string, input: Record<string, unknown>): Promise<unknown> { const resp = await fetch(`${BASE_URL}/api/mcp/call`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${API_KEY}`, }, body: JSON.stringify({ tool: toolName, input }), }); if (!resp.ok) { const errorBody = await resp.text(); throw new Error(`API error ${resp.status}: ${errorBody}`); } const data = await resp.json(); return data.result; }