Skip to main content
Glama
jomon003

PlayMCP Browser Automation Server

by jomon003

getScripts

Extract all JavaScript code from web pages to analyze scripts, debug issues, or collect code snippets for automation tasks.

Instructions

Get all JavaScript code from the current page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler function in PlaywrightController that extracts all script content from the current page by evaluating JavaScript to query script tags, handling both inline scripts and external src URLs.
    async getScripts(): Promise<string[]> {
      try {
        if (!this.isInitialized()) {
          throw new Error('Browser not initialized');
        }
        this.log('Getting page scripts');
        const scripts = await this.state.page?.evaluate(() => {
          const scriptElements = Array.from(document.querySelectorAll('script'));
          return scriptElements.map(script => {
            if (script.src) {
              return `// External script: ${script.src}`;
            }
            return script.textContent || script.innerHTML;
          }).filter(content => content.trim().length > 0);
        });
        this.log('Scripts retrieved:', scripts?.length);
        return scripts || [];
      } catch (error: any) {
        console.error('Get scripts error:', error);
        throw new BrowserError('Failed to get scripts', 'Check if the page is loaded');
      }
    }
  • MCP Tool schema definition for getScripts, specifying name, description, and input schema (no required parameters).
    const GET_SCRIPTS_TOOL: Tool = {
      name: "getScripts",
      description: "Get all JavaScript code from the current page",
      inputSchema: {
        type: "object",
        properties: {},
        required: []
      }
    };
  • src/server.ts:526-526 (registration)
    Registration of the getScripts tool in the tools object provided to the MCP server's capabilities.
    getScripts: GET_SCRIPTS_TOOL,
  • MCP server request handler case for 'getScripts' that delegates to PlaywrightController.getScripts() and formats the response as MCP content.
    case 'getScripts': {
      const scripts = await playwrightController.getScripts();
      return {
        content: [{ type: "text", text: scripts.join('\n') }]
      };
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states what the tool does but doesn't describe what 'Get all JavaScript code' means operationally: does it extract inline scripts, external script references, or both? Does it return raw code, URLs, or structured data? No information about format, limitations, or potential side effects is provided.

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, clear sentence with no wasted words. It's front-loaded with the essential information and doesn't contain any redundant or unnecessary content. Perfectly concise for a simple tool.

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?

For a tool with no annotations, no output schema, and multiple similar siblings in a browser automation context, the description is insufficient. It doesn't explain what format the JavaScript code is returned in, whether it includes external vs. inline scripts, or how this differs from other page inspection tools. The agent would need to guess about the tool's behavior and output.

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

Parameters4/5

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

The tool has zero parameters, and the input schema has 100% description coverage (though empty). The description appropriately doesn't discuss parameters since none exist, which is correct for this case. No additional parameter information is needed or provided.

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 ('Get') and resource ('all JavaScript code from the current page'), making the tool's purpose immediately understandable. It doesn't explicitly differentiate from siblings like 'executeJavaScript' or 'getPageSource', but the specificity of 'JavaScript code' provides reasonable distinction.

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?

The description provides no guidance on when to use this tool versus alternatives like 'getPageSource' (which might include JavaScript) or 'executeJavaScript' (which runs code). There's no mention of prerequisites, timing considerations, or comparison with sibling tools.

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/jomon003/PlayMCP'

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