Skip to main content
Glama

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:

  1. Via Composer (recommended): composer require woocommerce/qit-cli --dev

  2. Set QIT_CLI_PATH environment variable: export QIT_CLI_PATH=/path/to/qit

  3. Ensure 'qit' is available in your system PATH

For more information, visit: https://github.com/woocommerce/qit-cli

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesCache action: get (retrieve), set (store), or delete (remove)
keyYesThe cache key to operate on
valueNoThe value to store (required for 'set' action)
expirationNoExpiration time in seconds (optional for 'set' action)

Implementation Reference

  • 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); },
  • 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, }; } });

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/woocommerce/qit-mcp'

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