Skip to main content
Glama

manage_browser_sessions

List, close, or clean up idle browser sessions. Get detailed session status and statistics, with protection for documentation sessions to prevent data loss.

Instructions

Manage browser sessions: list, close, cleanup idle sessions, get status

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesManagement action to perform: 'list' shows all sessions, 'close' closes specific session, 'close_all' closes all sessions, 'cleanup_idle' removes idle sessions, 'get_status' provides detailed session statistics
session_idNoSession ID to operate on. Required for 'close' action, ignored for other actions
force_closeNoWhether to force close sessions even if they are marked as documentation sessions (which are normally protected from auto-close)
cleanup_criteriaNoCriteria for cleanup_idle action. Defines which sessions should be considered for cleanup

Implementation Reference

  • Main handler for manage_browser_sessions tool. Accepts action parameter: 'list', 'close', 'close_all', 'cleanup_idle', or 'get_status' and dispatches to the appropriate enhanced session management method.
    private async manageBrowserSessions(args: z.infer<typeof BrowserManageSessionsSchema>) {
      const params = BrowserManageSessionsSchema.parse(args);
      
      let result;
      switch (params.action) {
        case 'list':
          result = await this.listBrowserSessionsEnhanced();
          break;
          
        case 'close':
          if (!params.session_id) {
            return { success: false, error: 'session_id required for close action' };
          }
          result = await this.closeBrowserSessionEnhanced(params.session_id, params.force_close);
          break;
          
        case 'close_all':
          result = await this.closeAllSessions(params.force_close);
          break;
          
        case 'cleanup_idle':
          result = await this.cleanupIdleSessions(params.cleanup_criteria);
          break;
          
        case 'get_status':
          result = await this.getSessionsStatus();
          break;
          
        default:
          return { success: false, error: `Unknown action: ${params.action}` };
      }
      
      return this.transformResultData(result, 'manage_browser_sessions');
    }
  • Zod schema defining the input validation for manage_browser_sessions. Supports actions: list, close, close_all, cleanup_idle, get_status with optional session_id, force_close, and cleanup_criteria fields.
    export const BrowserManageSessionsSchema = z.object({
      action: z.enum(["list", "close", "close_all", "cleanup_idle", "get_status"]).describe("Management action to perform: 'list' shows all sessions, 'close' closes specific session, 'close_all' closes all sessions, 'cleanup_idle' removes idle sessions, 'get_status' provides detailed session statistics"),
      session_id: z.string().optional().describe("Session ID to operate on. Required for 'close' action, ignored for other actions"),
      force_close: z.boolean().default(false).describe("Whether to force close sessions even if they are marked as documentation sessions (which are normally protected from auto-close)"),
      cleanup_criteria: z
        .object({
          max_idle_minutes: z.number().default(10).describe("Maximum idle time in minutes before a session is considered for cleanup"),
          exclude_documentation: z.boolean().default(true).describe("Whether to exclude documentation sessions from cleanup (recommended to prevent data loss)"),
        })
        .optional().describe("Criteria for cleanup_idle action. Defines which sessions should be considered for cleanup"),
    }).describe("Manage browser sessions with actions like listing, closing, bulk cleanup, and getting detailed status information. Includes protection for documentation sessions to prevent data loss.");
  • Tool registration within BrowserTools.getTools() method. Registers manage_browser_sessions with its name, description, input/output schemas, and handler.
    {
      name: 'manage_browser_sessions',
      description: 'Manage browser sessions: list, close, cleanup idle sessions, get status',
      inputSchema: zodToJsonSchema(BrowserManageSessionsSchema),
      outputSchema: zodToJsonSchema(BrowserOperationResponseSchema),
      handler: (args: any) => this.manageBrowserSessions(args)
    },
  • Registration in the installer's list of browser automation tools under the MCP prefixed name.
    "mcp__claude-mcp-tools__manage_browser_sessions",
  • Helper that enriches raw session data with metadata (workflow type, auto-close, last activity, task completion) for the 'list' action.
    private async listBrowserSessionsEnhanced() {
      const sessions = await this.listSessionsCore();
      
      return {
        success: true,
        sessions: sessions.map(session => {
          const metadata = this.sessionMetadata.get(session.id);
          return {
            ...session,
            workflowType: metadata?.workflowType || 'unknown',
            autoClose: metadata?.autoClose || false,
            lastActivity: metadata?.lastActivity || session.lastUsed,
            taskCompleted: metadata?.taskCompleted || false
          };
        })
      };
    }
Behavior2/5

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

No annotations are provided, so the description must disclose behavioral traits. It only says 'manage' without stating that actions like 'close' and 'cleanup_idle' are destructive. The schema mentions protection for documentation sessions, but the description omits this crucial behavioral detail.

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

Conciseness4/5

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

The description is a single sentence that efficiently conveys the tool's scope. It is not overly verbose, though it could benefit from structured format (e.g., bullet points) for clarity.

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's complexity (4 parameters, nested object, multiple actions) and lack of output schema, the description is too minimal. It does not explain action outcomes, return values, or when to use specific actions, leaving the agent underinformed.

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?

Schema description coverage is 100%, so the baseline is 3. The description adds no additional meaning beyond listing actions; all parameter details are already in the schema.

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

Purpose5/5

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

The description explicitly states the tool's purpose: managing browser sessions with actions like list, close, cleanup idle, and get status. It clearly distinguishes from siblings such as 'list_browser_sessions' and 'close_browser_session' by offering a consolidated management interface.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description lists actions but does not explicitly guide when to use this tool versus sibling tools. It implies usage for multi-action management (e.g., bulk cleanup) but lacks direct comparisons or exclusions.

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/ZachHandley/ZMCPTools'

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