Skip to main content
Glama
devskido

Playwright MCP Server

by devskido

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
NameRequiredDescriptionDefault
sessionIdYesID of the session to clear

Implementation Reference

  • 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 };
      }
    };
  • 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"]
      }
    },
  • 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));
  • 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'
    ];

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

C2.9/5.0
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states the tool clears a session, implying a destructive/mutation operation, but doesn't disclose behavioral traits such as whether this is reversible, what 'clear' entails (e.g., deleting data, resetting state), permissions required, error handling, or side effects. For a mutation tool with zero annotation coverage, this is inadequate.

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

Conciseness5/5

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

The description is a single, efficient sentence that is front-loaded with the core action ('Clear a code generation session') and adds a clarifying detail ('without generating a test'). There is no wasted text, and it's appropriately sized for the tool's complexity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool is a mutation operation (clearing a session) with no annotations and no output schema, the description is incomplete. It doesn't explain what 'clear' means behaviorally, what happens after clearing, potential errors, or return values. For a destructive tool, more context is needed to be fully helpful.

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?

The input schema has 100% description coverage, with 'sessionId' documented as 'ID of the session to clear'. The description doesn't add any parameter semantics beyond this, such as format examples or constraints. With high schema coverage, the baseline is 3, as the schema does the heavy lifting and no extra value is added.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Clear') and resource ('a code generation session'), specifying what the tool does. It distinguishes from potential sibling 'end_codegen_session' by noting it clears 'without generating a test', though it doesn't explicitly name alternatives. This provides good clarity but lacks explicit sibling differentiation for a full 5.

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?

The description implies usage by stating 'without generating a test', which hints at when not to use it (i.e., if you want a test, use something else). However, it doesn't provide explicit guidance on when to use this tool versus alternatives like 'end_codegen_session' or other session management tools, nor does it mention prerequisites or context. This is minimal guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.