Skip to main content
Glama

get_current_url

Retrieve the current URL of a specified browser tab in Firefox using the Firefox MCP Server. Ideal for automation and multi-tab debugging workflows with Playwright integration.

Instructions

Get current page URL

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tabIdNo

Implementation Reference

  • The core handler function for the 'get_current_url' tool. It ensures the browser is running, gets the page for the specified or active tab, retrieves the current URL using page.url(), and returns it formatted in MCP response.
    async getCurrentUrl(args = {}) {
      this.ensureBrowserRunning();
      const { tabId } = args;
      const page = this.getPage(tabId);
      const url = page.url();
      
      return {
        content: [{
          type: 'text',
          text: `Current URL in tab '${tabId || this.activeTabId}': ${url}`
        }]
      };
    }
  • The tool schema definition in the listTools response, specifying name, description, and input schema (optional tabId string).
    {
      name: 'get_current_url',
      description: 'Get current page URL',
      inputSchema: {
        type: 'object',
        properties: { tabId: { type: 'string' } }
      }
    },
  • Registration in the CallToolRequestSchema handler switch statement, dispatching calls to the getCurrentUrl method.
    case 'get_current_url':
      return await this.getCurrentUrl(args);
  • Helper method used by getCurrentUrl to retrieve the Playwright Page object for the given tabId or the active tab.
    getPage(tabId) {
      if (tabId) {
        if (!this.pages.has(tabId)) {
          throw new Error(`Tab '${tabId}' not found`);
        }
        return this.pages.get(tabId);
      } else {
        if (!this.activeTabId || !this.pages.has(this.activeTabId)) {
          throw new Error('No active tab. Use create_tab or set_active_tab first.');
        }
        return this.pages.get(this.activeTabId);
      }
    }
  • Helper method called by getCurrentUrl to ensure the browser instance is launched before accessing pages.
    ensureBrowserRunning() {
      if (!this.browser) {
        throw new Error('Firefox browser is not running. Please launch it first using the launch_firefox_multi tool.');
      }
    }

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/JediLuke/firefox-mcp-server'

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