Repository navigation
content: migrate Descope demo from Inbound Apps to Agentic Identity Hub - #669
dishanthirpara-maker wants to merge 6 commits into
Conversation
Switches the demo from Descope Inbound App endpoints to Agentic Identity Hub MCP Server endpoints (agentic authorize/token paths, resource param, optional PKCE), and reads user profile claims from a JWKS-verified id_token instead of a userinfo call that doesn't support agentic-issued tokens. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
|
@shuni can you review this? |
| if (resource) bodyParams.resource = resource; | ||
|
|
||
| const resp = await fetch( | ||
| `${base_url}/oauth2/v1/apps/agentic/${project_id}/${mcp_server_id}/token`, |
There was a problem hiding this comment.
This is going to change to Project Level Issuers
| if (cached) return cached; | ||
|
|
||
| const resp = await fetch( | ||
| `${base_url}/v1/apps/agentic/${project_id}/${mcp_server_id}/.well-known/openid-configuration`, |
| client_secret: c.env.DESCOPE_CLIENT_SECRET, | ||
| code: c.req.query("code"), | ||
| redirect_uri: new URL("/callback", c.req.url).href, | ||
| project_id: c.env.DESCOPE_PROJECT_ID, |
There was a problem hiding this comment.
I think if we can just paste the issuer URL that would be simpler.
Client ID and secret is still good to have (if the user will use token exchange or connection fetching in the MCP server)
| DESCOPE_CLIENT_ID="your_mcp_server_client_id" | ||
| DESCOPE_CLIENT_SECRET="your_mcp_server_client_secret" | ||
| DESCOPE_PROJECT_ID="your_descope_project_id" | ||
| DESCOPE_MCP_SERVER_ID="your_descope_mcp_server_id" |
There was a problem hiding this comment.
As mentioned before, just the Issuer URL
| - **Define the scopes** the server requests (in the client's Scopes section). This server asks for `openid profile email`, so add: | ||
| 1. Create an MCP Server resource and a Client in the Descope Console: | ||
| - Go to **Agentic Identity Hub → MCP Servers** and create a new MCP Server. Set its **MCP Server URL** to `http://localhost:8787/mcp` (add your deployed `https://<worker>.workers.dev/mcp` too when you deploy) — this value is included in the `aud` claim on issued access tokens. | ||
| - Under that MCP Server, create a **Client**. Allow the Authorization Code grant type, and set the redirect / callback URL to `http://localhost:8787/callback` (add your deployed `https://<worker>.workers.dev/callback` too when you deploy). |
There was a problem hiding this comment.
It's not under an MCP server, Clients are separate from MCP Servers / Resources
…h construction - Replace DESCOPE_PROJECT_ID/DESCOPE_MCP_SERVER_ID with a single DESCOPE_ISSUER_URL - Resolve token_endpoint and authorization_endpoint from the .well-known discovery document instead of hardcoding agentic API paths, per upcoming Project Level Issuers change - Keep DESCOPE_CLIENT_ID/DESCOPE_CLIENT_SECRET for token exchange/connection use cases - Correct README: Clients are bound to MCP Server Resources, not nested under them - Drop redundant DESCOPE_BASE_URL now that the issuer URL is fully-qualified Addresses review comments from @gaokevin1. Verified end-to-end against a live Descope Agentic Identity Hub project: full authorization-code + PKCE flow, discovery-based authorize/token resolution, and id_token signature verification all pass. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
What
Migrates the
remote-mcp-server-descope-authdemo from Descope's legacy Inbound Apps model to Descope's Agentic Identity Hub (AIH), and updates the README so setup instructions match the new flow.Related to descope/etc#13584
Implementation Details
id_tokenusing a JWKS fetched from the discovery document (jose'screateRemoteJWKSet/jwtVerify), replacing unverified decoding of the/userinforesponseDESCOPE_ENABLE_PKCEflag/userinfoto a verifiedid_token, a caution about enabling Dynamic Client Registration without an approval step, and the updated.dev.vars/wrangler secret putvariable listsVerification
Local type-check (
tsc --noEmit) passes clean, and a live sandbox test against a real Descope Agentic Identity Hub project confirmed the full authorization-code + PKCE flow, id_token verification, and scope propagation all work end-to-end; a separate management-API client-rebinding path hit an unrelated backend issue, reported separately to Descope.