Skip to main content
Glama

Inventory Status

inventory_status
Read-onlyIdempotent

Retrieve current stock snapshot for a connected store, including out-of-stock and low-stock items sorted by urgency.

Instructions

Snapshot of current stock levels for a connected store. Returns a summary object with total product count, out-of-stock count, low-stock count (≤10 units), plus two arrays: out_of_stock and low_stock — each containing product id, title, sku, quantity, and status. Items are sorted by urgency (lowest quantity first). Read-only and idempotent.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
store_idYesUUID of a connected store (returned by store_connect with action="connect" or visible in store_connect with action="list" / the store_overview resource)

Implementation Reference

  • Core handler function for the inventory_status tool. Validates the store UUID, fetches products from storage, filters active products, computes out-of-stock and low-stock (<=10 units) counts, and returns a sorted (by quantity ascending) list of up to 50 products with their status.
    export async function getInventoryStatus(storeId: string): Promise<InventoryStatusResult> {
      validateUUID(storeId, 'store');
      const store = await storage.getStoreById(storeId);
      if (!store) throw new NotFoundError('Store', storeId);
    
      const products = await storage.getProducts(storeId);
      const activeProducts = products.filter((p) => p.status === 'active');
    
      const outOfStock = activeProducts.filter((p) => p.inventory_quantity <= 0);
      const lowStock = activeProducts.filter((p) => p.inventory_quantity > 0 && p.inventory_quantity <= 10);
      const totalUnits = activeProducts.reduce((sum, p) => sum + Math.max(0, p.inventory_quantity), 0);
    
      return {
        store_id: storeId,
        total_products: activeProducts.length,
        total_units: totalUnits,
        out_of_stock: outOfStock.length,
        low_stock: lowStock.length,
        products: activeProducts
          .sort((a, b) => a.inventory_quantity - b.inventory_quantity)
          .slice(0, 50)
          .map((p) => ({
            id: p.id,
            title: p.title,
            sku: p.sku,
            quantity: p.inventory_quantity,
            status: p.inventory_quantity <= 0 ? 'out_of_stock' : p.inventory_quantity <= 10 ? 'low' : 'ok',
          })),
      };
    }
  • TypeScript interface defining the return shape of getInventoryStatus: store_id, summary counts, and a products array with per-product stock status.
    export interface InventoryStatusResult {
      store_id: string;
      total_products: number;
      total_units: number;
      out_of_stock: number;
      low_stock: number;
      products: Array<{
        id: string;
        title: string;
        sku: string | null;
        quantity: number;
        status: string;
      }>;
    }
  • src/index.ts:127-144 (registration)
    MCP server registration of the 'inventory_status' tool via server.registerTool(). Defines the input schema (store_id UUID), annotations, and the handler that delegates to getInventoryStatus.
    // ── Tool: inventory_status ────────────────────────────────────────
    server.registerTool(
      'inventory_status',
      {
        title: 'Inventory Status',
        description: 'Snapshot of current stock levels for a connected store. Returns a summary object with total product count, out-of-stock count, low-stock count (≤10 units), plus two arrays: out_of_stock and low_stock — each containing product id, title, sku, quantity, and status. Items are sorted by urgency (lowest quantity first). Read-only and idempotent.',
        inputSchema: z.object({
          store_id: z.string().uuid().describe('UUID of a connected store (returned by store_connect with action="connect" or visible in store_connect with action="list" / the store_overview resource)'),
        }),
        annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
      },
      async ({ store_id }) => {
        try {
          const result = await getInventoryStatus(store_id);
          return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }] };
        } catch (e) { return handleToolError(e); }
      }
    );
  • Storage helper used by getInventoryStatus to look up the store by UUID, throwing NotFoundError if missing.
    async getStoreById(id: string): Promise<StoreConfig | undefined> {
      const stores = await this.getStores();
      return stores.find((s) => s.id === id);
    }
  • Storage helper used by getInventoryStatus to fetch all products for a given store_id from the JSON file-based storage.
    async getProducts(storeId: string): Promise<Product[]> {
      const all = await this.readJSON<Product>('products');
      return all.filter((p) => p.store_id === storeId);
    }
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description adds value beyond annotations by detailing the output structure (summary object, two arrays, fields per item) and sorting behavior (by quantity ascending). It confirms read-only and idempotent nature, which aligns with annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a concise three-sentence paragraph, front-loading the purpose and then providing necessary details. Every sentence adds value with no redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Despite no output schema, the description fully explains the return value format and fields. Combined with clear purpose and parameter info, the tool definition is complete for an agent to use and interpret results.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema provides 100% coverage for store_id with a detailed description linking to other tools. The tool description adds no additional meaning for the parameter, so baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it provides a 'snapshot of current stock levels' for a connected store, listing specific output fields and sorting. It distinguishes from siblings (e.g., inventory_forecast, product_performance) by focusing on current status.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description does not explicitly state when to use this tool vs alternatives or provide exclusions. It implies usage for current stock checks but lacks guidance like 'use for real-time inventory view; for predictions use inventory_forecast'.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/enzoemir1/shopops-mcp'

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