Skip to main content
Glama
cachly-dev

Cachly — AI Cognitive Brain

cache_stream_set

Cache ordered string chunks from an LLM token stream as Redis list elements for later replay.

Instructions

Cache a list of string chunks (e.g. LLM token stream) via Redis RPUSH. Each chunk is stored as a separate list element under cachly:stream:{key}. Replay with cache_stream_get.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
instance_idYesUUID of the cache instance
keyYesCache key
chunksYesOrdered list of string chunks
ttlNoTTL in seconds for the stored list (optional)

Implementation Reference

  • Handler implementation for cache_stream_set. Destructures args (instance_id, key, chunks, ttl), validates chunks is a non-empty array, deletes any existing list at cachly:stream:{key}, then uses a Redis pipeline to RPUSH all chunks and optionally sets a TTL. Returns a success message with chunk count, TTL info, and total char size.
    case 'cache_stream_set': {
      const { instance_id, key, chunks, ttl } = args as { instance_id: string; key: string; chunks: string[]; ttl?: number };
      if (!Array.isArray(chunks) || chunks.length === 0) return '⚠️ No chunks provided.';
      const redis = await getConnection(instance_id);
      const listKey = `cachly:stream:${key}`;
      await redis.del(listKey);
      const pipe = redis.pipeline();
      for (const chunk of chunks) pipe.rpush(listKey, chunk);
      if (ttl && ttl > 0) pipe.expire(listKey, ttl);
      await pipe.exec();
      return `✅ **cache_stream_set** – ${chunks.length} chunk(s) stored.\n  Key: \`${key}\`\n${ttl ? `  TTL: ${ttl}s\n` : ''}  Total size: ${chunks.reduce((a, c) => a + c.length, 0)} chars`;
    }
  • Schema/registration definition for cache_stream_set tool. Defines name, description, and inputSchema with required fields: instance_id (string), key (string), chunks (string array), and optional ttl (number).
    {
      name: 'cache_stream_set',
      description:
        'Cache a list of string chunks (e.g. LLM token stream) via Redis RPUSH. ' +
        'Each chunk is stored as a separate list element under cachly:stream:{key}. ' +
        'Replay with cache_stream_get.',
      inputSchema: {
        type: 'object',
        properties: {
          instance_id: { type: 'string',  description: 'UUID of the cache instance' },
          key:         { type: 'string',  description: 'Cache key' },
          chunks:      { type: 'array', items: { type: 'string' }, description: 'Ordered list of string chunks' },
          ttl:         { type: 'number',  description: 'TTL in seconds for the stored list (optional)' },
        },
        required: ['instance_id', 'key', 'chunks'],
      },
    },
  • Registration of cache_stream_set in the CACHE_TOOL_NAMES set, which is used by the dispatch logic in handleCacheTool to route tool calls to the correct case branch.
    export const CACHE_TOOL_NAMES = new Set([
      'cache_get', 'cache_set', 'cache_delete', 'cache_exists', 'cache_ttl', 'cache_keys',
      'cache_stats', 'semantic_search', 'detect_namespace', 'cache_warmup', 'index_project',
      'cache_mset', 'cache_mget', 'cache_lock_acquire', 'cache_lock_release',
      'cache_stream_set', 'cache_stream_get',
    ]);
Behavior3/5

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

Describes underlying Redis RPUSH and key pattern, adding behavioral context beyond the schema. However, no annotations exist, and it omits details like overwrite behavior (appends) or default TTL.

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 no fluff; key information front-loaded.

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?

Covers main purpose and mechanism, but lacking details on idempotency, return value (no output schema), and limits. Adequate but not comprehensive for a mutation tool with no annotations.

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 covers all 4 parameters with descriptions. The description adds limited extra context (list elements, key pattern) but does not substantially enhance understanding beyond 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?

Clear verb and resource: caches a list of string chunks via Redis RPUSH. Distinguishes from siblings like cache_set by specifying streaming semantics and naming the complementary getter tool.

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?

Implies use for streaming data (LLM token stream) and mentions replay via cache_stream_get, but lacks explicit when-to-use vs alternatives (e.g., cache_set) or exclusions.

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/cachly-dev/cachly-mcp'

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