Skip to main content
Glama

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
NameRequiredDescriptionDefault
typeNoType of content to gettext

Implementation Reference

  • 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', }, }, }, },
  • 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 || '' }], }; } }
  • 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}"
  • 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)

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