rr_get_sales_history
Retrieve historical sales data for specific products and stores to analyze performance and inform inventory decisions.
Instructions
Get sales history
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sku | No | ||
| store_id | No | ||
| days | No | ||
| limit | No |
Implementation Reference
- src/index.ts:86-92 (handler)The tool request handler uses the `callApi` helper function to execute tool logic remotely. The specific logic for 'rr_get_sales_history' is handled by the `callApi` function via a POST request to the configured backend 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) }], }; - src/index.ts:38-38 (schema)Definition of the 'rr_get_sales_history' tool schema, including input arguments like sku, store_id, days, and limit.
{ name: 'rr_get_sales_history', description: 'Get sales history', inputSchema: { type: 'object' as const, properties: { sku: { type: 'string' }, store_id: { type: 'string' }, days: { type: 'number', default: 30 }, limit: { type: 'number' } } } }, - src/index.ts:57-74 (helper)The `callApi` function serves as the central helper to dispatch tool calls to the remote 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; }