Skip to main content
Glama

navigate

Navigate to specified URLs for browser automation and web testing on ARM64 devices, enabling website interaction and UI testing.

Instructions

Navigate to a URL

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesThe URL to navigate to

Implementation Reference

  • The main handler function that executes the navigation by ensuring Chromium is running and sending a Page.navigate CDP command.
    async navigate(url) {
      await this.ensureChromium();
      await this.sendCDPCommand('Page.navigate', { url });
      
      return {
        content: [{ type: 'text', text: `Successfully navigated to ${url}` }],
      };
    }
  • Input schema defining the required 'url' parameter as a string for the navigate tool.
    inputSchema: {
      type: 'object',
      properties: {
        url: {
          type: 'string',
          description: 'The URL to navigate to',
        },
      },
      required: ['url'],
    },
  • Tool registration entry in the ListTools response, including name, description, and schema.
    {
      name: 'navigate',
      description: 'Navigate to a URL',
      inputSchema: {
        type: 'object',
        properties: {
          url: {
            type: 'string',
            description: 'The URL to navigate to',
          },
        },
        required: ['url'],
      },
    },
  • Dispatch registration in the CallToolRequest handler switch statement that routes to the navigate handler.
    case 'navigate':
      return await this.navigate(args.url);
    case 'get_content':
  • Helper function to send Chrome DevTools Protocol (CDP) commands over WebSocket, used by the navigate handler.
    async sendCDPCommand(method, params = {}) {
      return new Promise((resolve, reject) => {
        if (!wsConnection || wsConnection.readyState !== WebSocket.OPEN) {
          reject(new Error('No browser connection available'));
          return;
        }
    
        const commandId = Date.now();
        const command = { id: commandId, method, params };
    
        const timeout = setTimeout(() => {
          reject(new Error(`CDP command timeout: ${method}`));
        }, 10000);
    
        const messageHandler = (data) => {
          try {
            const response = JSON.parse(data.toString());
            if (response.id === commandId) {
              clearTimeout(timeout);
              wsConnection.off('message', messageHandler);
              if (response.error) {
                reject(new Error(`CDP error: ${response.error.message}`));
              } else {
                resolve(response.result);
              }
            }
          } catch (error) {
            // Ignore parsing errors for non-matching messages
          }
        };
    
        wsConnection.on('message', messageHandler);
        wsConnection.send(JSON.stringify(command));
      });
    }

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/nfodor/claude-arm64-browser'

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