Skip to main content
Glama

render.execute_js

Execute JavaScript code on webpages to analyze client-side behavior, test for vulnerabilities, and automate security assessments during bug bounty hunting.

Instructions

Execute JavaScript in the context of a webpage

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesURL to load
scriptYesJavaScript code to execute

Implementation Reference

  • The handler function for 'render.execute_js'. It creates a new browser page, navigates to the given URL, executes the provided JavaScript using page.evaluate with eval, and returns the result or error.
    async ({ url, script }: any): Promise<ToolResult> => {
      let page: Page | null = null;
      try {
        const browserInstance = await getBrowser();
        page = await browserInstance.newPage();
        
        await page.goto(url, { waitUntil: 'networkidle2', timeout: 30000 });
    
        const result = await page.evaluate((scriptToRun) => {
          try {
            return eval(scriptToRun);
          } catch (e) {
            return { error: e instanceof Error ? e.message : String(e) };
          }
        }, script);
    
        await page.close();
    
        return formatToolResult(true, {
          url,
          result,
        });
      } catch (error: any) {
        if (page) await page.close().catch(() => {});
        return formatToolResult(false, null, error.message);
      }
  • Input schema defining the parameters 'url' and 'script' for the 'render.execute_js' tool.
    inputSchema: {
      type: 'object',
      properties: {
        url: { type: 'string', description: 'URL to load' },
        script: { type: 'string', description: 'JavaScript code to execute' },
      },
      required: ['url', 'script'],
    },
  • Registration of the 'render.execute_js' tool using server.tool() within the registerRenderTools function.
    server.tool(
      'render.execute_js',
      {
        description: 'Execute JavaScript in the context of a webpage',
        inputSchema: {
          type: 'object',
          properties: {
            url: { type: 'string', description: 'URL to load' },
            script: { type: 'string', description: 'JavaScript code to execute' },
          },
          required: ['url', 'script'],
        },
      },
      async ({ url, script }: any): Promise<ToolResult> => {
        let page: Page | null = null;
        try {
          const browserInstance = await getBrowser();
          page = await browserInstance.newPage();
          
          await page.goto(url, { waitUntil: 'networkidle2', timeout: 30000 });
    
          const result = await page.evaluate((scriptToRun) => {
            try {
              return eval(scriptToRun);
            } catch (e) {
              return { error: e instanceof Error ? e.message : String(e) };
            }
          }, script);
    
          await page.close();
    
          return formatToolResult(true, {
            url,
            result,
          });
        } catch (error: any) {
          if (page) await page.close().catch(() => {});
          return formatToolResult(false, null, error.message);
        }
      }
    );
  • src/index.ts:42-42 (registration)
    Top-level call to registerRenderTools(server), which includes registration of 'render.execute_js'.
    registerRenderTools(server);
  • Helper function getBrowser() that provides a shared Puppeteer browser instance, used by the tool handler.
    async function getBrowser(): Promise<Browser> {
      if (!browser) {
        browser = await puppeteer.launch({
          headless: true,
          args: ['--no-sandbox', '--disable-setuid-sandbox'],
        });
      }
      return browser;
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states the basic behavior but lacks critical details: it doesn't specify if this requires network access, what permissions are needed, whether it's read-only or destructive, how errors are handled, or what the output looks like (e.g., return value or side effects). For a tool that executes arbitrary JavaScript, this is a significant gap in transparency.

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?

The description is a single, efficient sentence that directly states the tool's purpose without any fluff or redundancy. It's appropriately sized and front-loaded, making it easy to understand at a glance.

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

Completeness2/5

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

Given the complexity of executing JavaScript in a webpage (which involves network requests, potential security implications, and dynamic behavior), the description is insufficient. No annotations or output schema exist to compensate, leaving gaps in understanding behavioral traits, error handling, and return values. It should provide more context about execution environment and results.

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?

Schema description coverage is 100%, with clear descriptions for both parameters ('url' and 'script'). The description adds no additional meaning beyond the schema, such as format examples or constraints (e.g., URL must be accessible, script execution scope). With high schema coverage, the baseline score of 3 is appropriate as the schema does the heavy lifting.

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?

The description clearly states the action ('Execute JavaScript') and the context ('in the context of a webpage'), which is specific and unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'js.analyze' or 'js.beautify', which may also involve JavaScript processing but in different contexts.

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?

No guidance is provided on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing a webpage loaded), exclusions, or comparisons to sibling tools like 'render.extract_dom' or 'render.screenshot', which might be used in similar web rendering contexts.

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/telmon95/VulneraMCP'

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