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
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | ID 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"),