MCP + OAuth on Cloudflare Workers
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP + OAuth on Cloudflare Workerslist available tools"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP + OAuth on Cloudflare Workers
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 installCreate 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.varsStart the two Workers and Caddy in separate terminals:
bun run dev:idp
bun run dev:mcp
sudo caddy run --config Caddyfile --adapter caddyfileCaddy 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.
Related MCP server: Remote MCP Server
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 --previewUse 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_SECRETThe 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/inspectorUse https://mcp.localhost/mcp as the server URL and scope mcp:tools.
Regular OAuth client
Client ID:
mcp-inspector-localClient secret:
mcp-inspector-local-secretRedirect 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 caddyfileThis server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/thiskevinwang/mcp-and-oidc'
If you have feedback or need assistance with the MCP directory API, please join our Discord server