feat(remote-mcp-server-descope-auth): migrate to stateless MCP SDK v2 + enable CIMD - #646
Open
mariamantsurova wants to merge 1 commit into
Open
Conversation
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Migrates the
remote-mcp-server-descope-authdemo from the statefulMcpAgent(Durable Object) transport to the stateless MCP SDK v2 handler (createMcpHandlerfromagents/mcp/server, protocol revision2026-07-28), and enables Client ID Metadata Document (CIMD) support.Why
The stateless handler is the current recommended pattern for remote MCP servers on Workers. It removes the Durable Object entirely - no
durable_objectsbinding and nomigrationsto configure - making the demo simpler to understand and deploy. Auth props that previously lived onthis.propsare now read per-request viagetMcpAuthContext(), sourced fresh from the decrypted bearer token by@cloudflare/workers-oauth-provider.Changes
src/index.ts— replaceclass MyMCP extends McpAgentwith acreateServer()factory wrapped bycreateMcpHandler(); read auth viagetMcpAuthContext()(helperrequireProps()); update tool registration to the SDK v2registerTool(...)signature; enable CIMD on theOAuthProvider(clientIdMetadataDocumentEnabled: true).wrangler.jsonc— removedurable_objects+migrations(no DO anymore); bumpcompatibility_dateto2026-07-02; add theglobal_fetch_strictly_publiccompatibility flag (required for CIMD); rename the worker toremote-mcp-server-descope-auth.src/env.d.ts(new) — hand-written type declarations for the Descope secrets, whichwrangler typesdoes not emit.worker-configuration.d.ts— regenerated viawrangler types.package.json— bumpagentsto^0.20.1; add@modelcontextprotocol/sdk+@modelcontextprotocol/server(v2); add atype-checkscript.src/descope-utils.ts— narrow the token-response type so type-check passes.README.md— add an Architecture section describing the stateless handler.Testing
npm run type-check— passesnpx oxlint— passes (exit 0)/mcp): DCR registration, full Descope OAuth login, andgetUserInfo/getTokentools all work. Confirmed the metadata endpoint reportsclient_id_metadata_document_supported: true.