Before writing any server code, get your environment right. This takes about 10 minutes.
What you need
- Node.js 18+ — check with
node --version. If you're under 18, update at nodejs.org. - Claude Desktop — download at claude.ai/download if you haven't.
- A code editor — VS Code works fine.
# Verify node version
node --version
# Should output v18.x.x or higher
# Verify npm
npm --version
Create your project
mkdir my-mcp-server
cd my-mcp-server
npm init -y
Install the MCP SDK
npm install @modelcontextprotocol/sdk zod
npm install -D typescript @types/node tsx
What each package does:
@modelcontextprotocol/sdk— the official MCP SDK from Anthropiczod— schema validation (the SDK uses it for defining tool inputs)typescript+@types/node— TypeScript supporttsx— runs TypeScript files directly without a build step (huge quality of life improvement)
Configure TypeScript
Create a tsconfig.json:
{
"compilerOptions": {
"target": "ES2022",
"module": "Node16",
"moduleResolution": "Node16",
"outDir": "./build",
"rootDir": "./src",
"strict": true
}
}
Update package.json to add a build script and set the module type:
{
"type": "module",
"scripts": {
"build": "tsc",
"dev": "tsx src/index.ts"
}
}
Find your Claude Desktop config file
Claude Desktop reads a config file to know which MCP servers to load. You'll need this in Module 2.
Mac:
~/Library/Application Support/Claude/claude_desktop_config.json
Windows:
%APPDATA%\Claude\claude_desktop_config.json
If the file doesn't exist yet, create it. If it exists but is empty, that's fine too.
# Mac: open the config directory
open ~/Library/Application\ Support/Claude/
# Windows (PowerShell)
explorer $env:APPDATA\Claude\
Your folder structure should now look like:
my-mcp-server/
├── src/
│ └── index.ts ← your server goes here
├── package.json
└── tsconfig.json
Environment's ready. Time to write the actual server.