Skip to main content
Glama

clear-session

Remove a specific session from the CodeAnalysis MCP Server to free up resources and ensure accurate analysis by providing the unique sessionId.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesID of the session to clear

Implementation Reference

  • MCP tool registration and handler for 'clear-session'. Calls the clearSession helper, handles errors, and returns formatted JSON response.
    server.tool( "clear-session", { sessionId: z.string().describe("ID of the session to clear"), }, async ({ sessionId }) => { try { const cleared = clearSession(sessionId); const result = createSuccessResponse( { sessionId, cleared, timestamp: new Date().toISOString(), }, "clear-session" ); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: JSON.stringify( createErrorResponse( error instanceof Error ? error.message : String(error), "clear-session" ), null, 2 ), }, ], isError: true, }; } } );
  • Core implementation of clearSession: deletes the session from the internal 'sessions' Map if it exists.
    export function clearSession(sessionId: string): boolean { if (sessions.has(sessionId)) { sessions.delete(sessionId); return true; } return false; }
  • src/server.ts:84-86 (registration)
    Registers the session manager feature (including clear-session tool) by calling registerSessionTools via registerToolsOnce.
    console.log("• Registering session manager features..."); registerToolsOnce(registerSessionTools); console.log("✓");
  • Zod input schema for the clear-session tool requiring a sessionId string.
    { sessionId: z.string().describe("ID of the session to clear"),

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/0xjcf/MCP_CodeAnalysis'

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