Skip to main content
Glama

close_session

Ends the current LinkedIn browser session and releases system resources to maintain performance and security.

Instructions

Close the current browser session and clean up resources.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'close_session' tool, decorated with @mcp.tool() for automatic registration. It closes all browser drivers and returns success/error status.
    @mcp.tool()
    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)}",
            }
  • Supporting utility function that closes all active Chrome WebDriver instances and clears the session store, called by the close_session handler.
    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")

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.1/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must disclose behavioral traits. It mentions resource cleanup but does not specify irreversibility, side effects (e.g., cookies cleared), or error conditions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is one short sentence that conveys the essential purpose without extraneous words. It is appropriately front-loaded and efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with zero parameters and an output schema, the description adequately explains the action and cleanup. No further context is necessary.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

There are no parameters, so schema coverage is 100%. The description does not need to add parameter detail; the baseline of 4 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Close') and the resource ('current browser session') with additional context ('clean up resources'). It is distinct from sibling tools which are all retrieval operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use versus alternatives. The use case is implied (ending a session), but no 'when not to use' or prerequisite information is given.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.