14. Authentication
Chapter 14 of 22 · 20 min
Local verification checkpoint
Run the smallest example from this chapter in a local workspace and record the package version, runtime, data path, and observed output. If the result depends on model size, vector count, CPU/GPU backend, or available memory, note that constraint beside the exercise so the lesson remains reproducible.
EXERCISE
Implement token-based authentication for an MCP server. Create endpoints for registration, login, and token refresh. Add a middleware that validates tokens on all tool calls. Test that unauthenticated requests receive 401 responses.