analytics-mcp
MCP server for querying Google Analytics accounts, properties, reports, and realtime data using the Data API and Admin API.
README
Google Analytics MCP Server — adtechnacity fork (Experimental)
This is a fork. It is based on
googleanalytics/google-analytics-mcp(Apache-2.0) and maintained atadtechnacity/ga-mcp. It adds Google Analytics Admin API write tools —create_custom_dimensionandcreate_key_event— on top of the upstream read-only server, and broadens the requested OAuth scope to includeanalytics.editso those tools can run.Everything from upstream still works unchanged. The Python package/module is still
analytics_mcpand the entry point is stillpython -m analytics_mcp.server, so it's a drop-in replacement. This fork is not published to PyPI — run it from source (see Setup).⚠️ The write tools make permanent property-configuration changes. Beyond the
analytics.editscope, the authenticated principal must also hold an Editor / Administrator role on the target GA4 property, or the Admin API returnsPERMISSION_DENIED.
This repo runs a local MCP server that interacts with APIs for Google Analytics.
Tools 🛠️
The server uses the Google Analytics Admin API and Google Analytics Data API to provide several Tools for use with LLMs.
Retrieve account and property information 🟠
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.list_property_annotations: Returns the annotations configured on a property.
Run core reports 📙
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 report using the Data API.get_custom_dimensions_and_metrics: Retrieves the custom dimensions and metrics for a specific property.
Run realtime reports ⏳
run_realtime_report: Runs a Google Analytics realtime report using the Data API.
Write / configure a property (fork addition) ✍️
Not in the upstream read-only server. These make permanent changes and require the
analytics.editscope and an Editor / Administrator role on the target property.
create_custom_dimension: Creates a custom dimension on a GA4 property — permanently registers an event/user/item parameter so it becomes reportable.create_key_event: Marks an event as a Key Event / conversion on a GA4 property.
Setup instructions 🔧
Setup involves the following steps:
- Install a runner (
uvrecommended). - Get the fork (clone it).
- Enable the Google Analytics APIs in your Google Cloud project.
- Configure credentials for Google Analytics.
- Configure your MCP client (Gemini, Claude Code, …).
Install a runner 🐍
Install uv (used to
run the server from source). pipx
also works if you prefer to run a branch straight from GitHub.
Get the fork ⬇️
git clone https://github.com/adtechnacity/ga-mcp.git
Note the absolute path to the clone — you'll reference it as PATH_TO_REPO
below.
Enable APIs in your project ✅
Follow the instructions to enable the following APIs in your Google Cloud project:
Configure credentials 🔑
Configure your Application Default Credentials (ADC). Make sure the credentials are for a principal with access to your Google Analytics accounts or properties.
This fork requests two scopes — the read scope used by all read tools, and the edit scope required by the write tools:
https://www.googleapis.com/auth/analytics.readonly
https://www.googleapis.com/auth/analytics.edit
If you only intend to use the read tools, the edit scope is harmless (it's still requested, but unused). To actually create custom dimensions / key events, the principal must also hold an Editor / Administrator role on the target GA4 property — the scope alone is not enough.
Check out Manage OAuth Clients for how to create an OAuth client.
Here are some sample gcloud commands you might find useful:
-
Set up ADC using user credentials and an OAuth desktop or web client after downloading the client JSON to
YOUR_CLIENT_JSON_FILE.gcloud auth application-default login \ --scopes https://www.googleapis.com/auth/analytics.readonly,https://www.googleapis.com/auth/analytics.edit,https://www.googleapis.com/auth/cloud-platform \ --client-id-file=YOUR_CLIENT_JSON_FILE -
Set up ADC using service account impersonation.
gcloud auth application-default login \ --impersonate-service-account=SERVICE_ACCOUNT_EMAIL \ --scopes=https://www.googleapis.com/auth/analytics.readonly,https://www.googleapis.com/auth/analytics.edit,https://www.googleapis.com/auth/cloud-platform
When the gcloud auth application-default command completes, copy the
PATH_TO_CREDENTIALS_JSON file location printed to the console. You'll need it
for the next step.
Using a service account (e.g. for headless / CI use)? Set
GOOGLE_APPLICATION_CREDENTIALSto the key file in your MCP clientenv(see below). Remember the service account still needs the Editor / Administrator property role for writes.
Configure Gemini
-
Install Gemini CLI or Gemini Code Assist.
-
Create or edit
~/.gemini/settings.json, adding the server to themcpServerslist. ReplacePATH_TO_REPOwith the path to your clone andYOUR_PROJECT_IDwith your project ID. SetGOOGLE_APPLICATION_CREDENTIALSonly if you're using a service-account key file rather than ADC.{ "mcpServers": { "analytics-mcp": { "command": "uv", "args": [ "--directory", "PATH_TO_REPO", "run", "python", "-m", "analytics_mcp.server" ], "env": { "GOOGLE_PROJECT_ID": "YOUR_PROJECT_ID" } } } }
Configure Claude Code
Add the MCP server, running it from your clone with uv. Replace PATH_TO_REPO
with the path to your clone and YOUR_PROJECT_ID with your
project ID.
claude mcp add analytics-mcp \
--scope user \
-e "GOOGLE_PROJECT_ID=YOUR_PROJECT_ID" \
-- uv --directory PATH_TO_REPO run python -m analytics_mcp.server
Add -e "GOOGLE_APPLICATION_CREDENTIALS=PATH_TO_CREDENTIALS_JSON" if you're
authenticating with a service-account key file instead of ADC.
Try it out 🥼
Launch your MCP client and list the available servers (e.g. /mcp in Gemini or
Claude Code). You should see analytics-mcp with 11 tools.
Here are some sample prompts to get you started:
-
Ask what the server can do:
what can the analytics-mcp server do? -
Ask about a Google Analytics property
Give me details about my Google Analytics property with 'xyz' in the name -
Prompt for analysis:
what are the most popular events in my Google Analytics property in the last 180 days? -
Ask about property configuration:
what are the custom dimensions and custom metrics in my property? -
Use a write tool (needs the edit scope + an Editor role on the property):
create an event-scoped custom dimension named "Respin Genre" for the parameter fs_respin_genre on property 123456789
Relationship to upstream 🔗
This fork tracks
googleanalytics/google-analytics-mcp
as upstream. The only additions are the two Admin-API write tools and the
analytics.edit scope; the read tools are unchanged. Source-file copyright
headers from upstream are retained (Apache-2.0). Generally-useful fixes are
welcome here, but consider sending broadly-applicable changes upstream too — see
CONTRIBUTING.md.
Contributing ✨
Contributions welcome! See the Contributing Guide.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。