MCP Template
MCP Template
这是一个面向 Cloudflare Workers 的模板,内置 Better Auth 的 Passkey 认证,以及用于确认已认证连接的 MCP Tool。
端点
MCP:
https://mcp.example.com/mcp健康检查:
https://mcp.example.com/health认证:
https://mcp.example.com/auth/*Passkey 注册:
https://mcp.example.com/passkey/register?token=...
请将 https://mcp.example.com 改为与 wrangler.jsonc 中的 PUBLIC_ORIGIN 一致。
Related MCP server: GitHub OAuth MCP Server
技术栈
Cloudflare Workers
Hono
TypeScript
pnm
Model Context Protocol
Better Auth
Cloudflare D1
包含内容
Cloudflare Workers、Hono、TypeScript strict
Better Auth、Passkey、OAuth、CIMD
用于 Cloudflare D1 的 Better Auth Migration
仅已认证 User 可执行的
get_server_status用于首次 Passkey 注册的 24 小时・仅限一次使用的 URL
设置
修改
package.json、wrangler.jsonc、src/auth.ts中的服务名与公开 URL。创建 D1 数据库,并设置
wrangler.jsonc中的database_id。执行
pnm install。执行
pnm wrangler d1 migrations apply mcp-template-db --remote。本地开发时,将
.dev.vars.example复制为.dev.vars,并设置BETTER_AUTH_SECRET。远程环境中,通过
pnm wrangler secret put BETTER_AUTH_SECRET设置相同的 Secret。使用
pnm dev启动。
PUBLIC_ORIGIN 请设置为 HTTPS 的公开 URL。本地开发使用 Passkey 时,请将 wrangler.jsonc 中的值与访问的 URL 保持一致。
首次 User 与 Passkey 注册
没有公开注册。请先在 D1 中手动注册 User,然后发放注册 URL。
pnpm user:issue-passkey-url user@example.com mcp-template-db https://mcp.example.com该 URL 只能使用一次,并在 24 小时内失效。
验证
pnpm format:check
pnpm typecheck
pnpm build文档
实现及更新文档时的规则请参阅 AGENTS.md。
This server cannot be deployed
Maintenance
Related MCP Connectors
Cloudflare Workers MCP server: ai-provider-status
Cloudflare Workers MCP server: blog
Cloudflare Workers MCP server: a11y-scorer
Cloudflare Workers MCP server: ai-gateway
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA reference MCP server for Cloudflare Workers that provides remote connection support with integrated GitHub OAuth authentication. It enables developers to build and deploy authenticated remote tools with user-specific access controls and persistent state management.-
- FlicenseNot gradedqualityCmaintenanceA remote MCP server for Cloudflare Workers featuring built-in GitHub OAuth for secure user authentication and identity-based access control to tools. It provides a reference implementation for managing remote MCP connections with persistent state and OAuth provider integration.1-
- FlicenseNot gradedqualityCmaintenanceA Cloudflare Workers-based MCP server that enables secure remote connections using built-in OAuth authentication via Cloudflare Access. It provides identity-based access control for MCP tools and supports persistent state management through Durable Objects and SSE.-
- FlicenseNot gradedqualityCmaintenanceThis is an MCP server deployed on Cloudflare Workers with OAuth authentication, enabling remote MCP clients to connect and use tools.-