Skip to main content
Glama

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
NameRequiredDescriptionDefault
skuNo
store_idNo
daysNo
limitNo

Implementation Reference

  • 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) }],
        };
  • 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' } } } },
  • 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;
    }

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