Skip to main content
Glama
tosin2013

Memory Cache Server

store_data

Store data in a cache with optional expiration time to optimize token usage during 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

  • Executes the store_data tool by parsing arguments and delegating to CacheManager.set()
    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)
    Registers the store_data tool including its description and input schema in the ListTools response
    {
      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'],
      },
    },
  • Input schema definition for the store_data tool
    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'],
    },
  • Core implementation of data storage in the cache, including size calculation, memory limit enforcement, and TTL handling
    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 the full burden of behavioral disclosure. It states the tool stores data in a cache with optional TTL, which implies a write operation, but doesn't cover critical aspects like whether it overwrites existing keys, requires specific permissions, has rate limits, or what happens on failure. This leaves significant gaps 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 purpose and includes only essential additional detail (optional TTL), making it appropriately sized and easy to parse.

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 insufficient. It lacks details on behavioral traits (e.g., overwrite behavior, error handling), return values, and usage context relative to siblings. Given the complexity of a write operation, more completeness is needed to guide an agent effectively.

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 input schema already documents all parameters (key, value, ttl) with clear descriptions. The description adds minimal value by mentioning 'optional TTL', which is redundant with the schema. No additional syntax, format, or constraints are provided beyond what's in the structured data.

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'), making the purpose evident. However, it doesn't explicitly differentiate from sibling tools like 'retrieve_data' or 'clear_cache', which would require mentioning it's specifically for writing/inserting data rather than reading or deleting.

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 includes 'with optional TTL', which implies a usage scenario for time-based expiration, but provides no guidance on when to use this tool versus alternatives like 'retrieve_data' for reading or 'clear_cache' for deletion. There's no mention of prerequisites, constraints, or typical use cases.

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