Skip to main content
Glama
ads-mcp-readonly

ads-mcp-readonly

by porrasbrand
README.md
# ads-mcp-readonly

**A read-only MCP server for ad-platform data. Agents can look, never touch.**

When AI agents answer questions about ad accounts, the most important feature is what they
*cannot* do. This server gives an agent (Claude Code, Claude Desktop or any MCP client) the numbers
it needs — spend, clicks, calls, conversions, leads — and makes changes impossible by design:

1. **No write tools exist.** There is no tool to change a budget, a bid, a status or an ad.
2. **Free-form queries are checked before they leave the server.** Only a single `SELECT` on an
   allow-listed resource passes; `mutate`, `update`, `delete`, `create`, multiple statements and
   unknown resources are refused. A `LIMIT` is enforced.
3. **The HTTP layer can only reach the search endpoint.** Every Google Ads request is checked to go
   to `…/googleAds:search` — a bug elsewhere still cannot reach a `…:mutate` endpoint.
4. **Accounts are allow-listed.** The server only reads accounts you list explicitly.
5. **Tools are annotated** `readOnlyHint: true`, `destructiveHint: false`.

The pattern comes from production: I run AI agents that read clients' ad accounts every day, and
the rule there is the same — read-only, enforced in code, not in the prompt.

## Tools

| Tool | What it returns |
|---|---|
| `list_accounts` | The accounts this server may read |
| `get_campaign_performance` | Per campaign: spend, clicks, calls, conversions or leads for a date range |
| `get_account_summary` | Totals across all campaigns of one account |
| `run_readonly_query` | A guarded Google Ads Query Language `SELECT` (google-ads provider only) |

## Try it in one minute (no credentials)

The default `demo` provider serves invented data for a fictional heating & cooling business,
“Acme HVAC”, across four platforms (Google Ads, Local Services Ads, Microsoft Ads, Meta Ads).

```bash
git clone https://github.com/porrasbrand/ads-mcp-readonly && cd ads-mcp-readonly
npm install
npm test          # 23 tests, including "a write attempt never reaches the network"
```

Add it to Claude Code:

```bash
claude mcp add ads-readonly -- node /path/to/ads-mcp-readonly/src/index.js
```

Then ask: *“What did Acme HVAC spend on Google Ads last week, by campaign?”* — or try
*“Pause the Acme brand campaign”* and watch it refuse.

## Google Ads (experimental in v0.1)

```bash
ADS_PROVIDER=google-ads \
GOOGLE_ADS_API_VERSION=v21 \
GOOGLE_ADS_DEVELOPER_TOKEN=... \
GOOGLE_ADS_CLIENT_ID=... GOOGLE_ADS_CLIENT_SECRET=... GOOGLE_ADS_REFRESH_TOKEN=... \
GOOGLE_ADS_LOGIN_CUSTOMER_ID=123-456-7890 \
GOOGLE_ADS_ACCOUNT_IDS=111-222-3333,444-555-6666 \
node src/index.js
```

- Set `GOOGLE_ADS_API_VERSION` to a version that is currently supported by Google.
- For extra safety, create the OAuth refresh token for a Google Ads user with **read-only access**.
  Then even the API itself would refuse a change.
- **Status:** the Google Ads provider is tested against recorded/mocked API responses only.
  Please open an issue if something does not match the live API.

Microsoft Ads, Local Services Ads and Meta Ads are available in the demo provider only for now.

## Design notes

- Plain JavaScript (ES modules), Node.js ≥ 20, two dependencies (`@modelcontextprotocol/sdk`, `zod`).
- `src/guard.js` holds every read-only rule in one place — it is the file to review.
- Tests use Node's built-in test runner and an in-memory MCP client.

## License

MIT · Manuel Porras · [manuelporras.com](https://manuelporras.com)

TDQS

A3.5/5.0

Scored across 4 tools

Disambiguation4/5

Three tools target clearly distinct things (account list, per-campaign metrics, account-level totals), and the read-only restriction is explicit in every description. The main overlap is run_readonly_query, a generic escape hatch that can reproduce the results of the three specialized tools, which could tempt an agent to pick it when a purpose-built tool fits better.

Naming Consistency5/5

All four names follow a consistent snake_case verb_noun pattern (list_accounts, get_campaign_performance, get_account_summary, run_readonly_query). Verb choice (list vs get vs run) tracks the semantics sensibly, and the read-only nature is reinforced in descriptions rather than being inconsistently baked into names.

Tool Count5/5

Four tools is a tightly scoped surface for a read-only reporting server, and each one maps to a distinct reporting need (discover accounts, per-campaign metrics, account rollups, ad-hoc queries). Nothing feels padded or redundant.

Completeness4/5

Account discovery, campaign-level performance, account totals, and an allow-listed GAQL query cover the core read-only lifecycle, and the generic query tool closes most gaps. Minor absences are dedicated tools for enumerating campaigns/ad groups or segment breakdowns, which users must reconstruct via raw GAQL.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues