Skip to main content
Glama
AdsPower

AdsPower LocalAPI MCP Server

Official

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

NameRequiredDescriptionDefault
scriptYesThe 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

  • 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; },
  • 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(),
  • 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));

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/AdsPower/local-api-mcp-typescript'

If you have feedback or need assistance with the MCP directory API, please join our Discord server