Skip to main content
Glama

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

TableJSON Schema
NameRequiredDescriptionDefault

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,
            }
  • 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)

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/eliasbiondo/linkedin-mcp-server'

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