Skip to main content
Glama
RonsDad
by RonsDad

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 that retrieves the current browser URL using stagehand.page.url() and returns it as text content.
    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 'browserbase_stagehand_get_url', description, and empty input schema.
    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 object that combines the schema and handler, exported as default for use in tool registries.
    const getUrlTool: Tool<typeof GetUrlInputSchema> = {
      capability: "core",
      schema: getUrlSchema,
      handle: handleGetUrl,
    };
  • The central TOOLS array that includes getUrlTool among other tools, imported and used for MCP server registration.
    export const TOOLS = [
      ...multiSessionTools,
      ...sessionTools,
      navigateTool,
      actTool,
      extractTool,
      observeTool,
      screenshotTool,
      getUrlTool,
    ];
  • src/index.ts:199-226 (registration)
    The loop that registers each tool from the TOOLS array with the MCP server using server.tool(), including browserbase_stagehand_get_url.
    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 of behavioral disclosure. It clearly indicates this is a read-only operation ('Gets') and specifies the return format ('complete URL including protocol, domain, path, and any query parameters or fragments'), but lacks details on error conditions, session requirements, or performance characteristics like latency.

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 sentences with zero waste: the first states the purpose, and the second details the return format. It is front-loaded with the core functionality and efficiently conveys necessary information without redundancy or fluff.

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

Completeness3/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 adequate but has gaps. It explains the return value well, but without annotations or output schema, it misses context like error handling or session dependencies. For a simple read operation, it's minimally viable but not fully comprehensive.

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% description coverage (though empty). The description appropriately does not discuss parameters, focusing instead on the return value. This meets the baseline of 4 for tools with no parameters, as there is nothing to compensate for.

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 tautological.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'browserbase_stagehand_get_all_urls' or 'browserbase_stagehand_observe', nor does it mention prerequisites such as requiring an active browser session. It only states what the tool does, not when it should be used.

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

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