interceptor_browser_close
Close a browser instance launched for proxy interception. Requires the target ID from the browser launch command.
Instructions
Close a browser instance launched by interceptor_browser_launch (or interceptor_camoufox_launch).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| target_id | Yes | Target ID from interceptor_browser_launch or interceptor_camoufox_launch |
Implementation Reference
- src/interceptors/browser.ts:141-151 (handler)BrowserInterceptor.deactivate() — closes browser context and browser, removes entry from launched map
async deactivate(targetId: string): Promise<void> { const entry = this.launched.get(targetId); if (!entry) { throw new Error(`No browser instance with target ID '${targetId}'`); } try { await entry.context.close(); } catch { /* best effort */ } try { await entry.browser.close(); } catch { /* already gone */ } this.launched.delete(targetId); } - src/tools/interceptors.ts:268-290 (registration)MCP tool registration for 'interceptor_browser_close' with schema (target_id) and handler that delegates to interceptorManager.deactivate()
server.tool( "interceptor_browser_close", "Close a browser instance launched by interceptor_browser_launch (or interceptor_camoufox_launch).", { target_id: z.string().describe("Target ID from interceptor_browser_launch or interceptor_camoufox_launch"), }, async ({ target_id }) => { try { const interceptorId = typeof target_id === "string" && target_id.startsWith("camoufox_") ? "camoufox" : "browser"; await interceptorManager.deactivate(interceptorId, target_id); return { content: [{ type: "text", text: JSON.stringify({ status: "success", message: `Browser instance ${target_id} closed.` }), }], }; } catch (e) { return { content: [{ type: "text", text: JSON.stringify({ status: "error", error: errorToString(e) }) }] }; } }, ); - src/interceptors/manager.ts:45-71 (helper)InterceptorManager.deactivate() — resolves interceptor by ID and calls its deactivate(targetId)
/** Deactivate a specific target on a specific interceptor. */ async deactivate(interceptorId: string, targetId: string): Promise<void> { const interceptor = this.interceptors.get(interceptorId); if (!interceptor) { throw new Error(`Interceptor '${interceptorId}' not found.`); } await interceptor.deactivate(targetId); } /** Deactivate ALL targets on ALL interceptors. Called during proxy shutdown. */ async deactivateAll(): Promise<void> { const errors: string[] = []; for (const interceptor of this.interceptors.values()) { try { await interceptor.deactivateAll(); } catch (e) { errors.push(`${interceptor.id}: ${e}`); } } if (errors.length > 0) { throw new Error(`Errors during deactivateAll: ${errors.join("; ")}`); } } } /** Singleton instance. */ export const interceptorManager = new InterceptorManager(); - src/tools/interceptors.ts:271-273 (schema)Zod schema for target_id input parameter (string)
{ target_id: z.string().describe("Target ID from interceptor_browser_launch or interceptor_camoufox_launch"), }, - src/interceptors/types.ts:62-76 (helper)Interceptor interface defining the deactivate(targetId) contract
/** * Deactivate a specific target by ID. */ deactivate(targetId: string): Promise<void>; /** * Deactivate all active targets. Called during proxy shutdown. */ deactivateAll(): Promise<void>; /** * Get metadata for display: availability, active targets. */ getMetadata(): Promise<InterceptorMetadata>; }