+ OAuth On Cloudflare Workers
БесплатноНе проверенStateless Streamable HTTP MCP endpoint with OAuth 2.1 authentication via Cloudflare Workers, supporting PKCE, DCR, and token introspection.
Описание
Stateless Streamable HTTP MCP endpoint with OAuth 2.1 authentication via Cloudflare Workers, supporting PKCE, DCR, and token introspection.
README
This workspace deliberately has two independent Workers:
idp-serviceis an OAuth 2.1 authorization server backed only by itsOAUTH_KVnamespace. It issues opaque access tokens, supports S256 PKCE, DCR, CIMD, refresh tokens, and automatic local authorization aslocal-developer.mcp-serviceis a stateless Streamable HTTP MCP endpoint. It knows the IdP issuer, RFC 8414 metadata, RFC 7662, and its dedicated introspection credentials. It has no binding to the IdP Worker and no shared storage.
mcp-service discovers the IdP's introspection_endpoint, caches that endpoint, and sends bearer tokens only through authenticated client_secret_basic introspection. It accepts only active tokens with the exact https://mcp.localhost/mcp audience, the mcp:tools scope, and a subject. Invalid or unauthorized tokens return 401; an unavailable IdP, rejected introspection credentials, or malformed introspection response returns 503.
Local HTTPS
Install Caddy, then install dependencies:
brew install caddy
bun install
Create independent local secret files before starting either Worker. Use the same value in both files; these files are ignored by Git.
cp packages/idp-service/.dev.vars.example packages/idp-service/.dev.vars
cp packages/mcp-service/.dev.vars.example packages/mcp-service/.dev.vars
Start the two Workers and Caddy in separate terminals:
bun run dev:idp
bun run dev:mcp
sudo caddy run --config Caddyfile --adapter caddyfile
Caddy is the public HTTPS entry point: https://idp.localhost proxies to the IdP on port 8787, and https://mcp.localhost/mcp proxies to MCP on port 8788. *.localhost resolves to loopback without an /etc/hosts entry. Caddy uses its local CA; if needed, run sudo caddy trust.
Cloudflare configuration
Create a dedicated KV namespace for the IdP and replace both placeholder IDs in packages/idp-service/wrangler.jsonc:
wrangler kv namespace create OAUTH_KV
wrangler kv namespace create OAUTH_KV --preview
Use a dedicated client ID (mcp-service-introspection) and store the matching secret independently in each Worker. Do not put it in vars or commit it.
cd packages/idp-service
wrangler secret put MCP_INTROSPECTION_CLIENT_SECRET
cd ../mcp-service
wrangler secret put MCP_INTROSPECTION_CLIENT_SECRET
The IdP's public metadata at /.well-known/oauth-authorization-server advertises /introspect and only client_secret_basic as its supported introspection authentication method. /introspect always sends Cache-Control: no-store and never logs token values.
Testing with MCP Inspector
Keep both Workers and Caddy running as above, then start Inspector with the local CA available:
NODE_USE_SYSTEM_CA=1 bunx @modelcontextprotocol/inspector
Use https://mcp.localhost/mcp as the server URL and scope mcp:tools.
Regular OAuth client
- Client ID:
mcp-inspector-local - Client secret:
mcp-inspector-local-secret - Redirect URL:
http://localhost:6274/oauth/callbackorhttp://localhost:6274/oauth/callback/debug
The client is seeded in OAUTH_KV on demand. Local authorization immediately completes as local-developer; no interaction page is involved.
Dynamic Client Registration
DCR is available from the metadata document's registration_endpoint (/register). Register a client, then use its returned credentials with the same callback URLs and mcp:tools scope.
Client ID Metadata Documents
For CIMD, use this local fixture client ID and leave the client secret empty:
https://idp.localhost/client-metadata/mcp-inspector.json
Caddy serves fixtures/mcp-inspector-cimd.json at that path before proxying to the IdP Worker. The JSON document's client_id matches the served URL exactly. Built-in CIMD fetches require public HTTPS in deployed environments, so automated localhost tests mock that fetch; use a public deployment to test the production fetch boundary.
Workers intentionally refuse CIMD fetches to private .localhost targets. For this exact local fixture URL only, idp-service seeds an equivalent public client in KV so the browser flow works locally; all other HTTPS client IDs continue through the provider's built-in CIMD fetch and validation path.
Validation
bun run test
bun run typecheck
bun run lint
bun run format:check
caddy validate --config Caddyfile --adapter caddyfile
Установка + OAuth On Cloudflare Workers
У этого сервера нет опубликованного пакета — он собирается из исходников. Открой репозиторий и следуй инструкции в README.
▸ github.com/thiskevinwang/mcp-and-oidcFAQ
+ OAuth On Cloudflare Workers MCP бесплатный?
Да, + OAuth On Cloudflare Workers MCP бесплатный — установка в пару кликов через Unyly без оплаты.
Нужен ли API-ключ для + OAuth On Cloudflare Workers?
Нет, + OAuth On Cloudflare Workers работает без API-ключей и переменных окружения.
+ OAuth On Cloudflare Workers — hosted или self-hosted?
Доступен hosted-вариант: Unyly запускает сервер в облаке, локальная установка не обязательна.
Как установить + OAuth On Cloudflare Workers в Claude Desktop, Claude Code или Cursor?
Открой + OAuth On Cloudflare Workers на unyly.org, выбери вкладку своего клиента (Claude Desktop, Claude Code, Cursor) и нажми Install — конфиг сгенерируется автоматически, без правки JSON.
Похожие MCP
GitHub
PRs, issues, code search, CI status
автор: GitHubFilesystem
Secure file operations with configurable access controls.
Memory
Knowledge graph-based persistent memory system.
Template MCP Server
A CLI tool to create a new Model Context Protocol server project with TypeScript support, dual transport options, and an extensible structure
автор: mcpdotdirectCompare + OAuth On Cloudflare Workers with
Не уверен что выбрать?
Найди свой стек за 60 секунд
Автор?
Embed-бейдж для README
Похожее
Все в категории development
