You are asked to build a local HTTP service that implements a minimal MCP (Model Context Protocol) server with one tool: whoami. The server must be protected by Auth0-issued JWT access tokens.
Implement middleware that validates incoming requests using a Bearer token in the Authorization header.
The JWT must be validated as follows:
iss
(issuer) must match the configured Auth0 issuer
aud
(audience) must match the configured API audience
iat
and
exp
must be validated (token not expired; issued-at is reasonable)
azp
or
client_id
The MCP tool whoami must only be callable if the token contains the scope:
tool:whoami
(Assume scopes are delivered in the token as a space-delimited scope claim; you may also support permissions if present.)
Return standard HTTP errors:
whoami tool behaviorWhen authorized, the whoami tool should return basic identity information derived from the validated token (e.g., subject/user id, client id, issuer, audience, scopes).
A locally runnable server that successfully starts and can be called with a real Auth0 access token. The whoami tool must be protected by the JWT middleware and the tool:whoami scope.
Login required