rr_get_inventory_value
Calculate total inventory value with breakdown for Shopify and Amazon stores to support purchase order management and stockout risk assessment.
Instructions
Get total inventory value breakdown
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| store_id | No |
Implementation Reference
- src/index.ts:86-100 (handler)The handler that executes the rr_get_inventory_value tool. It extracts the tool name and arguments from the request, calls the callApi helper to make the HTTP request, and returns the result as JSON text content.
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:41-41 (schema)The input schema for rr_get_inventory_value tool. Defines it accepts an optional store_id parameter of type string.
{ name: 'rr_get_inventory_value', description: 'Get total inventory value breakdown', inputSchema: { type: 'object' as const, properties: { store_id: { type: 'string' } } } }, - src/index.ts:41-41 (registration)Registration of the rr_get_inventory_value tool in the TOOLS array, which is exposed via the ListToolsRequestSchema handler.
{ name: 'rr_get_inventory_value', description: 'Get total inventory value breakdown', inputSchema: { type: 'object' as const, properties: { store_id: { type: 'string' } } } }, - src/index.ts:57-74 (helper)The callApi helper function that makes the actual HTTP POST request to the ReplenishRadar API endpoint. It sends the tool name and input arguments, handles authentication with Bearer token, and returns the API result.
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; }