Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 174 additions & 0 deletions demos/mcp-delegated-clerk-oauth/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
# Logs

logs
_.log
npm-debug.log_
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)

report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json

# Runtime data

pids
_.pid
_.seed
\*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover

lib-cov

# Coverage directory used by tools like istanbul

coverage
\*.lcov

# nyc test coverage

.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)

.grunt

# Bower dependency directory (https://bower.io/)

bower_components

# node-waf configuration

.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)

build/Release

# Dependency directories

node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)

web_modules/

# TypeScript cache

\*.tsbuildinfo

# Optional npm cache directory

.npm

# Optional eslint cache

.eslintcache

# Optional stylelint cache

.stylelintcache

# Microbundle cache

.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history

.node_repl_history

# Output of 'npm pack'

\*.tgz

# Yarn Integrity file

.yarn-integrity

# dotenv environment variable files

.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)

.cache
.parcel-cache

# Next.js build output

.next
out

# Nuxt.js build / generate output

.nuxt
dist

# Gatsby files

.cache/

# Comment in the public line in if your project uses Gatsby and not Next.js

# https://nextjs.org/blog/next-9-1#public-directory-support

# public

# vuepress build output

.vuepress/dist

# vuepress v2.x temp and cache directory

.temp
.cache

# Docusaurus cache and generated files

.docusaurus

# Serverless directories

.serverless/

# FuseBox cache

.fusebox/

# DynamoDB Local files

.dynamodb/

# TernJS port file

.tern-port

# Stores VSCode versions used for testing VSCode extensions

.vscode-test

# yarn v2

.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.\*

# wrangler project

.dev.vars
.wrangler/

worker-configuration.d.ts
15 changes: 15 additions & 0 deletions demos/mcp-delegated-clerk-oauth/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Model Context Protocol (MCP) Server + Delegated Clerk OAuth

WIP

Instead of acting as an OAuth client to Clerk and hosting our own OAuth provider inside the MCP / MCP auth service, we delegate OAuth completely to Clerk and utilize it as the OAuth provider.

Supports dynamic client registration on Clerk by only supporting the registration endpoint on our separate auth service hosted on the same worker. I say separate because I think it is confusing to say the MCP server itself manages the auth - I would say it is separate.

To be clear - the MCP server is a resource that simply checks against an access token, the Auth service provides the access token.

Code does not work without making changes to both the MCP TypeScript SDK and `mcp-remote` from Cloudflare.

Required secrets:
* `CLERK_BACKEND_URL`: Clerk Backend URL
* `CLERK_SECRET_KEY`: Clerk Instance Secret Key
31 changes: 31 additions & 0 deletions demos/mcp-delegated-clerk-oauth/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"$schema": "https://biomejs.dev/schemas/1.6.2/schema.json",
"organizeImports": {
"enabled": true
},
"files": {
"ignore": ["node_modules/**/*", "dist/**/*"],
"include": ["src/**/*.ts"]
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"suspicious": {
"noExplicitAny": "off",
"noDebugger": "off",
"noConsoleLog": "off",
"noConfusingVoidType": "off"
},
"style": {
"noNonNullAssertion": "off"
}
}
},
"formatter": {
"enabled": true,
"indentStyle": "tab",
"indentWidth": 4,
"lineWidth": 100
}
}
25 changes: 25 additions & 0 deletions demos/mcp-delegated-clerk-oauth/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "mcp-delegated-clerk-oauth",
"type": "module",
"scripts": {
"deploy": "wrangler deploy",
"dev": "wrangler dev",
"start": "wrangler dev",
"cf-typegen": "wrangler types",
"format": "biome format --write",
"lint": "biome lint --error-on-warnings",
"lint:fix": "biome lint --fix"
},
"devDependencies": {
"typescript": "^5.5.2",
"wrangler": "^4.2.0",
"@biomejs/biome": "^1.8.2"
},
"dependencies": {
"@cloudflare/workers-oauth-provider": "^0.0.2",
"@modelcontextprotocol/sdk": "^1.7.0",
"hono": "^4.7.4",
"agents": "^0.0.46",
"zod": "^3.24.2"
}
}
Loading