evaluate-script
Execute custom scripts in AdsPower browser to manipulate web elements, automate tasks, and interact with dynamic content via the LocalAPI MCP Server.
Instructions
Evaluate the script
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| script | Yes | The script to evaluate, eg: "document.querySelector('#username').value = 'test'" |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"script": {
"description": "The script to evaluate, eg: \"document.querySelector('#username').value = 'test'\"",
"type": "string"
}
},
"required": [
"script"
],
"type": "object"
}
Implementation Reference
- src/handlers/automation.ts:132-136 (handler)The core handler function for the 'evaluate-script' tool. It checks if the browser is connected, evaluates the provided JavaScript script in the current page context using Puppeteer's evaluate method, and returns the result.async evaluateScript({ script }: EvaluateScriptParams) { browser.checkConnected(); const result = await browser.pageInstance!.evaluate(script); return result; },
- src/types/schemas.ts:209-211 (schema)Zod schema definition for the 'evaluate-script' tool input parameters, defining a 'script' string field.evaluateScriptSchema: z.object({ script: z.string().describe('The script to evaluate, eg: "document.querySelector(\'#username\').value = \'test\'"') }).strict(),
- src/utils/toolRegister.ts:86-87 (registration)Registration of the 'evaluate-script' tool on the MCP server, linking the name, description, schema, and wrapped handler function.server.tool('evaluate-script', 'Evaluate the script', schemas.evaluateScriptSchema.shape, wrapHandler(automationHandlers.evaluateScript));