Level 1 · Complete · Cheat Sheet

Level 1 Mastery Card

Your compact reference for all 10 foundational MCP concepts. Keep this open while you build.

10 Days ~5 hrs learning MCP Foundations Production Ready
Days 1 – 10

One Card Per Day

Day 1

What Is MCP?

  • Architecture: Host → Client → Server (3-tier)
  • MCP = USB-C for AI: one standard, universal capability connection
  • 3 Primitives: Tools (actions) · Resources (data) · Prompts (templates)
  • Wire format: JSON-RPC 2.0 over any transport
Day 2

JSON-RPC 2.0

  • Request: { jsonrpc, id, method, params }
  • Response: { jsonrpc, id, result } or { …, error }
  • Notification: no id field (fire-and-forget)
  • Lifecycle: initializeinitialized → [use] → close
Day 3

TypeScript SDK

  • new McpServer(info, { capabilities })
  • server.tool(name, desc, schema, handler)
  • StdioServerTransportserver.connect(transport)
  • Zod schema: z.object({ x: z.string().describe('…') })
Day 4

Tools in Depth

  • Naming: verb_noun — e.g. search_repos, get_file_content
  • Always try/catch → return isError: true on failure
  • Annotations: readOnlyHint · destructiveHint · idempotentHint
  • Pagination: cursor-based, return nextCursor in response
Day 5

Resources Deep Dive

  • Static: server.resource(name, uri, {mimeType}, handler)
  • Template: new ResourceTemplate('github://repo/{owner}/{repo}', …)
  • {+path} allows slashes in variable (RFC 6570 level 2)
  • text field for UTF-8 · blob field for base64 binary
Day 6

Prompts & Sampling

  • server.prompt(name, desc, argSchema, handler)
  • Returns: { messages: PromptMessage[] }
  • Sampling: server.createMessage() → calls LLM via host
  • EmbeddedResource: { type:'resource', resource:{uri,…} }
Day 7

Capstone: DevDash Server

  • All 3 primitives in one server
  • Per-connection McpServer instances for WS/SSE
  • console.error ONLY for logging (stdout = JSON-RPC wire)
  • capabilities.sampling = {} required for createMessage()
Day 8

Transport Deep Dive

  • stdio: 1:1, no network, Claude Desktop, console.error only
  • HTTP+SSE: GET /sse (stream) + POST /message (client→server)
  • WebSocket: full-duplex, sticky sessions needed in load balancer
  • nginx SSE: proxy_buffering off + proxy_read_timeout 86400s
Day 9

MCP Client SDK

  • new Client(info, {capabilities})client.connect(transport)
  • StdioClientTransport: spawns server as child process
  • SSEClientTransport: connects to remote HTTP+SSE server
  • result.isError = domain failure · McpError = protocol failure
Day 10

Error Handling & Resilience

  • Domain errors → isError:true · Protocol errors → throw McpError
  • Retry: InternalError ✓ · InvalidParams ✗ · RequestTimeout
  • Circuit breaker: CLOSED → OPEN (N failures) → HALF_OPEN → CLOSED
  • Timeout: AbortController + clearTimeout in finally block
🔴
JSON-RPC Error Codes
Quick retry decision guide
Code Name Notes Retry?
-32700 ParseError Malformed JSON No
-32600 InvalidRequest Bad JSON-RPC structure No
-32601 MethodNotFound Unknown method No
-32602 InvalidParams Wrong params — won't fix itself Never
-32603 InternalError Server-side crash ✓ Yes
-32001 RequestTimeout Took too long ✓ Yes
-32002 ResourceNotFound URI not found No
📦
SDK Import Cheat Sheet
Copy-paste ready imports
// Server
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js'
import { ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js'

// Client
import { Client } from '@modelcontextprotocol/sdk/client/index.js'
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js'
import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js'

// Types
import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js'

// Validation
import { z } from 'zod'
Golden Rules
The 10 commandments of MCP development — memorize these
1
Never console.log in stdio servers — it corrupts the JSON-RPC stream. Use console.error.
2
Tool errors → isError:true. Protocol errors → throw McpError. Never mix the two.
3
Every Zod field needs .describe() — Claude reads these descriptions to understand how to call your tools.
4
Use {+path} not {path} for URI templates that need to contain forward slashes.
5
Always call client.close() in a finally block — never leave connections dangling.
6
Guard optional features: call getServerCapabilities() first before assuming a feature is available.
7
Declare sampling:{} capability in your server options to enable server-to-AI sampling calls.
8
Use exponential backoff with jitter for retries. Never use a fixed delay — it thundering-herds your backend.
9
Circuit breaker OPEN = fail fast — don't hammer a downstream service that's already struggling to recover.
10
Per-connection McpServer instances = isolated, safe state. Never share a single instance across WS/SSE connections.
Level 2 Unlocked

Ready for Level 2?

You've nailed the foundations. Level 2 takes you into advanced territory — real APIs, auth flows, and production-grade patterns.

Days 11–20 Advanced Server Patterns OAuth & Auth Flows Real API Integrations Production Deployment
Begin Day 11 →