rr_get_suggested_purchase_orders
Generate purchase order recommendations to optimize inventory levels and prevent stockouts based on demand forecasts and current stock status.
Instructions
Get suggested purchase orders
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| status | No | ||
| vendor_id | No | ||
| store_id | No | ||
| limit | No |
Implementation Reference
- src/index.ts:86-100 (handler)The CallToolRequestSchema handler in src/index.ts dispatches all tool calls, including 'rr_get_suggested_purchase_orders', to the backend via the callApi helper function.
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:29-29 (registration)Registration and definition of the 'rr_get_suggested_purchase_orders' tool in the TOOLS array.
{ name: 'rr_get_suggested_purchase_orders', description: 'Get suggested purchase orders', inputSchema: { type: 'object' as const, properties: { status: { type: 'string' }, vendor_id: { type: 'string' }, store_id: { type: 'string' }, limit: { type: 'number' } } } }, - src/index.ts:57-74 (helper)The callApi function acts as the generic handler that executes the logic for the tool by sending a POST request 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; }