check_stock_levels
Retrieve current stock levels for inventory items, showing quantity on hand, reserved, and available to manage warehouse inventory effectively.
Instructions
Get current stock levels for a specific inventory item by ID. Returns quantity on hand, reserved, available. Requires API key.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| item_id | Yes | Inventory item ID |
Implementation Reference
- src/index.ts:111-125 (handler)The handler function for check_stock_levels tool. Validates authentication, calls client.get() to fetch stock levels from /inventory/items/{item_id}/stock endpoint, and returns formatted JSON response.
server.tool( 'check_stock_levels', 'Get current stock levels for a specific inventory item by ID. Returns quantity on hand, reserved, available. Requires API key.', { item_id: z.string().describe('Inventory item ID'), }, async (params) => { if (!client.isAuthenticated) { return { content: [{ type: 'text' as const, text: 'Error: API key required.' }] }; } const response = await client.get(`/inventory/items/${params.item_id}/stock`); if (!response.ok) return { content: [{ type: 'text' as const, text: `Error: ${response.error}` }] }; return { content: [{ type: 'text' as const, text: JSON.stringify(response.data, null, 2) }] }; }, ); - src/index.ts:111-125 (registration)Registration of the check_stock_levels tool with MCP server using server.tool(). Includes name, description, input schema (item_id), and inline handler function.
server.tool( 'check_stock_levels', 'Get current stock levels for a specific inventory item by ID. Returns quantity on hand, reserved, available. Requires API key.', { item_id: z.string().describe('Inventory item ID'), }, async (params) => { if (!client.isAuthenticated) { return { content: [{ type: 'text' as const, text: 'Error: API key required.' }] }; } const response = await client.get(`/inventory/items/${params.item_id}/stock`); if (!response.ok) return { content: [{ type: 'text' as const, text: `Error: ${response.error}` }] }; return { content: [{ type: 'text' as const, text: JSON.stringify(response.data, null, 2) }] }; }, ); - src/index.ts:114-116 (schema)Zod schema definition for check_stock_levels tool input validation. Defines item_id as a required string parameter.
{ item_id: z.string().describe('Inventory item ID'), }, - src/client.ts:136-138 (helper)CerebroChainClient.get() helper method used by the handler to make authenticated GET requests to the inventory API. Wraps the generic request() method.
async get<T = unknown>(path: string, query?: Record<string, string>): Promise<ApiResponse<T>> { return this.request<T>({ method: 'GET', path, query }); }