Skip to main content
Glama

browser_navigate

Navigate browser instances to specific URLs with configurable wait conditions and timeouts for automated web interactions.

Instructions

Navigate to a specified URL

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
instanceIdYesInstance ID
urlYesTarget URL
timeoutNoTimeout in milliseconds
waitUntilNoWait conditionload

Implementation Reference

  • Core handler function that executes the browser navigation using Playwright's page.goto() method.
    private async navigate(instanceId: string, url: string, options: NavigationOptions): Promise<ToolResult> {
      const instance = this.browserManager.getInstance(instanceId);
      if (!instance) {
        return { success: false, error: `Instance ${instanceId} not found` };
      }
    
      try {
        const gotoOptions: any = {
          waitUntil: options.waitUntil
        };
        if (options.timeout) {
          gotoOptions.timeout = options.timeout;
        }
        await instance.page.goto(url, gotoOptions);
        return {
          success: true,
          data: { url: instance.page.url(), title: await instance.page.title() },
          instanceId
        };
      } catch (error) {
        return {
          success: false,
          error: `Navigation failed: ${error instanceof Error ? error.message : error}`,
          instanceId
        };
      }
    }
  • Tool schema definition including name, description, and inputSchema for validation.
      name: 'browser_navigate',
      description: 'Navigate to a specified URL',
      inputSchema: {
        type: 'object',
        properties: {
          instanceId: {
            type: 'string',
            description: 'Instance ID'
          },
          url: {
            type: 'string',
            description: 'Target URL',
          },
          timeout: {
            type: 'number',
            description: 'Timeout in milliseconds',
            default: 30000
          },
          waitUntil: {
            type: 'string',
            enum: ['load', 'domcontentloaded', 'networkidle'],
            description: 'Wait condition',
            default: 'load'
          }
        },
        required: ['instanceId', 'url']
      }
    },
  • src/server.ts:40-45 (registration)
    MCP server registration for listing tools, which includes the browser_navigate tool via BrowserTools.getTools().
    this.server.setRequestHandler(ListToolsRequestSchema, async () => {
      const tools = this.browserTools.getTools();
      return {
        tools: tools,
      };
    });
  • src/server.ts:48-75 (registration)
    MCP server registration for calling tools, dispatching browser_navigate via BrowserTools.executeTools().
    this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const { name, arguments: args } = request.params;
    
      try {
        const result = await this.browserTools.executeTools(name, args || {});
        
        if (result.success) {
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(result.data, null, 2),
              },
            ],
          };
        } else {
          throw new McpError(ErrorCode.InternalError, result.error || 'Tool execution failed');
        }
      } catch (error) {
        if (error instanceof McpError) {
          throw error;
        }
        throw new McpError(
          ErrorCode.InternalError,
          `Tool execution failed: ${error instanceof Error ? error.message : error}`
        );
      }
    });
  • Dispatch handler in executeTools() that routes browser_navigate calls to the navigate method.
    case 'browser_navigate':
      return await this.navigate(args.instanceId, args.url, {
        timeout: args.timeout || 30000,
        waitUntil: args.waitUntil || 'load'
      });

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/sailaoda/concurrent-browser-mcp'

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