HTTP-ready fork of google-analytics-mcp with dual SSE + Streamable HTTP transport, OpenAI-compatible tool schemas, and API key authentication. Works out of the box with ChatGPT Desktop (SSE) and Open Web UI (Streamable HTTP).
This repo contains the source code for running a containerized MCP server that interacts with APIs for Google Analytics.
The server uses the Google Analytics Admin API and Google Analytics Data API to provide several Tools for use with LLMs.
get_account_summaries: Retrieves information about the user's Google Analytics accounts and properties.get_property_details: Returns details about a property.list_google_ads_links: Returns a list of links to Google Ads accounts for a property.
run_report: Runs a Google Analytics report using the Data API.run_funnel_report: Runs a Google Analytics funnel report using the Data API.run_conversions_report: Runs a Google Analytics conversions / attribution report.get_custom_dimensions_and_metrics: Retrieves the custom dimensions and metrics for a specific property.
run_realtime_report: Runs a Google Analytics realtime report using the Data API.
- Docker and docker-compose
- A Google Cloud project with the Analytics Admin API and Analytics Data API enabled
- OAuth 2.0 credentials (Desktop client) for a Google account with access to your GA4 properties
- An ADC (Application Default Credentials) JSON file with the
analytics.readonlyscope
-
Clone the repo
git clone https://github.com/broobe/google-analytics-mcp.git cd google-analytics-mcp -
Configure OAuth credentials
Generate your ADC file (you only need to do this once):
gcloud auth application-default login \ --scopes https://www.googleapis.com/auth/analytics.readonly,https://www.googleapis.com/auth/cloud-platform \ --client-id-file=YOUR_CLIENT_JSON_FILE
Copy the generated credentials file into the project:
cp PATH_TO_CREDENTIALS_JSON credentials.json
-
Configure environment
cp .env.example .env
Edit
.envand set:GOOGLE_CLOUD_PROJECT— your Google Cloud project IDGOOGLE_APPLICATION_CREDENTIALS— path to your ADC JSON fileMCP_API_KEY— a secure API key of your choice (used for bearer auth)
-
Build and run
docker compose up -d ga4-mcp-http
The server listens on port 8080 inside the container. Map it to any host port (default in docker-compose.yml:
8081:8080).
Configure your MCP client with:
- URL:
http://your-host:8081/ - Transport: SSE (GET
/) - Auth:
Authorization: Bearer YOUR_MCP_API_KEY
The server returns an SSE endpoint event, and the client POSTs JSON-RPC messages back.
Configure your MCP connection with:
- URL:
http://your-host:8081/ - Transport: Streamable HTTP (POST
/) - Auth:
Authorization: Bearer YOUR_MCP_API_KEY
The client sends initialize → notifications/initialized → tools/list (server returns all 9 tools).
Returns SSE stream if Accept: text/event-stream header is present. Otherwise returns a simple status message.
All JSON-RPC method calls. Requires Authorization: Bearer <MCP_API_KEY>.
If the query contains session_id (e.g., /messages/?session_id=xxx), the POST is routed to the SSE transport's message handler. Otherwise it goes to the Streamable HTTP transport.
| Feature | Streamable HTTP | SSE |
|---|---|---|
| Transport | POST request/response | SSE stream (GET) + POST messages |
| Client example | Open Web UI, custom MCP clients | ChatGPT Desktop |
| Session lifecycle | Per-request | Long-lived connection |
For detailed report examples and a full dimension/metric reference, see GA4-MCP-PROMPT.md.
Contributions welcome! See the Contributing Guide.