Get the FREE Ultimate OpenClaw Setup Guide →

cloudflare -google-oauth-analytics

Google OAuth-enabled MCP server with built-in analytics tracking for Cloudflare Workers

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
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:

  1. Install dependencies

    • npm install
  2. 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
  3. 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
  4. Deploy to Cloudflare Workers:

    • wrangler publish

Local testing (optional):

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

Sponsor this space

Reach thousands of developers