Skip to main content
Glama

browserbase_stagehand_navigate

Navigate to a specified URL in a cloud browser to access web content and perform automated interactions. Use this tool to visit websites and initiate web-based workflows.

Instructions

Navigate to a URL in the browser. Only use this tool with URLs you're confident will work and be up to date. Otherwise, use https://google.com as the starting point

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesThe URL to navigate to

Implementation Reference

  • The handler function that executes the tool logic: retrieves stagehand and active page, navigates to the URL, and returns a confirmation message.
    async function handleNavigate(
      context: Context,
      params: NavigateInput,
    ): Promise<ToolResult> {
      const action = async (): Promise<ToolActionResult> => {
        try {
          const stagehand = await context.getStagehand();
          const page = await context.getActivePage();
    
          if (!page) {
            throw new Error("No active page available");
          }
          await page.goto(params.url, { waitUntil: "domcontentloaded" });
    
          const sessionId = stagehand.browserbaseSessionId;
          if (!sessionId) {
            throw new Error("No Browserbase session ID available");
          }
    
          return {
            content: [
              {
                type: "text",
                text: `Navigated to: ${params.url}`,
              },
            ],
          };
        } catch (error) {
          const errorMsg = error instanceof Error ? error.message : String(error);
          throw new Error(`Failed to navigate: ${errorMsg}`);
        }
      };
    
      return {
        action,
        waitForNetwork: false,
      };
    }
  • Tool schema defining the name 'browserbase_stagehand_navigate', description, and input schema (URL). Note: Input schema defined earlier at lines 6-8.
    const navigateSchema: ToolSchema<typeof NavigateInputSchema> = {
      name: "browserbase_stagehand_navigate",
      description: `Navigate to a URL in the browser. Only use this tool with URLs you're confident will work and be up to date. 
        Otherwise, use https://google.com as the starting point`,
      inputSchema: NavigateInputSchema,
    };
  • Creates and exports the navigateTool object, registering the schema and handler.
    const navigateTool: Tool<typeof NavigateInputSchema> = {
      capability: "core",
      schema: navigateSchema,
      handle: handleNavigate,
    };
    
    export default navigateTool;
  • Includes the navigateTool in the central TOOLS array for overall tool registration.
    export const TOOLS = [
      ...sessionTools,
      navigateTool,
      actTool,
      extractTool,
      observeTool,
      screenshotTool,
      getUrlTool,
    ];
  • src/tools/index.ts:1-1 (registration)
    Imports the navigateTool for inclusion in the tools registry.
    import navigateTool from "./navigate.js";

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/kolbertistvan2/stagehand-mcp-server'

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