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
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | Exact session ID to close (get from 'multi_browserbase_stagehand_session_list'). Double-check this ID - once closed, the session cannot be recovered! |
Implementation Reference
- src/tools/multiSession.ts:203-237 (handler)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, }; }, }); - src/tools/index.ts:30-40 (registration)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, ]; - src/tools/multiSession.ts:205-216 (schema)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!", ), }), },