close_session
Terminate the active LinkedIn browser session and release system resources to maintain performance and security.
Instructions
Close the current browser session and clean up resources.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- linkedin_mcp_server/server.py:41-55 (handler)The main execution logic for the close_session tool. It imports and calls close_all_drivers to terminate browser sessions and returns a success or error status.async def close_session() -> Dict[str, Any]: """Close the current browser session and clean up resources.""" from linkedin_mcp_server.drivers.chrome import close_all_drivers try: close_all_drivers() return { "status": "success", "message": "Successfully closed the browser session and cleaned up resources", } except Exception as e: return { "status": "error", "message": f"Error closing browser session: {str(e)}", }
- linkedin_mcp_server/server.py:33-40 (registration)Registers the close_session tool on the MCP server using the @mcp.tool decorator with appropriate annotations.@mcp.tool( annotations=ToolAnnotations( title="Close Session", readOnlyHint=False, destructiveHint=False, openWorldHint=False, ) )
- Helper function that closes all active Chrome WebDriver instances by iterating over the global active_drivers dictionary and calling quit() on each.def close_all_drivers() -> None: """Close all active drivers and clean up resources.""" global active_drivers for session_id, driver in active_drivers.items(): try: logger.info(f"Closing Chrome WebDriver session: {session_id}") driver.quit() except Exception as e: logger.warning(f"Error closing driver {session_id}: {e}") active_drivers.clear() logger.info("All Chrome WebDriver sessions closed")