Cloudflare Scaffold
БесплатноНе проверенScaffold for building authenticated MCP servers on Cloudflare Workers with Cloudflare Access (OIDC). Includes OAuth 2.1 provider, Durable Objects, and a mock ve
Описание
Scaffold for building authenticated MCP servers on Cloudflare Workers with Cloudflare Access (OIDC). Includes OAuth 2.1 provider, Durable Objects, and a mock vector DB demo. Connect from Claude.ai or any MCP client.
README
A remote MCP server deployed to Cloudflare Workers, protected by Cloudflare Access for SaaS (OIDC), connectable from Claude.ai as a custom connector.
Includes a mock vector database as a demo — swap it for Vectorize, D1, or any real backend.
Architecture
Claude.ai ──OAuth──▶ Worker (/authorize, /token, /register, /mcp)
│
└──OIDC──▶ Cloudflare Access (SaaS app)
│
└──▶ Identity Provider (One-time PIN, Google, etc.)
The Worker runs @cloudflare/workers-oauth-provider as the OAuth 2.1 server that Claude.ai talks to. It delegates user authentication to Cloudflare Access (configured as an OIDC SaaS app), which in turn federates to whichever IdP you wire up.
Project layout
├── src/
│ ├── index.ts # MCP server + OAuth provider entry point
│ └── access-handler.ts # Access OIDC code-exchange handler
├── wrangler.jsonc
└── package.json
MCP tools included
| Tool | Description |
|---|---|
vector_search |
Natural language search against the vector store |
vector_get |
Retrieve a document by ID |
vector_list |
List all stored document IDs |
vector_upsert |
Insert or update a document |
vector_delete |
Delete a document by ID |
health |
Health check with user info and doc count |
Setup
Prerequisites
- Node.js 20+ and npm
- Wrangler CLI (
npm install -g wrangleror usenpx wrangler) - A Cloudflare account
- A Zero Trust team name chosen at https://one.dash.cloudflare.com
(first-time prompt). This becomes
<team>.cloudflareaccess.com. - At least one identity provider wired into Zero Trust under Settings → Authentication → Login methods. For a POC, "One-time PIN" needs no configuration.
1. Authenticate Wrangler
npx wrangler login
Opens a browser for OAuth. For CI/headless, create a Cloudflare API Token
(My Profile → API Tokens → "Edit Cloudflare Workers" template) and export
CLOUDFLARE_API_TOKEN.
2. Clone and install
git clone https://github.com/w00jay/MCP-server-cloudflare-scaffold.git
cd MCP-server-cloudflare-scaffold
npm install
3. Create the KV namespace
npx wrangler kv namespace create OAUTH_KV
Copy the returned id and replace YOUR_KV_NAMESPACE_ID in wrangler.jsonc.
4. Create the Access for SaaS OIDC app
In https://one.dash.cloudflare.com:
- Access controls → Applications → Add an application → SaaS
- Application: type your app name and click the textbox (custom app, not gallery)
- Authentication protocol: OIDC
- Click Add application
- Scopes: check
openid,email,profile - Redirect URLs:
https://<worker-name>.<your-subdomain>.workers.dev/callback- Deploy once first (
npx wrangler deploy) to discover your subdomain, or check your Workers dashboard.
- Deploy once first (
- Copy these five values (some only shown once):
- Client ID
- Client secret
- Authorization endpoint
- Token endpoint
- Key endpoint (JWKS)
- Click Next
Create the Access policy
- Add a policy
- Policy name: e.g.
allow-mcp - Action: Allow
- Session duration: 24 hours
- Configure rules → Include:
- Selector:
Emails→ your email - Or:
Emails ending in→@yourcompany.com
- Selector:
- Click Next
Pick identity providers
- Check the IdPs you want (One-time PIN is simplest for POC)
- If only one IdP, enable Instant Auth to skip the picker screen
- Next → Add application
5. Set Worker secrets
Use the values from the Cloudflare One SaaS app page, NOT from an upstream IdP (Google, GitHub, etc.). Access is the OAuth provider to your Worker; it federates to your IdP underneath.
npx wrangler secret put ACCESS_CLIENT_ID
npx wrangler secret put ACCESS_CLIENT_SECRET
npx wrangler secret put ACCESS_AUTHORIZATION_URL
npx wrangler secret put ACCESS_TOKEN_URL
npx wrangler secret put ACCESS_JWKS_URL
npx wrangler secret put COOKIE_ENCRYPTION_KEY # openssl rand -hex 32
6. Deploy
npm run deploy
# or: npx wrangler deploy
Worker is now live at https://vector-mcp.<your-subdomain>.workers.dev.
7. Smoke-test with Workers AI Playground
- Open https://playground.ai.cloudflare.com
- Under MCP Servers, enter
https://<worker-name>.<your-subdomain>.workers.dev/mcp - Click Connect → Approve
- Complete the Access login (OTP email or your IdP)
- You should see "Connected" and the
vector_*tools listed
8. Add to Claude.ai
- Settings → Connectors → Add custom connector
- URL:
https://<worker-name>.<your-subdomain>.workers.dev/mcp - Leave Advanced Settings empty — the Worker advertises Dynamic Client Registration, so Claude registers itself. Do NOT paste the Access client credentials here; those stay on the Worker.
- Click Add → Connect
- Complete the Access login flow in the popup
- The
vector_*tools should appear in your tool list
Troubleshooting
| Symptom | Cause / Fix |
|---|---|
defaultHandler must be either an ExportedHandler... |
access-handler.ts missing its export. Verify with grep -n "export" src/access-handler.ts. |
302 redirect loop on /authorize |
Wrong ACCESS_AUTHORIZATION_URL secret, or redirect URL on the SaaS app doesn't match https://<worker>.workers.dev/callback. |
Token exchange failed in /callback |
ACCESS_CLIENT_SECRET mismatch or ACCESS_TOKEN_URL typo. |
| Access login succeeds but Claude shows error | Email not in policy include rule. Edit the Access policy. |
| Claude can't reach the Worker at all | You may have a self-hosted Access app on the same hostname. Use SaaS type, not Self-hosted. |
Live logs: npm run tail or npx wrangler tail
Caveats
- id_token signature is not verified. The handler decodes the JWT payload
but doesn't validate against
ACCESS_JWKS_URL. Fine behind Access for a POC; for production add jose and verify. - Vector store is in-memory in the Durable Object instance and resets on eviction. Swap for D1, Vectorize, or KV for persistence.
- SSE transport is included at
/ssefor legacy MCP clients but is deprecated; new clients should use/mcp.
License
MIT
Установка Cloudflare Scaffold
У этого сервера нет опубликованного пакета — он собирается из исходников. Открой репозиторий и следуй инструкции в README.
▸ github.com/w00jay/MCP-server-cloudflare-scaffoldFAQ
Cloudflare Scaffold MCP бесплатный?
Да, Cloudflare Scaffold MCP бесплатный — установка в пару кликов через Unyly без оплаты.
Нужен ли API-ключ для Cloudflare Scaffold?
Нет, Cloudflare Scaffold работает без API-ключей и переменных окружения.
Cloudflare Scaffold — hosted или self-hosted?
Self-hosted: сервер запускается локально на твоей машине командой из раздела установки.
Как установить Cloudflare Scaffold в Claude Desktop, Claude Code или Cursor?
Открой Cloudflare Scaffold на unyly.org, выбери вкладку своего клиента (Claude Desktop, Claude Code, Cursor) и нажми Install — конфиг сгенерируется автоматически, без правки JSON.
Похожие MCP
Fetch
Web content fetching and conversion for efficient LLM usage.
AWS KB Retrieval
Retrieval from AWS Knowledge Base using Bedrock Agent Runtime.
автор: modelcontextprotocolSpring AI MCP Server
Provides auto-configuration for setting up an MCP server in Spring Boot applications.
llm-analysis-assistant
A very streamlined mcp client that supports calling and monitoring stdio/sse/streamableHttp, and can also view request responses through the /logs page. It also
автор: xuzexin-hzMCP-Agent
A simple, composable framework to build agents using Model Context Protocol by [LastMile AI](https://www.lastmileai.dev)
автор: lastmile-aiSpring AI MCP Client
Provides auto-configuration for MCP client functionality in Spring Boot applications.
mcp.natoma.ai
A Hosted MCP Platform to discover, install, manage and deploy MCP servers by [Natoma Labs](https://www.natoma.ai)
MCPHub
Website to list high quality MCP servers and reviews by real users. Also provide online chatbot for popular LLM models with MCP server support.
MCP Servers Rating and User Reviews
Website to rate MCP servers, write authentic user reviews, and [search engine for agent & mcp](http://www.deepnlp.org/search/agent)
mkinf
An Open Source registry of hosted MCP Servers to accelerate AI agent workflows.
Compare Cloudflare Scaffold with
Не уверен что выбрать?
Найди свой стек за 60 секунд
Автор?
Embed-бейдж для README
Похожее
Все в категории ai
