Skip to main content
Glama

jp_lit_prune_cache

Remove outdated cache files from local storage by listing entries older than a set number of days and deleting them only in non-dry-run mode.

Instructions

古いローカルキャッシュ候補を列挙し、dry_run=false のときだけ安全に削除する

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
older_than_daysNo
toolNo
dry_runNo
limitNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
dry_runYes
older_than_daysYes
cutoff_saved_atYes
toolYes
limitYes
matched_countYes
pruned_countYes
total_bytesYes
candidatesYes
skipped_countYes
skippedYes
messageYes

Implementation Reference

  • Main tool handler: creates the prune-cache tool function. Parses input (older_than_days, tool filter, dry_run, limit), lists cache inventory, filters/sorts candidates by cutoff date, optionally removes them, and returns structured output.
    export function createJpLitPruneCacheTool(
      baseDir = process.cwd(),
      now = () => new Date()
    ) {
      return async (input: unknown) => {
        const parsed = pruneCacheInputSchema.parse(input);
        const cutoff = cutoffFrom(now(), parsed.older_than_days);
        const inventory = await listCacheInventory(baseDir, parsed.tool);
        const candidates = inventory.items
          .filter((item) => item.saved_at < cutoff)
          .sort((left, right) => left.saved_at.localeCompare(right.saved_at))
          .slice(0, parsed.limit);
    
        let prunedCount = 0;
        if (!parsed.dry_run) {
          for (const candidate of candidates) {
            await removeInventoryItem(candidate, baseDir);
            prunedCount += 1;
          }
        }
    
        const totalBytes = candidates.reduce((sum, item) => sum + item.bytes, 0);
        const structuredContent: PruneCacheOutput = pruneCacheOutputSchema.parse({
          dry_run: parsed.dry_run,
          older_than_days: parsed.older_than_days,
          cutoff_saved_at: cutoff,
          tool: parsed.tool ?? null,
          limit: parsed.limit,
          matched_count: candidates.length,
          pruned_count: prunedCount,
          total_bytes: totalBytes,
          candidates: candidates.map(({ tool, cache_key, saved_at, bytes, root }) => ({
            tool,
            cache_key,
            saved_at,
            bytes,
            root
          })),
          skipped_count: inventory.skipped.length,
          skipped: inventory.skipped,
          message: parsed.dry_run
            ? `${candidates.length} 件の削除候補があります。削除するには dry_run=false を指定してください。`
            : `${prunedCount} 件のキャッシュを削除しました。`
        });
    
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify(structuredContent, null, 2)
            }
          ],
          structuredContent
        };
      };
    }
  • Input schema: older_than_days (default 30), optional tool filter, dry_run (default true), limit (default 100, max 1000).
    export const pruneCacheInputSchema = z.object({
      older_than_days: z.number().int().positive().default(30),
      tool: z.string().trim().min(1).optional(),
      dry_run: z.boolean().default(true),
      limit: z.number().int().positive().max(1000).default(100)
    });
  • Output schema: structured result including dry_run, cutoff date, tool filter, counts, candidate list, skipped items, and a human-readable message.
    export const pruneCacheOutputSchema = z.object({
      dry_run: z.boolean(),
      older_than_days: z.number().int().positive(),
      cutoff_saved_at: z.string(),
      tool: z.string().nullable(),
      limit: z.number().int().positive(),
      matched_count: z.number().int().nonnegative(),
      pruned_count: z.number().int().nonnegative(),
      total_bytes: z.number().int().nonnegative(),
      candidates: z.array(z.object({
        tool: z.string(),
        cache_key: z.string(),
        saved_at: z.string(),
        bytes: z.number().int().nonnegative(),
        root: z.enum(["current", "legacy"])
      })),
      skipped_count: z.number().int().nonnegative(),
      skipped: z.array(z.object({
        path: z.string(),
        reason: z.string()
      })),
      message: z.string()
    });
  • src/server.ts:487-495 (registration)
    Registration of the tool on the MCP server with name 'jp_lit_prune_cache', description, and schema references.
    server.registerTool(
      "jp_lit_prune_cache",
      {
        description: "古いローカルキャッシュ候補を列挙し、dry_run=false のときだけ安全に削除する",
        inputSchema: pruneCacheInputSchema,
        outputSchema: pruneCacheOutputSchema
      },
      pruneCacheTool
    );
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description discloses the crucial dry_run toggle: enumeration only when true, safe deletion when false. This is valuable behavioral information. However, with no annotations provided, the description should also cover permission requirements, side effects (e.g., irreversible deletion), and return value structure – all of which are missing.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, concise sentence. It communicates the core action efficiently without fluff. However, some brevity comes at the cost of omitting necessary details, so while concise, it sacrifices completeness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has 4 parameters and no annotations, the description is too sparse. It fails to explain the role of 'tool' and 'limit', the meaning of 'older_than_days', or the output structure (despite an output schema existing). The agent would likely need additional documentation to use the tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has 0% description coverage, so the description must compensate, but it adds minimal parameter-level context. It implicitly references 'older_than_days' via 'old' and mentions the dry_run toggle, but does not explain the purpose of 'tool', 'limit', or the default values. The agent would still need to infer meanings from parameter names.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool prunes old local cache candidates and deletes when dry_run is false. It distinguishes itself from sibling tools like jp_lit_delete_cache (which likely deletes specific caches) and jp_lit_list_cache (which lists caches). However, it could be more explicit about the meaning of 'old' in relation to the older_than_days parameter.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives such as jp_lit_delete_cache or jp_lit_list_cache. It does not specify prerequisites, when not to use it, or trade-offs, leaving the agent without decision support.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/itarunnn/jp-lit-mcp'

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