blog.pierrehenry.be

How to Use ChatGPT in VSCode Without Leaving Your Terminal

C plus plus code in an coloured editor square strongly foreshortened How to Use ChatGPT in VSCode Without Leaving Your Terminal - Photo by Patrick Martin on Unsplash

Alright, let’s get straight into something I’m genuinely excited about. I’ve been working on my MCP project, and I wanted to take my MCP server up a notch. You know how it goes: you build something, it works, but then you get that itch—what if I could make it even better?

So, I started playing around with prompts for my MCP server, and then it hit me: “Pierre, you should just install the ChatGPT desktop app.” That’s exactly what I did. The cool thing? You can connect your terminal directly inside the app. Just a click, and boom—your terminal is right there, and you can interact with it or even hook up other applications like Visual Studio Code or whatever else you’ve got open.

Setting Up: ChatGPT Meets Terminal

Let me walk you through what I did. I fired up my MCP server (after a bit of a wild goose chase finding the right window—classic), and I wasn’t totally happy with it yet. So I asked ChatGPT to help me improve it.

For context, I’m using Fastify for this server. I’ve been a Fastify fan for years—super reliable. I’m also using the usual suspects: dotenv for environment variables, fastify-static for serving static files (mostly schema files in this case), and number to cast the port from the environment variable into a digit, just in case it’s undefined. Then I start the server and set up the root endpoint. Nothing fancy, just the essentials for the MCP server.

Endpoints are standard—again, just what’s needed. For example, I split a string into an array using commas as delimiters. If you’re curious, that’s how I handle tags: each tag is separated by a comma, so split does the trick. It’s the classic way to turn a string into an array with a delimiter.

The Real Magic: ChatGPT + VSCode

Here’s where things get really interesting. Inside the ChatGPT app, I decided to install the Visual Studio Code extension called “ChatGPT: Work with Code.” Now, everyone knows about the regular Copilot extension, but not many folks realize you can get ChatGPT working directly with your code on macOS. That’s the exciting bit.

So, I installed the extension. Now, I can add Visual Studio Code to the ChatGPT app. I had a bunch of unnecessary files open—like hc.ts (a health endpoint from another backend API), some scripts, my food tracking app, a Medium post script, and even a data science project. I closed everything except the MCP server to keep things clean.

Now, with just the MCP server open, I told ChatGPT: “Bring the improvements into the MCP server codebase. Test them. Only add relevant changes—no irrelevant stuff. Only the important, accurate improvements.” Sent it off.

Photo by Growtika How to Use ChatGPT in VSCode Without Leaving Your Terminal - Photo by Growtika on Unsplash

Honestly, this was my first time integrating ChatGPT with my codebase like this, and I wanted to do it live. It’s just more fun to discover things together, right?

Health Endpoints and Real-Time Improvements

ChatGPT started suggesting improvements. For example, it added a health endpoint. If you’ve seen my earlier stuff, you know I had an hc endpoint before. These days, a health endpoint is more than just a ping—it gives you real details about your server’s status. Ping is just “hey, the server’s alive,” but health endpoints go deeper.

ChatGPT also generated new files like types/mcp.ts and env.ts with new variables. It actually read my VSCode project and understood what I had in there. That’s a good sign.

Now, here’s the catch: at first, it couldn’t write changes directly to VSCode. It could read everything, but writing was a no-go. It offered to bundle the changes into a zip file, but the zip came out empty. Classic “zip is invalid” error. I doubted myself for a second, but it was just an empty zip.

So, I asked ChatGPT if it could update the files directly in the VSCode project. And guess what? It can! There’s an “auto update code” feature. I tried it, and it worked. You can review the changes, see the diff, and save them. It’s even better than I expected.

Everyday Learning: AI as a Coding Partner

Every day, I’m learning new possibilities with this setup. I didn’t know ChatGPT could write code directly into my project like that. If you want, you can just tell it to apply the changes, and it’ll update your codebase right away. It’s honestly amazing—imagination is the only limit here.

I’m a creative person, and today felt like one of those days where everything just clicks. Life is beautiful when your tools work with you, not against you.

Here’s a quick look at what the workflow looks like:

1// Example: Adding a health endpoint with Fastify
2fastify.get('/health', async (request, reply) => {
3  return {
4    status: 'ok',
5    uptime: process.uptime(),
6    timestamp: Date.now()
7  };
8});

Photo by Chris Stein How to Use ChatGPT in VSCode Without Leaving Your Terminal - Photo by Chris Stein on Unsplash

And for splitting tags:

1const tagsString = "ai,fastify,chatgpt";
2const tagsArray = tagsString.split(','); // ['ai', 'fastify', 'chatgpt']

Key Takeaways

“Imagination is the only limit here.”

“Life is beautiful when your tools work with you, not against you.”


Pierre-Henry Soria

GitHub · PierreHenry.Dev · YouTube

<< Previous Post

|

Next Post >>

#Ai Integration #Chatgpt #Developer Tools #Tasks #Tech #Terminal #Vscode