Skip to main content
Glama
jomon003

PlayMCP Browser Automation Server

by jomon003

getConsoleMessages

Retrieve browser console messages for debugging web applications, monitoring JavaScript errors, and capturing log outputs during automation tasks.

Instructions

Get console messages from the browser

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function that sets up console event listening and collects browser console messages.
    async getConsoleMessages(): Promise<string[]> {
      try {
        if (!this.isInitialized() || !this.state.page) {
          throw new Error('Browser not initialized');
        }
        this.log('Getting console messages');
        
        const messages: string[] = [];
        
        // Listen to console events
        this.state.page.on('console', msg => {
          messages.push(`[${msg.type().toUpperCase()}] ${msg.text()}`);
        });
        
        // Return collected messages
        this.log('Console messages retrieved');
        return messages;
      } catch (error: any) {
        console.error('Get console messages error:', error);
        throw new BrowserError('Failed to get console messages', 'Browser console monitoring error');
      }
    }
  • Tool schema definition including name, description, and empty input schema (no parameters required).
    const GET_CONSOLE_MESSAGES_TOOL: Tool = {
      name: "getConsoleMessages",
      description: "Get console messages from the browser",
      inputSchema: {
        type: "object",
        properties: {},
        required: []
      }
    };
  • src/server.ts:514-552 (registration)
    Registration of the tool in the capabilities.tools dictionary for listTools endpoint.
    const tools = {
      openBrowser: OPEN_BROWSER_TOOL,
      navigate: NAVIGATE_TOOL,
      type: TYPE_TOOL,
      click: CLICK_TOOL,
      moveMouse: MOVE_MOUSE_TOOL,
      scroll: SCROLL_TOOL,
      screenshot: SCREENSHOT_TOOL,
      getPageSource: GET_PAGE_SOURCE_TOOL,
      getPageText: GET_PAGE_TEXT_TOOL,
      getPageTitle: GET_PAGE_TITLE_TOOL,
      getPageUrl: GET_PAGE_URL_TOOL,
      getScripts: GET_SCRIPTS_TOOL,
      getStylesheets: GET_STYLESHEETS_TOOL,
      getMetaTags: GET_META_TAGS_TOOL,
      getLinks: GET_LINKS_TOOL,
      getImages: GET_IMAGES_TOOL,
      getForms: GET_FORMS_TOOL,
      getElementContent: GET_ELEMENT_CONTENT_TOOL,
      getElementHierarchy: GET_ELEMENT_HIERARCHY_TOOL,
      executeJavaScript: EXECUTE_JAVASCRIPT_TOOL,
      goForward: GO_FORWARD_TOOL,
      hover: HOVER_TOOL,
      dragAndDrop: DRAG_AND_DROP_TOOL,
      selectOption: SELECT_OPTION_TOOL,
      pressKey: PRESS_KEY_TOOL,
      waitForText: WAIT_FOR_TEXT_TOOL,
      waitForSelector: WAIT_FOR_SELECTOR_TOOL,
      resize: RESIZE_TOOL,
      handleDialog: HANDLE_DIALOG_TOOL,
      getConsoleMessages: GET_CONSOLE_MESSAGES_TOOL,
      getNetworkRequests: GET_NETWORK_REQUESTS_TOOL,
      uploadFiles: UPLOAD_FILES_TOOL,
      evaluateWithReturn: EVALUATE_WITH_RETURN_TOOL,
      takeScreenshot: TAKE_SCREENSHOT_TOOL,
      mouseMove: MOUSE_MOVE_TOOL,
      mouseClick: MOUSE_CLICK_TOOL,
      mouseDrag: MOUSE_DRAG_TOOL,
      closeBrowser: CLOSE_BROWSER_TOOL
  • src/server.ts:899-904 (registration)
    Tool call handler in the server's callTool request handler switch statement, which invokes the controller method and returns the result.
    case 'getConsoleMessages': {
      const messages = await playwrightController.getConsoleMessages();
      return {
        content: [{ type: "text", text: JSON.stringify(messages, null, 2) }]
      };
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It doesn't specify whether this retrieves all console messages (including logs, errors, warnings), if it clears the console buffer, requires specific browser state, or returns structured vs. raw data. 'Get' implies read-only, but details are lacking.

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 with zero waste—'Get console messages from the browser' is front-loaded and precisely conveys the core function without fluff. Every word earns its place.

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 no annotations, no output schema, and moderate complexity (retrieving dynamic browser data), the description is incomplete. It doesn't explain return format (e.g., list of messages with timestamps/types), potential limitations (e.g., only works in certain browser contexts), or error conditions, leaving gaps for agent understanding.

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 input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description appropriately doesn't discuss parameters, aligning with the schema. Baseline is 4 for zero parameters, as it avoids unnecessary detail.

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 'Get console messages from the browser' clearly states the action (Get) and resource (console messages) with specific scope (from the browser). It distinguishes from siblings like getPageSource or getNetworkRequests by focusing on console output, though it doesn't explicitly contrast them.

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. It doesn't mention prerequisites (e.g., requires an open browser session), typical use cases (debugging JavaScript errors), or when other tools like getPageText or evaluateWithReturn might be more appropriate.

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