Concept

OAuth 2.1

Modern authorization for apps and AI clients — I built an OAuth 2.1 authorization server for a remote MCP server: DCR, PKCE, rotation.

  • #security
  • #auth
  • #mcp

OAuth 2.1 consolidates OAuth 2.0 best practices: authorization code with PKCE for every client, no implicit flow, and stricter refresh-token handling. The MCP (Model Context Protocol) specification uses it to authorize remote MCP servers.

How I use it

In AI Agent Products & Remote MCP I implemented a remote MCP server that is also its own authorization server:

  • Discovery: protected-resource metadata (RFC 9728) and authorization-server metadata (RFC 8414), so MCP clients find everything from the server URL alone.
  • Dynamic Client Registration (RFC 7591): Claude, ChatGPT or Claude Code register themselves — no manual API keys.
  • Authorization code + PKCE (S256) with Google sign-in for identity and an explicit consent screen.
  • Refresh-token rotation and revocation (RFC 7009), plus an account page where users see and disconnect connected apps.

It is also part of the stack in my current role at Somnio Software.

Why it matters

Standards-based auth is what lets an AI connector be both one-click and safe — and it is the part most MCP servers get wrong.

Related