Skip to main content
Glama

rr_get_inventory_position

Retrieve current inventory levels by location for specific products to monitor stock availability across warehouses or sales channels.

Instructions

Get stock-by-location for an item

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
item_idNo
skuNo

Implementation Reference

  • The main request handler that processes all tool calls including rr_get_inventory_position. It extracts the tool name and arguments, calls the callApi helper, and returns the result as MCP 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:27-27 (registration)
    Registration of rr_get_inventory_position tool in the TOOLS array with name 'rr_get_inventory_position', description 'Get stock-by-location for an item', and its input schema.
    { name: 'rr_get_inventory_position', description: 'Get stock-by-location for an item', inputSchema: { type: 'object' as const, properties: { item_id: { type: 'string' }, sku: { type: 'string' } } } },
  • Input schema for rr_get_inventory_position tool defining two optional properties: item_id (string) and sku (string).
    { name: 'rr_get_inventory_position', description: 'Get stock-by-location for an item', inputSchema: { type: 'object' as const, properties: { item_id: { type: 'string' }, sku: { type: 'string' } } } },
  • The callApi helper function that forwards tool execution to the ReplenishRadar REST API at https://api.replenishradar.com/api/mcp/call. This is where the actual business logic resides on the backend.
    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