MCP Security II — OAuth 2.1, Resource Indicators, Incremental Scopes

Remote MCP servers need authorization, not just authentication. The 2025-11-25 spec aligns with OAuth 2.1 + PKCE + resource indicators (RFC 8707) + protected-resource metadata (RFC 9728). SEP-835 adds incremental scope consent with step-up authorization on 403 WWW-Authenticate. This lesson implements the step-up flow as a state machine so you can see every hop.

Build 1.3 hr Python (stdlib, OAuth state machine simulator)

Prerequisites: Phase 13 · 09 (transports), Phase 13 · 15 (security I)

#Learning Objectives

  • Distinguish resource server from authorization server responsibilities.
  • Walk the PKCE-protected OAuth 2.1 authorization code flow.
  • Use resource (RFC 8707) and protected-resource metadata (RFC 9728) to prevent confused-deputy attacks.
  • Implement step-up authorization: server responds 403 with WWW-Authenticate asking for a higher scope; client re-prompts user consent and retries.
Full Access lesson

Keep going. The rest of this lesson is one step away.

Unlock all 503 lessons, video, code, quizzes and every future update. Pay in your own currency with Paystack.

The text and code of this lesson are based on AI Engineering from Scratch by Rohit Ghumare, MIT licensed.