OAuth 2.1
full spec, DCR to PKCE
2.5 yrs
shipping at pagent
Pagent's MCP server lets AI clients act on a workspace through the Model Context Protocol, with a full OAuth 2.1 authorization server behind it so each client gets scoped, revocable, expiring access instead of a shared API key.
Every AI client that wanted access asked for an API key. Keys don't expire, can't be scoped to one workspace, and can't be revoked for a single client without breaking every other integration. The protocol already had an answer, so the work was implementing it properly rather than inventing a shortcut.
Dynamic client registration under RFC 7591, with a strict redirect-URI policy and per-IP rate limits so anyone can register but nobody can flood it. PKCE on the token endpoint. `.well-known` discovery documents so clients configure themselves. A consent screen that shows which workspace you are granting, with the brand mark of the agent asking. Tokens carry a chosen lifetime and record when they were last used, and a nightly job sweeps expired codes, dead token generations, and orphan clients.
The part that took longest was not the crypto. It was the CSRF hook: the app checks request origin on every POST, and OAuth endpoints are cookieless and cross-site by design. I made the check route-aware rather than punching a hole in it.
Role
Sole author, schema to production
Year
2026
Stack
4 technologies
See more work
Back to all projects