Skip to main content
Glama

get_page_text

Extract visible text from web pages using Firefox browser automation. Input a CSS selector and tab ID to retrieve specific text content for automation or debugging purposes.

Instructions

Get visible text content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorNo
tabIdNo

Implementation Reference

  • The core handler function for the 'get_page_text' tool. It retrieves the text content from a specified selector or the entire body of the page in the given tab using Playwright's page.textContent method, then returns it formatted for MCP response.
    async getPageText(args = {}) {
      this.ensureBrowserRunning();
      const { selector, tabId } = args;
      const page = this.getPage(tabId);
      
      let text;
      if (selector) {
        text = await page.textContent(selector);
      } else {
        text = await page.textContent('body');
      }
      
      return {
        content: [{
          type: 'text',
          text: text || ''
        }]
      };
    }
  • Input schema definition for the get_page_text tool, specifying optional selector (CSS selector for specific element) and tabId (for multi-tab support).
      name: 'get_page_text',
      description: 'Get visible text content',
      inputSchema: {
        type: 'object',
        properties: {
          selector: { type: 'string' },
          tabId: { type: 'string' }
        }
      }
    },
  • Registration in the tool dispatch switch statement within the CallToolRequestSchema handler, routing calls to the getPageText method.
    case 'get_page_text':
      return await this.getPageText(args);
  • Tool list registration in ListToolsRequestSchema handler, including get_page_text in the advertised tools list with its schema.
    setupToolHandlers() {
      this.server.setRequestHandler(ListToolsRequestSchema, async () => {
        return {
          tools: [
            // Original tools (abbreviated for space)
            {
              name: 'launch_firefox_multi',
              description: 'Launch Firefox browser with multi-tab support and debugging',
              inputSchema: {
                type: 'object',
                properties: {
                  headless: { type: 'boolean', default: false },
                  enableDebugLogging: { type: 'boolean', default: true }
                }
              }
            },
            {
              name: 'create_tab',
              description: 'Create a new tab with isolated session and debugging',
              inputSchema: {
                type: 'object',
                properties: {
                  tabId: { type: 'string' },
                  url: { type: 'string', default: 'about:blank' },
                  contextId: { type: 'string' },
                  enableMonitoring: { type: 'boolean', default: true }
                },
                required: ['tabId']
              }
            },
            {
              name: 'list_tabs',
              description: 'List all active tabs',
              inputSchema: { type: 'object', properties: {} }
            },
            {
              name: 'close_tab',
              description: 'Close a specific tab',
              inputSchema: {
                type: 'object',
                properties: { tabId: { type: 'string' } },
                required: ['tabId']
              }
            },
            {
              name: 'navigate',
              description: 'Navigate to a URL',
              inputSchema: {
                type: 'object',
                properties: {
                  url: { type: 'string' },
                  tabId: { type: 'string' }
                },
                required: ['url']
              }
            },
            {
              name: 'click',
              description: 'Click on an element',
              inputSchema: {
                type: 'object',
                properties: {
                  selector: { type: 'string' },
                  coordinates: {
                    type: 'object',
                    properties: { x: { type: 'number' }, y: { type: 'number' } }
                  },
                  tabId: { type: 'string' }
                }
              }
            },
            {
              name: 'type_text',
              description: 'Type text into an input field',
              inputSchema: {
                type: 'object',
                properties: {
                  selector: { type: 'string' },
                  text: { type: 'string' },
                  tabId: { type: 'string' }
                },
                required: ['selector', 'text']
              }
            },
            {
              name: 'send_key',
              description: 'Send keyboard events',
              inputSchema: {
                type: 'object',
                properties: {
                  key: { type: 'string' },
                  selector: { type: 'string' },
                  modifiers: { type: 'array', items: { type: 'string' } },
                  repeat: { type: 'number', default: 1 },
                  tabId: { type: 'string' }
                },
                required: ['key']
              }
            },
            {
              name: 'drag',
              description: 'Perform drag operation',
              inputSchema: {
                type: 'object',
                properties: {
                  selector: { type: 'string' },
                  fromCoordinates: {
                    type: 'object',
                    properties: { x: { type: 'number' }, y: { type: 'number' } }
                  },
                  toCoordinates: {
                    type: 'object',
                    properties: { x: { type: 'number' }, y: { type: 'number' } }
                  },
                  offsetX: { type: 'number' },
                  offsetY: { type: 'number' },
                  duration: { type: 'number', default: 0 },
                  steps: { type: 'number', default: 1 },
                  tabId: { type: 'string' }
                }
              }
            },
            {
              name: 'execute_script',
              description: 'Execute JavaScript in the browser',
              inputSchema: {
                type: 'object',
                properties: {
                  script: { type: 'string' },
                  tabId: { type: 'string' }
                },
                required: ['script']
              }
            },
            {
              name: 'screenshot',
              description: 'Take a screenshot',
              inputSchema: {
                type: 'object',
                properties: {
                  path: { type: 'string', default: 'screenshot.png' },
                  fullPage: { type: 'boolean', default: false },
                  tabId: { type: 'string' }
                }
              }
            },
            {
              name: 'get_page_content',
              description: 'Get HTML content',
              inputSchema: {
                type: 'object',
                properties: {
                  selector: { type: 'string' },
                  tabId: { type: 'string' }
                }
              }
            },
            {
              name: 'get_page_text',
              description: 'Get visible text content',
              inputSchema: {
                type: 'object',
                properties: {
                  selector: { type: 'string' },
                  tabId: { type: 'string' }
                }
              }
            },
            {
              name: 'wait_for_element',
              description: 'Wait for element to appear',
              inputSchema: {
                type: 'object',
                properties: {
                  selector: { type: 'string' },
                  timeout: { type: 'number', default: 30000 },
                  tabId: { type: 'string' }
                },
                required: ['selector']
              }
            },
            {
              name: 'close_browser',
              description: 'Close browser and all tabs',
              inputSchema: { type: 'object', properties: {} }
            },
            {
              name: 'get_current_url',
              description: 'Get current page URL',
              inputSchema: {
                type: 'object',
                properties: { tabId: { type: 'string' } }
              }
            },
            {
              name: 'back',
              description: 'Navigate back',
              inputSchema: {
                type: 'object',
                properties: { tabId: { type: 'string' } }
              }
            },
            {
              name: 'forward',
              description: 'Navigate forward',
              inputSchema: {
                type: 'object',
                properties: { tabId: { type: 'string' } }
              }
            },
            {
              name: 'reload',
              description: 'Reload page',
              inputSchema: {
                type: 'object',
                properties: { tabId: { type: 'string' } }
              }
            },
            {
              name: 'set_active_tab',
              description: 'Set active tab',
              inputSchema: {
                type: 'object',
                properties: { tabId: { type: 'string' } },
                required: ['tabId']
              }
            },
    
            // NEW DEBUG TOOLS
            {
              name: 'get_console_logs',
              description: 'Get captured console logs from browser',
              inputSchema: {
                type: 'object',
                properties: {
                  tabId: { type: 'string' },
                  since: { type: 'number', description: 'Timestamp to filter logs since' },
                  types: {
                    type: 'array',
                    items: { type: 'string', enum: ['log', 'error', 'warn', 'info', 'debug'] },
                    description: 'Filter by log types'
                  },
                  limit: { type: 'number', default: 50, description: 'Max number of logs to return' }
                }
              }
            },
            {
              name: 'get_javascript_errors',
              description: 'Get captured JavaScript errors',
              inputSchema: {
                type: 'object',
                properties: {
                  tabId: { type: 'string' },
                  since: { type: 'number' },
                  limit: { type: 'number', default: 20 }
                }
              }
            },
            {
              name: 'get_network_activity',
              description: 'Get captured network requests and responses',
              inputSchema: {
                type: 'object',
                properties: {
                  tabId: { type: 'string' },
                  since: { type: 'number' },
                  filter: { type: 'string', enum: ['all', 'xhr', 'websocket', 'fetch'], default: 'all' },
                  limit: { type: 'number', default: 30 }
                }
              }
            },
            {
              name: 'get_websocket_messages',
              description: 'Get captured WebSocket messages (for LiveView debugging)',
              inputSchema: {
                type: 'object',
                properties: {
                  tabId: { type: 'string' },
                  since: { type: 'number' },
                  limit: { type: 'number', default: 50 }
                }
              }
            },
            {
              name: 'get_performance_metrics',
              description: 'Get performance metrics (timing, memory usage)',
              inputSchema: {
                type: 'object',
                properties: {
                  tabId: { type: 'string' }
                }
              }
            },
            {
              name: 'start_monitoring',
              description: 'Start/restart monitoring for a tab',
              inputSchema: {
                type: 'object',
                properties: {
                  tabId: { type: 'string' },
                  types: {
                    type: 'array',
                    items: { type: 'string', enum: ['console', 'errors', 'network', 'websocket', 'performance'] },
                    default: ['console', 'errors', 'network', 'websocket']
                  }
                }
              }
            },
            {
              name: 'clear_debug_buffers',
              description: 'Clear debug event buffers for a tab',
              inputSchema: {
                type: 'object',
                properties: {
                  tabId: { type: 'string' },
                  types: {
                    type: 'array',
                    items: { type: 'string', enum: ['console', 'errors', 'network', 'websocket'] }
                  }
                }
              }
            },
            {
              name: 'get_all_debug_activity',
              description: 'Get combined feed of all debug events',
              inputSchema: {
                type: 'object',
                properties: {
                  tabId: { type: 'string' },
                  since: { type: 'number' },
                  limit: { type: 'number', default: 100 }
                }
              }
            },
            {
              name: 'inject_debugging_helpers',
              description: 'Inject debugging helper functions into the page',
              inputSchema: {
                type: 'object',
                properties: {
                  tabId: { type: 'string' },
                  includeWebSocketMonitoring: { type: 'boolean', default: true }
                }
              }
            }
          ],
        };
  • Helper method used by getPageText to resolve the target Page object from tabId or 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);
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It mentions 'visible text content', hinting at behavior (e.g., excludes hidden elements), but lacks details on permissions, rate limits, error handling, or output format. For a tool with 2 parameters and no annotations, this is insufficient behavioral disclosure.

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 extremely concise with a single phrase 'Get visible text content', which is front-loaded and wastes no words. Every part earns its place by specifying the action and resource scope efficiently.

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

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 2 parameters with 0% schema coverage, no annotations, no output schema, and sibling tools like 'get_page_content', the description is incomplete. It doesn't explain parameter usage, return values, or how it differs from alternatives, making it inadequate for effective tool selection and invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It adds no information about the 'selector' or 'tabId' parameters, their purposes, formats, or constraints. With 2 undocumented parameters, the description fails to provide meaningful semantic context beyond the basic action.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Get visible text content' clearly states the action (get) and resource (visible text content), but it's vague about scope and doesn't distinguish from siblings like 'get_page_content' or 'execute_script'. It specifies 'visible' text, which adds some differentiation from raw HTML content tools.

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?

No explicit guidance on when to use this tool versus alternatives like 'get_page_content' or 'execute_script' for text extraction. The description implies it's for retrieving visible text, but doesn't specify contexts, prerequisites, or exclusions, leaving usage ambiguous.

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

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

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