Skip to main content
Glama
CoderDayton

verifiable-thinking-mcp

clear_session

Clear session data to free memory in the verifiable-thinking-mcp server. Remove specific or all sessions using session_id or all parameters.

Instructions

Clear session(s) to free memory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
session_idNoSession ID to clear (omit for all)
allYesClear all sessions

Implementation Reference

  • Main handler for clear_session tool. Exports clearSessionTool with name 'clear_session', description, zod schema for parameters (session_id optional, all boolean), and execute function that clears either a specific session or all sessions using SessionManager.clear/clearAll and clearTracker helpers.
    export const clearSessionTool = {
      name: "clear_session",
      description: "Clear session(s) to free memory",
      parameters: z.object({
        session_id: z.string().optional().describe("Session ID to clear (omit for all)"),
        all: z.boolean().default(false).describe("Clear all sessions"),
      }),
      execute: async (args: { session_id?: string; all?: boolean }) => {
        let result: string;
    
        if (args.all) {
          const count = SessionManager.clearAll();
          result = `Cleared ${count} session(s).`;
        } else if (!args.session_id) {
          result = "Provide session_id or set all=true";
        } else {
          // Also clear concept tracker for this session
          clearTracker(args.session_id);
    
          const cleared = SessionManager.clear(args.session_id);
          result = cleared
            ? `Cleared session: ${args.session_id}`
            : `Session not found: ${args.session_id}`;
        }
    
        const tokens = calculateTokenUsage(args, result);
        return `${result}\n\n---\n_tokens: ${tokens.input_tokens} in, ${tokens.output_tokens} out, ${tokens.total_tokens} total_`;
      },
    };
  • Zod schema defining input parameters for clear_session tool: session_id (optional string) and all (boolean default false).
    parameters: z.object({
      session_id: z.string().optional().describe("Session ID to clear (omit for all)"),
      all: z.boolean().default(false).describe("Clear all sessions"),
    }),
  • src/index.ts:24-24 (registration)
    Registers clearSessionTool with the FastMCP server using server.addTool(clearSessionTool).
    server.addTool(clearSessionTool);
  • SessionManager.clear() and clearAll() methods used by clear_session tool to remove sessions from memory.
    clear(sessionId: string): boolean {
      // Clear active session tracking if this is the active session
      if (this.activeSessionId === sessionId) {
        this.activeSessionId = null;
      }
      return this.sessions.delete(sessionId);
    }
    
    clearAll(): number {
      const count = this.sessions.size;
      this.sessions.clear();
      // Also clear the active session tracking
      this.activeSessionId = null;
      return count;
    }
  • clearTracker() helper function that removes the concept tracker for a specific session when clearing.
    export function clearTracker(sessionId: string): void {
      trackers.delete(sessionId);
    }

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/CoderDayton/verifiable-thinking-mcp'

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