Building an MCP Server in 5 Steps
From zero to a working tool in under 20 minutes
Step 1: Project Setup2 min
npm init, install @modelcontextprotocol/sdk, zod, tsx
Step 2: Create Server1 min
Instantiate McpServer with name and version
Step 3: Register Tools10 min
Define tool name, description, Zod schema, async handler
Step 4: Connect Transport1 min
StdioServerTransport for local, SSE/HTTP for remote
Step 5: Test5 min
MCP Inspector for debugging, then connect to Claude Desktop
Theory is over. In this module, you'll build a working MCP server that exposes a custom tool. By the end, you'll have a server running in Claude Desktop that the AI can call on demand.
Minimal MCP Server Structure
Three files to go from zero to a working server
index.tsEntry point: creates server, registers tools, starts transport~40 lines
package.jsonDependencies: @modelcontextprotocol/sdk, zod for validation~15 lines
tsconfig.jsonTypeScript config: strict mode, ES2022 target~10 lines
Total setup: Under 65 lines of code. The SDK handles protocol negotiation, message framing, and error serialization.