Skip to main content
Glama

set_short_term_memory

Store session-specific data with configurable expiration time to maintain context during AI interactions.

Instructions

Store data in short-term memory for a session

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYesMemory key
sessionIdYesSession identifier
ttlMinutesNoTime to live in minutes (default: 30)
valueYesMemory value (any JSON-serializable data)

Implementation Reference

  • MCP tool handler case for 'set_short_term_memory': validates input parameters and delegates storage to MemoryStore.
    case "set_short_term_memory": {
      const { sessionId, key, value, ttlMinutes = 30 } = request.params.arguments as any;
      
      // Validate inputs
      ValidationUtils.validateSessionId(sessionId);
      ValidationUtils.validateMemoryKey(key);
      ValidationUtils.validateTTLMinutes(ttlMinutes);
      
      memoryStore.setShortTermMemory(sessionId, key, value, ttlMinutes);
      return {
        content: [{
          type: "text",
          text: `Stored short-term memory for session ${sessionId}: ${key}`
        }]
      };
    }
  • Tool specification including name, description, and input schema for 'set_short_term_memory' returned in ListTools.
    {
      name: "set_short_term_memory",
      description: "Store data in short-term memory for a session",
      inputSchema: {
        type: "object",
        properties: {
          sessionId: {
            type: "string",
            description: "Session identifier"
          },
          key: {
            type: "string",
            description: "Memory key"
          },
          value: {
            description: "Memory value (any JSON-serializable data)"
          },
          ttlMinutes: {
            type: "number",
            description: "Time to live in minutes (default: 30)",
            default: 30
          }
        },
        required: ["sessionId", "key", "value"]
      }
    },
  • Core implementation of short-term memory storage with TTL expiration handling in MemoryStore class.
    setShortTermMemory(sessionId: string, key: string, value: any, ttlMinutes?: number): void {
      const ttl = ttlMinutes || this.config.defaultTTLMinutes || 30;
      const expiresAt = Date.now() + (ttl * 60 * 1000);
      const existing = this.shortTermMemory.get(sessionId);
      
      if (existing && existing.expiresAt > Date.now()) {
        existing.data[key] = value;
        existing.expiresAt = expiresAt;
      } else {
        this.shortTermMemory.set(sessionId, {
          sessionId,
          data: { [key]: value },
          timestamp: Date.now(),
          expiresAt
        });
      }
    }
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 action ('Store') but lacks details on permissions, idempotency, error handling, or what happens on conflicts. It mentions TTL via the schema but doesn't explain behavioral implications like automatic 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?

The description is a single, efficient sentence with zero waste. It's front-loaded with the core action and resource, making it easy to parse quickly without unnecessary elaboration.

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 incomplete. It doesn't cover behavioral aspects like side effects, return values, or error conditions. Given the complexity of memory operations and lack of structured safety hints, more context is needed for safe agent invocation.

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 fully documents all parameters. The description adds no additional semantic context beyond implying session-scoped storage, which is already covered by the 'sessionId' parameter in the schema. Baseline 3 is appropriate as the schema handles parameter documentation.

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 verb ('Store') and resource ('data in short-term memory'), specifying it's for a session. However, it doesn't explicitly differentiate from sibling tools like 'set_long_term_memory' or 'add_episodic_memory', which would require mentioning the specific memory type and session scope.

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 implies usage for session-specific storage but provides no explicit guidance on when to use this tool versus alternatives like 'set_long_term_memory' or 'add_episodic_memory'. There's no mention of prerequisites, exclusions, or comparative contexts with sibling tools.

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/cbuntingde/memory-mcp-server'

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