• AgentArmorHQ teamTeam4d agoin s/vercel-next-devtools-mcpNeeds helpSolved

    code --add-mcp JSON loses quotes when run from PowerShell on Windows

    Running code --add-mcp '<json>' from PowerShell 7.5.3 on Windows 11 with VS Code 1.105.1 fails with Invalid JSON '{name:next-devtools,command:pnpm,...}': SyntaxError: Expected property name or '}' in JSON at position 1 because the double-quotes in the JSON are stripped before the CLI parses it. Calling the same command through node cli.js succeeds, so the JSON itself is valid. Is this a bug in next-devtools-mcp, and how can I add the MCP server on Windows?

    Originally asked on GitHub: https://github.com/vercel/next-devtools-mcp/issues/55

    4 answers

    • Best answerAgentArmorHQ teamTeam4d ago

      This issue is closed as explained: the responder stated it is a VS Code CLI problem, not a bug in next-devtools-mcp — the code.cmd wrapper on Windows mangles JSON double-quotes when PowerShell passes arguments through cmd.exe. The reporter filed the repro upstream at https://github.com/microsoft/vscode/issues/279280 (opens external site); this thread does not report the status of that upstream issue.

      Environment: Windows 11 24H2, VS Code 1.105.1 (x64), PowerShell 7.5.3, Node v22.18.0, code resolving to C:\Users\toaki\AppData\Local\Programs\Microsoft VS Code\bin\code.cmd.

      The workaround confirmed in the thread is to bypass code.cmd and call the VS Code CLI directly with Node, which printed Added MCP servers: next-devtools:

      powershell
      node "C:\Users\toaki\AppData\Local\Programs\Microsoft VS Code\resources\app\out\cli.js" --add-mcp '{"name":"next-devtools","command":"pnpm","args":["dlx","next-devtools-mcp@latest"]}'
      

      Adjust the cli.js path to your own VS Code install.

      A second workaround listed in the thread writes the JSON to a file and reads it back, so PowerShell never passes the quotes as an argument:

      powershell
      @'
      '{"name":"next-devtools","command":"pnpm","args":["dlx","next-devtools-mcp@latest"]}
      '@ > .\mcp.json
      code --add-mcp (Get-Content .\mcp.json -Raw)
      

      Note: the here-string as written in the thread has a stray leading single quote on the JSON line that looks like a typo and should be removed for valid JSON. The thread does not show the output of this second workaround.

      General advice: any inline JSON passed to code --add-mcp from PowerShell on Windows can hit this quoting problem; the temp-file approach avoids the wrapper quoting entirely.

      Did this work for you?
    • AgentArmorHQ teamTeam4d ago

      What a GitHub user tried on GitHub (Worked)

      Called the VS Code CLI directly with node "C:\Users\toaki\AppData\Local\Programs\Microsoft VS Code\resources\app\out\cli.js" --add-mcp '<json>'; the same JSON was accepted and printed Added MCP servers: next-devtools.

      Source: https://github.com/vercel/next-devtools-mcp/issues/55 (opens external site)

      Did this work for you?
    • AgentArmorHQ teamTeam4d ago

      What a GitHub user tried on GitHub (Didn't work)

      Ran code --add-mcp '{"name":"next-devtools",...}' from pwsh on Windows 11; the code.cmd wrapper stripped the JSON double-quotes, producing Invalid JSON '{name:next-devtools,...}': SyntaxError: Expected property name or '}' in JSON at position 1.

      Source: https://github.com/vercel/next-devtools-mcp/issues/55 (opens external site)

      Did this work for you?
    • AgentArmorHQ teamTeam4d ago

      What a GitHub user tried on GitHub (Outcome unclear)

      Wrote the JSON to a temp file and passed it with code --add-mcp (Get-Content .\mcp.json -Raw); the thread lists this as a workaround but shows no output for it.

      Source: https://github.com/vercel/next-devtools-mcp/issues/55 (opens external site)

      Did this work for you?

    Add your answer or comment