clear_codegen_session
Clear a Playwright browser automation code generation session by removing stored data without creating test files. Use this to reset session state when automation workflows change.
Instructions
Clear a code generation session without generating a test
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | ID of the session to clear |
Implementation Reference
- src/tools/codegen/index.ts:182-202 (handler)Primary implementation of the clear_codegen_session tool, defining its schema (parameters), description, and handler function. The handler calls ActionRecorder.clearSession(sessionId) to remove the session and returns success status.export const clearCodegenSession: Tool = { name: 'clear_codegen_session', description: 'Clear a code generation session', parameters: { type: 'object', properties: { sessionId: { type: 'string', description: 'ID of the session to clear' } }, required: ['sessionId'] }, handler: async ({ sessionId }: { sessionId: string }) => { const success = ActionRecorder.getInstance().clearSession(sessionId); if (!success) { throw new Error(`Session ${sessionId} not found`); } return { success }; } };
- src/tools.ts:64-77 (schema)MCP tool schema definition for clear_codegen_session, used in createToolDefinitions() for tool listing and validation.{ name: "clear_codegen_session", description: "Clear a code generation session without generating a test", inputSchema: { type: "object", properties: { sessionId: { type: "string", description: "ID of the session to clear" } }, required: ["sessionId"] } },
- src/toolHandler.ts:371-372 (registration)Registration and dispatch logic in the main tool handler switch statement, calling the imported clearCodegenSession.handler directly.case 'clear_codegen_session': return await handleCodegenResult(clearCodegenSession.handler(args));
- src/tools/codegen/recorder.ts:72-77 (helper)Supporting clearSession method in ActionRecorder singleton that removes the session from the internal sessions Map and clears active session if matching.clearSession(sessionId: string): boolean { if (this.activeSession === sessionId) { this.activeSession = null; } return this.sessions.delete(sessionId); }
- src/tools.ts:485-490 (registration)Listing of clear_codegen_session in CODEGEN_TOOLS array, likely used for categorization or conditional enabling of codegen tools.export const CODEGEN_TOOLS = [ 'start_codegen_session', 'end_codegen_session', 'get_codegen_session', 'clear_codegen_session' ];