Skip to main content
Glama

get_short_term_memory

Retrieve session-specific data from temporary memory storage to maintain context and continuity in AI interactions.

Instructions

Retrieve data from short-term memory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyNoMemory key (optional, returns all if not provided)
sessionIdYesSession identifier

Implementation Reference

  • MCP tool handler execution logic: validates sessionId and optional key, retrieves short-term memory from store, returns as formatted JSON text response.
    case "get_short_term_memory": {
      const { sessionId, key } = request.params.arguments as any;
      
      // Validate inputs
      ValidationUtils.validateSessionId(sessionId);
      if (key !== undefined) {
        ValidationUtils.validateMemoryKey(key);
      }
      
      const memory = memoryStore.getShortTermMemory(sessionId, key);
      return {
        content: [{
          type: "text",
          text: JSON.stringify(memory, null, 2)
        }]
      };
    }
  • Input schema definition for the get_short_term_memory tool, specifying sessionId as required and key as optional.
    inputSchema: {
      type: "object",
      properties: {
        sessionId: {
          type: "string",
          description: "Session identifier"
        },
        key: {
          type: "string",
          description: "Memory key (optional, returns all if not provided)"
        }
      },
      required: ["sessionId"]
  • Tool registration in the list of available tools, including name, description, and input schema.
    {
      name: "get_short_term_memory",
      description: "Retrieve data from short-term memory",
      inputSchema: {
        type: "object",
        properties: {
          sessionId: {
            type: "string",
            description: "Session identifier"
          },
          key: {
            type: "string",
            description: "Memory key (optional, returns all if not provided)"
          }
        },
        required: ["sessionId"]
      }
    },
  • Core implementation of short-term memory retrieval: fetches from in-memory map, checks expiration and cleans up if expired, returns specific key or entire session data.
    getShortTermMemory(sessionId: string, key?: string): any {
      const memory = this.shortTermMemory.get(sessionId);
      if (!memory || memory.expiresAt <= Date.now()) {
        this.shortTermMemory.delete(sessionId);
        return null;
      }
      return key ? memory.data[key] : memory.data;
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves data, implying a read-only operation, but does not specify if it requires authentication, has rate limits, returns structured or unstructured data, or handles errors. This leaves significant gaps in understanding the tool's behavior beyond basic retrieval.

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 no wasted words. It is front-loaded with the core action and resource, making it easy to parse quickly. Every word earns its place by directly conveying the tool's purpose.

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?

Given the lack of annotations and output schema, the description is incomplete for a retrieval tool. It does not explain what data is returned, in what format, or any behavioral traits like error handling. For a tool with 2 parameters and no structured output, more context is needed to guide effective usage.

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%, with clear documentation for both parameters: 'key' (optional, returns all if not provided) and 'sessionId' (required). The description does not add any meaning beyond what the schema provides, such as explaining the format of keys or session IDs, so it meets the baseline for high schema coverage without extra value.

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

Purpose3/5

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

The description 'Retrieve data from short-term memory' clearly states the verb ('retrieve') and resource ('short-term memory'), distinguishing it from siblings like 'add_episodic_memory' or 'set_short_term_memory'. However, it lacks specificity about what kind of data is retrieved or the scope, making it somewhat vague compared to a fully detailed purpose statement.

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 provides no guidance on when to use this tool versus alternatives like 'get_long_term_memory' or 'get_episodic_memory'. It does not mention any prerequisites, exclusions, or specific contexts for usage, leaving the agent to infer based on tool names alone.

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