What Happens When an AI Has Access to a Node.js Environment? Spoiler: Wild Things

Bookmark
Rate this content

Give an AI access to a real Node.js runtime, and things start to get interesting. It can run code, install packages, generate files, and even launch servers on the fly. In this talk, you will see how I built a Node.js Sandbox server powered by the Model Context Protocol (MCP), an open standard that connects AI to real tools and data in a safe, controlled way.

We will walk through how the sandbox works: starting fresh Docker containers, installing npm packages on the fly, executing JavaScript, and sending back logs or files. Everything happens through simple MCP messages, allowing the AI to interact with your system just like a developer would, only faster.

You will see how this unlocks powerful use cases like generating charts with Chart.js, summarizing long articles from the web, creating and testing QR codes, scraping and saving content, generating PDFs and fake CSV data, or even spinning up mock APIs in seconds. By the end, you will know how to build your own MCP server and give your AI the keys to a real coding playground.

This talk has been presented at JSNation US 2025, check out the latest edition of this JavaScript Conference.

FAQ

The Node.js Sandbox MCP server is a project that allows a language model (LLM) to run its own code in a Node.js environment. It enables the LLM to write code, execute it, install dependencies, access the file system, and more.

MCP, or Model Context Protocol, provides a unified way to connect AI applications with data sources and tools, solving the problem of disparate connections and lack of standardization in AI integration.

Running AI-generated code locally enhances security and privacy, allowing for tasks like local data analysis and visualization without relying on cloud services, thus keeping sensitive data private.

The MCP server uses Docker containers to safely execute AI-generated code, ensuring the code runs in an isolated environment to prevent security risks associated with executing untrusted code.

Docker is used to create isolated environments for running AI-generated code. It provides a balance between complexity and safety, allowing code execution without affecting the host machine.

Yes, the Node.js Sandbox MCP server can be easily expanded to support other languages, such as Python, by modifying a few lines of code to change the execution environment and dependencies.

The server can be used for generating QR codes, web searching, PDF generation, file manipulation, markdown slides generation, and more, leveraging the extensive package ecosystem of JavaScript.

The MCP server allows AI-generated code to define and install its own dependencies by writing a package.json file and performing an npm install within the Docker container.

Security is crucial, as MCP servers treat all incoming code as untrusted. Developers need to sanitize inputs, ensure isolation, and be aware of potential command injection vulnerabilities.

You can find more information, report issues, or contribute to the project by visiting the repository mentioned in the presentation. Contributions and feedback are encouraged to help the project grow.

Alfonso Graziano
Alfonso Graziano
23 min
20 Nov, 2025

Comments

Sign in or register to post your comment.
Video Summary and Transcription
Alfonso delves into AI in Node.js, focusing on AI agents and the Model Context Protocol (MCP). The discussion covers reasons for building MCP servers, secure code execution using Node.js and Docker, and customization for running code securely. Enhancements in LLM capabilities, Docker integration, and security measures are highlighted. Features like working directory snapshots, file updates comparison, and emphasizing security in MCP servers stand out.

1. Exploring AI in Node.js with MCP

Short description:

Alfonso discusses the exciting topic of AI in Node.js. Learn more about AI agents in Node.js and reach out on LinkedIn. Explore the Node.js Sandbox MCP server project on js.ai.com. Understand the Model Context Protocol (MCP) and its role in connecting AI agents to data sources.

Hi folks. Thanks a lot for being here today. I'm Alfonso and today we're going to talk about something which is very exciting. So we're going to learn and we're going to see what happens when an AI, so an LLM, has access to a Node.js environment and therefore can write its own code and run its own code. Before we start, a quick introduction from my side. Hey, again, I'm Alfonso, probably from Italy, and I'm a tech lead in a company called NearForm and we're basically a consultancy company for especially Node.js and a few other technologies. But if you are interested about the topics that we're going to discuss today, if you want to learn more about the usage of AI agents in Node.js or AI in the software development lifecycle, please reach out on LinkedIn. I'm always more than happy to have chats and get feedback on these projects because they're very, very valuable. So again, if you want, let's have a chat on LinkedIn.

Let's get started. So everything that's going to be discussed in this talk is in this website, which is js.ai.com. And this project is the Node.js Sandbox MCP server. The idea behind this project is that we'll allow any LLM to run its own code. So it's going to write some code, run it, install dependencies, have access to the file system, and so much more, as you may guess. In case you want to give it a shot, in case you want to try it, you can take a look at this website. Or if you want, this project is one of the verified projects on the Docker Hub. So it's mcp slash Node.js Sandbox. You can easily download it if you are using Docker Desktop. It's super easy, it takes around 30 seconds. So let's get started.

And before we go into the technical bits and the technical details of the implementation, let's see what are the reasons of this project. And first of all, what is the MCP? So what is the Model Context Protocol? I'm not going to invest too much time in this section, because I'm sure that you already heard quite a bit of MCP, and you already know what it is and how it works. But I just want to bring you, I just want to bring what are the problems that MCP is supposed to solve. So before MCP, while creating connections between AI agents or AI applications and data sources and tools, we had one common problem, which was the amp-for-end problem. So the idea is that you have M applications, so like your calendar application, maybe your Gmail, maybe, I don't know, anything that you can think of, right? And then you have to connect those applications to the data sources, which might be like a database or a scheduler, whatever. The problem here is that you don't have a unified way of connecting those two things, right? So in the case of an AI agent, you don't have any standard way to connect your AI to a data source or to something which allows you to use tools. And that's where MCP comes into play. So the main idea is that you can just communicate, you can just use the protocol. So the LLM, it's going to implement the MCP client. So for example, Cloud Desktop is going to implement it, ShareGP recently implemented it.

2. Building and Using MCP Servers for AI

Short description:

Integrating with MCP servers for AI tools. Reasons to build an MCP server: local code execution, data privacy, text-based AI processing, JavaScript's vast ecosystem.

So the idea is that you can just integrate with the, and then you can, and then you can implement your own tools. You can just connect to an MCP server. So it's that easy. We will see it in a bit. The way it works from a technical standpoint, it's relatively easy, but still interesting to see. So the idea is that we do have an MCP client, as I mentioned. In reality, it is called, for example, Cloud, it's the MCP host, because then each server is going to have its own client. But the way it works is that we simply do an MCP request to the server. Then the MCP server is going to act as a proxy and it's going to do whatever we need to. So it's going to do API calls, running code, I don't know, going through a database, whatever we have to. And then it's going to give the results back to the MCP server. And then the MCP server, of course, it's going to give back the results to the client.

Now, the question is, okay, we kind of understood what is MCP, but why should I build an MCP server? Well, there are a few reasons for that. The first reason is that I want my AI to be able to write and run its own code in a safe way locally. So the thing is that we already know that things like ChargePT, Gemini and Cloud, they already have their own tools, but they run on the cloud, right? They run on some things maybe like an edge runtime or something else. But we want something which runs locally because this allows us to do some cool things. So, for example, one thing that we can do is local data analysis and visualization. So let's say that we do have some personal finance data, some medical data, I don't know, anything that we want to keep private. Instead of uploading it to ChargePT, we want to keep it private on our machines. And we can also do, again, visualization and analysis using tools like ChargeJS, Danfo JS, and so on. So this is one cool thing that having it running locally unlocks. Of course, this has some improvements both in terms of security and privacy and so on. Next one is that DLLM thinks in text or tokens, if we want to be precise, but not bits. So as we can see on the left, we do have a relatively simple expression and the model, especially not state-of-the-art models, can easily hallucinate and give wrong results because they have not been trained to run a mathematical expression, but they have been trained to predict the next token. So how do we fix this? Well, as we can see on the right, we can just say verify with code. So the DLLM is going to write some code which is then going to run and the result is going to be, like in this case, three errors in strawberry. So there is going to be something like count the number of errors, and this code is going to be executed. Last but not least, the question is, okay, but why JavaScript? Why no JS? Well, the reason is that the JavaScript ecosystem is actually huge. We do have more than 3.1 million packages, which means that for every problem or for every idea that we do have, most probably there is at least one dependency that is going to solve that problem. All right.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Building a Voice-Enabled AI Assistant With Javascript
JSNation 2023JSNation 2023
21 min
Building a Voice-Enabled AI Assistant With Javascript
Top Content
This Talk discusses building a voice-activated AI assistant using web APIs and JavaScript. It covers using the Web Speech API for speech recognition and the speech synthesis API for text to speech. The speaker demonstrates how to communicate with the Open AI API and handle the response. The Talk also explores enabling speech recognition and addressing the user. The speaker concludes by mentioning the possibility of creating a product out of the project and using Tauri for native desktop-like experiences.
The Ai-Assisted Developer Workflow: Build Faster and Smarter Today
JSNation US 2024JSNation US 2024
31 min
The Ai-Assisted Developer Workflow: Build Faster and Smarter Today
Top Content
AI is transforming software engineering by using agents to help with coding. Agents can autonomously complete tasks and make decisions based on data. Collaborative AI and automation are opening new possibilities in code generation. Bolt is a powerful tool for troubleshooting, bug fixing, and authentication. Code generation tools like Copilot and Cursor provide support for selecting models and codebase awareness. Cline is a useful extension for website inspection and testing. Guidelines for coding with agents include defining requirements, choosing the right model, and frequent testing. Clear and concise instructions are crucial in AI-generated code. Experienced engineers are still necessary in understanding architecture and problem-solving. Energy consumption insights and sustainability are discussed in the Talk.
The Rise of the AI Engineer
React Summit US 2023React Summit US 2023
30 min
The Rise of the AI Engineer
Top Content
Watch video: The Rise of the AI Engineer
The rise of AI engineers is driven by the demand for AI and the emergence of ML research and engineering organizations. Start-ups are leveraging AI through APIs, resulting in a time-to-market advantage. The future of AI engineering holds promising results, with a focus on AI UX and the role of AI agents. Equity in AI and the central problems of AI engineering require collective efforts to address. The day-to-day life of an AI engineer involves working on products or infrastructure and dealing with specialties and tools specific to the field.
AI and Web Development: Hype or Reality
JSNation 2023JSNation 2023
24 min
AI and Web Development: Hype or Reality
Top Content
This talk explores the use of AI in web development, including tools like GitHub Copilot and Fig for CLI commands. AI can generate boilerplate code, provide context-aware solutions, and generate dummy data. It can also assist with CSS selectors and regexes, and be integrated into applications. AI is used to enhance the podcast experience by transcribing episodes and providing JSON data. The talk also discusses formatting AI output, crafting requests, and analyzing embeddings for similarity.
Web Apps of the Future With Web AI
JSNation 2024JSNation 2024
32 min
Web Apps of the Future With Web AI
Web AI in JavaScript allows for running machine learning models client-side in a web browser, offering advantages such as privacy, offline capabilities, low latency, and cost savings. Various AI models can be used for tasks like background blur, text toxicity detection, 3D data extraction, face mesh recognition, hand tracking, pose detection, and body segmentation. JavaScript libraries like MediaPipe LLM inference API and Visual Blocks facilitate the use of AI models. Web AI is in its early stages but has the potential to revolutionize web experiences and improve accessibility.
The AI-Native Software Engineer
JSNation US 2025JSNation US 2025
35 min
The AI-Native Software Engineer
Software engineering is evolving with AI and VIBE coding reshaping work, emphasizing collaboration and embracing AI. The future roadmap includes transitioning from augmented to AI-first and eventually AI-native developer experiences. AI integration in coding practices shapes a collaborative future, with tools evolving for startups and enterprises. AI tools aid in design, coding, and testing, offering varied assistance. Context relevance, spec-driven development, human review, and AI implementation challenges are key focus areas. AI boosts productivity but faces verification challenges, necessitating human oversight. The impact of AI on code reviews, talent development, and problem-solving evolution in coding practices is significant.

Workshops on related topic

AI on Demand: Serverless AI
DevOps.js Conf 2024DevOps.js Conf 2024
163 min
AI on Demand: Serverless AI
Top Content
Featured WorkshopFree
Nathan Disidore
Nathan Disidore
In this workshop, we discuss the merits of serverless architecture and how it can be applied to the AI space. We'll explore options around building serverless RAG applications for a more lambda-esque approach to AI. Next, we'll get hands on and build a sample CRUD app that allows you to store information and query it using an LLM with Workers AI, Vectorize, D1, and Cloudflare Workers.
AI for React Developers
React Advanced 2024React Advanced 2024
142 min
AI for React Developers
Top Content
Featured Workshop
Eve Porcello
Eve Porcello
Knowledge of AI tooling is critical for future-proofing the careers of React developers, and the Vercel suite of AI tools is an approachable on-ramp. In this course, we’ll take a closer look at the Vercel AI SDK and how this can help React developers build streaming interfaces with JavaScript and Next.js. We’ll also incorporate additional 3rd party APIs to build and deploy a music visualization app.
Topics:- Creating a React Project with Next.js- Choosing a LLM- Customizing Streaming Interfaces- Building Routes- Creating and Generating Components - Using Hooks (useChat, useCompletion, useActions, etc)
Building Full Stack Apps With Cursor
JSNation 2025JSNation 2025
46 min
Building Full Stack Apps With Cursor
Featured Workshop
Mike Mikula
Mike Mikula
In this workshop I’ll cover a repeatable process on how to spin up full stack apps in Cursor.  Expect to understand techniques such as using GPT to create product requirements, database schemas, roadmaps and using those in notes to generate checklists to guide app development.  We will dive further in on how to fix hallucinations/ errors that occur, useful prompts to make your app look and feel modern, approaches to get every layer wired up and more!  By the end expect to be able to run your own AI generated full stack app on your machine!
Please, find the FAQ here
Vibe coding with Cline
JSNation 2025JSNation 2025
64 min
Vibe coding with Cline
Featured Workshop
Nik Pash
Nik Pash
The way we write code is fundamentally changing. Instead of getting stuck in nested loops and implementation details, imagine focusing purely on architecture and creative problem-solving while your AI pair programmer handles the execution. In this hands-on workshop, I'll show you how to leverage Cline (an autonomous coding agent that recently hit 1M VS Code downloads) to dramatically accelerate your development workflow through a practice we call "vibe coding" - where humans focus on high-level thinking and AI handles the implementation.You'll discover:The fundamental principles of "vibe coding" and how it differs from traditional developmentHow to architect solutions at a high level and have AI implement them accuratelyLive demo: Building a production-grade caching system in Go that saved us $500/weekTechniques for using AI to understand complex codebases in minutes instead of hoursBest practices for prompting AI agents to get exactly the code you wantCommon pitfalls to avoid when working with AI coding assistantsStrategies for using AI to accelerate learning and reduce dependency on senior engineersHow to effectively combine human creativity with AI implementation capabilitiesWhether you're a junior developer looking to accelerate your learning or a senior engineer wanting to optimize your workflow, you'll leave this workshop with practical experience in AI-assisted development that you can immediately apply to your projects. Through live coding demos and hands-on exercises, you'll learn how to leverage Cline to write better code faster while focusing on what matters - solving real problems.
Free webinar: Building Full Stack Apps With Cursor
Productivity Conf for Devs and Tech LeadersProductivity Conf for Devs and Tech Leaders
71 min
Free webinar: Building Full Stack Apps With Cursor
Top Content
WorkshopFree
Mike Mikula
Mike Mikula
In this webinar I’ll cover a repeatable process on how to spin up full stack apps in Cursor.  Expect to understand techniques such as using GPT to create product requirements, database schemas, roadmaps and using those in notes to generate checklists to guide app development.  We will dive further in on how to fix hallucinations/ errors that occur, useful prompts to make your app look and feel modern, approaches to get every layer wired up and more!  By the end expect to be able to run your own ai generated full stack app on your machine!
Working With OpenAI and Prompt Engineering for React Developers
React Advanced 2023React Advanced 2023
98 min
Working With OpenAI and Prompt Engineering for React Developers
Top Content
Workshop
Richard Moss
Richard Moss
In this workshop we'll take a tour of applied AI from the perspective of front end developers, zooming in on the emerging best practices when it comes to working with LLMs to build great products. This workshop is based on learnings from working with the OpenAI API from its debut last November to build out a working MVP which became PowerModeAI (A customer facing ideation and slide creation tool).
In the workshop they'll be a mix of presentation and hands on exercises to cover topics including:
- GPT fundamentals- Pitfalls of LLMs- Prompt engineering best practices and techniques- Using the playground effectively- Installing and configuring the OpenAI SDK- Approaches to working with the API and prompt management- Implementing the API to build an AI powered customer facing application- Fine tuning and embeddings- Emerging best practice on LLMOps