get_content
Extract page content (HTML or text) for web automation and testing on ARM64 devices like Raspberry Pi using the MCP server. Ideal for navigation, UI testing, and JavaScript execution.
Instructions
Get page content (HTML or text)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| type | No | Type of content to get | text |
Implementation Reference
- index.js:701-720 (handler)Core handler function for the 'get_content' MCP tool. Retrieves page content as HTML (using DOM.getOuterHTML) or text (using document.body.innerText) via Chrome DevTools Protocol (CDP).async getContent(type) { await this.ensureChromium(); let content; if (type === 'html') { const doc = await this.sendCDPCommand('DOM.getDocument'); const html = await this.sendCDPCommand('DOM.getOuterHTML', { nodeId: doc.root.nodeId }); content = html.outerHTML; } else { const result = await this.sendCDPCommand('Runtime.evaluate', { expression: 'document.body.innerText', returnByValue: true }); content = result.result?.value || ''; } return { content: [{ type: 'text', text: content }], }; }
- index.js:184-198 (registration)Registration of the 'get_content' tool in the MCP ListTools response, defining name, description, and input schema (type: string enum ['html','text']).{ name: 'get_content', description: 'Get page content (HTML or text)', inputSchema: { type: 'object', properties: { type: { type: 'string', enum: ['html', 'text'], description: 'Type of content to get', default: 'text', }, }, }, },
- index-browser-only.js:328-348 (handler)Variant handler for 'get_content' in the browser-only MCP server, similar CDP logic for HTML/text extraction.async getContent(type = 'text') { await this.ensureChromium(); if (type === 'html') { const result = await this.sendCDPCommand('DOM.getDocument'); const html = await this.sendCDPCommand('DOM.getOuterHTML', { nodeId: result.root.nodeId, }); return { content: [{ type: 'text', text: html.outerHTML }], }; } else { const result = await this.sendCDPCommand('Runtime.evaluate', { expression: 'document.body.innerText', returnByValue: true, }); return { content: [{ type: 'text', text: result.result.value || '' }], }; } }
- arm64_browser_tools.py:106-149 (helper)Python helper wrapper that calls the JS MCP server via subprocess to execute the 'get_content' tool.def arm64_browser_get_content(content_type: str = "text") -> str: """Get page content using ARM64 Chromium browser. Args: content_type: 'text' or 'html' Returns: Page content or error message """ request = { "jsonrpc": "2.0", "method": "tools/call", "params": {"name": "get_content", "arguments": {"type": content_type}}, "id": 1 } try: result = subprocess.run( ["node", INDEX_PATH], input=json.dumps(request), text=True, capture_output=True, timeout=30, cwd=SERVER_DIR ) # Parse both stdout and stderr for JSON responses all_output = result.stdout + result.stderr lines = [line for line in all_output.strip().split('\n') if line.startswith('{"')] for line in lines: try: response = json.loads(line) if 'result' in response: content = response.get('result', {}).get('content', [{}]) return content[0].get('text', 'No content retrieved') except json.JSONDecodeError: continue return f"No valid response found. Output: {all_output[:200]}" except Exception as e: return f"Content retrieval error: {e}"
- arm64_browser.py:97-100 (helper)Convenience wrapper function in arm64_browser.py that invokes the MCP 'get_content' tool via the generic call_mcp_tool.def get_content(content_type: str = "text") -> str: """Get page content (text or html)""" return call_mcp_tool("get_content", type=content_type)