Connect Google Analytics to VS Code
Query GA4 properties, reports, audiences, and events. Add Toolspoke to VS Code once and it can use 12 Google Analytics actions. Your Google Analytics credential stays in Toolspoke, and you choose which actions VS Code may call.
Set it up in VS Code
Three steps, the first one once for every toolkit you will ever add.
Add Toolspoke to VS Code
.vscode/mcp.json, or the MCP: Add Server command
{ "servers": { "toolspoke": { "type": "http", "url": "https://toolspoke.com/mcp" } } }Approve the authorization request when VS Code opens it.
Install Google Analytics and connect it
Add Google Analytics to a project in your Toolspoke workspace.
Press connect and sign in to Google Analytics. Toolspoke keeps the token encrypted and refreshes it when it expires, so there is nothing to copy and nothing to rotate by hand.
Choose what VS Code may do
All 12 actions only read, and any of them can be switched off for a project.
What you can ask VS Code for
A few of the Google Analytics actions that only read, so they are safe to try first.
- List the Google Analytics accounts the connected user can reach, each with the GA4 properties underneath it
- List GA4 properties
- List a property's custom metrics
- Look up the dimension and metric API names a property supports, including its custom definitions
What VS Code can do in Google Analytics
12 actions read.
Reads
List accounts
List the Google Analytics accounts the connected user can reach, each with the GA4 properties underneath it. Call this first when you do not know which property ID to report on.
List properties
List GA4 properties. Pass account_id to list only the properties under one account; omit it to flatten every property from every account the user can reach. Returns the numeric property IDs the reporting actions need.
Get property
Fetch the configuration of one GA4 property, display name, time zone, reporting currency, industry category and creation time. Read the time zone and currency from here before interpreting date ranges or revenue metrics.
List data streams
List the web, iOS and Android data streams feeding a GA4 property, including the web measurement ID and stream URLs. Use it to confirm which site or app a property actually collects data from.
List custom dimensions
List the custom dimensions and custom metrics registered on a property, with the API names to use in run_report (customEvent:name, customUser:name). Check here before assuming a business-specific field is reportable.
List custom metrics
List a property's custom metrics. Call list_custom_dimensions for its custom dimensions.
List dimensions and metrics
Look up the dimension and metric API names a property supports, including its custom definitions. Call this when run_report rejects a field name, or to discover the exact spelling of a field before building a report. Results are searchable and capped, so pass a search term rather than fetching the whole catalogue.
Run report
Run an arbitrary GA4 report: pick dimensions, metrics, a date range, sorting and an optional filter. This is the general-purpose reporting action, use it for anything the top_pages and traffic_sources presets do not cover. Field names must be GA4 Data API names (activeUsers, sessions, pagePath, sessionDefaultChannelGroup); look them up with list_dimensions_and_metrics if a name is rejected. Rows come back as flat objects keyed by field name.
Realtime report
Report on activity in the last 30 minutes. Only the realtime schema is available: metrics activeUsers, screenPageViews, eventCount, keyEvents; dimensions country, city, deviceCategory, platform, eventName, unifiedScreenName, audienceName, streamId, minutesAgo. Use it for 'who is on the site right now' questions.
Top pages
Rank the most-viewed pages or screens over a date range with views, active users and engagement time. A preset over run_report for the common 'what content is performing' question.
Traffic sources
Break traffic down by acquisition channel, source/medium or campaign over a date range, with sessions, users, engagement and revenue. A preset over run_report for 'where are visitors coming from' questions.
Check compatibility
Check whether a set of dimensions and metrics can appear in the same GA4 report before running it. Call this when run_report fails with an incompatibility error, the response says which fields clash and which remain usable.
Google Analytics in VS Code: questions
Does VS Code see my Google Analytics credential?
No. The credential is stored encrypted in Toolspoke, and the gateway adds it to each call. VS Code only ever talks to Toolspoke, and the dashboard shows the last four characters of the credential and nothing more.
Will 12 actions crowd VS Code's context?
No. Toolspoke shows VS Code five bridge tools, plus a guide where a toolkit has one, and VS Code searches for the Google Analytics action it needs when it needs it. Adding more toolkits does not add more tools to its list.
Where do the tools show up in VS Code?
In chat, in agent mode, which is where VS Code uses MCP servers. Add the block to .vscode/mcp.json for one workspace, or use the MCP: Add Server command.
What does it cost?
Tool calls are free on every plan, and a Google Analytics call does not run in a sandbox, so it bills nothing.
Try Google Analytics in VS Code
Free to start, and tool calls cost nothing on any plan.