Build an MCP Server in TypeScript with the Official SDK

The FastMCP tutorials in this series are Python, and FastMCP wraps the Model Context Protocol so you rarely touch it directly. This article drops down a level and builds the same kind of server with the official TypeScript SDK (@modelcontextprotocol/sdk) — the reference implementation Anthropic maintains. You register tools and resources on an McpServer, connect it to the stdio transport, and a local client launches it as a subprocess. The stack is Node, tsc, and vitest. ...

12 min

Build a TypeScript Hello World Application

A minimal TypeScript project that prints a greeting, accepts a name from the command line, includes a test suite using Vitest, and uses a Makefile to drive common tasks. This tutorial covers project setup, TypeScript configuration, argument parsing, unit testing, and build automation. Prerequisites Node.js 20 or later npm 9 or later A Unix-like terminal (macOS, Linux, or WSL on Windows) make installed (pre-installed on macOS and most Linux distributions) Step 1: Set up the project structure Create the file mkdir -p hello-world touch hello-world/.gitignore Add the code: hello-world/.gitignore node_modules/ dist/ .DS_Store *.log tmp/ Detailed breakdown node_modules/ excludes installed dependencies, which are restored with npm install. dist/ excludes compiled TypeScript output generated by the build step. .DS_Store, *.log, and tmp/ cover common OS and temporary artifacts. Step 2: Initialize the project and install dependencies Create the file cd hello-world npm init -y Install TypeScript and the test framework as development dependencies: ...

8 min

Build a WebSocket Chat Server in TypeScript

A real-time chat server using WebSockets, built with TypeScript and the ws library on Node.js. The server supports named users, broadcasts messages to all connected clients, tracks join/leave events, and includes a browser-based test client. Prerequisites Node.js 20 or later npm 9 or later A Unix-like terminal (macOS, Linux, or WSL on Windows) A modern web browser for the test client Step 1: Set up the project structure Create the file mkdir -p websocket-chat-server touch websocket-chat-server/.gitignore Add the code: websocket-chat-server/.gitignore node_modules/ dist/ *.js *.d.ts *.js.map !jest.config.js .DS_Store *.log tmp/ Detailed breakdown node_modules/ excludes installed dependencies, which are restored with npm install. dist/ excludes compiled TypeScript output. *.js, *.d.ts, *.js.map exclude generated JavaScript files in the source tree. The !jest.config.js exception keeps the test config if it were in JS format. .DS_Store, *.log, and tmp/ cover common OS and temporary artifacts. Step 2: Initialize the project and install dependencies Create the file cd websocket-chat-server npm init -y Install runtime and development dependencies: ...

15 min