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 };
        }
      }
    );
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full burden. Adds useful behavioral context that execution supports 'await' for async operations and implies page context ('on the page'). However, lacks disclosure of error handling behavior, return value serialization format, or whether execution modifies page state.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, front-loaded with core purpose first ('Run...'), second sentence adds specific capability ('Supports await'). Zero waste, appropriately sized for a single-parameter tool.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Minimum viable for a single-parameter tool with full schema coverage. Omits expected return format and error behavior given no output schema exists, but covers the essential invocation contract. Adequate but lean given the tool's power to execute arbitrary code.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema has 100% coverage with the expression parameter already documented. Description meets baseline 3 by essentially restating the schema, with slight value added by mentioning 'await' support which constrains valid expression content.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clear verb ('Run') and resource ('JavaScript expression on the page'), with explicit outcome ('return the result'). Distinguishes from siblings like pilot_page_text or pilot_click by specifying code evaluation rather than interaction or extraction.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Only implicit guidance via 'Supports await' indicating async capability. No explicit when-to-use guidance, no alternatives mentioned (e.g., when to use pilot_page_text vs JS evaluation), and no prerequisites like requiring navigation first.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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