GA4 BigQuery Semantic Layer
Provides a semantic layer on top of Google Analytics 4 event data exported to BigQuery, enabling simplified querying of GA4 dimensions and measures.
Allows querying GA4 event data stored in Google BigQuery through a semantic layer, providing consistent and simplified access to dimensions and measures.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@GA4 BigQuery Semantic LayerShow me daily event counts for last week"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
GA4 BigQuery Semantic Layer
This project provides a semantic layer on top of Google Analytics 4 (GA4) event data stored in Google BigQuery. It uses the boring-semantic-layer library to define a semantic model and exposes it through a Model-View-Controller Protocol (MCP) server.
This allows for consistent and simplified querying of your GA4 data from compatible client applications (like Cursor).
Features
Connects to your Google BigQuery project and dataset.
Defines a semantic model for GA4 event data (
ga4_events_sm).Exposes dimensions like
event_dateanduser_pseudo_id.Exposes measures like
event_count.Runs an MCP server to serve the semantic model, making it available for querying.
Related MCP server: BigQuery MCP Server
Prerequisites
Python 3.11 or newer.
Access to a Google Cloud project with the BigQuery API enabled.
GA4 event data exported to a BigQuery table.
Google Cloud SDK installed and authenticated on your local machine. You can authenticate by running:
gcloud auth application-default login
Setup & Installation
Clone the repository:
git clone <your-repository-url> cd measurecamp-london-bigqery-mcpInstall dependencies: The project uses
uvto manage and run the Python environment. The required dependencies are listed at the top of thelayer.pyfile.uvwill install them automatically when you run the server. If you don't haveuv, you can install it with:pip install uv
Configuration
Before running the server, you need to configure it to point to your BigQuery data. Open the layer.py file and modify the following lines:
Update BigQuery Connection: Change
project_idanddataset_idto match your Google Cloud setup.con = ibis.bigquery.connect( project_id="your-gcp-project-id", dataset_id="your_bigquery_dataset_id", )Update Table Name: Change the table name to your GA4 events table.
ga4_table = con.table("events_YYYYMMDD")Update Primary Key: The current
primary_keyin thega4_events_smmodel is set to"code", which is likely a remnant from an example. You should update this to a unique key for your events table or remove it if one is not applicable. A combination ofuser_pseudo_idandevent_timestampis often used to uniquely identify an event, butboring-semantic-layercurrently supports single-column primary keys. For now, you can remove the line.
Running the Server
Once configured, you can start the MCP server by running the following command in your terminal:
uv run layer.pyThe server will start and listen for connections from MCP clients.
Usage with an MCP Client (e.g., Cursor)
To connect to this server from an MCP-compatible editor like Cursor, you need to configure it as an MCP server.
In Cursor, create or open the
.cursor/mcp.jsonfile in your project's root directory.Add the following configuration to the
mcpServersobject:{ "mcpServers": { "ga4-semantic-layer": { "command": "uv run layer.py", "language": "python" } } }Reload Cursor. You can now use
@ga4-semantic-layerin the chat to query your semantic model. For example:@ga4-semantic-layer How many events were there per day?
This will query your BigQuery table through the semantic layer and return the results.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/mohrstade/measurecamp-london-bigqery-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server