Build a local TypeScript server
Set up the TypeScript project
Create a small Node.js project using the current MCP TypeScript server package, Zod schemas, and a repeatable development command.
8 minute lesson
Before going into the code, complete the MCP Course. This course assumes you know why tools, resources, and prompts are different.
We will build one small server named project-notes. It will expose the same capabilities over local stdio and remote HTTP.
You need Node.js 20 or later. Create the project:
mkdir project-notes-mcp
cd project-notes-mcp
npm init -y
npm pkg set type=module
npm install @modelcontextprotocol/server zod tsx
npm install --save-dev typescript @types/node
mkdir src
Version 2 is now the stable SDK line. Pin the exact versions in your lockfile and record them when you test the server.
Add two scripts to package.json:
{
"scripts": {
"dev": "tsx src/index.ts",
"check": "tsc --noEmit"
}
}
Create tsconfig.json:
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true,
"noEmit": true,
"types": ["node"]
},
"include": ["src/**/*.ts"]
}
type=module matters because the SDK ships as ES modules. NodeNext also explains why local imports will use a .js extension even when the source file ends in .ts.
Run npm run check now. A clean empty project gives us a known baseline before protocol code enters the picture.
Lesson completed