OAuth token exchange with Keycloak (RFC 8693): narrowing tokens for AI agents and MCP servers
A hands-on lab with Keycloak: an MCP server exchanges a user's token for a narrower one for a downstream API, then three bad exchanges are refused.
An MCP server that accepts a token and forwards it downstream breaks audience checks and hides who called what. These posts explain the OAuth rules for MCP servers and what to do instead: validate the audience, exchange the token and bind it to a key.
The tools below help you read the tokens and metadata involved without leaving your browser.
No posts in this audience.
A hands-on lab with Keycloak: an MCP server exchanges a user's token for a narrower one for a downstream API, then three bad exchanges are refused.
A lab with the official MCP Python SDK and Keycloak: the 401 handshake, audience checks, an RFC 8693 exchange for the payments API, and a refused passthrough.