Skip to main content
Glama

pilot_evaluate

Execute JavaScript expressions on web pages to retrieve results, supporting asynchronous operations for dynamic content interaction.

Instructions

Run a JavaScript expression on the page and return the result. Supports await.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expressionYesJavaScript expression to evaluate

Implementation Reference

  • The handler for the 'pilot_evaluate' tool, which evaluates a JS expression in the browser.
    async ({ expression }) => {
      await bm.ensureBrowser();
      try {
        const wrapped = wrapForEvaluate(expression);
        const result = await bm.getPage().evaluate(wrapped);
        const text = typeof result === 'object' ? JSON.stringify(result, null, 2) : String(result ?? '');
        return { content: [{ type: 'text' as const, text }] };
      } catch (err) {
        return { content: [{ type: 'text' as const, text: wrapError(err) }], isError: true };
      }
    }
  • Tool registration for 'pilot_evaluate' in src/tools/inspection.ts.
    server.tool(
      'pilot_evaluate',
      'Run a JavaScript expression on the page and return the result. Supports await.',
      { expression: z.string().describe('JavaScript expression to evaluate') },
      async ({ expression }) => {
        await bm.ensureBrowser();
        try {
          const wrapped = wrapForEvaluate(expression);
          const result = await bm.getPage().evaluate(wrapped);
          const text = typeof result === 'object' ? JSON.stringify(result, null, 2) : String(result ?? '');
          return { content: [{ type: 'text' as const, text }] };
        } catch (err) {
          return { content: [{ type: 'text' as const, text: wrapError(err) }], isError: true };
        }
      }
    );

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/TacosyHorchata/Pilot'

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