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'
    ];
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool clears a session but doesn't explain what 'clear' entails—whether it deletes data, resets state, or has side effects like requiring specific permissions or affecting other sessions. This lack of detail makes it hard for an agent to predict outcomes or assess risks.

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 directly states the tool's purpose without unnecessary words. It's front-loaded and wastes no space, making it easy for an agent to parse quickly and understand the core action.

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?

For a tool that performs a mutation (clearing a session) with no annotations and no output schema, the description is incomplete. It lacks details on behavioral traits, side effects, or what happens after clearing, which are critical for an agent to use it correctly and safely in context with sibling tools.

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 the 'sessionId' parameter well-documented. The description doesn't add any extra meaning about parameters beyond what the schema provides, such as format or validation rules. Given the high schema coverage, a baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

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'), and distinguishes it from generating tests. However, it doesn't explicitly differentiate from its sibling 'end_codegen_session', which might serve a similar purpose, leaving some ambiguity about when to use one versus the other.

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 provides minimal guidance by mentioning 'without generating a test', but it doesn't specify when to use this tool versus alternatives like 'end_codegen_session' or other session management tools. No explicit context or exclusions are provided, leaving the agent with little direction on appropriate usage scenarios.

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

Install Server

Other Tools

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/devskido/customed-playwright'

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