Skip to main content
Glama
haasonsaas

MCP Utility Tools

by haasonsaas

cache_put

Store any JSON-serializable value in a cache with a configurable time-to-live (TTL) to avoid redundant API calls or computations. Specify key, value, optional namespace, and TTL from 1 second to 24 hours.

Instructions

Store a value in the cache with TTL. Useful for caching API responses, computed values, etc.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYesCache key
valueYesValue to cache (any JSON-serializable data)
ttl_secondsNoTime to live in seconds
namespaceNoOptional namespace to prevent key collisionsdefault

Implementation Reference

  • src/index.ts:98-121 (registration)
    Tool registration with inputSchema for cache_put (name, description, inputSchema properties including key, value, ttl_seconds)
    {
      name: "cache_put",
      description: "Store a value in the cache with TTL",
      inputSchema: {
        type: "object",
        properties: {
          key: {
            type: "string",
            description: "Cache key"
          },
          value: {
            description: "Value to cache (any JSON-serializable data)"
          },
          ttl_seconds: {
            type: "number",
            description: "Time to live in seconds",
            default: 300,
            minimum: 1,
            maximum: 86400 // 24 hours
          }
        },
        required: ["key", "value"]
      }
    },
  • Handler function for cache_put tool execution - stores value with TTL in an in-memory Map
    case "cache_put": {
      const { key, value, ttl_seconds = 300 } = args as any;
      
      const expiresAt = Date.now() + (ttl_seconds * 1000);
      cache.set(key, { value, expiresAt });
    
      return {
        content: [{
          type: "text",
          text: JSON.stringify({
            success: true,
            key,
            ttl_seconds,
            expires_at: new Date(expiresAt).toISOString()
          })
        }]
      };
    }
  • Alternate registration in index-v2.ts with additional namespace support
    {
      name: "cache_put",
      description: "Store a value in the cache with TTL. Useful for caching API responses, computed values, etc.",
      inputSchema: {
        type: "object",
        properties: {
          key: {
            type: "string",
            description: "Cache key"
          },
          value: {
            description: "Value to cache (any JSON-serializable data)"
          },
          ttl_seconds: {
            type: "number",
            description: "Time to live in seconds",
            default: 300,
            minimum: 1,
            maximum: 86400 // 24 hours
          },
          namespace: {
            type: "string",
            description: "Optional namespace to prevent key collisions",
            default: "default"
          }
        },
        required: ["key", "value"]
      }
    },
  • Handler function for cache_put in index-v2.ts - adds namespace support using composite cache keys
    case "cache_put": {
      const { key, value, ttl_seconds = 300, namespace = "default" } = args as any;
      const cacheKey = getCacheKey(key, namespace);
      
      const expiresAt = Date.now() + (ttl_seconds * 1000);
      cache.set(cacheKey, { value, expiresAt });
    
      return {
        content: [{
          type: "text",
          text: JSON.stringify({
            success: true,
            key,
            namespace,
            ttl_seconds,
            expires_at: new Date(expiresAt).toISOString(),
            cache_size: cache.size
          })
        }]
      };
    }
  • Helper function getCacheKey used by cache_put handler in index-v2.ts to support namespaced cache keys
    function getCacheKey(key: string, namespace: string = "default"): string {
      return `${namespace}:${key}`;
    }
Behavior3/5

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

No annotations are provided, so the description must cover behavioral traits. It mentions TTL and examples but omits details like overwrite behavior, error handling, or what happens upon expiration.

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?

Two sentences, no unnecessary words. Information is front-loaded and every part contributes.

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

Completeness3/5

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

Given 4 parameters, no output schema, and no annotations, the description is adequate but lacks details on return value or error conditions. Could be more complete.

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 coverage is 100%, so baseline is 3. The description adds no extra meaning beyond what the schema already documents (e.g., default TTL, namespace optionality).

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

Purpose5/5

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

The description clearly states the action ('Store') and resource ('cache'), and specifies the TTL feature. It distinguishes from siblings like cache_get, cache_delete, and cache_clear by emphasizing storage with expiration.

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

Usage Guidelines3/5

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

The description provides examples of use cases ('caching API responses, computed values') but does not explicitly state when to use this tool over alternatives or when not to use it.

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/haasonsaas/mcp-utility-tools'

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