Skip to main content
Glama
epsilon-labs-llc

MCP Template

MCP Template

MCP Cloudflare Workers Hono TypeScript pnm

这是一个面向 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

设置

  1. 修改 package.jsonwrangler.jsoncsrc/auth.ts 中的服务名与公开 URL。

  2. 创建 D1 数据库,并设置 wrangler.jsonc 中的 database_id

  3. 执行 pnm install

  4. 执行 pnm wrangler d1 migrations apply mcp-template-db --remote

  5. 本地开发时,将 .dev.vars.example 复制为 .dev.vars,并设置 BETTER_AUTH_SECRET

  6. 远程环境中,通过 pnm wrangler secret put BETTER_AUTH_SECRET 设置相同的 Secret。

  7. 使用 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

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    A 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.
    -
  • F
    license
    Not graded
    quality
    C
    maintenance
    A 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
    -
  • F
    license
    Not graded
    quality
    C
    maintenance
    A 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.
    -
  • F
    license
    Not graded
    quality
    C
    maintenance
    This is an MCP server deployed on Cloudflare Workers with OAuth authentication, enabling remote MCP clients to connect and use tools.
    -