Skip to main content
Glama
epsilon-labs-llc

MCP Template

MCP Template

MCP Cloudflare Workers Hono TypeScript pnpm

Better Authのパスキー認証と、認証済み接続を確認するMCP Toolを備えたCloudflare Workers用テンプレートです。公開サインアップは行わず、手動登録したUserだけが利用できます。

含まれるもの

  • Cloudflare Workers、Hono、TypeScript strict

  • Better Auth、Passkey、OAuth、CIMD

  • Cloudflare D1のBetter Auth用Migration

  • 認証済みUserだけが実行できるget_server_status

  • 初回パスキー登録用の24時間・一度限りURL

Related MCP server: GitHub OAuth MCP Server

事前準備

  • Node.js 24以上とpnpm 11

  • CloudflareアカウントとWranglerのログイン

  • Passkeyで使うHTTPS公開URL

セットアップ

1. サービス名と公開URLを決める

以下を実際のサービスに合わせて変更します。

ファイル

変更内容

package.json

パッケージ名

wrangler.jsonc

Worker名、PUBLIC_ORIGIN、D1の名前とID

src/auth.ts

Passkey表示名とCookie prefix

PUBLIC_ORIGINにはHTTPSの公開URLを設定します。Passkeyを使う際は、設定値と実際にアクセスするURLを一致させてください。

2. 依存関係とD1を準備する

pnpm install
pnpm wrangler d1 create mcp-template-db

作成結果のdatabase_idwrangler.jsoncへ設定します。D1名を変更した場合は、以降のコマンドにも同じ名前を使います。

3. SecretとMigrationを設定する

ローカル開発用に.dev.vars.example.dev.varsへ複製し、十分にランダムなBETTER_AUTH_SECRETを設定します。

Copy-Item .dev.vars.example .dev.vars
pnpm wrangler d1 migrations apply mcp-template-db --remote
pnpm wrangler secret put BETTER_AUTH_SECRET

リモートのBETTER_AUTH_SECRETには、ローカルと同じ値を設定します。

4. デプロイする

pnpm deploy

デプロイ後の主なエンドポイントです。

  • MCP: https://mcp.example.com/mcp

  • ヘルスチェック: https://mcp.example.com/health

  • 認証: https://mcp.example.com/auth/*

  • パスキー登録: https://mcp.example.com/passkey/register?token=...

初回Userとパスキー登録

公開サインアップはありません。D1へUserを手動登録してから、登録URLを発行します。User作成は要件ごとに安全な運用手順を決めるため、テンプレには自動作成スクリプトを含めていません。

pnpm user:issue-passkey-url user@example.com mcp-template-db https://mcp.example.com

URLは1回だけ使用でき、24時間で失効します。

ローカル開発

pnpm dev

/healthでWorkerの起動を確認できます。Passkeyを使うローカル検証では、PUBLIC_ORIGINとアクセスURLを一致させてください。

開発時の確認

pnpm format
pnpm format:check
pnpm lint
pnpm lines:check
pnpm typecheck
  • pnpm format は対象ファイルを整形します。

  • pnpm format:check はフォーマット済みか確認します。

  • pnpm lint はlintとimport整理を確認します。

  • pnpm lines:checksrc/scripts/の500行上限を検証します。

  • GitHub ActionsはpushとPull Requestでフォーマット、lint、行数、型を確認します。

ドキュメント

実装・ドキュメント更新時のルールは 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.
    -