jp_lit_delete_cache
Delete cached data by cache key or tool to free local storage and retrieve up-to-date Japanese literature search results.
Instructions
ローカル保存されたキャッシュを cache_key 単位または tool 単位で削除する
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tool | Yes | ||
| cache_key | Yes | ||
| clear_all | Yes | ||
| deleted_count | Yes | ||
| deleted | Yes | ||
| message | Yes |
Implementation Reference
- src/tools/jpLitDeleteCache.ts:8-45 (handler)Main handler function that deletes cache entries by cache_key (single) or clear_all (bulk per tool) using the FileCache interface.
export function createJpLitDeleteCacheTool(cache: FileCache) { return async (input: unknown) => { const parsed = deleteCacheInputSchema.parse(input); let deletedCount = 0; let deleted = false; if (parsed.clear_all) { deletedCount = await cache.clear(parsed.tool); deleted = deletedCount > 0; } else if (parsed.cache_key) { deleted = await cache.delete(parsed.tool, parsed.cache_key); deletedCount = deleted ? 1 : 0; } const structuredContent: DeleteCacheOutput = deleteCacheOutputSchema.parse({ tool: parsed.tool, cache_key: parsed.cache_key ?? null, clear_all: parsed.clear_all, deleted_count: deletedCount, deleted, message: parsed.clear_all ? `${parsed.tool} のキャッシュを ${deletedCount} 件削除しました` : deleted ? `cache_key=${parsed.cache_key} を削除しました` : `cache_key=${parsed.cache_key} は見つかりませんでした` }); return { content: [ { type: "text" as const, text: JSON.stringify(structuredContent, null, 2) } ], structuredContent }; }; } - src/lib/schemas.ts:414-428 (schema)Input schema: requires either cache_key or clear_all=true; tool defaults to 'jp_lit_search'.
export const deleteCacheInputSchema = z .object({ tool: z.string().trim().min(1).default("jp_lit_search"), cache_key: z.string().trim().min(1).optional(), clear_all: z.boolean().default(false) }) .superRefine((data, ctx) => { if (!data.clear_all && !data.cache_key) { ctx.addIssue({ code: z.ZodIssueCode.custom, message: "cache_key を指定するか clear_all=true を指定してください", path: ["cache_key"] }); } }); - src/lib/schemas.ts:430-437 (schema)Output schema containing tool name, cache_key, clear_all flag, deleted_count, deleted boolean, and a human-readable message.
export const deleteCacheOutputSchema = z.object({ tool: z.string(), cache_key: z.string().nullable(), clear_all: z.boolean(), deleted_count: z.number().int().nonnegative(), deleted: z.boolean(), message: z.string() }); - src/server.ts:477-485 (registration)Registration of the tool with the MCP server under the name 'jp_lit_delete_cache' with description and schemas.
server.registerTool( "jp_lit_delete_cache", { description: "ローカル保存されたキャッシュを cache_key 単位または tool 単位で削除する", inputSchema: deleteCacheInputSchema, outputSchema: deleteCacheOutputSchema }, deleteCacheTool ); - src/server.ts:80-80 (registration)Import of the handler factory, and line 315 instantiates it: const deleteCacheTool = createJpLitDeleteCacheTool(cache);
import { createJpLitDeleteCacheTool } from "./tools/jpLitDeleteCache.js";