Finally got my MCP setup working in VS Code Insiders on my Raspberry Pi! 🎉 And I'm posting this directly from the editor on my Windows PC, connected over SSH with the Remote-SSH extension. The whole setup is feeling pretty seamless now. I spend a lot of time in VSCode, so I'm really coming to like MCP servers.
#MCP #VSCode #Pi #RaspberryPi #RemoteSSH #DevEnvironment #CodingSetup
I switched to #Positron https://github.com/posit-dev/positron by @Posit for most of my #rstats and #rpackage development activity. I have not touched #RStudio for many weeks. https://codeium.com/ as AI autocomplete for now, as GitHub Copilot is not working yet in #Positron. Occasional fallback to #VScode for #RemoteSSH work.
GitHub - posit-dev/positron: Positron, a next-generation data science IDE

Positron, a next-generation data science IDE. Contribute to posit-dev/positron development by creating an account on GitHub.

GitHub

PSA – VS Code can kill…

Public Service Announcement: Visual Studio Code can kill remote machines…

I found this out the hard way.

I was using a Raspberry Pi (RPi) for a home project. It would slow down then die, seemly at random. A repower always fixed it.

The first thing I suspected was my Python code. I went down a deep dark rabbit hole trying to find the cause, included sending telemetry to a separate box running an ELK stack.

Looking at the telemetry visualisation, I had a lightbulb moment as it became clear that there was a 100% correlation between my code editor, Microsoft Visual Studio Code (VS Code) connecting to the RPi, and it suddenly running out of swap memory and becoming unresponsive.

VS Code was killing my little RPi. But correlation is not necessarily causation.

Figure 1 – Was VS Code attacking my RPi?[1]

The telemetry showed the RPi swap memory dropping to zero immediately after I did a remote connect to it with VS Code:

Figure 2 – Raspberry Pi dies after VS Code Connection

I searched cyberspace and found a post describing similar issues caused by the VS Code “TypeScript and Javascript Language Features” extension. I disabled that extension, but the issue persisted.

After more digging, I found an RPi forum topic with a reference to the other post. The Python extension was the culprit this time. That sounded promising as my code was Python.

I disabled the Python extensions and restarted VS Code and the RPi.

Figure 3 – The fix: disabling two Python extensions

I retested and the problem was solved:

Figure 4 – VS Code connected at 10:13, temporary spike in CPU and small drop in swap memory

Reenabled the Python and Python Debugger extensions in VS Code caused the problem to come back, so for me the issue is reproducible.

Disabling the Python extensions hasn’t caused me any issues as I wasn’t using the features, such as debugging. I just need a tool for editing my code remotely.

Why this happened

The VS Code “Remote – SSH” extension is super-convenient, but I hadn’t bothered to dig into how it works.

My assumption was that VS Code used SSH to connect to the remote machine and all the heavy lifting was done on the client side:

Figure 5 – Wrong: how I assumed VS Code “Remote – SSH” was architected

As with a lot of assumptions, this was wrong. Here is what it actually does[2]:

Figure 6 – VS Code “Remote – SSH” architecture: What really happens

Note the blue boxes on the remote machine. This is a heavy install that spins up node.js to run extensions and other code. The resource utilisation is more that you would be expecting if you were only thinking it was an SSH connection that lived off the land on the remote machine.

Extensions run on the remote machine. Disabling these extensions in VS Code reduced the memory usage on my RPi to an acceptable level.

To be fair, the in-app documentation for the “Remote – SSH” extension (which I hadn’t read) says the remote machine needs (among other things) a whole heap of RAM.

Figure 7 – The VS Code “Remote – SSH” extension needs a whole heap of RAM on the remote machine…

My little RPi has a paltry 512MB of RAM, so it is under the supported spec, and by all accounts it shouldn’t even work! Also, it runs an ARM CPU, and the documentation says support for this is limited.

I think the “Remote – SSH” extension should issue a warning if the remote machine is not up to spec.

Wrapping it up

VS Code is a useful and free code editing tool for developers. Use the “Remote – SSH” extension with caution. It requires significant resources (CPU, memory) on the remote machine and can cause impact to system performance.

Figure 8 – Public Service Announcement [3]

Never ever use VS Code to remote SSH to a production server (not that you would of course!).

PSA over.

[1] Image generated on Google Image FX with prompt “A stylised cartoon image of a big aggressive microsoft vscode blue icon attacks a small raspberry pi computer”

[2] VS Code Server architecture used on remote machines: https://code.visualstudio.com/docs/remote/vscode-server

[3] Image generated on Google Image FX with prompt “vintage Public Service Announcement poster on a brick wall that says “VSCode remotes need RAM””

#RaspberryPi #RemoteSSH #VSCode

Raspberry Pi

From industries large and small, to the kitchen table tinkerer, to the classroom coder, we make computing accessible and affordable for everybody.

Raspberry Pi
#VSCode ‘s #RemoteSSH extension is awesome, except that every time VSCode gets an update, you must wait for the extension to download and then upload its VSCode server to the remote host.