evaluate
Execute JavaScript code directly in the Chromium browser on ARM64 devices to automate tasks, test web applications, and interact with page elements programmatically.
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 primary handler function for the 'evaluate' MCP tool. It ensures the Chromium browser is running, executes the provided JavaScript script using the CDP Runtime.evaluate command, and returns the result formatted as MCP content.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:171-183 (schema)Input schema definition for the 'evaluate' tool used in tool listing and validation.name: 'evaluate', description: 'Execute JavaScript in the browser', inputSchema: { type: 'object', properties: { script: { type: 'string', description: 'JavaScript code to execute', }, }, required: ['script'], }, },
- index-browser-only.js:382-393 (handler)Alternative handler function for the 'evaluate' tool in the browser-only MCP server implementation.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:149-161 (schema)Input schema for the 'evaluate' tool in the browser-only server.name: 'evaluate', description: 'Execute JavaScript in the browser (read-only operations)', inputSchema: { type: 'object', properties: { script: { type: 'string', description: 'JavaScript code to execute (for reading page info)', }, }, required: ['script'], }, },
- index.js:359-360 (registration)Dispatch registration for the 'evaluate' tool within the CallToolRequestSchema switch statement.case 'evaluate': return await this.evaluate(args.script);