gam-mcp
Provides read-only analytics and reporting for Google Ad Manager, including revenue, pacing, fill rate, ad unit and line item performance, and related publisher metrics.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
gam-mcp
Read-only MCP server for Google Ad Manager analytics. Lets an LLM (Claude Desktop, Claude Code, any MCP client) answer real publisher questions — what's revenue WoW, which line items are under-pacing, what's our fill rate by buyer network, which ad units drove yesterday's revenue — without writing report builders by hand.
29 tools over HTTP, 33 over stdio (stdio adds 4 saved-query tools that HTTP does not register) — descriptive ("what is happening"), comparative ("compared to what"), and diagnostic ("what's at risk") analytics. Generic across publishers — no per-network assumptions baked in.
What's new in 0.6.0
A correctness release for the analytics tools. The shared report path, the result cache and the tool-input contract were rewritten.
Reports are reused, not redefined. A report is named after the hash of its definition, so an identical query reuses the one already in the network instead of defining another. Results are cached in memory, and optionally on disk so reuse survives a restart.
Large results are paged, not buffered.
fetch_report_pagewalks a result with a cursor; every page carries the same provenance.Every result explains itself. A
provenanceblock names the report and result, the run time, the resolved date range, the network's reporting time zone and the zone dates were chosen in, the currency, and whether the cache was hit.Computed numbers are labelled as computed. Anything the server derives rather than reads from GAM sits under a
derivedobject carrying itsmethod,inputs, and whether a heuristic was used — so a caller can tell a measurement from an estimate.Unknown tool arguments are refused by name. A typo or a stale field returns
INVALID_INPUTnaming the key instead of being silently dropped.Ranked tools really rank.
top_nsorts by the metric in the summary and caps the rows.Entity rows carry IDs beside names, so two entities sharing a display name no longer merge into one row.
Bad configuration fails at startup, not on the first query — the credential and network code are checked before any tool is served, and a
GAM_TIMEZONEthat isn't a real IANA zone is refused rather than silently misinterpreted.Ambiguity is an error. A name matching more than one entity returns
AMBIGUOUS_NAMEwith the candidates, instead of silently picking the first.An optional HTTP transport with a Host allowlist, optional bearer token, and a request body limit.
0.6.0 contains breaking changes — see the CHANGELOG for the full list, and the upgrade notes in Configuration and Troubleshooting below.
Related MCP server: google-analytics-mcp-server
Install
You don't. Add it to your MCP client config and let npx fetch it on first use.
Setup
Provision a service account in Google Cloud Console with Ad Manager API access:
Create a project (or pick one).
Enable the Google Ad Manager API.
Create a service account, generate a JSON key, download it.
In Ad Manager (UI): Admin → Access & authorization → API access, add the service account email and grant it the read role you need (e.g., "Reports user" or higher).
Add to your MCP client config:
Claude Desktop (
~/Library/Application Support/Claude/claude_desktop_config.json):{ "mcpServers": { "google-ad-manager": { "command": "npx", "args": ["-y", "gam-mcp"], "env": { "GAM_NETWORK_CODE": "1234", "GAM_SERVICE_ACCOUNT_KEY_FILE": "/Users/me/secrets/gam-sa.json", "GAM_TIMEZONE": "Asia/Tokyo" } } } }Claude Code — add the same
mcpServersblock to.mcp.jsonat your project root or to your global Claude Code config.Alternative credential sources — if mounting a key file isn't convenient (containers, hosted MCP), use one of:
// inline JSON (raw or base64-encoded) "env": { "GAM_NETWORK_CODE": "1234", "GAM_SERVICE_ACCOUNT_KEY_JSON": "eyJ0eXBlIjoic2VydmljZV9hY2NvdW50Ii4uLn0=" }// Application Default Credentials — no key vars needed // (works on GCE/Cloud Run, or locally after `gcloud auth application-default login`) "env": { "GAM_NETWORK_CODE": "1234" }Restart your MCP client.
Configuration
Env var | Required | Default | Purpose |
| yes | — | Numeric network code |
| one-of | — | Absolute path to service-account JSON. Wins over |
| one-of | — | Service-account JSON inline, either as raw text or base64-encoded. Useful in hosted environments (Cloud Run, Fly, Render) where mounting a key file is awkward. Eagerly parsed at startup — a malformed value fails fast. |
(none of the above) | one-of | — | Falls back to Application Default Credentials. Picks up |
| no | the network's own time zone | IANA name choosing which calendar dates are requested. It does not change the zone GAM counts days in — every report is sent with |
| no | 5000 | Rows returned per page of report results, clamped to 10000 (values above the cap are used as 10000 and logged once as |
| no | 300000 | Max time to poll one report job, in milliseconds — digits only ( |
| no |
| One of |
| no |
| Path to the saved-query JSON store used by |
| no | (off — in-memory only) | When set, stores a reference to each report result — report name, result name, row count, run time, never rows — as one JSON file per entry, at |
| no | 3600000 (1h) | How long a cached result reference is reused, in milliseconds — applies to both the in-memory and disk tiers. |
| no | (off — stdio mode) | When set, the MCP listens for Streamable-HTTP requests on this port at |
| no | (off) | HTTP mode only — see the HTTP transport notes below. |
| no | (off — no Host check) | HTTP mode only — see the HTTP transport notes below. |
Report cache
GAM_REPORT_CACHE_DIR adds a disk tier on top of the in-process one. Each distinct report definition gets its own file at <dir>/<network code>/<64-character hex definition hash>.json, holding a reference to the GAM result that answered it — the report name, the result name, the run time, the date range GAM computed, and the row count — never report rows. Rows are always fetched fresh from GAM on every call, cache hit or not; only the pointer to which result to read is what gets reused.
Nothing sweeps the directory on a schedule. The in-process tier is bounded (an LRU of 1000 entries), but the disk tier is not — it grows by roughly one small file per distinct query shape you run, indefinitely, unless something removes it. The only automatic removal is per-entry and happens on access: a file is re-read the next time its own definition is requested, and if GAM_REPORT_CACHE_TTL_MS has passed by then, that read deletes it and gam-mcp runs the report again. A file this server can't make sense of — one that fails to parse, or names another network's report — is simply ignored on every read; it is left in place, not deleted. Deleting the whole directory, or any file in it, is safe at any time: the worst case is a handful of reports being re-run on the next matching call.
Upgrading from 0.5.x: that version's disk cache wrote gzip-compressed row dumps directly into GAM_REPORT_CACHE_DIR (<sha256-of-key>.json.gz, one level, no per-network subdirectory). 0.6.0 writes into a <network code>/ subdirectory instead and only ever opens the exact .json path its own hash names — it never lists the directory — so it will neither read nor delete those old .json.gz files. They just sit there, inert. Delete the directory when you upgrade if you want the space back; nothing breaks if you don't.
provenance.cache.hit on a report's first page means that call obtained its result from the cache tier instead of starting (or resuming) a fresh GAM report job. A page fetched with fetch_report_page, though, always reports cache.hit: false — even when the result it is paging through was itself served from cache on the call that produced the cursor. Fetching a further page never re-enters the cache lookup at all; it fetches the next page of an already-open result directly. Read cache.hit as "this call's own first page came from the cache," not as a property of the underlying result.
HTTP transport
Setting GAM_HTTP_PORT switches the server from stdio to Streamable HTTP: requests go to POST /mcp (GET /healthz for liveness probes) on that port instead of the MCP frames going over stdio.
GAM_HTTP_BEARER_TOKEN— when set, every request to/mcpmust carryAuthorization: Bearer <token>; a missing or wrong token is refused401./healthzdeliberately skips this check, so a probe that only reaches the container directly still works. Leaving the token unset does not stop the server from starting: it logshttp.unauthenticatedonce at startup and then serves every request to/mcpwith no authentication at all.GAM_HTTP_ALLOWED_HOSTS— a comma-separated list of host names (no ports). A request whoseHostheader names anything else is refused403, checked before the bearer token. Leave it unset and there is no Host check at all.Body size — a request body over 1 MiB is refused
413, whether that is obvious fromContent-Lengthup front or only discovered once the body is already streaming in.A busy port — if
GAM_HTTP_PORTis already bound by something else, startup stops with exit code 2 and a message naming the variable and the port (GAM_HTTP_PORT <port> is already in use by another process), instead of the server half-starting. 0.5.2 didn't handle this at all: the same situation surfaced as an unhandled error, and the process exited 1 with a raw stack trace instead of a message naming the cause.
Tools
Tool | Purpose |
Descriptive | What's happening |
| Total revenue/impressions, optionally grouped by day/week/month/advertiser/order/line_item/ad_unit/country/device/line_item_type |
| Top-N by revenue or impressions, with context |
| Top values of a publisher-configured custom-targeting key, by revenue or impressions, optionally narrowed to one ad unit / order / line item. Requires the key's ID — discover it via |
| Programmatic vs direct vs house split by |
| Time series at day/week granularity, optionally split by one dimension |
| Fill-rate funnel by ad_unit / device_category / country / day |
| Current-period delivery per line item (note: pacing % vs goal not directly available — use |
| Open Bidding (EBDA) yield by bidder — AdX impressions, revenue, average eCPM per |
| Yield-group (Open Bidding / mediation) yield — impressions, estimated revenue, estimated eCPM, mediation fill rate, and passbacks per partner ( |
| Video completion funnel — starts → 25% → 50% → 75% → completes + completion rate, by ad_unit / placement type / size / duration. Optional secondary slice by day / country / device. |
| Active View viewability — viewable / measurable / eligible impressions + viewable & measurable rates, by ad_unit / size / device. Optional secondary slice by day / country / device. |
| Unique audience and delivered frequency from GAM's Reach report type — total unique visitors (deduplicated people, not cookies), total reach impressions, and average impressions per unique visitor, by line_item / order / advertiser / ad_unit, optionally sliced by country or day and filtered to specific IDs. Use it to size a frequency cap from what a campaign actually delivered. Reach metrics come from a separate GAM report type, so they can't be mixed with revenue/impression metrics; unique counts are not additive across rows. Ad-server/reservation delivery only (excludes AdX and AdSense), ~3-day lag, ~1-year retention. |
| Ad latency and page-speed diagnostics ( |
| Forward-looking inventory availability ( |
| Privacy and user-messaging performance ( |
| "Codeless" ad units — those that received fewer than |
Comparative | Compared to what |
| Run any report twice and get per-row deltas — WoW, MoM, YoY, or explicit. Output rows carry |
Diagnostic | What's at risk |
| Four kinds: |
| Infer AdX floor-price effectiveness per ad unit from the match-rate × eCPM relationship vs the network median. Verdicts: |
| Explain why ad units have low fill. Runs the AdX funnel report (requests → routed to AdX → AdX match → ad-server response → unfilled) + WoW comparison, then attributes a single primary cause per row: |
Power tools | The escape hatches |
| Generic GAM Reports query — pick any dimensions/metrics from |
| Fetch the next page of rows from a result any other report tool returned, by passing back its |
| High-level KV-narrowed report: give |
| Name ↔ ID resolution for advertisers, orders, line items, ad units, placements, companies, custom_targeting_keys. Lists up to 1000 with transparent pagination. |
| Read a line item's configuration rather than its delivery — status, flight dates, type/priority, rate and goal, frequency caps, delivery and rotation settings, creative placeholders, and |
| Browse the dimensions and metrics this MCP can query — the complete GAM REST enum: 764 dimensions and 526 metrics. Filter with |
Saved queries | Templates the analyst can stash and replay |
| Persist a |
| List every saved template with name, description, and save timestamp. |
| Replay a saved template against a fresh |
| Delete a saved template by name. |
Operations | Diagnose the MCP itself |
| End-to-end probe — verifies auth + network + permissions by listing one company. On failure, returns |
| Session-to-date counters: GAM API calls by type, report-job count, cumulative report latency, cache hits/misses with hit-rate. Lets the LLM self-pace and the analyst spot redundant work. |
Resources
The server also advertises an MCP resources capability so the LLM (or client UI) can browse the curated schema without spending a tool call:
URI | Content |
| Full curated dimension + metric catalog with descriptions. |
| Dimensions only. |
| Metrics only. |
| The configured network's identity: |
Prompts
The server ships preset workflows under the MCP prompts capability. These show up as user-invokable templates in clients that surface prompts (e.g. Claude Desktop):
Prompt | Arguments | Purpose |
|
| Pacing + fill-rate + eCPM + viewability anomalies for the past week, with a "top 3 to fix" summary. |
|
| Close-of-month revenue: total, mix, top advertisers, YoY comparison. Defaults to last full month. |
|
| Investigate a fill-rate drop: enumerate affected ad units, quantify lost revenue, identify likely cause. |
Example queries
Things an LLM with this MCP attached can answer directly. (No prompts engineering required — just ask.)
WoW revenue check. "How does last week's revenue compare to the week before?" →
compare_periods({dimensions:["DATE"], metrics:["REVENUE"], base_range:{relative:"last_7_days"}, comparison:"previous_period"}).Programmatic vs direct mix. "What's the demand-channel breakdown for the last 30 days, with eCPM per channel?" →
inventory_breakdownplus arun_reportslice onLINE_ITEM_TYPE.Buyer network share. "Which DSPs spend the most on us?" →
run_report({dimensions:["BUYER_NETWORK_NAME"], metrics:["AD_EXCHANGE_REVENUE","AD_EXCHANGE_AVERAGE_ECPM"], date_range:{relative:"last_7_days"}}).Pacing risk. "Which line items are under-pacing this month?" →
find_anomalies({kind:"pacing_underdelivery", top_n:20}).Fill-rate regression. "Did any ad units have a fill-rate drop this week?" →
find_anomalies({kind:"fill_rate_drops", threshold_pct:5}). 5a. eCPM regression. "Which DSPs are paying us less this week than last?" →find_anomalies({kind:"ecpm_regression", threshold_pct:10}). 5b. Viewability regression. "Any ad units where viewability tanked?" →find_anomalies({kind:"viewability_drops", threshold_pct:5}). 5d. Fill-rate root cause. "Why is one of my ad units only filling 30%?" →diagnose_fill_rate({ad_unit_query:"<part of the ad unit name>"}). Returns funnel-position ratios with an attributed cause per row. 5c. Open Bidding yield. "Which Open Bidding bidders drove the most revenue last week, and on which devices?" →bidder_breakdown({date_range:{start:"2026-05-04", end:"2026-05-10"}, group_by:"device"}). 5e. Yield-group waterfall health. "Which Open Bidding partners have low fill and high passbacks?" →yield_breakdown({date_range:{start:"2026-05-04", end:"2026-05-10"}, by:"buyer"}). 5f. Video drop-off. "Where do viewers abandon my video ads by placement type?" →video_breakdown({date_range:{start:"2026-05-04", end:"2026-05-10"}, by:"placement"}). 5g. Low-viewability inventory. "Which ad sizes have the worst viewable rate?" →viewability_breakdown({date_range:{start:"2026-05-04", end:"2026-05-10"}, by:"size"}). 5i. Frequency cap from evidence. "What frequency cap should this direct campaign use?" →reach_report({date_range:{start:"2026-05-01", end:"2026-05-31"}, by:"line_item", ids:[<line_item_id>]})— returns unique visitors and the average impressions each one already received, so the cap is set against observed frequency instead of a guess. 5j. Slow ads, not bad placements. "Viewability is poor on mobile — is it the placement or the page?" →ad_speed({date_range:{start:"2026-05-04", end:"2026-05-10"}, by:"device", focus:"unviewed_reason"}). A high "scrolled before ad loaded" share is a speed problem; "slot never entered viewport" is a placement problem. 5k. Can we take the booking? "An advertiser wants 5M impressions next month — do we have it?" →sell_through({date_range:{start:"2026-06-01", end:"2026-06-30"}, by:"ad_unit"})and readavailable impressions. 5l. Cost of consent. "What share of EU users consent, and how does that vary by country?" →consent_messaging({date_range:{start:"2026-05-01", end:"2026-05-31"}, focus:"eu_consent", group_by:"country"}). 5h. Floors set too high. "Where are my AdX floors costing me fills?" →diagnose_floor_pricing({lookback_days:7})— surfacesfloor_likely_highad units ranked by recoverable revenue.Specific ad units. "Revenue and impressions for our Nimbus placements last week." →
run_reportwithfilters:[{field:"AD_UNIT_NAME", op:"CONTAINS", value:"Nimbus"}].AdX yield diagnosis. "AdX match rate and average eCPM per ad unit yesterday." →
run_report({dimensions:["AD_UNIT_NAME"], metrics:["AD_EXCHANGE_TOTAL_REQUESTS","AD_EXCHANGE_MATCH_RATE","AD_EXCHANGE_AVERAGE_ECPM"], date_range:{relative:"yesterday"}}).Custom dimension breakdown. "Revenue by section." → first
lookup({entity_type:"custom_targeting_key", query:"section"})to find the key ID, thenrun_report({dimensions:["CUSTOM_DIMENSION_0_VALUE"], metrics:["IMPRESSIONS","REVENUE"], date_range:{relative:"last_7_days"}, custom_dimension_key_ids:[<that_id>]}).YoY comparison. "How does last month's revenue compare to the same month last year?" →
compare_periods({base_range:{relative:"last_full_month"}, comparison:"previous_year", dimensions:["DATE"], metrics:["REVENUE"]}). (month_to_dateworks too, except on the first day of a month, when there's no complete day yet to report — it returnsINVALID_DATE_RANGE;last_full_monthavoids that edge case entirely.)Top advertisers in a country. "Top advertisers in Germany this month." →
top_advertiserswith aCOUNTRY_NAMEfilter.
Schema notes
describe_schemareturns the full GAM catalog. Read it before composingrun_reportqueries — but filter it: 1290 entries with prose will swamp a context window.describe_schema({report_type:"REACH"})ordescribe_schema({search:"viewab"})is almost always what you want.
Schema provenance
src/schema-generated.ts is generated from Google's report_definition.proto — it is the complete REST Metric, Dimension, and ReportType enums, including each entry's report-type compatibility and its data format (which determines whether a metric reads as a count, a currency, or a rate). Hand-written descriptions and the observed incompatibility matrix live in src/schema-overrides.ts and are merged over the generated entries, so regenerating never destroys curated prose.
npm run refresh-schema # regenerate src/schema-generated.ts from the proto
npm run schema:gap # diff generated vs whitelisted; flags drift both waysschema:gap reports names GAM has that we lack and names we whitelist that GAM no longer declares. The second direction matters more: a whitelisted-but-nonexistent name passes local validation and then fails against the live API.
Report types
GAM runs each report family as a distinct reportType, and a request is wholly one type. This server derives the type by intersecting the report types every requested dimension and metric accepts, so callers never pass it — and asking for, say, reach and historical metrics together is rejected locally with a message naming which side wants which type, instead of a generic GAM 400.
HISTORICAL and REACH have purpose-built tools. The other ten types in the enum are reachable through run_report (their metrics are whitelisted) but are forwarded unverified — you'll get a warning on the envelope saying so.
KEY_VALUES_NAMEoverlap caveat: one impression can match multiple key-value pairs, so summing impressions/revenue across rows OVERSTATES the true total. Use it to rank active KVs, not for share-of-total math. For clean aggregation, useCUSTOM_DIMENSION_<N>_VALUEwithcustom_dimension_key_ids— those slots are mutually exclusive (one value per request).CUSTOM_DIMENSION_<N>_VALUEis publisher-configured. Slot 0 means whatever your network admin has mapped to it (might besection, might betier, might be unused). Discover vialookup(entity_type="custom_targeting_key").No EQUALS in GAM. The
=and!=filter ops are aliases the MCP translates toIN/NOT_INwith a single value. Substring search usesCONTAINS/NOT_CONTAINS(literal substring, no wildcards).AD_REQUESTSandUNFILLED_IMPRESSIONScan't be sliced byLINE_ITEM_TYPE— those metrics live at the request stage before any line item is selected. Use them at the network or ad-unit level only.
Reliability
Retries — automatic exponential backoff on 429/5xx and network errors (4 attempts, 250ms base + jitter). 4xx surfaces immediately.
Pagination —
lookuptransparently pages through GAM's 200-per-page responses up to your requestedlimit(max 1000).Report cache — an identical report definition (same dimensions, metrics, filters, sort, and resolved date range) reuses a previously obtained GAM result instead of running a fresh report job. What's reused is a reference to that result, never the rows themselves — every call still fetches its own pages from GAM. Reuse has a TTL of one hour by default (
GAM_REPORT_CACHE_TTL_MS), applied to both the in-process tier and the optional on-disk tier (see Report cache above);0turns reuse off entirely.Every report tool leaves a report object behind in your GAM network. Before gam-mcp can read a result, it defines a report for the exact query it is about to run via the GAM REST API. That report is created
HIDDEN(it never appears in the Ad Manager UI), and the REST API gives gam-mcp no way to delete it. gam-mcp names each report after the SHA-256 hash of its own definition — dimensions, metrics, filters, sort, and the resolved date range — and reuses that same object for every later call whose hash matches; the count in your network is bounded by the number of distinct (query shape, resolved date range) combinations you've asked for, not by the number of calls, but that count never goes back down. Because the resolved date range is part of the hash, a tool queried with a fixeddate_rangedefines at most one report per shape, while a rolling window (e.g. "last 7 days", run daily) resolves to a different start/end every day and so defines a new report every day it runs. Four tools cannot be pinned to a fixed window at all:find_unused_ad_units,diagnose_fill_rate, anddiagnose_floor_pricingtake onlylookback_days(nodate_rangefield in their input), andfind_anomaliestakes no window input whatsoever — it always uses a hardcoded 7-day lookback. Calling any of those four on a recurring schedule (e.g. a daily cron) defines one new hidden report per tool, every day, forever. This is a permanent, cumulative footprint on whichever network gam-mcp is pointed at — worth knowing before you point it at one, not after.
Troubleshooting
"AUTH_FAILED" — verify
GAM_SERVICE_ACCOUNT_KEY_FILEpath is readable and the service account has API access in the Ad Manager UI."REPORT_TIMEOUT" — narrow the date range, or set
GAM_REPORT_TIMEOUT_MS=900000for 15 minutes. GAM is still running the job: it is not abandoned on timeout, so calling the same tool with the same input again resumes waiting on that same operation instead of starting a second one."REPORT_ERROR_CONSTRAINTS_INCOMPATIBILITY" — some dimension/metric combos are forbidden by GAM (e.g.,
AD_REQUESTS×LINE_ITEM_TYPE). Split into separate queries."REPORT_ERROR_MISSING_DYNAMIC_DIMENSION_ID_AT_INDEX" — you queried
CUSTOM_DIMENSION_<N>_VALUEwithout supplyingcustom_dimension_key_ids[N]. Look the key ID up vialookup(entity_type="custom_targeting_key")."INVALID_DATE_RANGE" on a period-to-date range (
month_to_date,quarter_to_date,year_to_date) — on the first day of that period there is no complete day yet to report. Use an explicit{start, end}range, or a range that names a prior complete period (e.g.last_full_month), or retry after that day has ended."AMBIGUOUS_NAME" — a name-based lookup (an advertiser, order, line item, ad unit, or custom targeting key) matched more than one entity; 0.5.2 silently took the first match, 0.6.0 refuses. Inspect
details.candidatesin the error and re-run with a specific numeric ID instead of the name."DUPLICATE_JOIN_KEY" —
compare_periodsfound two rows in the same period that reduce to the same join key, so it can't tell which one the other period's row should be compared against. Add a more granular dimension (e.g. an ID rather than just a name) so each row's key is unique."RESULT_TOO_LARGE" — the report has more rows than this call can return: over 50,000 rows for a tool that reads a whole report into memory (e.g.
find_anomalies), or more than the configured page size for a paged result. Narrow the date range, add filters, or request fewer dimensions."REPORT_RESULT_EXPIRED" — GAM no longer serves the report result a
fetch_report_pagecursor (or a reused report) pointed at; GAM keeps report results for a limited time. Re-run the original tool call — notfetch_report_page— and it will run the report afresh.Startup stops with exit code 2 — several conditions do this, each named on stderr: a missing or non-numeric
GAM_NETWORK_CODE; an unrecognizedGAM_TIMEZONE(or a raw UTC offset instead of an IANA name); a non-numeric/out-of-rangeGAM_REPORT_TIMEOUT_MS,GAM_REPORT_CACHE_TTL_MS, orGAM_PAGE_ROWS; aGAM_REPORT_CACHE_DIRwhose directory can't be created; an invalidGAM_HTTP_PORT,GAM_HTTP_BEARER_TOKEN, orGAM_HTTP_ALLOWED_HOSTS; aGAM_HTTP_PORTalready in use by another process; or a credential that can't authenticate or read the configured network. Fix the named variable and restart."
gam-mcp: GAM_NETWORK_CODE is required" — the env var didn't make it into the subprocess. Check your MCP client config'senvblock.Logs go to stderr, not stdout. If your MCP client is hiding them, check its log file.
Development
git clone <this repo>
cd gam-mcp
npm install
npm test # unit tests with synthetic fixtures; no credential needed
npm run build # tsc → dist/
GAM_NETWORK_CODE=... GAM_SERVICE_ACCOUNT_KEY_FILE=... npm run smoke
# opt-in: hits real GAM end-to-end, through the library
GAM_NETWORK_CODE=... GAM_SERVICE_ACCOUNT_KEY_FILE=... \
npm run smoke:transports -- --yes
# opt-in: drives the packaged dist/cli.js over BOTH
# stdio and HTTP, then repeats the run in a fresh
# process to prove report reuse works across processes
GAM_NETWORK_CODE=... GAM_SERVICE_ACCOUNT_KEY_FILE=... \
npm run smoke:transports -- --yes --define-ad-unit-report
# opt-in (separately from --yes): also calls
# find_unused_ad_units once, over stdio, to check its
# AdUnit field names against the live API. This
# DEFINES A NEW HIDDEN, UNDELETABLE REPORT every
# distinct calendar day it runs (see below), so it is
# not part of a routine smoke run
GAM_NETWORK_CODE=... GAM_SERVICE_ACCOUNT_KEY_FILE=... npm run verify:pack
# release gate: pack tarball, install in tempdir,
# exercise the bin as a real MCP client wouldsmoke:transports refuses to start without --yes: it runs against a live network and defines a report
object, which the Ad Manager API creates hidden and cannot delete. It uses one fixed date range for every
run so it only ever defines one such report — later runs find that report again instead of adding another.
Override GAM_SMOKE_DATE_START / GAM_SMOKE_DATE_END if GAM has aged that window out of retention.
With --define-ad-unit-report (or GAM_SMOKE_DEFINE_AD_UNIT_REPORT=yes), it also exercises
find_unused_ad_units once, on the stdio run only. That tool filters on AdUnit.status === 'ACTIVE' and
derives leaf ad units from AdUnit.parentAdUnit, and neither field name was ever confirmed against the
live API — no unit test can confirm a live API's field spelling, because every fixture is written by
whoever wrote the code reading it. Because a missing status is treated as not-active, a wrong field name
fails totally, not partially: every ad unit gets excluded and the tool returns zero rows on every call,
silently, forever. The smoke script fails loudly on exactly that signature — ad units listed and every one
excluded — while still passing on a network with genuinely no ad units.
This check is a separate opt-in from --yes, not part of a routine smoke run, because it is
unavoidably expensive: find_unused_ad_units has no date_range input, only lookback_days, which
resolves against today's date, so unlike run_report's fixed window, its report definition changes every
calendar day — every day this flag is used defines another new hidden, undeletable report in the
network. Without the flag, the script prints one line on stderr saying the check was skipped and how to
run it, rather than skipping it silently.
npm publish is gated by prepublishOnly which runs build + tests + verify:pack — a publish can't ship a broken artifact.
See CLAUDE.md for design principles when extending the schema or tools (notably: this is a generic GAM MCP — no publisher-specific assumptions).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Read-only Google Analytics 4 MCP server for AI assistants.
Read-only Google Search Console and Google Analytics for AI agents.
Read and edit GA4, Search Console and Google Tag Manager from any MCP client. 29 tools.
Query selected Google and Bing analytics, search, and advertising reports through MCP.
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables LLM applications to query Google Analytics 4 data through standard MCP interfaces, supporting real-time data, custom reports, and metadata discovery.564 npm1MIT
- AlicenseAqualityBmaintenanceEnables MCP clients to query Google Analytics 4 reporting and configuration data through 27 read-only tools, including pivots, funnels, realtime reports, Admin API inspection, and diagnostics, with identifiers redacted by default.27Apache 2.0
- FlicenseAqualityCmaintenanceRead-only MCP server that connects Claude Desktop to the publisher-side Ad Manager API so users can browse networks, saved reports, orders, and line items, and run saved reports to pull their rows into a conversation. No tool mutates data, and per-user OAuth ensures each person inherits only their existing account permissions.5-
- AlicenseNot gradedqualityNot gradedmaintenanceEnables MCP clients to query Google Analytics 4 and Google Search Console through OAuth-authenticated, read-only tools. Exposes 17 capabilities covering account and property listings, custom, realtime and pivot reports, key events, plus site, sitemap and URL inspection data.MIT