Google Calendar MCP OAuth Proxy
Google Calendar MCP OAuth Proxy
この Worker は、MCP クライアント(Codex など)と Google 公式 Calendar MCP の間の OAuth 境界として機能します。
Codex / MCP client
|
| OAuth to this Worker
v
Cloudflare OAuth Provider
|
| Google OAuth (client ID + client secret)
v
Google OAuth
|
| Google access token
v
Google Calendar MCP
https://calendarmcp.googleapis.com/mcp/v1クライアントが Google OAuth クライアントシークレットを受け取ることはありません。Google のアクセストークンとリフレッシュトークンは、Cloudflare OAuth プロバイダーが管理する暗号化された OAuth grant props に保存されます。保護された /mcp ハンドラーは、MCP トラフィックを上流に転送する前に、クライアントのローカル Bearer トークンをユーザーの Google アクセストークンに置き換えます。
Google のスコープ
wrangler.jsonc は、GOOGLE_OAUTH_SCOPES で Google Calendar のスコープを定義しています。
https://www.googleapis.com/auth/calendar.calendarlist.readonly
https://www.googleapis.com/auth/calendar.events.freebusy
https://www.googleapis.com/auth/calendar.events.readonly
https://www.googleapis.com/auth/calendar.calendarsWorker は、コールバックが Google の user-info エンドポイントを使用して許可されたユーザーを特定するため、email profile を自動的に追加します。
Google の認可リクエストは、Google がリフレッシュトークンを返すように、access_type=offline と prompt=consent も使用します。
Related MCP server: google-mcp-server
ローカルシークレット
サンプルファイルをコピーします。
cp .dev.vars.example .dev.vars設定します。
GOOGLE_CLIENT_ID=<Google OAuth web client ID>
GOOGLE_CLIENT_SECRET=<Google OAuth client secret>
COOKIE_ENCRYPTION_KEY=<strong random secret>
HOSTED_DOMAIN=<optional Google Workspace domain restriction>GOOGLE_OAUTH_SCOPES と GOOGLE_MCP_URL は、wrangler.jsonc 内の非シークレット Worker 変数です。
Google Cloud OAuth クライアント
Google OAuth の Web アプリケーション クライアントを使用してください。
認可されたリダイレクト URI は、この Worker またはトンネルの公開ホスト名に /callback を加えたものにする必要があります。
https://mcp-auth.example.com/callback上記の Calendar スコープを Google Auth Platform の同意 / データアクセス設定に追加してください。
ローカルで実行する
依存関係をインストールし、Worker の型を生成します。
npm install
npm run cf-typegenWrangler をポート 5555 でローカル起動します。
npm run devローカルエンドポイントは次のとおりです。
http://localhost:5555/mcpOAuth では 公開HTTPS コールバックが必要なため、エンドツーエンドのローカルテストには Cloudflare Tunnel を使用します。
固定の名前付きトンネル
同じコールバックを Google Cloud に登録する必要があるため、固定ホスト名が望ましいです。
npx wrangler dev --tunnel-name=mcp-google-auth --tunnel名前付きトンネルのホスト名を Wrangler 開発サーバーにルーティングするように設定します。例:
https://mcp-auth.example.com -> local Wrangler dev server次に登録します。
https://mcp-auth.example.com/callbackを Google OAuth のリダイレクト URI として登録します。
Codex に公開される MCP URL は次のとおりです。
https://mcp-auth.example.com/mcpCodex の設定
この Worker は Codex から見た OAuth 認可サーバーであるため、Codex は Google クライアント ID や Google クライアントシークレットを必要としません。
[mcp_servers.google_calendar_proxy]
enabled = true
url = "https://mcp-auth.example.com/mcp"
auth = "oauth"次に認証します。
codex mcp login google_calendar_proxy期待されるフローは次のとおりです。
Codex がこの Worker の OAuth エンドポイントを検出します。
Codex がこの Worker に登録 / 認証します。
Worker がブラウザーを Google に送ります。
Google が Worker / トンネルの
/callbackに戻ります。Worker が
GOOGLE_CLIENT_SECRETを使用して Google の認可コードを交換します。Codex は Worker が発行した OAuth トークンを受け取ります。
/mcpへの呼び出しは、ユーザーの Google アクセストークンを使用して、Google 公式 Calendar MCP に転送されます。
トークンリフレッシュの動作
Google のリフレッシュトークンは、暗号化された OAuth grant props に保持されます。プロキシは、Google アクセストークンの isolate ローカルな有限 LRU キャッシュを保持し、エントリがリフレッシュウィンドウに達すると削除し、キャッシュを 100 ユーザーに制限します。保存されたアクセストークンが期限切れの場合、または Google の MCP が 401 を返した場合、Worker は Google のリフレッシュトークンと Worker 側のクライアントシークレットを使用して新しい Google アクセストークンを発行し、1 回だけ再試行します。
インメモリキャッシュは単なる最適化です。新しい Worker の isolate は、暗号化された grant props から常にリフレッシュできます。
レガシーグラント
リフレッシュトークン対応の前に作成された OAuth grant には、元の Google アクセストークンとユーザーメタデータのみが含まれます。プロキシはこれらの grant を検出し、Google がそのアクセストークンをまだ受け入れている間は、既存のアクセストークンを使い続けます。Google がそのトークンを拒否すると、Worker は 401 invalid_token を返すため、不十分な資格情報でリフレッシュを試みるのではなく、MCP 接続を再認証できます。
This 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.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceAn MCP server that enables authentication and authorization with Google's OAuth2 API, allowing users to securely authenticate and access Google services through natural language interactions.
- AlicenseNot gradedqualityDmaintenanceMCP Server for Google Services, with the ability to define your own scopes and bring your own oauth key.3MIT
- FlicenseNot gradedqualityDmaintenanceEnables seamless Google Calendar integration with MCP-compatible clients, allowing creation, viewing, updating, and deletion of calendar events via OAuth 2.0 authentication.
- AlicenseNot gradedqualityCmaintenanceEnables access to Google Workspace services (Calendar, Gmail, Drive, Tasks) via an MCP server deployed on Vercel.1,226MIT
Related MCP Connectors
Streamable HTTP MCP server for Google Calendar and Sheets with OAuth login.
Hosted Google Calendar MCP server for AI agents. No self-hosting or Google Cloud setup.
Self-hosted federated MCP gateway: one OAuth 2.1 MCP server in front of N apps, user-level scopes.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- 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/REVREBEL/cloudflare-mcp-google-auth'
If you have feedback or need assistance with the MCP directory API, please join our Discord server