Skip to main content
Glama

restore_session_context

Restores previous session context to recover work progress, decisions, code snippets, and debugging information for continued development tasks.

Instructions

restore|revert|go back|recover session - Restore previous session context

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesSession ID to restore
restoreLevelNoLevel of detail to restore
filterTypeNoFilter context by type

Implementation Reference

  • The core handler function for the 'restore_session_context' tool. It retrieves context memories from MemoryManager, filters by sessionId, optional restoreLevel and filterType, limits results, and formats a text response listing restored items.
    export async function restoreSessionContext(args: { sessionId: string; restoreLevel?: string; filterType?: string }): Promise<ToolResult> {
      const { sessionId, restoreLevel = 'detailed', filterType = 'all' } = args;
    
      try {
        const memoryManager = MemoryManager.getInstance();
    
        // Get all context memories
        let memories = memoryManager.list('context');
    
        // Filter by session ID
        memories = memories.filter(m => m.key.includes(sessionId));
    
        // Filter by context type if not 'all'
        if (filterType !== 'all') {
          memories = memories.filter(m => {
            try {
              const contextData = JSON.parse(m.value);
              return contextData.contextType === filterType;
            } catch {
              return false;
            }
          });
        }
    
        const maxItems = restoreLevel === 'essential' ? 3 : restoreLevel === 'detailed' ? 10 : 20;
        const limitedMemories = memories.slice(0, maxItems);
    
        if (limitedMemories.length === 0) {
          return {
            content: [{ type: 'text', text: `✗ No context found for session: ${sessionId}` }]
          };
        }
    
        let response = `✓ Restored ${limitedMemories.length} context item(s) for session: ${sessionId}\n`;
    
        limitedMemories.forEach(m => {
          try {
            const data = JSON.parse(m.value);
            response += `\n• ${data.contextType || 'context'} (${data.urgency || 'medium'})`;
            if (data.summary) response += `: ${data.summary}`;
            response += `\n  Time: ${new Date(m.timestamp).toLocaleString()}`;
          } catch {
            response += `\n• ${m.key}\n  Time: ${new Date(m.timestamp).toLocaleString()}`;
          }
        });
    
        return {
          content: [{ type: 'text', text: response }]
        };
      } catch (error) {
        return {
          content: [{ type: 'text', text: `✗ Error: ${error instanceof Error ? error.message : 'Unknown error'}` }]
        };
      }
    }
  • The ToolDefinition object defining the tool's name, description, input schema (with sessionId required, optional restoreLevel and filterType), and annotations.
    export const restoreSessionContextDefinition: ToolDefinition = {
      name: 'restore_session_context',
      description: 'restore|revert|go back|recover session - Restore previous session context',
      inputSchema: {
        type: 'object',
        properties: {
          sessionId: { type: 'string', description: 'Session ID to restore' },
          restoreLevel: { type: 'string', description: 'Level of detail to restore', enum: ['essential', 'detailed', 'complete'] },
          filterType: { type: 'string', description: 'Filter context by type', enum: ['all', 'progress', 'decisions', 'code-snippets', 'debugging', 'planning'] }
        },
        required: ['sessionId']
      },
      annotations: {
        title: 'Restore Session',
        audience: ['user', 'assistant']
      }
    };
  • src/index.ts:650-651 (registration)
    In the executeToolCall switch statement, dispatches calls to the restoreSessionContext handler function.
    case 'restore_session_context':
      return await restoreSessionContext(args as any) as CallToolResult;
  • src/index.ts:132-132 (registration)
    The tool definition is added to the 'tools' array, making it available via listTools in the MCP server.
    restoreSessionContextDefinition,
  • src/index.ts:64-64 (registration)
    Imports the handler function and its ToolDefinition from the tool's module.
    import { restoreSessionContext, restoreSessionContextDefinition } from './tools/memory/restoreSessionContext.js';
Behavior3/5

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

Annotations only provide a title ('Restore Session'), with no hints on read-only or destructive behavior. The description adds minimal behavioral context by implying a restoration action, but it doesn't disclose details like whether this overwrites current context, requires specific permissions, or has side effects. With no annotations to rely on, the description carries the burden but offers limited transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and front-loaded with key verbs, using minimal words to convey the core action. However, it could be more structured by clarifying the tool's scope or differentiating it from siblings, but it avoids redundancy and is efficiently phrased.

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?

Given no output schema and no annotations beyond a title, the description is incomplete for a tool with 3 parameters and behavioral implications. It covers the basic purpose but lacks details on return values, error conditions, or integration with sibling tools, making it minimally viable but with clear gaps in context.

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 descriptions and enums for parameters. The description adds no additional meaning beyond the schema, such as explaining the impact of 'restoreLevel' or 'filterType' choices. Baseline score of 3 is appropriate as the schema adequately documents parameters without description enhancement.

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 states the action ('restore|revert|go back|recover') and resource ('session context'), making the purpose clear. However, it does not differentiate from sibling tools like 'recall_memory' or 'list_memories' that also deal with session or memory retrieval, leaving ambiguity about when to choose this tool over others.

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?

No explicit guidance is provided on when to use this tool versus alternatives. The description implies it's for restoring session context, but it doesn't specify scenarios, prerequisites, or exclusions, such as whether it requires a previously saved session or how it differs from tools like 'recall_memory'.

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/ssdeanx/ssd-ai'

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