Skip to main content
Glama
google-ad-manager-mcp

google-ad-manager-mcp

by Jakob-Peters
README.md
# google-ad-manager-mcp

An MCP server for the [Google Ad Manager](https://admanager.google.com) API. It gives Claude (or any MCP client) read access to a GAM network: reports, forecasts, line item and order troubleshooting, pacing, inventory, targeting, creatives, deals and change history.

**Read-only.** 54 tools that read, report and forecast. None of them creates, changes or deletes anything in your network (see [Safety](#safety)). Not affiliated with Google.

## Why REST and SOAP

Google's new [Ad Manager REST API](https://developers.google.com/ad-manager/api/beta/reference/rest) (`admanager.googleapis.com/v1`) is still in beta and does not yet cover everything. Forecasting and forecast adjustments, creatives and line item–creative associations, line item templates, proposals, yield groups, users and teams, PQL and change history, and ads.txt diagnostics are still only available through the legacy SOAP API.

So this server is a hybrid. REST is used wherever it covers the job, pinned to a discovery revision, and SOAP (`v202605`) fills the gaps. The goal is to be REST-only: as Google moves each remaining service to REST, the matching tool moves over and its SOAP code is deleted.

## Setup

You need a Google Cloud service account with a JSON key, added in GAM under **Admin → Global settings → API access** (enable API access, then add the service account as a user with a role that can read what you need). Note your network code from the same page.

```sh
git clone https://github.com/Jakob-Peters/google-ad-manager-mcp.git
cd google-ad-manager-mcp
npm install
cp .env.example .env   # fill in GOOGLE_SERVICE_ACCOUNT_EMAIL, GOOGLE_PRIVATE_KEY, GOOGLE_AD_MANAGER_NETWORK_CODE
npm test
```

The server reads `.env` from its own directory. It starts and lists tools without credentials; tools return an actionable error until `.env` is filled in.

### Local (stdio)

Claude Code (inside this repo, `.mcp.json` registers it as `gam` automatically). From anywhere else:

```sh
claude mcp add gam -- npx tsx /path/to/google-ad-manager-mcp/src/server.ts
```

Claude Desktop (`claude_desktop_config.json`):

```json
{
  "mcpServers": {
    "gam": {
      "command": "npx",
      "args": ["tsx", "/path/to/google-ad-manager-mcp/src/server.ts"]
    }
  }
}
```

### Remote (Vercel)

`vercel deploy --prod` serves the same tools at `https://<your-deployment>/mcp` over stateless Streamable HTTP, with an unauthenticated `/health`. Set the three `GOOGLE_*` variables on the project, plus one auth mode:

- **Shared token**: set `MCP_BEARER_TOKEN` and send it as `Authorization: Bearer <token>`.

  ```sh
  claude mcp add --transport http gam https://<your-deployment>/mcp --header "Authorization: Bearer <token>"
  ```

- **Your own OAuth server**: set `JWT_SECRET` (HS256), optionally `GAM_JWT_ISSUER` / `GAM_JWT_AUDIENCE`, and `OAUTH_AUTHORIZATION_SERVER`. The server then publishes RFC 9728 metadata at `/.well-known/oauth-protected-resource`, so clients such as Claude Desktop's custom connectors can sign in.

With neither set the endpoint refuses every request. Deployment notes:

- Leave Vercel Authentication off: MCP clients cannot pass Vercel's SSO. The bearer check above is the access control.
- `catalog/**` must stay bundled (`includeFiles` in `vercel.json`), or `gam_report_metadata` fails in the function.
- The rate-limit queue and token cache are per process, so concurrent functions multiply them. Report jobs poll for up to 180 s inside a 300 s function limit.

## Tools

Tool names describe the job; descriptions carry the GAM UI's wording ("Key-values", "Traffic explorer", "Delivery tools", "Ad review centre") so the model can map UI language to the right tool.

| Area | Tools |
|---|---|
| Reporting | `gam_run_report` (Interactive Reports, presets, computed totals, `where`/`having` filters), `gam_saved_reports` (run saved UI reports, incl. ad speed), `gam_report_metadata` (dimensions, metrics and date ranges per report type) |
| Forecasting | `gam_traffic_data` (traffic explorer), `gam_forecast_availability`, `gam_forecast_existing_line_item`, `gam_forecast_delivery`, `gam_forecast_adjustments` |
| Delivery & troubleshooting | `gam_find_line_items`, `gam_get_line_item`, `gam_find_orders`, `gam_get_order`, `gam_check_pacing`, `gam_diagnose_line_item`, `gam_diagnose_order`, `gam_change_history`, `gam_line_item_templates` |
| Creatives | `gam_line_item_creatives` (incl. preview on page), `gam_find_creatives`, `gam_creative_templates`, `gam_creative_config` |
| Inventory & targeting | `gam_ad_unit_tree`, `gam_get_ad_unit`, `gam_ad_unit_sizes`, `gam_find_placements`, `gam_targeting_keys`, `gam_targeting_values`, `gam_audience_segments`, `gam_geo_lookup`, `gam_labels`, `gam_technology_targets`, `gam_suggested_ad_units` |
| Video | `gam_video_content`, `gam_cms_metadata`, `gam_ad_rules`, `gam_taxonomy_categories` |
| Deals & programmatic | `gam_find_proposals`, `gam_get_proposal`, `gam_private_auctions`, `gam_yield_groups`, `gam_programmatic_buyers` |
| Network & admin | `gam_network_info`, `gam_teams`, `gam_users`, `gam_companies`, `gam_sites`, `gam_child_publishers`, `gam_mobile_apps`, `gam_ads_txt_diagnostics`, `gam_admin_config`, `gam_ad_review_center` |
| Other | `gam_find_advertiser` (brand name → advertisers and all their orders, tolerant of spelling variants), `gam_pql_query` (PQL `SELECT`, bind variables only), `gam_submit_feedback` |

The server also ships MCP prompts (diagnose delivery, yesterday's performance, availability, recent changes) and server instructions that route questions to the right tools.

`gam_geo_lookup` answers Danish, Swedish and Norwegian locations from an offline pack (`data/geo-nordic.json`) and everything else from the live API.

`gam_submit_feedback` lets the model report friction with the tools. It writes to stderr with the marker `GAM_MCP_FEEDBACK` and, if `GAM_FEEDBACK_LOG` is set, appends to that JSONL file. It never touches GAM.

Large parts of the GAM UI have no API (billing, payments, optimisation, protections, pricing rules), so they are not here.

### Access groups

Every tool carries MCP `annotations` (`readOnlyHint` and friends) and `_meta["gam/group"]`: `read`, `reporting` (`gam_run_report`, `gam_saved_reports`, `gam_report_metadata`) or `write` (none yet). A proxy in front of the server can use them to gate tools per user. The map lives in `src/tools/groups.ts`.

## Safety

- Read-only: no tool creates, updates or deletes line items, orders, creatives, ad units, targeting or any other network setting. The only things the server creates are report and forecast jobs: reports are hidden, API-only definitions reused across identical runs, and forecasts are computed without saving anything. The service account therefore needs no edit permissions, only view access and permission to run reports.
- Tools only address `GOOGLE_AD_MANAGER_NETWORK_CODE` (and `GAM_TEST_NETWORK_CODE` when set).
- Every call goes through a rate-limit queue, because GAM quotas are shared across the network and with the UI.

## Response conventions

- **Money** is always `{amount, currency}`, converted exactly once (REST units+nanos, SOAP and report micros).
- **Rates** are fractions (0.5961 = 59.61%).
- **Dates** are ISO strings; SOAP datetimes carry the network time zone (`2026-08-24T14:58:03 Europe/Berlin`).
- **Lists** report `truncated` honestly and return a continuation token; caps and client-side filters surface a `note`.
- **Anything assumed or repaired** is flagged (`defaults_applied`, `selfHealed`, `valueNotes`, `checks_skipped`). Silence means nothing was touched.
- **Verdicts** (`gam_diagnose_*`, `gam_check_pacing`) ship the delivery figures they rest on, and `contradictions` when a failed check meets an item that is still serving.

## Development

| Command | What |
|---|---|
| `npm test` | Unit tests, no network |
| `npm run typecheck` | TypeScript check |
| `npm run dev` / `npm start` | Run the stdio server (tsx / built) |
| `npx tsx scripts/smoke.ts <tool> '<json>'` | Call one tool against your live network |
| `npm run pin-discovery` | Re-pin the REST discovery revision and regenerate the report catalog in `catalog/` |
| `npm run extract-wsdl -- <Service>` | Write a WSDL type digest for a SOAP service to `catalog/wsdl/` |

Every `Rest*` interface is checked against the pinned discovery schema in `npm test`, so a field that does not exist in the API fails the build.

## License

MIT

TDQS

A3.8/5.0

Scored across 54 tools

Disambiguation4/5

The set is large but unusually well self-documented: descriptions explicitly disambiguate look-alikes (find vs get vs forecast vs diagnose, forecast_availability vs forecast_existing_line_item vs forecast_delivery, line_item_creatives vs find_creatives vs creative_config vs creative_templates). Residual ambiguity exists around catalog-style tools (gam_companies vs gam_find_advertiser vs gam_programmatic_buyers) and the generic gam_pql_query escape hatch, which overlaps with nearly every find tool.

Naming Consistency4/5

All names share a gam_ prefix and snake_case, with a readable verb convention: find_* for searches, get_* for single-record fetches, and bare nouns (gam_teams, gam_labels, gam_sites) for catalog listings. The bare-noun form and a few odd forms like gam_ads_txt_diagnostics and gam_admin_config break strict verb_noun predictability but remain interpretable.

Tool Count2/5

54 tools is far above what an agent can comfortably scan and select from in one context, even for a domain as large as Ad Manager. The `kind` parameter pattern (admin_config, creative_config, technology_targets, video_content) sensibly folds several resources into single tools, but the surface still sprawls into 54 entries where many are long-tail (ads_txt_diagnostics, suggested_ad_units, forecast_adjustments, saved_reports) that few tasks will ever touch.

Completeness4/5

Within its stated read-only scope the coverage is excellent: inventory hierarchy, delivery/pacing, forecasting, reporting, proposals/private auctions, video (content, CMS metadata, ad rules), MCM/child publishers, and admin config are all present with id-resolution paths. The obvious gap is the entire write/lifecycle half of ad ops — no create/update/pause/approve operations exist, so an agent can diagnose a campaign but never fix it.