Set up Node.js and npm—the alternative for creating MCP Servers in TypeScript.
Node.js is a runtime that lets you run JavaScript outside the browser—directly on your computer or server. Created in 2009 by Ryan Dahl, it revolutionized web development by making it possible to use the same language on the frontend and backend. In the context of MCP, Node.js is essential for creating servers in TypeScript, the second most popular language in the MCP ecosystem.
Node.js is a JavaScript runtime based on Chrome's V8 engine. It lets you run JavaScript and TypeScript code on the server, outside the browser. The official MCP SDK maintained by Anthropic is available in TypeScript (@modelcontextprotocol/sdk), making Node.js a powerful alternative to Python for creating MCP servers — especially for teams that already work with web technologies.
Node.js is used by more than 6.3 million websites around the world. The npm registry has more than 2.1 million packages, the world's largest open-source package ecosystem. In the MCP ecosystem, many official servers—such as the filesystem server, GitHub server e Slack server — are written in TypeScript running on Node.js, demonstrating the platform's maturity for MCP.
The recommended way to install Node.js is to use nvm (Node Version Manager), which lets you easily install and switch between multiple Node versions. This is especially useful when different projects require different versions. For MCP, we recommend Node.js 20 LTS (Long Term Support).
O nvm (Node Version Manager) is a tool that manages multiple Node.js installations on the same computer. Instead of installing Node directly on the system (which can cause version conflicts), nvm installs each version in an isolated directory and lets you switch between them with a simple nvm use 20. This is analogous to what uv does for Python—isolated, controlled environments.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
Close and reopen the terminal after installation.
nvm install 20
nvm installs Node.js 20 LTS and sets it as the default version.
Access nodejs.org and download the LTS installer. Run the installer with the default options. npm is installed automatically with Node.js.
Avoid installing Node.js via apt on Ubuntu! Ubuntu’s standard repositories often contain very old versions of Node.js (such as version 12 or 14). Always use nvm or the official NodeSource repository to make sure you get a current version that’s compatible with the MCP SDK.
O npm (Node Package Manager) is the package manager included with Node.js. Just as uv manages Python packages, npm manages JavaScript and TypeScript packages. It's responsible for installing dependencies, running scripts, and managing the file package.json — the equivalent of Python's pyproject.toml.
O npm is three things at once: a registry (an online repository with millions of packages), a CLI (command-line tool for installing and managing packages) and a dependency manager (which manages versions via package.json and package-lock.json). When you install Node.js, npm is included — there is no need to install it separately.
Essential npm commands you’ll use in the course:
npm init — Creates a new project (package.json)npm install pacote — Installs a dependencynpm run script — Runs a script defined in package.jsonnpm list — Lists packages installed in the projectO npx is a tool that comes with npm and lets you run packages directly without installing them globally. This is especially important in the MCP ecosystem, where many servers run via npx — such as the filesystem server and the template creation server.
O npx (Node Package Execute) downloads and runs a package temporarily, without installing it permanently on the system. This is essential for MCP because it lets you run servers such as npx @modelcontextprotocol/server-filesystem without cluttering your global environment. npx always fetches the latest package version, so you use the up-to-date version without having to manage updates manually.
npm install -g @modelcontextprotocol/server-filesystemsudo npm install -gnpx @modelcontextprotocol/server-filesystemJust as we did with Python and uv, it’s essential to check that Node.js, npm, and npx are installed correctly and accessible in the terminal. Issues at this stage can cause confusing errors later, so it’s worth spending a few minutes checking.
Verification confirms three components: the Node.js (JavaScript runtime), the npm (package manager) and the npx (package runner). All three should return their versions when queried via the terminal. If any of them fails, the problem is usually with the system PATH or an incomplete installation.
Execute node -v. It should show v20.x.x or higher.
Execute npm -v. It should show the npm version (usually 10.x.x with Node 20).
Execute npx --version. It should show the same npm version.
nvm list whether Node was installed.node -v shows v14 or v16, run nvm install 20 && nvm use 20.sudo with npm. If it's asking for sudo, the installation wasn't done correctly — use nvm.Let's run a hands-on test using the create-server official MCP — a template generator that creates the complete structure of an MCP Server in TypeScript. If this command works, your Node.js environment is 100% ready for the course.
The package @modelcontextprotocol/create-server is an official generator that creates the complete structure of an MCP Server in TypeScript. It automatically generates the package.json, o tsconfig.json, the initial source code with examples of tools, resources, and prompts, as well as build and run scripts. It’s the equivalent of the uv init + uv add fastmcp of the Python world.
Run the command below in the terminal to create your first MCP Server in TypeScript:
npx @modelcontextprotocol/create-server meu-server
The generator will ask for the server's name and description. When it's done, enter the folder with cd meu-server and explore the generated files. If everything worked without errors, your Node.js environment is MCP-ready!
Next Module: 2.3 — Getting to Know the Terminal