Skip to main content
Glama

initialize_session

Create a persistent browser session to handle login, multi-step navigation, or manual interaction required for analyzing complex chat interfaces. Maintains authentication state across operations until explicitly closed.

Instructions

Create a persistent browser session for step-by-step reverse engineering of complex chat interfaces. Use this when the chat requires login, multi-step navigation, or manual interaction before analysis. Returns a sessionId that must be used with all subsequent interactive tools. The session maintains cookies, authentication state, and can be used across multiple operations until explicitly closed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesThe initial URL to navigate to (e.g., login page or chat homepage)
headlessNoRun browser in headless mode (true) or visible mode (false). Set false to watch the automation process (default: true)

Implementation Reference

  • Core handler function that launches a persistent browser session, navigates to the initial URL, stores session data in memory, and returns the sessionId for use with other tools.
    export async function initializeSession(url, headless = true) {
      const sessionId = generateSessionId();
    
      const browser = await BrowserUtilities.launchBrowser(headless);
      const context = await browser.newContext({
        viewport: { width: 1280, height: 800 },
      });
      const page = await context.newPage();
    
      await page.goto(url, { waitUntil: "load", timeout: 30000 });
    
      activeSessions.set(sessionId, {
        browser,
        context,
        page,
        createdAt: new Date().toISOString(),
        currentUrl: url,
      });
    
      return {
        sessionId,
        success: true,
        currentUrl: page.url(),
        title: await page.title(),
        message: "Session initialized successfully",
      };
    }
  • Input schema defining parameters for the initialize_session tool: url (required string) and optional headless boolean.
    inputSchema: {
      type: "object",
      properties: {
        url: {
          type: "string",
          description:
            "The initial URL to navigate to (e.g., login page or chat homepage)",
        },
        headless: {
          type: "boolean",
          description:
            "Run browser in headless mode (true) or visible mode (false). Set false to watch the automation process (default: true)",
          default: true,
        },
      },
      required: ["url"],
    },
  • src/index.js:77-98 (registration)
    Tool registration in the ListTools response, including name, description, and input schema.
    {
      name: "initialize_session",
      description:
        "Create a persistent browser session for step-by-step reverse engineering of complex chat interfaces. Use this when the chat requires login, multi-step navigation, or manual interaction before analysis. Returns a sessionId that must be used with all subsequent interactive tools. The session maintains cookies, authentication state, and can be used across multiple operations until explicitly closed.",
      inputSchema: {
        type: "object",
        properties: {
          url: {
            type: "string",
            description:
              "The initial URL to navigate to (e.g., login page or chat homepage)",
          },
          headless: {
            type: "boolean",
            description:
              "Run browser in headless mode (true) or visible mode (false). Set false to watch the automation process (default: true)",
            default: true,
          },
        },
        required: ["url"],
      },
    },
  • src/index.js:417-427 (registration)
    Dispatch handler in the CallToolRequestSchema switch statement that validates parameters and calls the initializeSession function.
    case "initialize_session": {
      const { url, headless = true } = args;
      if (!url) {
        throw new McpError(
          ErrorCode.InvalidParams,
          "URL parameter is required"
        );
      }
      result = await initializeSession(url, headless);
      break;
    }
  • Helper function to generate unique session IDs used in initializeSession.
    function generateSessionId() {
      return `session_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
    }
Behavior4/5

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

With no annotations provided, the description carries the full burden and does so effectively: it discloses that the session is persistent, maintains cookies and authentication state, can be used across multiple operations, and must be explicitly closed. However, it lacks details on potential rate limits, error handling, or session timeout behavior, keeping it from a perfect score.

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 front-loaded with the core purpose, followed by usage context and behavioral details in three concise sentences. Each sentence earns its place by providing essential information without redundancy, making it highly efficient for agent comprehension.

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

Completeness4/5

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

Given the tool's complexity (session management for reverse engineering), no annotations, and no output schema, the description does well by explaining the session's purpose, usage, and state. However, it lacks details on output (e.g., format of sessionId or error responses) and potential limitations, slightly reducing completeness.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents both parameters ('url' and 'headless') thoroughly. The description adds no additional parameter semantics beyond what the schema provides, such as examples or edge cases, meeting the baseline for high coverage.

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 specific action ('Create a persistent browser session') and resource ('for step-by-step reverse engineering of complex chat interfaces'), distinguishing it from siblings like 'reverse_engineer_chat' or 'navigate_to_url' by focusing on session initialization rather than direct interaction or analysis.

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

Usage Guidelines5/5

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

It explicitly states when to use this tool ('when the chat requires login, multi-step navigation, or manual interaction before analysis') and provides context on prerequisites (e.g., returns a sessionId for subsequent tools) and alternatives (implied by distinguishing from direct tools like 'reverse_engineer_chat'), offering clear guidance for agent decision-making.

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

Install Server

Other Tools

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/pyscout/webscout-mcp'

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