Minimal implementation of MCP server auth with TypeScript.
This demo always validates the access token audience (resource indicator) returned by the introspection endpoint.
Checks performed during introspection:
- Token is successfully introspected (HTTP 200 from the authorization server).
activeflag (RFC 7662) is notfalse.audclaim (string or array) is present and at least one value matches the server's base URL (RFC 8707 resource indicator semantics).- Scopes are parsed into an array for later use (no specific scopes required by default).
Not implemented (could be added):
- Local JWT signature verification via JWKS (currently relies on remote introspection).
- Explicit
iss,typ,nbf,expenforcement (onlyexpis returned and stored, not validated inline). - Caching / throttling of introspection requests.
Use this code for experimentation only; harden before production.