Skip to main content
Glama
workbackai

MCP NodeJS Debugger

by workbackai

retry_connect

Manually reconnects to the Node.js debugger when the connection is lost or unstable, allowing debugging to resume without restarting the server.

Instructions

Manually triggers a reconnection attempt to the Node.js debugger

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
portNoOptional port to connect to. Defaults to current port (9229)

Implementation Reference

  • The handler function for the 'retry_connect' tool. It optionally updates the port, disconnects the current WebSocket if connected, resets the retry count, and initializes a new connection attempt to the Node.js debugger.
    async ({ port }) => {
      try {
        // If a new port is specified, update the inspector's port
        if (port && port !== inspector.port) {
          inspector.port = port;
        }
        
        // If already connected, disconnect first
        if (inspector.connected && inspector.ws) {
          inspector.ws.close();
          inspector.connected = false;
    inspector.debuggerEnabled = false;
        }
        
        // Reset retry count and initialize
        inspector.retryCount = 0;
        inspector.initialize();
        
        return {
          content: [{
            type: "text",
            text: `Attempting to connect to Node.js debugger on port ${inspector.port}...`
          }]
        };
      } catch (err) {
        return {
          content: [{
            type: "text",
            text: `Error initiating connection retry: ${err.message}`
          }]
        };
      }
    }
  • The input schema definition for the 'retry_connect' tool, specifying an optional 'port' parameter using Zod validation.
    {
      port: z.number().optional().describe("Optional port to connect to. Defaults to current port (9229)")
    },
  • The registration of the 'retry_connect' tool using server.tool(), including the tool name, description, input schema, and inline handler function.
    server.tool(
      "retry_connect",
      "Manually triggers a reconnection attempt to the Node.js debugger",
      {
        port: z.number().optional().describe("Optional port to connect to. Defaults to current port (9229)")
      },
      async ({ port }) => {
        try {
          // If a new port is specified, update the inspector's port
          if (port && port !== inspector.port) {
            inspector.port = port;
          }
          
          // If already connected, disconnect first
          if (inspector.connected && inspector.ws) {
            inspector.ws.close();
            inspector.connected = false;
    		inspector.debuggerEnabled = false;
          }
          
          // Reset retry count and initialize
          inspector.retryCount = 0;
          inspector.initialize();
          
          return {
            content: [{
              type: "text",
              text: `Attempting to connect to Node.js debugger on port ${inspector.port}...`
            }]
          };
        } catch (err) {
          return {
            content: [{
              type: "text",
              text: `Error initiating connection retry: ${err.message}`
            }]
          };
        }
      }
    );

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/workbackai/mcp-nodejs-debugger'

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