Skip to content

fix: parse launch.json as jsonc#2

Open
Albro3459 wants to merge 1 commit intoNyxJae:mainfrom
Albro3459:fix/get-debugger-configurations-launch-json
Open

fix: parse launch.json as jsonc#2
Albro3459 wants to merge 1 commit intoNyxJae:mainfrom
Albro3459:fix/get-debugger-configurations-launch-json

Conversation

@Albro3459
Copy link
Copy Markdown

@Albro3459 Albro3459 commented Mar 12, 2026

Summary

  • parse .vscode/launch.json as JSONC with jsonc-parser instead of stripping comments with a regex
  • preserve strings that contain //, such as serverReadyAction.pattern values with URLs
  • add the parser dependency and update the related lockfiles

Reproduce

Current main can fail to parse a valid VS Code launch.json like this:

{
  // VS Code accepts comments in launch.json
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Debug App",
      "type": "pwa-node",
      "request": "launch",
      "serverReadyAction": {
        "pattern": "Local:.*(https?://localhost:\\d+)",
        "action": "startDebugging",
        "name": "Launch Chrome"
      }
    }
  ]
}

The previous implementation removes comments with a regex before calling JSON.parse. That also strips the // inside https?://..., corrupts the string, and causes get_debugger_configurations to reject a file that VS Code itself accepts.

Validation

  • ran npm run build in mcp-server
  • set VSCODE_WORKSPACE_PATH to a workspace containing serverReadyAction.pattern: "Local:.*(https?://localhost:\\d+)"
  • invoked the built getDebuggerConfigurationsTool
  • confirmed the updated parser returns status: "success" and the expected configurations for that launch.json
  • reran the same check on main and reproduced the existing parse failure from the old regex-based parser

@Albro3459 Albro3459 marked this pull request as ready for review March 12, 2026 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant