Skip to main content
Glama

inject_debugging_helpers

Inject debugging helper functions into Firefox tabs to enable advanced debugging and WebSocket monitoring, enhancing testing and automation workflows.

Instructions

Inject debugging helper functions into the page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
includeWebSocketMonitoringNo
tabIdNo

Implementation Reference

  • The primary handler function for the 'inject_debugging_helpers' tool. It injects JavaScript code into the browser page to override console methods for logging capture, add global error and promise rejection handlers, and expose helper functions like getDebugLogs() and getWSMessages() for debugging.
    async injectDebuggingHelpers(args = {}) {
      const { tabId, includeWebSocketMonitoring = true } = args;
      const effectiveTabId = tabId || this.activeTabId;
      const page = this.getPage(effectiveTabId);
      
      // Inject comprehensive debugging helpers
      await page.evaluate(() => {
        // Enhanced console capture
        window._debugLogs = window._debugLogs || [];
        
        if (!window._originalConsole) {
          window._originalConsole = {
            log: console.log,
            error: console.error,
            warn: console.warn,
            info: console.info,
            debug: console.debug
          };
          
          ['log', 'error', 'warn', 'info', 'debug'].forEach(method => {
            console[method] = function(...args) {
              window._debugLogs.push({
                type: method,
                args: args,
                timestamp: Date.now(),
                stack: new Error().stack
              });
              window._originalConsole[method].apply(console, args);
            };
          });
        }
        
        // Helper functions
        window.getDebugLogs = () => JSON.stringify(window._debugLogs, null, 2);
        window.clearDebugLogs = () => window._debugLogs = [];
        window.getWSMessages = () => JSON.stringify(window._wsMessages || [], null, 2);
        window.clearWSMessages = () => window._wsMessages = [];
        
        // Global error handler
        if (!window._errorHandlerInstalled) {
          window.addEventListener('error', (event) => {
            window._debugLogs.push({
              type: 'uncaught-error',
              message: event.message,
              filename: event.filename,
              lineno: event.lineno,
              colno: event.colno,
              error: event.error ? event.error.toString() : null,
              timestamp: Date.now()
            });
          });
          
          window.addEventListener('unhandledrejection', (event) => {
            window._debugLogs.push({
              type: 'unhandled-promise-rejection',
              reason: event.reason ? event.reason.toString() : 'Unknown',
              timestamp: Date.now()
            });
          });
          
          window._errorHandlerInstalled = true;
        }
      });
      
      return {
        content: [{
          type: 'text',
          text: `Debugging helpers injected into tab '${effectiveTabId}'. Use window.getDebugLogs(), window.getWSMessages(), etc.`
        }]
      };
    }
  • Registration of the 'inject_debugging_helpers' tool in the MCP server's listTools response, defining its name, description, and input schema.
      name: 'inject_debugging_helpers',
      description: 'Inject debugging helper functions into the page',
      inputSchema: {
        type: 'object',
        properties: {
          tabId: { type: 'string' },
          includeWebSocketMonitoring: { type: 'boolean', default: true }
        }
      }
    }
  • Input schema for the 'inject_debugging_helpers' tool, specifying parameters tabId (string) and includeWebSocketMonitoring (boolean, default true).
    inputSchema: {
      type: 'object',
      properties: {
        tabId: { type: 'string' },
        includeWebSocketMonitoring: { type: 'boolean', default: true }
      }
  • Dispatch case in the CallToolRequestSchema handler that routes calls to the injectDebuggingHelpers method.
    case 'inject_debugging_helpers':
      return await this.injectDebuggingHelpers(args);
Behavior1/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 of behavioral disclosure. It fails to explain what 'debugging helper functions' are, whether this modifies page state permanently, what permissions are required, or what the expected outcome is. This is inadequate for a tool that likely performs page injection.

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 no wasted words. It's front-loaded with the core action and target, making it easy to parse quickly.

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

Completeness1/5

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

Given the lack of annotations, 0% schema coverage, no output schema, and the tool's likely complexity (injecting debugging helpers), the description is severely incomplete. It doesn't cover behavior, parameters, outcomes, or integration with sibling tools, leaving critical gaps for an AI agent.

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

Parameters1/5

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

Schema description coverage is 0%, and the description provides no information about the two parameters ('includeWebSocketMonitoring' and 'tabId'). It doesn't explain what these parameters control, their formats, or their impact on the injection process.

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 ('inject') and target ('debugging helper functions into the page'), providing a specific verb+resource combination. However, it doesn't explicitly differentiate from sibling tools like 'execute_script' or 'start_monitoring', which could have overlapping debugging purposes.

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 like 'execute_script' for custom debugging code or 'start_monitoring' for automated debugging. The description lacks context about prerequisites, timing, or exclusions.

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

Related 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/JediLuke/firefox-mcp-server'

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