Query Google Analytics 4 with Claude or Cursor via MCP.
A 5-minute setup that lets your AI tool ask plain-English questions about your GA4 data — pageviews, sessions, traffic sources, conversions, engagement — without exposing Google Analytics OAuth tokens to the AI vendor or opening firewall ports on your network.
Ask Nova, get SQL + charts
Meet Nova Database REST APIOne key per partner. No credentials shared.
Build an API AutomationScheduled sync to 6+ platforms
Explore API to SQLQuery APIs with SQL, no code
Explore AI Database MCPClaude, Cursor, ChatGPT & Grok talk to your data
Connect AIQuery Streams is a secure, real-time data integration platform that brings every database and SaaS API in your account into Claude, Cursor, ChatGPT, and Grok — through a single MCP key with no firewall changes. This google analytics mcp guide walks through wiring up the Google Analytics 4 connector specifically, so your AI tool can answer plain-English questions about pageviews, sessions, traffic sources, and conversions without you exporting CSV reports out of the GA4 web UI. Learn more at QueryStreams.com and sign up for free to start asking your AI tool real marketing-analytics questions.
What the Query Streams Google Analytics MCP server gives you
Other “Google Analytics MCP” servers on the open-source landscape connect the AI tool straight to the GA4 Data API. That works, but it pushes a Google OAuth token into your AI client’s config, scopes the AI tool to only Analytics, and gives you no audit trail of what the AI actually asked. The Query Streams Google Analytics MCP server solves a wider problem: one key, every connector, full audit trail, and the AI tool never holds your Google credentials. The agent caches each GA4 property into a local DuckDB file so the LLM sees real SQL surfaces — tables, columns, joins, semantic types — instead of REST endpoints with opaque dimension and metric names.
Zero inbound firewall holes
The Network Agent opens a single outbound encrypted cloud link to Query Streams. Your AI client connects to the cloud, never to your network. No port to open, no IP to allowlist, no VPN.
One key, every connector
The same MCP key reaches every database and SaaS API your account has connected. Add a Stripe or PostgreSQL connector tomorrow and the AI tool sees it without re-keying.
Schema Intelligence baked in
The AI sees AI-curated descriptions, semantic types, enum value lists, and discovered foreign keys for every column — not just bare information_schema output. It writes accurate SQL the first try.
Read-only enforced at the agent
Even a hallucinating LLM can’t issue DELETE or UPDATE through Query Streams MCP. The Network Agent rejects anything that isn’t SELECT, WITH, or EXPLAIN before it reaches the data source.
Per-key rate limits
Default 60 requests per minute and 10 execute calls per minute, configurable per key. A runaway AI tool-call loop hits a token bucket, not your GA4 Data API quota or your wallet.
How the Google Analytics MCP server works without opening firewall ports
The Query Streams Network Agent is a small program you install once on a machine that can reach the Google Analytics Data API (any laptop, server, or cloud VM). It opens one outbound TLS cloud link to the Query Streams cloud and waits there for tool calls. When Claude or Cursor asks a question, the cloud forwards the request to the agent, the agent calls the GA4 Data API, the agent caches the response in a local DuckDB so the AI can run SQL against it, and the result streams back through the same outbound channel. Nothing inbound. Nothing exposed. The AI tool never sees your Google OAuth token, and the GA4 MCP server never holds your credentials directly — the agent does, on your network.
AI Client
Cursor, Claude,
ChatGPT, Grok
QS MCP Server
Streamable HTTP
X-MCP-Key auth
Network Agent
On your network
Cloud link out
Google Analytics 4
cached as SQL
via DuckDB
The MCP key you give Cursor or Claude is scoped (read / analyze / execute), revocable at any time, and rate-limited per-key. The AI tool calls these MCP tools to do its work:
pattern_key with optional parameter overrides.Why Schema Intelligence makes the GA4 MCP server different
Most “MCP for X” servers in the open-source landscape hand your AI tool the same information_schema your database hands a stranger. Column names. Data types. Maybe a primary key. For Google Analytics 4 specifically, the picture is even bleaker: a typical GA4 MCP server returns a flat list of GA4 dimension and metric names, the AI has to guess which metrics are summable vs. averaged, has no idea that engagement_rate is stored as a 0-1 decimal rather than a percentage, and has no clue that event_date is a YYYYMMDD-formatted integer rather than a real SQL DATE. That’s why the first SQL most LLMs write against a bare GA4 schema — whether returned by a generic GA4 MCP or by a generic ga4 mcp library — is wrong on the first try. It’s not that the LLM is bad. It’s that it doesn’t have the data it needs to be right.
The Query Streams MCP server returns that same schema enriched with what we call Schema Intelligence (SI) — AI-curated metadata generated by running profiling queries against your actual GA4 data before the AI client ever asks. When SI is enabled on a connector, every schema tool the AI calls (qs_get_connector_schema, qs_get_table_schema, qs_profile_table, qs_get_relationships) returns the bare schema plus six layers of curated knowledge. The LLM stops guessing on event names, traffic sources, device categories, custom dimensions, and that integer-encoded date column.
To make this concrete, here is what the AI client gets back from a single qs_get_table_schema call against the GA4 connector’s ga4_events table — first without Schema Intelligence, then with it.
The six layers Schema Intelligence adds
Each layer addresses a specific class of question the LLM would otherwise guess at, and SI runs as an opt-in, read-only profiling pass that never changes your schema. More on how Schema Intelligence is generated →
AI-curated descriptions
Plain-English purpose for every database, schema, table, and column — generated once, refreshed when your schema changes. Confidence-scored; user-authored descriptions always win.
one row per user interaction.”
Table classifications
Each table tagged FACT (transactional events), DIM (descriptive reference), or LOOKUP (small code maps), plus a business domain — analytics, sales, hr, seo, finance, support, and 14 more.
ga4_traffic_sources [DIM, domain:analytics]
Semantic types per column
Eighteen types — currency, email, date_yyyymmdd, status_code, percentage, ranking_position, identifier, url, person_name, and more. The AI generates dialect-correct SQL appropriate to each type.
event_count: counter · event_date: date_yyyymmdd
Sample values from real data
Random rows surfaced to the LLM so it recognises patterns no schema can show — GA4-style underscored event names, custom-dimension shapes, and the actual encoding of your traffic-source strings.
‘/pricing’, ‘/features/text-to-sql’]
Enum detection with distributions
Low-cardinality columns (50 or fewer distinct values, at most 5% of rows unique) mapped to their full value list with row counts. The AI never guesses casing or spelling on event names again.
| session_start (18%) | purchase (3%)
Implicit foreign-key discovery
Cross-table data overlap analysis finds joins that aren’t declared as DDL constraints. Stored alongside formal FKs with confidence scores, returned by qs_get_relationships.
(99% overlap, conf 1.0)
Same prompt, different SQL
The proof is in the SQL the AI tool actually writes. Same Cursor session, same Claude model, same prompt — “Show me my top 10 landing pages by engagement last month, where pageviews are over 100.” Without Schema Intelligence the LLM has to guess. With it, the LLM knows.
si_recommendation block the AI can act on to enable SI mid-conversation via qs_request_si_analysis. How Schema Intelligence enrichment works →
MCP not for you? Try Nova AI instead.
Skip MCP entirely: Nova AI is built right into the Query Streams web portal, so you can sign in and ask the same plain-English GA4 questions — “what’s our bounce rate trend over the last 90 days?” or “which content categories drive the most signups?” — with no config files and nothing to wire up.
Meet Nova AIPrerequisites
Before you start, make sure you have:
- A free Query Streams account at my.querystreams.com.
- The Query Streams Network Agent installed on a machine with internet access — see Download the Query Streams Agent.
- A Google Analytics 4 connector configured against the agent — see the existing API Connector Setup guides for OAuth pairing. The agent holds the Google OAuth token; the AI tool never touches it.
- Any MCP-capable AI client. We’ll show Cursor, Claude Desktop, ChatGPT, and Grok in this guide; if you use Windsurf, Zed, Continue, Cline, VS Code Copilot, Codex, or Goose, the config block is essentially the same.
- Five minutes.
Drop it into your AI client
One JSON snippet for Cursor, Claude, ChatGPT, or Grok. Same key everywhere.
Ask a question
“What’s our top traffic source by conversion this month?” — the AI calls the right tools, you get the answer.
Step 1: Generate a Google Analytics MCP key in Query Streams
Sign in to Query Streams and open the MCP page (or sign in first at my.querystreams.com and click MCP in the left navigation). The same Google Analytics MCP key reaches every connector in your account — not just GA4 — so you only ever generate one. Click Generate key, give the key a recognizable name (something like cursor-laptop or claude-desktop), and pick the scopes you want this key to have:
read— the AI can browse connectors and read schema. Required for everything else.analyze— the AI can profile tables and discover relationships (sample values, distributions, semantic types). Optional but strongly recommended for analytics work, where understanding the shape of your event data matters.execute— the AI can actually run SQL. Without this, the AI is read-only against schema metadata only.
For a typical “let Claude analyse my Google Analytics data” workflow, all three scopes are appropriate. For a key you’re handing to a teammate or a less-trusted client, drop execute and let them browse only. You can revoke any key at any time from the same page; the AI client will see MCP_KEY_REVOKED on its next call and stop working immediately. There’s no propagation delay.
Copy the key now — Query Streams shows it once, then stores only a hash. If you lose it, generate a new one. The key looks like qsmcp_ followed by 48 random characters and is what your AI client sends in the X-MCP-Key request header.
Step 2: Add Query Streams MCP to your AI client
The configuration is the same shape across every MCP-capable client — an MCP server entry pointing at https://mcp.querystreams.com with your key in the X-MCP-Key header. Pick your client below.
// Edit ~/.cursor/mcp.json { "mcpServers": { "querystreams": { "url": "https://mcp.querystreams.com", "headers": { "X-MCP-Key": "qsmcp_PASTE_KEY_HERE" } } } }
// Settings → Developer → Edit Config { "mcpServers": { "querystreams": { "url": "https://mcp.querystreams.com", "headers": { "X-MCP-Key": "qsmcp_PASTE_KEY_HERE" } } } }
// Settings → Apps & Connectors → Add MCP Server URL https://mcp.querystreams.com Auth header X-MCP-Key Header value qsmcp_PASTE_KEY_HERE // Requires a paid ChatGPT plan // (Plus / Pro / Team / Enterprise).
// Grok → Settings → Tools { "mcp_servers": [{ "name": "querystreams", "url": "https://mcp.querystreams.com", "auth_header": "X-MCP-Key", "auth_value": "qsmcp_..." }] }
Restart your AI client. On its next start it will discover the eight Query Streams MCP tools listed above and surface them in its tool palette. In Cursor and Claude Desktop you can verify by typing “list connectors” — the AI should call qs_list_connectors and return your Google Analytics 4 connector along with anything else you have configured.
Step 3: Ask the AI a Google Analytics 4 question
You don’t write SQL — the AI does. You ask a question, the AI picks the right MCP tool, the agent runs the query against your cached GA4 data, and the answer comes back as text plus tables. Three example prompts to try first:
traffic_source_medium over the current month, joins to the conversion event count, and sorts by conversion rate. You’ll see the result table inline, plus a written interpretation of which channels are driving the most signups and which are leaking traffic.The first time the AI calls a tool, your client may pop up a confirmation prompt asking you to approve the tool call — that’s MCP’s standard consent flow, not anything Query Streams adds. Approve once and the AI proceeds with the rest of the conversation freely. You can revisit the consent at any time in your client’s settings.
Honest billing notice: MCP usage is charged on uncompressed bytes
Query Streams’ Excel add-in, Google Sheets add-on, web Query Builder, and Nova AI all run over our compressed cloud link — we measure and bill compressedBytes against your data realm. The MCP transport (Streamable HTTP per the official MCP spec) does not reliably support compression end-to-end across every client and intermediate proxy, so we measure and bill uncompressedBytes for MCP traffic.
- What this means: a 3 MB GA4 daily aggregate query costs ~3 MB of your data realm when fetched via MCP, vs. ~400–600 KB via Excel / Sheets / Nova / the Query Builder. GA4 event data is unusually compressible — repeated event-name and traffic-source strings compress 6–8x via LZ4 over our cloud link — so the gap on this connector is wider than for most databases.
- What this isn’t: a markup or a punishment for using MCP. We pass through actual bytes shipped. The other clients are cheaper because compression works reliably on those transports; we don’t punish you for the protocol choice, but we have to be transparent about the cost shape.
- What you can do: for very large recurring queries (e.g. 100K+ row event exports), prefer the Excel / Sheets / Nova path. For interactive AI tool calls (the typical 100–5,000 row response that fits in an LLM context), MCP is the right choice and the cost difference is in cents.
Frequently asked questions
Do I need to open ports or run a VPN to use this? +
https://mcp.querystreams.com from the public internet, so if outbound HTTPS works on the agent host, MCP works. See how the outbound-only connection works →
Which AI tools can I use with Query Streams MCP? +
Can I revoke an MCP key? +
/mcp page, per-org via plan settings, and platform-level), none of which need a database password rotation or agent restart. More on revoking keys and MCP key security →
How is MCP usage billed against my data realm? +
compressedBytes); MCP runs over Streamable HTTP, which doesn’t reliably support compression end-to-end through every client and proxy, so we bill uncompressedBytes. A 1 MB result returned to Excel typically costs ~150–250 KB of your data realm; the same 1 MB result returned to Cursor over MCP costs ~1 MB. We’re transparent about it because we’d rather you know up front than be surprised at the end of the billing cycle.
Does Query Streams MCP work with my GA4 property + custom dimensions and event parameters? +
ga4_events table and on every projection (ga4_page_performance, ga4_user_acquisition, ga4_conversions, ga4_traffic_sources) that includes them. Schema Intelligence detects custom dimensions on the first sync and includes them in the LLM’s view of the schema with semantic types, sample values, and enum distributions where applicable — so a column you defined as “customer_tier” with values free/pro/enterprise shows up to the AI as a status_code enum, not as an opaque varchar. You can register multiple GA4 properties as separate connectors (e.g. main site + blog + mobile app) and the LLM picks the right one by name. Universal Analytics, the deprecated predecessor, is not supported — GA4 only.
How does this differ from running an open-source GA4 MCP server myself? +
event_logs, and the same data-realm billing pipeline you already use — none of which a direct MCP gives you. And on the GA4 side specifically, the cached SQL surface (with the YYYYMMDD date semantic-type annotation, the engagement-rate percentage hint, and discovered enum values for event_name) gives the LLM far better first-shot accuracy than translating natural language straight into a GA4 Data API runReport call.
What happens if the AI tries to write or delete data? +
qs_run_query call is parsed by a hardcoded read-only validator that allows only SELECT, WITH, and EXPLAIN statements; anything else returns READONLY_VIOLATION and never reaches the GA4 cache. The validator runs in the agent process on your network, not in the cloud, so a compromised cloud surface couldn’t bypass it. (The GA4 Data API itself is read-only too, but the same protection applies to every other connector you might add — PostgreSQL, MySQL, etc.)
Can I see what the AI actually asked? +
event_logs with the org, user, key, scope, latency, and result code. The org-admin can answer “who used MCP last week, which connector, and what did they ask?” with a single query. Note that we log the tool name and metadata, not the SQL text or returned rows — those flow through the cloud link and never land in cloud logs. For GA4 specifically the event_logs table is also your only audit trail: unlike most databases, the GA4 Data API does not expose an admin audit log to OAuth applications, so the agent-side log is the source of truth for “who queried which property, when”.
Do I have to run Schema Intelligence to use Query Streams MCP? +
(connector, database) pair, and MCP works fine without it. The AI gets bare schema (types, primary keys, formal foreign keys, indexes) and writes basic queries. With SI enabled, the AI gets six additional layers of curated metadata: (1) AI-curated descriptions on every database, table, and column; (2) table classifications (FACT for transactional events, DIM for descriptive reference, LOOKUP for small code maps) plus a business domain tag (sales, hr, seo, finance, support, and 14 more); (3) a semantic type on every column (currency, email, date_yyyymmdd, status_code, percentage, ranking_position, identifier, url, person_name, and 9 more) that drives dialect-correct SQL generation; (4) sample values from your real data so the LLM recognises patterns no schema can show; (5) enum detection with full value distributions for low-cardinality columns; and (6) AI-discovered foreign keys based on cross-table data overlap, surfaced through qs_get_relationships. Without SI, every schema-tool response also carries an si_recommendation block listing exactly what’s missing for the call — the AI can read this and offer to trigger SI mid-conversation via qs_request_si_analysis. Run time scales with table count: a small database under 100 tables completes in around 10 minutes; a typical mid-size database (a few hundred tables) finishes in 15–25 minutes; a large enterprise database with 1,500+ tables can take 45–60 minutes for a full scan. SI runs through your Network Agent against your data (never in the cloud), never writes to your database, never changes your schema, and refreshes incrementally when your schema changes — so subsequent runs after you add or alter tables are much faster than the first one. The end-to-end effect: with SI enabled, your AI client writes correct SQL on the first try far more often than it does against any “MCP for X” server that just hands the LLM information_schema.
What if I add another connector later, like Stripe or PostgreSQL? +
qs_list_connectors picks it up automatically), so one config block buys your whole account, present and future. Why one key covers every connector →
Do I have to set up MCP just to chat with my data? +
Get started
Connect your AI tool to your GA4 data in five minutes.
One google analytics mcp key reaches GA4, every database, and every other API connector in your Query Streams account — with full audit trail, per-key rate limits, and zero firewall changes. Whether your stack is Claude + GA4, Cursor + GA4, ChatGPT, or Grok, the same key and the same Network Agent serve every client.
Related guides: Download the Query Streams Agent | API Connector Setup | All MCP Server guides | Nova AI text-to-SQL
Category: MCP Server
Tags: mcp, claude, cursor, chatgpt, grok, google-analytics, ga4, web-analytics, marketing-analytics, api-connector, ai
Meta Description: Connect Claude or Cursor to Google Analytics 4 via MCP. Query GA4 data with AI in plain English. Free.


