Skip to main content
Glama
RonsDad
by RonsDad

multi_browserbase_stagehand_session_close

Terminate a browser session to free cloud resources and prevent unnecessary billing charges. Properly closes sessions in multi-session workflows to avoid resource waste.

Instructions

Cleanup parallel session for multi-session workflows. Properly terminates a browser session, ends the Browserbase session, and frees cloud resources. Always use this when finished with a session to avoid resource waste and billing charges. Critical for responsible multi-session automation - each unclosed session continues consuming resources!

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesExact session ID to close (get from 'multi_browserbase_stagehand_session_list'). Double-check this ID - once closed, the session cannot be recovered!

Implementation Reference

  • The tool handler implementation for 'multi_browserbase_stagehand_session_close'. It retrieves the session from the store using the provided sessionId, removes it if found, and returns a confirmation message. Includes the schema definition and registration via defineTool.
    export const closeSessionTool = defineTool({
      capability: "close_session",
      schema: {
        name: "multi_browserbase_stagehand_session_close",
        description:
          "Cleanup parallel session for multi-session workflows. Properly terminates a browser session, ends the Browserbase session, and frees cloud resources. Always use this when finished with a session to avoid resource waste and billing charges. Critical for responsible multi-session automation - each unclosed session continues consuming resources!",
        inputSchema: z.object({
          sessionId: z
            .string()
            .describe(
              "Exact session ID to close (get from 'multi_browserbase_stagehand_session_list'). Double-check this ID - once closed, the session cannot be recovered!",
            ),
        }),
      },
      handle: async (_context: Context, { sessionId }): Promise<ToolResult> => {
        const session = stagehandStore.get(sessionId);
        if (!session) {
          throw new Error(`Session ${sessionId} not found`);
        }
    
        await stagehandStore.remove(sessionId);
    
        return {
          action: async () => ({
            content: [
              {
                type: "text",
                text: `Closed session ${sessionId}`,
              },
            ],
          }),
          waitForNetwork: false,
        };
      },
    });
  • Registers the multi_browserbase_stagehand_session_close tool (as closeSessionTool) in the multiSessionTools array, which is included in the main TOOLS export for use in the MCP server.
    export const multiSessionTools = [
      createSessionTool,
      listSessionsTool,
      closeSessionTool,
      navigateWithSessionTool,
      actWithSessionTool,
      extractWithSessionTool,
      observeWithSessionTool,
      getUrlWithSessionTool,
      getAllUrlsWithSessionTool,
    ];
  • Input schema for the tool, requiring a sessionId string.
    schema: {
      name: "multi_browserbase_stagehand_session_close",
      description:
        "Cleanup parallel session for multi-session workflows. Properly terminates a browser session, ends the Browserbase session, and frees cloud resources. Always use this when finished with a session to avoid resource waste and billing charges. Critical for responsible multi-session automation - each unclosed session continues consuming resources!",
      inputSchema: z.object({
        sessionId: z
          .string()
          .describe(
            "Exact session ID to close (get from 'multi_browserbase_stagehand_session_list'). Double-check this ID - once closed, the session cannot be recovered!",
          ),
      }),
    },
Behavior4/5

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

With no annotations provided, the description carries the full burden and does well by disclosing key behavioral traits: it's a destructive operation ('terminates', 'ends', 'frees', 'once closed, the session cannot be recovered'), has cost implications ('billing charges'), and is critical for resource management ('avoids resource waste', 'each unclosed session continues consuming resources'). It doesn't cover rate limits or auth needs, but given the lack of annotations, this is strong disclosure.

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 front-loaded with the core purpose in the first sentence, followed by critical usage guidelines and warnings. Every sentence earns its place by adding essential information about behavior, usage, and consequences, with no wasted words or redundancy.

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

Completeness4/5

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

Given the tool's complexity (destructive operation with cost implications), no annotations, and no output schema, the description is largely complete. It covers purpose, usage, behavioral traits, and parameter context. A minor gap is the lack of explicit error handling or confirmation of success, but it strongly addresses the core needs for a cleanup tool in this context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/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 value by emphasizing the importance of the sessionId parameter ('Double-check this ID - once closed, the session cannot be recovered!') and providing context on where to get it ('get from multi_browserbase_stagehand_session_list'), which enhances understanding beyond the schema's technical details.

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 clearly states the specific action ('cleanup', 'terminates', 'ends', 'frees') and resource ('parallel session for multi-session workflows', 'browser session', 'Browserbase session', 'cloud resources'). It distinguishes from siblings like 'browserbase_session_close' by specifying it's for 'multi-session workflows' and 'parallel sessions', making the purpose explicit and differentiated.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use ('Always use this when finished with a session') and why ('to avoid resource waste and billing charges', 'Critical for responsible multi-session automation'). It implicitly distinguishes from alternatives by specifying it's for 'multi-session workflows', helping the agent choose this over 'browserbase_session_close' for parallel sessions.

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/RonsDad/mcp-server-browserbase'

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