Skip to content

content: migrate Descope demo from Inbound Apps to Agentic Identity Hub - #669

Open
dishanthirpara-maker wants to merge 6 commits into
cloudflare:mainfrom
dishanthirpara-maker:scratch/aih-migration-verify
Open

dishanthirpara-maker wants to merge 6 commits into
cloudflare:mainfrom
dishanthirpara-maker:scratch/aih-migration-verify

Conversation

@dishanthirpara-maker

Copy link
Copy Markdown

What

Migrates the remote-mcp-server-descope-auth demo 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

  • Migrated authorize/token endpoints from Inbound App paths to Agentic Identity Hub MCP Server endpoints
  • Added signature verification for the Descope id_token using a JWKS fetched from the discovery document (jose's createRemoteJWKSet/jwtVerify), replacing unverified decoding of the /userinfo response
  • Added PKCE support (S256 code challenge/verifier), gated by a DESCOPE_ENABLE_PKCE flag
  • Added an RFC 8707 resource indicator to the authorization/token requests
  • Rewrote the README to describe MCP Server resource + Client creation, the create-time-only Client-to-MCP-Server binding, the switch from /userinfo to a verified id_token, a caution about enabling Dynamic Client Registration without an approval step, and the updated .dev.vars / wrangler secret put variable lists

Verification

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.

mariamantsurova and others added 4 commits August 23, 2026 10:31
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>
@changeset-bot

changeset-bot Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: aad17c8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dishanthirpara-maker

Copy link
Copy Markdown
Author

@shuni can you review this?

@dishanthirpara-maker
dishanthirpara-maker marked this pull request as ready for review October 7, 2026 17:41
if (resource) bodyParams.resource = resource;

const resp = await fetch(
`${base_url}/oauth2/v1/apps/agentic/${project_id}/${mcp_server_id}/token`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

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,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants