evaluate
Execute JavaScript code directly within the Chromium ARM64 Browser to automate testing, manipulate web content, and enhance browser functionality on ARM64 devices like Raspberry Pi.
Instructions
Execute JavaScript in the browser
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| script | Yes | JavaScript code to execute |
Implementation Reference
- index.js:689-699 (handler)The core handler function for the 'evaluate' tool that executes JavaScript in the browser context using Chrome DevTools Protocol (CDP) Runtime.evaluate and returns the serialized result.async evaluate(script) { await this.ensureChromium(); const result = await this.sendCDPCommand('Runtime.evaluate', { expression: script, returnByValue: true }); return { content: [{ type: 'text', text: `Result: ${JSON.stringify(result.result?.value)}` }], }; }
- index.js:170-183 (schema)The input schema and metadata for the 'evaluate' tool, defining the required 'script' parameter.{ name: 'evaluate', description: 'Execute JavaScript in the browser', inputSchema: { type: 'object', properties: { script: { type: 'string', description: 'JavaScript code to execute', }, }, required: ['script'], }, },
- index.js:359-360 (registration)Registration/dispatch of the 'evaluate' tool handler within the CallToolRequestSchema request handler switch statement.case 'evaluate': return await this.evaluate(args.script);
- index-browser-only.js:382-393 (handler)Alternative implementation of the evaluate handler in the browser-only variant of the MCP server.async evaluate(script) { await this.ensureChromium(); const result = await this.sendCDPCommand('Runtime.evaluate', { expression: script, returnByValue: true, }); return { content: [{ type: 'text', text: `Result: ${JSON.stringify(result.result.value)}` }], }; }
- index-browser-only.js:184-185 (registration)Dispatch for 'evaluate' tool in the browser-only server.case 'evaluate': return await this.evaluate(args.script);