boscli_cache_clear
Clears BOS application caches to fix loading errors or outdated data. Supports clearing all, config, route, view, or cache types.
Instructions
Clear BOS application caches
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "boscli_cache_clear"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| type | No |
Implementation Reference
- src/tools/cache.ts:11-18 (handler)Handler function for boscli_cache_clear tool. Calls POST /boscli/cache/clear on the BOS API client, passing an optional 'type' argument (defaults to 'all').
{ name: 'boscli_cache_clear', description: 'Clear BOS application caches', schema: { type: { type: 'string', enum: ['all', 'config', 'route', 'view', 'cache'], optional: true }, }, handler: async (args, client) => client.post('/boscli/cache/clear', { type: args.type || 'all' }), }, - src/tools/cache.ts:14-16 (schema)Input schema for boscli_cache_clear: optional 'type' parameter with enum values ['all', 'config', 'route', 'view', 'cache'].
schema: { type: { type: 'string', enum: ['all', 'config', 'route', 'view', 'cache'], optional: true }, }, - src/index.ts:9-31 (registration)cacheTools imported from ./tools/cache.js and spread into allTools array at line 31 in the main MCP server entry point (src/index.ts). Also imported in src/stdio.ts (line 9, 31) and src/http.ts (line 10, 31).
import { cacheTools } from './tools/cache.js'; import { systemTools } from './tools/system.js'; import { productTools, orderTools, cartTools, customerTools, inventoryTools, voucherTools, loyaltyTools, storeTools, checkoutTools, promotionTools, engagementTools, } from './tools/bos.js'; import { smartTools } from './tools/smart.js'; import { erpTools } from './tools/erp.js'; const allTools: McpTool[] = [ ...healthTools, ...moduleTools, ...routeTools, ...cacheTools, - src/index.ts:54-76 (registration)Generic registration loop: all tools (including boscli_cache_clear) are registered to the McpServer using server.tool() with their name, description, Zod schema, and a wrapper handler that calls tool.handler(args, client).
// Register all tools with proper Zod schemas for (const tool of allTools) { const zodSchema = toZodSchema(tool.schema); server.tool( tool.name, tool.description, zodSchema.shape, async (args: any) => { try { const result = await tool.handler(args, client); return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }], }; } catch (error: any) { return { content: [{ type: 'text' as const, text: JSON.stringify({ error: error.message || 'Unknown error' }) }], isError: true, }; } } ); } - src/tools/index.ts:21-62 (helper)toZodSchema helper converts the simple schema format (like boscli_cache_clear's schema with enum and optional) into a Zod schema for MCP SDK registration.
export function toZodSchema(schema: Record<string, any>): z.ZodObject<any> { const shape: Record<string, z.ZodTypeAny> = {}; for (const [key, def] of Object.entries(schema)) { let field: z.ZodTypeAny; switch (def.type) { case 'number': field = z.number(); break; case 'boolean': field = z.boolean(); break; case 'array': field = z.array(z.any()); break; case 'object': field = z.record(z.any()); break; case 'string': default: if (def.enum) { field = z.enum(def.enum); } else { field = z.string(); } break; } if (def.description) { field = field.describe(def.description); } if (def.optional) { field = field.optional(); } shape[key] = field; } return z.object(shape); }