Skip to main content
Glama
haasonsaas

MCP Utility Tools

by haasonsaas

cache_get

Retrieve a cached value by key, returning null if the key is missing or expired. Supports optional namespaces to prevent collisions.

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 cache_get tool handler in the original implementation. Retrieves a value from cache by key, checks for expiration, and returns the value with remaining TTL.
    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)
          })
        }]
      };
    }
  • The cache_get tool handler in the v2 implementation. Retrieves a value from cache by key (with namespace support), checks for expiration, and returns the value with remaining TTL.
    case "cache_get": {
      const { key, namespace = "default" } = args as any;
      const cacheKey = getCacheKey(key, namespace);
      
      const entry = cache.get(cacheKey);
      if (!entry) {
        return {
          content: [{
            type: "text",
            text: JSON.stringify({ 
              found: false, 
              key,
              namespace
            })
          }]
        };
      }
    
      // Check if expired
      if (entry.expiresAt <= Date.now()) {
        cache.delete(cacheKey);
        return {
          content: [{
            type: "text",
            text: JSON.stringify({ 
              found: false, 
              key,
              namespace,
              reason: "expired" 
            })
          }]
        };
      }
    
      return {
        content: [{
          type: "text",
          text: JSON.stringify({
            found: true,
            key,
            namespace,
            value: entry.value,
            expires_in_seconds: Math.floor((entry.expiresAt - Date.now()) / 1000)
          })
        }]
      };
    }
  • Schema definition for cache_get in the original implementation. Requires 'key' parameter (string).
    {
      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"]
      }
    },
  • Schema definition for cache_get in the v2 implementation. Requires 'key' (string) with optional 'namespace' (string, default 'default').
    {
      name: "cache_get",
      description: "Get a value from the cache by key. Returns null if not found or expired.",
      inputSchema: {
        type: "object",
        properties: {
          key: {
            type: "string",
            description: "Cache key to retrieve"
          },
          namespace: {
            type: "string",
            description: "Optional namespace to prevent key collisions",
            default: "default"
          }
        },
        required: ["key"]
      }
    },
  • src/index.ts:189-191 (registration)
    The 'cache_get' tool is registered via the 'tools' array (line 85) which is provided to the ListToolsRequestSchema handler. The call handler at line 211 dispatches to the case at line 268.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return { tools };
    });
Behavior4/5

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

Discloses return null on missing/expired keys, which addresses key behavioral trait. No annotations provided, so description carries full burden; adequate for a simple read operation.

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 concise sentences with purpose front-loaded. No wasted words; every sentence adds value.

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?

For a simple cache get tool, description covers purpose, return behavior, and key parameter. Could mention TTL expiration mechanism, but not critical given simplicity. No output schema needed.

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. Description does not add meaning beyond schema descriptions; 'Cache key' and 'Optional namespace' are already clear from schema.

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?

Description clearly states 'Get a value from the cache by key' and distinguishes from siblings like cache_put and cache_delete. Specific verb+resource with additional behavior (returns null if not found/expired).

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?

Clear when to use (retrieve cached value) and what to expect (null if missing/expired). Lacks explicit when-not-to-use or alternatives, but sibling names provide implicit context.

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