Skip to main content
Glama
ibproduct

Memory Cache MCP Server

by ibproduct

store_data

Store data in a cache with optional expiration time to reduce redundant token usage in language model interactions.

Instructions

Store data in the cache with optional TTL

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYesUnique identifier for the cached data
valueYesData to cache
ttlNoTime-to-live in seconds (optional)

Implementation Reference

  • The handler for the 'store_data' tool. Extracts key, value, and optional ttl from arguments and calls CacheManager.set to store the data, returning a success message.
    case 'store_data': {
      const { key, value, ttl } = request.params.arguments as {
        key: string;
        value: any;
        ttl?: number;
      };
      this.cacheManager.set(key, value, ttl);
      return {
        content: [
          {
            type: 'text',
            text: `Successfully stored data with key: ${key}`,
          },
        ],
      };
    }
  • src/index.ts:99-120 (registration)
    Registration of the 'store_data' tool in the ListTools response, including name, description, and input schema.
    {
      name: 'store_data',
      description: 'Store data in the cache with optional TTL',
      inputSchema: {
        type: 'object',
        properties: {
          key: {
            type: 'string',
            description: 'Unique identifier for the cached data',
          },
          value: {
            type: 'any',
            description: 'Data to cache',
          },
          ttl: {
            type: 'number',
            description: 'Time-to-live in seconds (optional)',
          },
        },
        required: ['key', 'value'],
      },
    },
  • The CacheManager.set method implementing the core caching logic: size calculation, memory limit enforcement, entry creation, storage in Map, and stats update.
    set(key: string, value: any, ttl?: number): void {
      const startTime = performance.now();
      
      // Calculate approximate size in bytes
      const size = this.calculateSize(value);
      
      // Check if adding this entry would exceed memory limit
      if (this.stats.memoryUsage + size > this.config.maxMemory) {
        this.enforceMemoryLimit(size);
      }
    
      const entry: CacheEntry = {
        value,
        created: Date.now(),
        lastAccessed: Date.now(),
        ttl: ttl ?? this.config.defaultTTL,
        size
      };
    
      this.cache.set(key, entry);
      this.stats.totalEntries = this.cache.size;
      this.stats.memoryUsage += size;
    
      const endTime = performance.now();
      this.updateAccessTime(endTime - startTime);
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions 'optional TTL' which hints at expiration behavior, but doesn't describe what happens when data is stored (e.g., overwrites existing keys, requires specific permissions, has size limits, or returns confirmation). For a mutation tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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 extremely concise with a single sentence that communicates the core purpose and one key feature (optional TTL). Every word earns its place with no redundancy or unnecessary elaboration. It's front-loaded with the main action and resource.

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 mutation tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what happens after storage (success/failure indicators), whether the operation is idempotent, what errors might occur, or how it interacts with sibling tools. The 100% schema coverage helps with parameters, but behavioral context is lacking.

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%, so the schema already documents all three parameters thoroughly. The description adds minimal value beyond the schema by mentioning 'optional TTL', but doesn't provide additional context about parameter usage, constraints, or best practices. This meets the baseline for high schema coverage.

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 action ('Store data') and target ('in the cache'), which is specific and unambiguous. It distinguishes from sibling tools like 'retrieve_data' (read vs. write) and 'clear_cache' (store vs. delete). However, it doesn't explicitly mention what type of cache or differentiate from 'get_cache_stats' beyond the basic verb distinction.

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 'retrieve_data' or 'clear_cache'. It mentions optional TTL but doesn't explain when TTL should be applied or any prerequisites for usage. There's no context about when this tool is appropriate versus other storage methods.

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/ibproduct/ib-mcp-cache-server'

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