Skip to main content
Glama

browserbase_stagehand_get_all_urls

Retrieve current URLs from all active browser sessions to monitor web automation progress and track navigation states.

Instructions

Gets the current URLs of all active browser sessions. Returns a mapping of session IDs to their current URLs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function that executes the tool logic: lists all active browser sessions using stagehandStore.list(), retrieves each page's URL, and returns a JSON mapping of session IDs to URLs.
    async function handleGetAllUrls(
      // eslint-disable-next-line @typescript-eslint/no-unused-vars
      context: Context,
      // eslint-disable-next-line @typescript-eslint/no-unused-vars
      params: GetAllUrlsInput,
    ): Promise<ToolResult> {
      const action = async (): Promise<ToolActionResult> => {
        try {
          const sessions = stagehandStore.list();
    
          if (sessions.length === 0) {
            return {
              content: [
                {
                  type: "text",
                  text: "No active sessions found",
                },
              ],
            };
          }
    
          // Collect URLs from all sessions
          const sessionUrls: Record<string, string> = {};
    
          for (const session of sessions) {
            try {
              const url = session.page.url();
              sessionUrls[session.id] = url;
            } catch (error) {
              // If we can't get URL for a session, mark it as error
              sessionUrls[session.id] =
                `<error: ${error instanceof Error ? error.message : "unknown"}>`;
            }
          }
    
          return {
            content: [
              {
                type: "text",
                text: JSON.stringify(sessionUrls, null, 2),
              },
            ],
          };
        } catch (error) {
          const errorMsg = error instanceof Error ? error.message : String(error);
          throw new Error(`Failed to get session URLs: ${errorMsg}`);
        }
      };
    
      return {
        action,
        waitForNetwork: false,
      };
    }
  • Tool schema defining the name, description, and empty input schema (z.object({})) for the browserbase_stagehand_get_all_urls tool.
    const getAllUrlsSchema: ToolSchema<typeof GetAllUrlsInputSchema> = {
      name: "browserbase_stagehand_get_all_urls",
      description:
        "Gets the current URLs of all active browser sessions. Returns a mapping of session IDs to their current URLs.",
      inputSchema: GetAllUrlsInputSchema,
    };
  • Tool object definition exporting the schema and handler for registration in the MCP server's tool list.
    export const getAllUrlsTool: Tool<typeof GetAllUrlsInputSchema> = {
      capability: "core",
      schema: getAllUrlsSchema,
      handle: handleGetAllUrls,
    };
  • stagehandStore.list() helper function that returns all active Stagehand sessions, used in the tool handler to iterate over sessions and get their URLs.
    export const list = (): StagehandSession[] => {
      return Array.from(store.values());
    };
  • src/index.ts:192-222 (registration)
    Generic registration loop in MCP server creation that registers all tools from TOOLS array (including this one) using server.tool().
    const tools: MCPToolsArray = [...TOOLS];
    
    // Register each tool with the Smithery server
    tools.forEach((tool) => {
      if (tool.schema.inputSchema instanceof z.ZodObject) {
        server.tool(
          tool.schema.name,
          tool.schema.description,
          tool.schema.inputSchema.shape,
          async (params: z.infer<typeof tool.schema.inputSchema>) => {
            try {
              const result = await context.run(tool, params);
              return result;
            } catch (error) {
              const errorMessage =
                error instanceof Error ? error.message : String(error);
              process.stderr.write(
                `[Smithery Error] ${new Date().toISOString()} Error running tool ${tool.schema.name}: ${errorMessage}\n`,
              );
              throw new Error(
                `Failed to run tool '${tool.schema.name}': ${errorMessage}`,
              );
            }
          },
        );
      } else {
        console.warn(
          `Tool "${tool.schema.name}" has an input schema that is not a ZodObject. Schema type: ${tool.schema.inputSchema.constructor.name}`,
        );
      }
    });
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses the tool's read-only behavior (it 'gets' URLs) and output format (a mapping), but lacks details on permissions, rate limits, or error handling. This is adequate for a simple retrieval tool but misses some behavioral context.

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 two concise sentences that are front-loaded with the core purpose and follow with the return value. Every word earns its place, with no wasted information or fluff.

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 simplicity (0 parameters, no output schema, no annotations), the description is nearly complete—it explains what the tool does and returns. A minor gap is the lack of output schema details (e.g., structure of the mapping), but for this low-complexity tool, it's sufficient.

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?

The tool has 0 parameters, and the input schema has 100% coverage (empty). The description does not need to add parameter semantics, so a baseline of 4 is appropriate, as it efficiently handles the lack of parameters without redundancy.

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 ('Gets the current URLs of all active browser sessions') and the resource involved ('session IDs to their current URLs'), distinguishing it from siblings like browserbase_stagehand_get_url (which gets a single URL) and browserbase_session_list (which lists sessions without URLs).

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

Usage Guidelines4/5

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

The description implies usage for retrieving URLs from multiple active sessions, providing clear context for when to use it (e.g., monitoring all sessions). However, it does not explicitly state when not to use it or name alternatives like browserbase_stagehand_get_url for single sessions, which would elevate the score to 5.

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/vaibhavAtlys/mcp-server-browserbase'

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