Skip to main content
Glama
qckfx

Node.js Debugger MCP Server

by qckfx

start_node_process

Start a Node.js process with debugging enabled to run scripts and manage execution for debugging purposes.

Instructions

Start a Node.js process with debugging enabled

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
scriptYesPath to the Node.js script to run
argsNoArguments to pass to the script
cwdNoWorking directory (optional)

Implementation Reference

  • The primary handler function that implements the 'start_node_process' tool. Validates the script path, finds an available debug port, spawns a Node.js process using 'spawn' with --inspect-brk, registers it in managedProcesses, sets up exit cleanup, and returns a success or error message.
    private async startNodeProcess(args: { script: string; args?: string[]; cwd?: string }) {
      const workingDir = args.cwd || process.cwd();
      const scriptPath = resolve(workingDir, args.script);
      
      // Validate script exists
      if (!existsSync(scriptPath)) {
        return {
          content: [{
            type: "text",
            text: `Script not found: ${scriptPath}`,
          }],
          isError: true,
        };
      }
      
      // Find available port
      const port = await this.findAvailablePort();
      const nodeArgs = [`--inspect-brk=${port}`, args.script, ...(args.args || [])];
      
      try {
        const child = spawn("node", nodeArgs, {
          cwd: args.cwd || process.cwd(),
          stdio: ["pipe", "pipe", "pipe"],
          detached: false,
        });
    
        if (!child.pid) {
          throw new Error("Failed to start process");
        }
    
        const managedProcess: ManagedProcess = {
          pid: child.pid,
          port,
          command: "node",
          args: nodeArgs,
          process: child,
          startTime: new Date(),
          scriptPath,
        };
        
        this.usedPorts.add(port);
    
        this.managedProcesses.set(child.pid, managedProcess);
    
        child.on("exit", (code) => {
          if (child.pid) {
            const process = this.managedProcesses.get(child.pid);
            if (process) {
              this.usedPorts.delete(process.port);
              this.managedProcesses.delete(child.pid);
              // Clean up debug session if it was connected to this process
              if (this.debugSession.port === process.port) {
                this.debugSession = { connected: false };
              }
            }
          }
        });
    
        return {
          content: [
            {
              type: "text",
              text: `Started Node.js process with PID ${child.pid} on debug port ${port}`,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error starting process: ${error}`,
            },
          ],
          isError: true,
        };
      }
    }
  • The input schema for the 'start_node_process' tool, defining the expected parameters: 'script' (required string), 'args' (optional string array), 'cwd' (optional string).
    inputSchema: {
      type: "object",
      properties: {
        script: { type: "string", description: "Path to the Node.js script to run" },
        args: { type: "array", items: { type: "string" }, description: "Arguments to pass to the script" },
        cwd: { type: "string", description: "Working directory (optional)" }
      },
      required: ["script"],
    },
  • src/index.ts:144-156 (registration)
    Registration of the 'start_node_process' tool in the ListToolsRequestSchema response, including name, description, and input schema.
    {
      name: "start_node_process",
      description: "Start a Node.js process with debugging enabled",
      inputSchema: {
        type: "object",
        properties: {
          script: { type: "string", description: "Path to the Node.js script to run" },
          args: { type: "array", items: { type: "string" }, description: "Arguments to pass to the script" },
          cwd: { type: "string", description: "Working directory (optional)" }
        },
        required: ["script"],
      },
    },
  • src/index.ts:244-245 (registration)
    Dispatch case in the CallToolRequestSchema handler that routes calls to the startNodeProcess handler.
    case "start_node_process":
      return await this.startNodeProcess(args as { script: string; args?: string[]; cwd?: string });
  • Helper method used by startNodeProcess to dynamically find an available debug port starting from 9229.
    private async findAvailablePort(): Promise<number> {
      let port = this.nextPort;
      while (this.usedPorts.has(port) || !(await this.isPortAvailable(port))) {
        port++;
      }
      this.nextPort = port + 1;
      return port;
    }
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 of behavioral disclosure. It states that debugging is enabled, which adds context beyond the basic 'start' action, but it doesn't cover critical behaviors like whether this starts a background process, what happens on errors, if it requires specific permissions, or the output format. For a tool that launches processes with debugging, 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 front-loads the core action ('Start a Node.js process') and adds a key condition ('with debugging enabled'). There is zero waste, and every word earns its place, making it highly concise and well-structured for quick understanding.

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 starting a debugging-enabled process, no annotations, and no output schema, the description is incomplete. It lacks information on behavioral traits (e.g., process lifecycle, error handling), output expectations, or integration with sibling tools like 'attach_debugger'. The description is too minimal for a tool that interacts with system processes and debugging.

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?

The input schema has 100% description coverage, with clear documentation for 'script', 'args', and 'cwd'. The description adds no additional parameter semantics beyond what the schema provides, such as example values or constraints. With high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

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 ('Start') and resource ('Node.js process') with a specific condition ('with debugging enabled'). It distinguishes from siblings like 'list_processes' (list vs start) and 'kill_process' (terminate vs start), though it doesn't explicitly mention these distinctions. The purpose is specific but could be more differentiated from similar tools like 'attach_debugger'.

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., needing a script file), when not to use it (e.g., if a process is already running), or explicit alternatives like 'attach_debugger' for existing processes. Usage is implied by the action but lacks contextual direction.

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/qckfx/node-debugger-mcp'

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