cloudflare -google-oauth-analytics
Google OAuth-enabled MCP server with built-in analytics tracking for Cloudflare Workers
claude mcp add --transport stdio bighadj22-cloudflare-mcp-google-oauth-analytics npx mcp-remote https://mcp-google-oauth.<your-subdomain>.workers.dev/sse \ --env HOSTED_DOMAIN="optional_specific_domain" \ --env GOOGLE_CLIENT_ID="your_google_client_id" \ --env GOOGLE_CLIENT_SECRET="your_google_client_secret" \ --env COOKIE_ENCRYPTION_KEY="your_random_secret_string" \ --env MCP_ANALYTICS_API_KEY="your_analytics_api_key"
How to use
This MCP server runs on Cloudflare Workers and provides an OAuth-enabled remote MCP endpoint with built-in analytics. It authenticates users via Google OAuth and exposes MCP tools to authenticated clients. Tools are tracked with mcp-analytics, including per-tool execution time, success/failure, input parameters (redacted), tool results, errors, user context, and session information. To use it from an MCP client like Claude Desktop or other MCP clients, configure the client to point at the server's SSE endpoint (https://mcp-google-oauth.<your-subdomain>.workers.dev/sse) and initiate the OAuth flow. Once connected, you’ll see available tools (e.g., add) and interactions will be automatically recorded for analytics.
How to install
Prerequisites:
- Node.js and npm installed
- Wrangler installed and configured for Cloudflare Workers
- Access to Google Cloud Console to create OAuth credentials
Step-by-step:
-
Install dependencies
- npm install
-
Configure OAuth and analytics secrets (via Wrangler):
- wrangler secret put GOOGLE_CLIENT_ID
- wrangler secret put GOOGLE_CLIENT_SECRET
- wrangler secret put COOKIE_ENCRYPTION_KEY
- wrangler secret put HOSTED_DOMAIN (optional)
- wrangler secret put MCP_ANALYTICS_API_KEY
-
Set up a KV namespace for OAuth state if required by the project:
- wrangler kv:namespace create "OAUTH_KV"
- Update wrangler.toml with the KV namespace ID
-
Deploy to Cloudflare Workers:
- wrangler publish
Local testing (optional):
- wrangler dev
- Access the local SSE endpoint (e.g., http://localhost:8788/sse) to test the OAuth flow and tool usage.
Additional notes
Tips and caveats:
- Ensure GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET are from a Google Cloud OAuth App configured to allow the deployed domain (your subdomain under workers.dev).
- If you want to restrict access to a specific Google Workspace domain, set HOSTED_DOMAIN accordingly.
- The MCP analytics API key must be valid for mcp-analytics and properly configured in your analytics dashboard.
- For local development, provide a .dev.vars file with GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, and MCP_ANALYTICS_API_KEY and use wrangler dev for testing.
- When using Claude Desktop or other MCP clients, expect some UX inconsistencies for remote MCP servers; verify connection status via the client’s OAuth or tool availability indicators.
- The example server exposes an "add" tool; you can expand tool availability based on OAuth identity and server configuration.
Related MCP Servers
mcp-router
A Unified MCP Server Management App (MCP Manager).
conductor-tasks
A task management system designed for AI development
advanced-reason
Enhanced version of "Sequential Thinking" MCP
mcp-sysoperator
MCP for Ansible, Terraform, LocalStack, and other IaC tools. Create and iterate IaC
inked
dead simple memory mcp server for Claude apps
mcp-quickstart
Setup an MCP server in 60 seconds.