Skip to main content
Glama
tosin2013

Memory Cache Server

clear_cache

Remove specific or all cached entries from the Memory Cache Server to free up memory and ensure data freshness during language model interactions.

Instructions

Clear specific or all cache entries

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyNoSpecific key to clear (optional - clears all if not provided)

Implementation Reference

  • MCP tool handler for 'clear_cache': handles optional 'key' argument, calls cacheManager.delete(key) if provided or cacheManager.clear() otherwise, and returns appropriate success/error text response.
    case 'clear_cache': {
      const { key } = request.params.arguments as { key?: string };
      if (key) {
        const success = this.cacheManager.delete(key);
        return {
          content: [
            {
              type: 'text',
              text: success
                ? `Successfully cleared cache entry: ${key}`
                : `No cache entry found for key: ${key}`,
            },
          ],
        };
      } else {
        this.cacheManager.clear();
        return {
          content: [
            {
              type: 'text',
              text: 'Successfully cleared all cache entries',
            },
          ],
        };
      }
    }
  • Tool definition including name, description, and input schema for 'clear_cache' used in ListTools response (serves as registration and schema).
    {
      name: 'clear_cache',
      description: 'Clear specific or all cache entries',
      inputSchema: {
        type: 'object',
        properties: {
          key: {
            type: 'string',
            description: 'Specific key to clear (optional - clears all if not provided)',
          },
        },
      },
    },
  • CacheManager.delete(key) method: removes specific cache entry if exists, updates stats, returns success boolean.
    delete(key: string): boolean {
      const entry = this.cache.get(key);
      if (entry) {
        this.stats.memoryUsage -= entry.size;
        this.cache.delete(key);
        this.stats.totalEntries = this.cache.size;
        return true;
      }
      return false;
    }
  • CacheManager.clear() method: clears all cache entries and resets statistics.
    clear(): void {
      this.cache.clear();
      this.resetStats();
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. 'Clear' implies a destructive operation, but it doesn't disclose behavioral traits like whether this requires admin permissions, if it's reversible, potential performance impact, or rate limits. The description states what it does but lacks critical context for a mutation tool.

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

Conciseness5/5

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

The description is a single, efficient sentence with zero waste. It's front-loaded with the core action and scope, making it easy to parse. Every word earns its place without redundancy.

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?

For a destructive tool with no annotations and no output schema, the description is incomplete. It doesn't cover behavioral risks, return values, or error conditions. Given the complexity of cache clearing (which can affect system performance), more context is needed beyond the minimal purpose statement.

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

Parameters3/5

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

Schema description coverage is 100%, with the parameter 'key' documented as optional for clearing specific entries (or all if omitted). The description adds marginal value by mentioning 'specific or all', which aligns with the schema. Baseline 3 is appropriate since the schema does the heavy lifting.

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 'Clear specific or all cache entries' clearly states the verb (clear) and resource (cache entries) with scope options (specific/all). It distinguishes from siblings like get_cache_stats (read-only) and retrieve_data/store_data (data operations), though not explicitly named. The purpose is specific but could be more explicit about sibling differentiation.

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 like get_cache_stats or store_data. It mentions 'specific or all' but doesn't explain scenarios for each option or prerequisites. Without explicit when/when-not instructions, usage is implied at best.

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/tosin2013/mcp-memory-cache-server'

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