close_browser
Close the browser instance to release system resources while preserving LinkedIn credentials for future sessions.
Instructions
Close the browser instance and release resources. Credentials are preserved.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- MCP tool registration with @mcp.tool decorator. Registers 'close_browser' with description and defines the handler that wraps the use case, returning a dict with is_valid and message fields.
@mcp.tool( name="close_browser", description="Close the browser instance and release resources. Credentials are preserved.", ) async def close_browser(ctx: Context) -> dict[str, Any]: try: result = await manage_session_uc.close_browser() return { "is_valid": result.is_valid, "message": result.message, } except Exception as e: map_domain_error(e, "close_browser") - Core business logic implementation. Closes the browser instance via the BrowserPort and returns a SessionStatus indicating the browser is closed.
async def close_browser(self) -> SessionStatus: """Close the browser instance and release resources.""" await self._browser.close() return SessionStatus(is_valid=False, message="Browser closed") - SessionStatus dataclass schema. Defines the structure returned by the close_browser use case with is_valid (bool), profile_path (optional str), and message (str) fields.
@dataclass class SessionStatus: """Represents the status of a browser session.""" is_valid: bool profile_path: str | None = None message: str = "" - MCP tool handler function. Receives Context, calls manage_session_uc.close_browser(), and transforms the SessionStatus result into a dict response with error handling.
async def close_browser(ctx: Context) -> dict[str, Any]: try: result = await manage_session_uc.close_browser() return { "is_valid": result.is_valid, "message": result.message, } - src/linkedin_mcp_server/adapters/driving/mcp_server.py:37-37 (registration)Registration call site. Invokes register_session_tools to register the close_browser tool with the MCP server instance.
register_session_tools(mcp, container.manage_session)