mcp-google-analytics

v1.3.0
io.github.leonardosepulvedat/mcp-google-analytics Checked 25 minutes ago Published 3 months ago

GA4 MCP that reads AND writes: reports, funnels, audits, and server-side events.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

ga_run_report

Run a custom Google Analytics report with dimensions and metrics. ⚠️ TOKEN OPTIMIZATION: Use 'limit' to control result size (default: 10). This tool can consume significant tokens with large datasets. Common dimensions: date, city, country, deviceCategory, browser, pagePath, eventName Common metrics: activeUsers, sessions, screenPageViews, conversions, totalRevenue

ParameterTypeDescription
dateRanges *arrayDate ranges for the report
metrics *arrayMetrics to measure (e.g., [{name: "activeUsers"}])
dimensionFilterobjectDimension filter expression
dimensionsarrayDimensions to group by (e.g., [{name: "date"}])
limitintegerMaximum number of rows to return (default: 10)
metricFilterobjectMetric filter expression
offsetintegerNumber of rows to skip (for pagination)
orderBysarraySorting specification
propertyIdstringGA4 property ID to query (overrides the default GA_PROPERTY_ID). Accepts "123456789" or "properties/123456789". Use ga_get_account_summaries to discover IDs.

ga_run_realtime_report

Get real-time Google Analytics data (last 30 minutes). ⚠️ TOKEN OPTIMIZATION: Use 'limit' to control result size (default: 10). Common dimensions: city, country, deviceCategory, unifiedScreenName Common metrics: activeUsers, screenPageViews, conversions

ParameterTypeDescription
metrics *arrayMetrics to measure
dimensionsarrayDimensions to group by
limitintegerMaximum number of rows (default: 10)
propertyIdstringGA4 property ID to query (overrides the default GA_PROPERTY_ID). Accepts "123456789" or "properties/123456789". Use ga_get_account_summaries to discover IDs.

ga_get_metadata

Get available dimensions and metrics metadata for your GA4 property. ⚠️ TOKEN OPTIMIZATION: This returns ALL available dimensions and metrics. Response can be large (~500+ items). Use sparingly and cache results when possible.

ParameterTypeDescription
propertyIdstringGA4 property ID to query (overrides the default GA_PROPERTY_ID). Accepts "123456789" or "properties/123456789". Use ga_get_account_summaries to discover IDs.

ga_list_accounts

List all Google Analytics accounts accessible to the service account. Use this to find account IDs for listing properties.

ga_list_properties

List Google Analytics properties. Optionally filter by account ID. Without an account ID, properties from all accessible accounts are aggregated.

ParameterTypeDescription
accountIdstringOptional account ID to filter properties (e.g., "123456789")

ga_get_property

Get details about a GA4 property (the configured one, or any accessible property via propertyId).

ParameterTypeDescription
propertyIdstringGA4 property ID to query (overrides the default GA_PROPERTY_ID). Accepts "123456789" or "properties/123456789". Use ga_get_account_summaries to discover IDs.

ga_list_data_streams

List data streams for the configured GA4 property. Use this to find measurement IDs for Measurement Protocol.

ParameterTypeDescription
propertyIdstringGA4 property ID to query (overrides the default GA_PROPERTY_ID). Accepts "123456789" or "properties/123456789". Use ga_get_account_summaries to discover IDs.

ga_run_pivot_report

Run a pivot table report with row and column dimensions. ⚠️ TOKEN OPTIMIZATION: Pivot reports can be VERY large. Limit dimensions and use small date ranges. Recommended for analysis, not raw data extraction.

ParameterTypeDescription
dateRanges *array
metrics *array
pivots *arrayPivot specifications with fieldNames
dimensionsarray
propertyIdstringGA4 property ID to query (overrides the default GA_PROPERTY_ID). Accepts "123456789" or "properties/123456789". Use ga_get_account_summaries to discover IDs.

ga_run_funnel_report

Run a funnel analysis report to track user progression through steps (Data API v1alpha). Each step matches an event: set 'eventName' per step (defaults to the step name). For advanced matching, pass a full 'filterExpression' instead.

ParameterTypeDescription
dateRanges *array
funnelSteps *arraySteps in the funnel
funnelBreakdownobjectOptional dimension to break down funnel
funnelVisualizationTypestring
propertyIdstringGA4 property ID to query (overrides the default GA_PROPERTY_ID). Accepts "123456789" or "properties/123456789". Use ga_get_account_summaries to discover IDs.

ga_batch_run_reports

Run multiple reports in a single request. ⚠️ TOKEN OPTIMIZATION: Can return LARGE amounts of data. Limit to 2-5 reports per batch. Each report should have small limits.

ParameterTypeDescription
requests *arrayArray of report requests (same format as ga_run_report)
propertyIdstringGA4 property ID to query (overrides the default GA_PROPERTY_ID). Accepts "123456789" or "properties/123456789". Use ga_get_account_summaries to discover IDs.

ga_get_account_summaries

Get a compact overview of all accessible GA accounts and their properties in a single call. The fastest way to discover account IDs, property IDs, and property names.

ga_list_custom_dimensions

List all custom dimensions defined for the configured GA4 property. Use this to discover custom dimension API names (e.g., "customEvent:plan_type") for reports.

ParameterTypeDescription
propertyIdstringGA4 property ID to query (overrides the default GA_PROPERTY_ID). Accepts "123456789" or "properties/123456789". Use ga_get_account_summaries to discover IDs.

ga_list_custom_metrics

List all custom metrics defined for the configured GA4 property. Use this to discover custom metric API names for reports.

ParameterTypeDescription
propertyIdstringGA4 property ID to query (overrides the default GA_PROPERTY_ID). Accepts "123456789" or "properties/123456789". Use ga_get_account_summaries to discover IDs.

ga_list_key_events

List the key events (conversions) configured for the GA4 property. Useful to know which event names count as conversions before building reports or sending events.

ParameterTypeDescription
propertyIdstringGA4 property ID to query (overrides the default GA_PROPERTY_ID). Accepts "123456789" or "properties/123456789". Use ga_get_account_summaries to discover IDs.

ga_check_compatibility

Check whether a combination of dimensions and metrics is valid for this property BEFORE running a report. Avoids wasted report requests and token-heavy error loops. Also lists which other fields remain compatible with the given combination.

ParameterTypeDescription
compatibilityFilterstringOnly return fields with this compatibility (recommended: COMPATIBLE)
dimensionsarrayDimensions to check (e.g., [{name: "city"}])
metricsarrayMetrics to check (e.g., [{name: "activeUsers"}])
propertyIdstringGA4 property ID to query (overrides the default GA_PROPERTY_ID). Accepts "123456789" or "properties/123456789". Use ga_get_account_summaries to discover IDs.

ga_send_event

Send a custom event to Google Analytics via Measurement Protocol. Use this for tracking custom user actions, conversions, or any GA4 event. Events are processed asynchronously and appear in reports within minutes. Common events: click, form_submit, video_play, file_download, custom_conversion

ParameterTypeDescription
events *arrayEvents to send (can send multiple in one request)
client_idstringClient ID (UUID format recommended). Auto-generated if not provided.
user_idstringOptional User ID for cross-device tracking
user_propertiesobjectUser properties (e.g., {subscription_tier: {value: "premium"}})

ga_validate_event

Validate an event before sending it to Google Analytics. Uses GA4's debug endpoint to check for errors without recording the event. Returns validation messages and errors if any.

ParameterTypeDescription
events *array
client_idstring
user_idstring
user_propertiesobjectUser properties (e.g., {subscription_tier: {value: "premium"}})

ga_send_pageview

Send a page view event to Google Analytics. Standard event for tracking page/screen views. Automatically uses 'page_view' event name.

ParameterTypeDescription
page_location *stringFull URL of the page
client_idstringClient ID (auto-generated if not provided)
page_referrerstringReferrer URL
page_titlestringPage title
user_idstringOptional User ID
user_propertiesobjectUser properties (e.g., {subscription_tier: {value: "premium"}})

ga_send_purchase

Send an ecommerce purchase event to Google Analytics. Standard event for tracking completed purchases with transaction details and items.

ParameterTypeDescription
currency *stringCurrency code (e.g., USD, EUR)
items *arrayPurchased items
transaction_id *stringUnique transaction ID
value *numberTotal purchase value
affiliationstringStore or affiliation
client_idstring
couponstringCoupon code used
shippingnumberShipping cost
taxnumberTax amount
user_idstring
user_propertiesobjectUser properties (e.g., {subscription_tier: {value: "premium"}})

ga_send_login

Send a login event to Google Analytics. Standard event for tracking user logins with authentication method.

ParameterTypeDescription
method *stringLogin method (e.g., "Google", "Email", "Facebook")
client_idstring
user_idstringUser ID (recommended for login events)
user_propertiesobjectUser properties (e.g., {subscription_tier: {value: "premium"}})

ga_send_signup

Send a sign-up event to Google Analytics. Standard event for tracking new user registrations.

ParameterTypeDescription
method *stringSign-up method (e.g., "Google", "Email")
client_idstring
user_idstringUser ID for the new user
user_propertiesobjectUser properties (e.g., {subscription_tier: {value: "premium"}})

ga_send_add_to_cart

Send an add to cart event to Google Analytics. Ecommerce event for tracking when items are added to shopping cart.

ParameterTypeDescription
currency *stringCurrency code
items *arrayItems added to cart
value *numberTotal value of items added
client_idstring
user_idstring
user_propertiesobjectUser properties (e.g., {subscription_tier: {value: "premium"}})

ga_send_begin_checkout

Send a begin checkout event to Google Analytics. Ecommerce event for tracking when users start the checkout process.

ParameterTypeDescription
currency *stringCurrency code
items *arrayItems in checkout
value *numberTotal value of cart
client_idstring
couponstringCoupon code applied
user_idstring
user_propertiesobjectUser properties (e.g., {subscription_tier: {value: "premium"}})

ga_send_view_item

Send a view item event to Google Analytics. Ecommerce event for tracking product/item detail views. Completes the standard funnel: view_item → add_to_cart → begin_checkout → purchase.

ParameterTypeDescription
currency *stringCurrency code
items *arrayItems viewed
value *numberValue of the viewed item(s)
client_idstring
user_idstring
user_propertiesobjectUser properties (e.g., {subscription_tier: {value: "premium"}})

ga_send_refund

Send a refund event to Google Analytics. Ecommerce event for full or partial refunds. Omit 'items' for a full refund; include them (with quantities) for a partial refund. Use the same transaction_id as the original purchase.

ParameterTypeDescription
transaction_id *stringTransaction ID of the original purchase
client_idstring
currencystringCurrency code
itemsarrayRefunded items (only for partial refunds)
user_idstring
user_propertiesobjectUser properties (e.g., {subscription_tier: {value: "premium"}})
valuenumberRefunded amount