manage_cache
Manipulate QIT cache data by getting, setting, or deleting key-value pairs with optional expiration control for WordPress/WooCommerce testing workflows.
Instructions
Low-level QIT cache manipulation. For refreshing cache data, use sync_cache instead.
⚠️ QIT CLI not detected. QIT CLI not found. Please install it using one of these methods:
Via Composer (recommended): composer require woocommerce/qit-cli --dev
Set QIT_CLI_PATH environment variable: export QIT_CLI_PATH=/path/to/qit
Ensure 'qit' is available in your system PATH
For more information, visit: https://github.com/woocommerce/qit-cli
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | Cache action: get (retrieve), set (store), or delete (remove) | |
| key | Yes | The cache key to operate on | |
| value | No | The value to store (required for 'set' action) | |
| expiration | No | Expiration time in seconds (optional for 'set' action) |
Implementation Reference
- src/tools/utilities.ts:109-132 (handler)The main handler function for the 'manage_cache' tool. It builds QIT CLI command arguments based on the provided action, key, optional value, and expiration, then executes the command using executeAndFormat.handler: async (args: { action: "get" | "set" | "delete"; key: string; value?: string; expiration?: number; }) => { // CLI uses positional args: cache <action> <key> [<value> [<expiration>]] const cmdArgs = ["cache", args.action, args.key]; if (args.action === "set") { if (!args.value) { return { content: "Error: 'value' is required for 'set' action", isError: true, }; } cmdArgs.push(args.value); if (args.expiration !== undefined) { cmdArgs.push(String(args.expiration)); } } return executeAndFormat(cmdArgs); },
- src/tools/utilities.ts:95-108 (schema)Zod input schema defining parameters for the 'manage_cache' tool: action (get/set/delete), key, optional value, and optional expiration.inputSchema: z.object({ action: z .enum(["get", "set", "delete"]) .describe("Cache action: get (retrieve), set (store), or delete (remove)"), key: z.string().describe("The cache key to operate on"), value: z .string() .optional() .describe("The value to store (required for 'set' action)"), expiration: z .number() .optional() .describe("Expiration time in seconds (optional for 'set' action)"), }),
- src/server.ts:25-38 (registration)MCP server request handler for listing tools, which includes 'manage_cache' by mapping over allTools (imported from tools/index.js). Converts Zod schemas to JSON schema.server.setRequestHandler(ListToolsRequestSchema, async () => { // Check if QIT CLI is available const cliInfo = detectQitCli(); const tools = Object.entries(allTools).map(([_, tool]) => ({ name: tool.name, description: cliInfo ? tool.description : `${tool.description}\n\n⚠️ QIT CLI not detected. ${getQitCliNotFoundError()}`, inputSchema: zodToJsonSchema(tool.inputSchema), })); return { tools }; });
- src/server.ts:41-87 (registration)MCP server request handler for calling tools, which looks up 'manage_cache' handler from allTools by name, validates arguments with its schema, executes the handler, and formats the response.server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; const tool = allTools[name as ToolName]; if (!tool) { return { content: [ { type: "text", text: `Unknown tool: ${name}`, }, ], isError: true, }; } try { // Validate input const validatedArgs = tool.inputSchema.parse(args); // Execute tool // eslint-disable-next-line @typescript-eslint/no-explicit-any const result = await (tool.handler as (args: any) => Promise<{ content: string; isError: boolean }>)(validatedArgs); return { content: [ { type: "text", text: result.content, }, ], isError: result.isError, }; } catch (error) { const message = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Error: ${message}`, }, ], isError: true, }; } });