Skip to main content
Glama
haasonsaas

MCP Utility Tools

by haasonsaas

cache_get

Retrieve cached data by key to access stored values and reduce redundant processing in MCP workflows.

Instructions

Get a value from the cache by key. Returns null if not found or expired.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYesCache key to retrieve
namespaceNoOptional namespace to prevent key collisionsdefault

Implementation Reference

  • The handler for the 'cache_get' tool. It retrieves the cache entry by key, checks if it exists and is not expired, and returns a JSON response with the value or indication if not found or expired.
    case "cache_get": {
      const { key } = args as { key: string };
      
      const entry = cache.get(key);
      if (!entry) {
        return {
          content: [{
            type: "text",
            text: JSON.stringify({ found: false, key })
          }]
        };
      }
    
      // Check if expired
      if (entry.expiresAt <= Date.now()) {
        cache.delete(key);
        return {
          content: [{
            type: "text",
            text: JSON.stringify({ found: false, key, reason: "expired" })
          }]
        };
      }
    
      return {
        content: [{
          type: "text",
          text: JSON.stringify({
            found: true,
            key,
            value: entry.value,
            expires_in_seconds: Math.floor((entry.expiresAt - Date.now()) / 1000)
          })
        }]
      };
    }
  • src/index.ts:84-97 (registration)
    The tool registration object in the tools array, which includes the name, description, and input schema. This is returned by the ListTools handler.
    {
      name: "cache_get",
      description: "Get a value from the cache by key",
      inputSchema: {
        type: "object",
        properties: {
          key: {
            type: "string",
            description: "Cache key to retrieve"
          }
        },
        required: ["key"]
      }
    },
  • The input schema defining the expected arguments for the cache_get tool: a required 'key' string.
    inputSchema: {
      type: "object",
      properties: {
        key: {
          type: "string",
          description: "Cache key to retrieve"
        }
      },
      required: ["key"]
    }
  • The CacheEntry interface and cache Map storage used by the cache_get handler and other cache tools.
    interface CacheEntry {
      value: any;
      expiresAt: number;
    }
    
    const cache = new Map<string, CacheEntry>();
Behavior4/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 effectively describes key behaviors: it's a read operation (implied by 'Get'), returns null on misses or expired entries, and handles key-based retrieval. It doesn't mention performance, rate limits, or auth needs, but covers essential operational traits adequately.

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 two sentences, front-loaded with the core purpose and followed by a critical behavioral note. Every word earns its place, with zero waste or redundancy, making it highly efficient and easy to parse.

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

Completeness4/5

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

Given the tool's low complexity, no annotations, no output schema, and 100% schema coverage, the description is mostly complete. It covers purpose, behavior, and outcome, but could enhance completeness by mentioning sibling tool relationships or potential errors. It's sufficient for basic use but has minor gaps.

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 both parameters (key and namespace) fully. The description adds no additional meaning beyond what the schema provides, such as examples or edge cases. Baseline 3 is appropriate as the schema does the heavy lifting.

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 specific action ('Get a value') and resource ('from the cache by key'), distinguishing it from siblings like cache_put (store), cache_delete (remove), and cache_clear (clear all). It precisely defines the tool's function without ambiguity.

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

Usage Guidelines4/5

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

The description implies usage context by stating it 'Returns null if not found or expired,' suggesting it's for retrieval when existence is uncertain. However, it doesn't explicitly state when to use this versus alternatives like batch_operation or retry_operation, nor does it provide exclusions or prerequisites for usage.

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