Skip to main content
Glama

browserbase_stagehand_get_url

Retrieve the complete URL of the current browser page, including protocol, domain, path, and query parameters, for web automation and data extraction tasks.

Instructions

Gets the current URL of the browser page. Returns the complete URL including protocol, domain, path, and any query parameters or fragments.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function `handleGetUrl` that gets the current URL from the Stagehand-managed Playwright page and returns it as text content in a ToolActionResult.
    async function handleGetUrl(
      context: Context,
      // eslint-disable-next-line @typescript-eslint/no-unused-vars
      params: GetUrlInput,
    ): Promise<ToolResult> {
      const action = async (): Promise<ToolActionResult> => {
        try {
          const stagehand = await context.getStagehand();
    
          // Get the current URL from the Playwright page
          const currentUrl = stagehand.page.url();
    
          return {
            content: [
              {
                type: "text",
                text: currentUrl,
              },
            ],
          };
        } catch (error) {
          const errorMsg = error instanceof Error ? error.message : String(error);
          throw new Error(`Failed to get current URL: ${errorMsg}`);
        }
      };
    
      return {
        action,
        waitForNetwork: false,
      };
    }
  • The tool schema defining the name, description, and input schema (empty object since no parameters required).
    const getUrlSchema: ToolSchema<typeof GetUrlInputSchema> = {
      name: "browserbase_stagehand_get_url",
      description:
        "Gets the current URL of the browser page. Returns the complete URL including protocol, domain, path, and any query parameters or fragments.",
      inputSchema: GetUrlInputSchema,
    };
  • src/tools/url.ts:54-58 (registration)
    The tool registration object combining schema and handler, exported and included in the main tools array.
    const getUrlTool: Tool<typeof GetUrlInputSchema> = {
      capability: "core",
      schema: getUrlSchema,
      handle: handleGetUrl,
    };
  • Inclusion of `getUrlTool` in the `TOOLS` array, which is imported and used to register all tools with the MCP server.
    export const TOOLS = [
      ...multiSessionTools,
      ...sessionTools,
      navigateTool,
      actTool,
      extractTool,
      observeTool,
      screenshotTool,
      getUrlTool,
    ];
  • src/index.ts:195-222 (registration)
    The loop that registers each tool from the TOOLS array to the MCP server using `server.tool()`, invoking `context.run(tool, params)` which calls the handler.
    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}`,
        );
      }
    });
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. It discloses key behavioral traits: it's a read operation (implied by 'Gets'), returns the complete URL including protocol, domain, path, query parameters, and fragments, and specifies it retrieves from the 'current' page. It doesn't mention error cases or performance aspects, but covers the core behavior adequately.

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 in the first sentence and adds necessary detail in the second. Both sentences earn their place by clarifying the action and return value without any waste, making it highly efficient and well-structured.

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 low complexity (0 parameters, no output schema, no annotations), the description is complete enough for a read-only operation. It explains what the tool does and what it returns. A minor gap is the lack of explicit error handling or state dependencies, but it suffices for basic use.

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 input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description appropriately focuses on the tool's purpose and output without redundant parameter details, earning a baseline score of 4 for handling this efficiently.

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 URL') and resource ('of the browser page'), distinguishing it from siblings like 'browserbase_stagehand_navigate' (which changes URLs) and 'browserbase_stagehand_get_all_urls' (which retrieves multiple URLs). It precisely defines what the tool does without being vague or tautological.

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?

The description implies usage by specifying it retrieves the 'current URL,' suggesting it should be used when the agent needs to know the active page location. However, it does not explicitly state when to use this tool versus alternatives like 'browserbase_stagehand_get_all_urls' or provide any exclusions or prerequisites, leaving some ambiguity.

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