Module 4: Handshake Sequence & JSON-RPC over STDIO
Trace the version negotiation handshake, and analyze STDIO process pipes routing JSON-RPC 2.0 frames.
Day 7
Handshake & Initialization
Why this matters
Handshake: Handshake negotiates capabilities and protocol version before any tool runs.
Before tools run, client and server perform an initialize handshake: negotiate protocol version and advertised capabilities.
Initialize sequence
- Client sends
initializewith protocol version + capabilities. - Server responds with its capabilities.
- Client sends
initializednotification. - Client calls
tools/listto discover available tools.
Mismatching protocol versions is a common reason for silent connection failures — always log the server's
initialize response during development.Common mistakes
- Confusing host with server (the host runs the client; the server is a separate process).
- Hard-coding API keys inside tool implementations instead of env vars.
- Using SSE locally when stdio is simpler and more secure.
Interview checkpoints
- Q: What is handshake in MCP? A: One-sentence definition + when it runs in the lifecycle.
- Q: One production pitfall? A: Name transport, auth, or schema mismatch.
Practice
- Basic: Sketch Handshake on a whiteboard.
- Intermediate: Find it in a real Claude Desktop or Cursor config.
- Advanced: Break it on purpose and document the error message.
Recap
- You can explain handshake clearly.
- You know host vs client vs server roles.
- You see how this connects to the next part.
Next: Transport
Day 8
Transport: STDIO & SSE
Why this matters
Transport: Transport choice (stdio vs SSE) determines deployment model: local subprocess vs remote HTTP.
MCP supports multiple transports:
| Transport | Use case | Notes |
|---|---|---|
| stdio | Local servers | Host spawns subprocess; stdin/stdout carry JSON-RPC lines |
| SSE / HTTP | Remote servers | Server-Sent Events for streaming; needs auth headers |
Pick stdio for Claude Desktop local tools; use SSE when the server runs on another machine or behind a tunnel.
Common mistakes
- Confusing host with server (the host runs the client; the server is a separate process).
- Hard-coding API keys inside tool implementations instead of env vars.
- Using SSE locally when stdio is simpler and more secure.
Interview checkpoints
- Q: What is transport in MCP? A: One-sentence definition + when it runs in the lifecycle.
- Q: One production pitfall? A: Name transport, auth, or schema mismatch.
Practice
- Basic: Sketch Transport on a whiteboard.
- Intermediate: Find it in a real Claude Desktop or Cursor config.
- Advanced: Break it on purpose and document the error message.
Recap
- You can explain transport clearly.
- You know host vs client vs server roles.
- You see how this connects to the next part.
Next: Desktop Config
