Skip to content

feat: add FastMCP OAuth proxy support for Cloud Run deployment#160

Open
FutureProve wants to merge 3 commits into
googleanalytics:mainfrom
FutureProve:main
Open

feat: add FastMCP OAuth proxy support for Cloud Run deployment#160
FutureProve wants to merge 3 commits into
googleanalytics:mainfrom
FutureProve:main

Conversation

@FutureProve
Copy link
Copy Markdown

Summary

  • Replaces the low-level mcp.server.Server + ADK FunctionTool / adk_to_mcp_tool_type
    machinery in coordinator.py with FastMCP and Tool.from_function().
  • Adds optional GoogleProvider OAuth 2.0 auth: when
    ANALYTICS_MCP_OAUTH_CLIENT_ID and ANALYTICS_MCP_OAUTH_CLIENT_SECRET
    are set, the server starts in streamable-http mode with a full OAuth
    authorization code flow. Without them it behaves exactly as before
    (stdio, Application Default Credentials).
  • Adds tools/client.py credential resolution that checks FastMCP's
    per-request OAuth token first, then falls back to ADC — so each user's
    request in HTTP mode uses their own credentials.
  • Adds a minimal Dockerfile (Python 3.11-slim + uv) for building a
    Cloud Run image.
  • Updates the README with a two-phase Cloud Run deployment guide.

Motivation

Enables the server to be deployed as a persistent remote MCP endpoint
(e.g. on Google Cloud Run) and accessed from web-based clients such as
claude.ai, following the same pattern as
google-ads-mcp.

Backward compatibility

No breaking changes. The stdio mode and existing client configurations
(Gemini CLI, Claude Desktop) are unaffected. The new behaviour only
activates when the two OAuth env vars are present.

Test plan

  • python -m pytest tests/ passes
  • analytics-mcp starts in stdio mode without OAuth env vars set
  • Server starts in HTTP mode and serves /mcp when OAuth env vars
    are set
  • OAuth flow completes and tool calls succeed against a real GA4
    property from claude.ai

Replace ADK/lowlevel MCP server setup with FastMCP and register tools via `Tool.from_function`. Add optional Google OAuth authentication using `GoogleProvider` driven by `ANALYTICS_MCP_OAUTH_CLIENT_ID/SECRET` and `ANALYTICS_MCP_BASE_URL`, removing the prior schema sanitization and ADK workaround code.feat(server): migrate coordinator to FastMCP w/ optional OAuth

Replace ADK/lowlevel MCP server setup with FastMCP and register tools via `Tool.from_function`. Add optional Google OAuth authentication using `GoogleProvider` driven by `ANALYTICS_MCP_OAUTH_CLIENT_ID/SECRET` and `ANALYTICS_MCP_BASE_URL`, removing the prior schema sanitization and ADK workaround code.
Document local vs remote deployment modes and add a step-by-step Cloud Run
setup, including OAuth client creation, required env vars, and claude.ai
integration instructions so web-based MCP clients can connect without
sharing credentials.docs(readme): add Cloud Run + OAuth remote deployment guide

Document local vs remote deployment modes and add a step-by-step Cloud Run
setup, including OAuth client creation, required env vars, and claude.ai
integration instructions so web-based MCP clients can connect without
sharing credentials.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant