GA4 MCP that reads AND writes: reports, funnels, audits, and server-side events. 26 tools.
io.github.leonardosepulvedat/mcp-google-analytics MCP Server
This Model Context Protocol (MCP) server integrates with Google Analytics 4 to both read and write data. It connects to the Google Analytics Data API for reporting and to Measurement Protocol v2 for sending server-side events, including audits and verification via realtime reporting. It provides 26 tools for GA4 workflows.
π οΈ Key Features
GA4 integration using the Google Analytics Data API (read reports)
Measurement Protocol v2 support (send events)
Includes reports, funnels, audits, and server-side events
Covers ecommerce and conversion events server-side
A Model Context Protocol (MCP) server for Google Analytics 4, providing comprehensive integration with both the Google Analytics Data API (for reading reports) and Measurement Protocol v2 (for sending events).
The GA4 MCP that reads AND writes. Most GA4 MCP servers (including Google's official one) are read-only. This one gives your AI agent the full loop: run reports and funnels, audit your setup (custom dimensions, key events, compatibility checks), send ecommerce and conversion events server-side, and verify them in the realtime report β 26 tools in one npx command.
Built for agencies too: every read tool accepts an optional propertyId, so one conversation can query all your clients' properties β no reconfiguration between clients. See Multi-Property Mode.
See QUICKSTART.md for a 5-minute setup guide, or follow the installation steps below.
π¦ Installation
Option 1: Install globally via npm
bash
npm install -g mcp-google-analytics
Option 2: Use with npx (no installation needed)
bash
npx mcp-google-analytics
π§ Configuration
Start with two values. That unlocks reports, funnels, realtime, and property audits β everything most people need, and the same setup every other GA4 MCP asks for.
Every read tool accepts an optional propertyId argument that overrides the configured GA_PROPERTY_ID β so a single conversation can query any property the service account can access, with no reconfiguration between clients.
Grant your service account "Viewer" access on each client's GA4 property (or at account level).
Set only GA_SERVICE_ACCOUNT_JSON (GA_PROPERTY_ID becomes optional β if set, it acts as the default).
Discover properties, then query any of them:
code
Show me all my accounts and properties β ga_get_account_summaries
Compare last week's active users between the β ga_run_report with propertyId "111111"
Acme property and the Globex property and again with propertyId "222222"
propertyId accepts both 123456789 and properties/123456789. Event sending (Measurement Protocol) remains tied to the configured GA_MEASUREMENT_ID/GA_API_SECRET, since each data stream has its own secret.
Note: Funnel reporting uses the Data API v1alpha channel (the only channel where Google exposes it). Each step matches an event: set eventName per step, or omit it to use the step's name as the event name. For advanced matching, pass a full filterExpression.
List the custom dimensions and metrics defined for the property, including their API names (e.g., customEvent:plan_type) so you can use them in reports.
ga_list_key_events
List the key events (conversions) configured for the property β useful before building conversion reports or deciding which events to send.
ga_list_google_ads_links
List Google Ads accounts linked to the property.
ga_check_compatibility
Check whether a dimension/metric combination is valid before running a report, avoiding wasted requests and token-heavy error loops.
Events take a few minutes to appear in standard reports, but show up almost immediately in the realtime report (ga_run_realtime_report).
Use ga_validate_event to test new events without recording them.
If you omit client_id, one is auto-generated per call. To have GA group several events (e.g., a cart-to-purchase flow) into the same session and user, pass the same client_id to every call.
Send product/item detail view events. Completes the standard ecommerce funnel: view_item β add_to_cart β begin_checkout β purchase.
ga_send_add_to_cart
Send add-to-cart events.
ga_send_begin_checkout
Send checkout initiation events.
ga_send_refund
Send full or partial refund events. Use the same transaction_id as the original purchase; omit items for a full refund, include them for a partial one.