Skip to main content
Glama

rr_get_demand_forecast

Generate demand forecasts for inventory items to predict future sales and optimize stock levels, helping prevent stockouts and overstocking.

Instructions

Get demand forecast stats for an item

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
skuNo
item_idNo
window_daysNo
store_idNo

Implementation Reference

  • src/index.ts:28-28 (registration)
    Tool registration: defines 'rr_get_demand_forecast' with name, description, and inputSchema in the TOOLS array
    { name: 'rr_get_demand_forecast', description: 'Get demand forecast stats for an item', inputSchema: { type: 'object' as const, properties: { sku: { type: 'string' }, item_id: { type: 'string' }, window_days: { type: 'number' }, store_id: { type: 'string' } } } },
  • Input schema for rr_get_demand_forecast: defines optional parameters (sku, item_id, window_days, store_id) as object properties
    { name: 'rr_get_demand_forecast', description: 'Get demand forecast stats for an item', inputSchema: { type: 'object' as const, properties: { sku: { type: 'string' }, item_id: { type: 'string' }, window_days: { type: 'number' }, store_id: { type: 'string' } } } },
  • callApi function: the handler that executes tool logic by making POST requests to the ReplenishRadar API endpoint with tool name and input parameters
    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;
    }
  • CallToolRequestSchema handler: processes incoming tool calls by extracting name and arguments, invoking callApi, and returning formatted results
    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,
        };
      }
    });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ReplenishRadar/MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server