ads-mcp-for-snapchat 0.10.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.env.example CHANGED
@@ -25,7 +25,8 @@ SNAP_REPORT_UTC_OFFSET=+00:00
25
25
  # Optional: SNAP_BROKER_URL=https://login.example.com (the shared login service; a refresh token is sent there, so use only one you trust)
26
26
  # Optional: SNAP_HOME=/some/folder (where settings, the change log and exports live; default ~/.ads-mcp-for-snapchat for an npm install)
27
27
  # Optional: SNAP_PORTFOLIO_FILES=/abs/path/.env,/abs/path/.env.account2 (accounts shown side by side by snap_portfolio_summary)
28
- # Optional: SNAP_TOOLSETS=setup,reports,checks (show only these tool groups: core, setup, read, reports, checks, changes, create; default all)
28
+ # Optional: SNAP_TOOLSETS=lite (24 everyday tools, short descriptions) or SNAP_COMPACT=1 (short descriptions for any tool set)
29
+ # Optional: SNAP_TOOLSETS=setup,reports,checks (show only these tool groups: core, lite, setup, read, reports, checks, changes, create; default all)
29
30
  # Optional: SNAP_MAX_LIFETIME_BUDGET, SNAP_MAX_ACTIVATION_DAILY_BUDGET, SNAP_MAX_ADDED_DAILY_BUDGET_24H, SNAP_ACCOUNT_CURRENCY=USD,
30
31
  # SNAP_READ_ONLY=1, SNAP_HUMAN_APPROVAL=elicit (see README "Safety settings")
31
32
  # Only needed once, by scripts/get-refresh-token.js (must match the redirect URL on your OAuth app)
package/ARCHITECTURE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Architecture and design notes
2
2
 
3
- For contributors. Unofficial MCP server (Node ESM) for the Snapchat Marketing API: 81 tools (55 in the default core set), all tests mocked (`npm test`). It runs locally over stdio, and the same tool code also runs as a private-test hosted Worker (`remote/`, see below). Read `README.md` first for setup and the tool table.
3
+ For contributors. Unofficial MCP server (Node ESM) for the Snapchat Marketing API: 87 tools (62 in the default core set), all tests mocked (`npm test`). It runs locally over stdio, and the same tool code also runs as a private-test hosted Worker (`remote/`, see below). Read `README.md` first for setup and the tool table.
4
4
 
5
5
  ## Architecture (src/)
6
6
  - `portfolio.js`: several accounts side by side, from the settings files the owner lists in SNAP_PORTFOLIO_FILES (read-only).
@@ -36,11 +36,11 @@ For contributors. Unofficial MCP server (Node ESM) for the Snapchat Marketing AP
36
36
  - Chunked media upload: INIT/ADD/FINALIZE, 30 MiB chunks, up to 1 GB.
37
37
  - Snap's default attribution (1-day view) overstates results vs last-click store data. Use Snap numbers to compare trends, not as revenue.
38
38
 
39
- ## Hosted version (`remote/`, private test)
39
+ ## Hosted version (`remote/`)
40
40
  A Cloudflare Worker that serves the same `registerTools` over HTTP. `worker.js` wraps Cloudflare's OAuth provider; `auth.js` is the consent page, the Snapchat redirect and the allowlist (`ALLOWED_MEMBERS`); `user-session.js` is one Durable Object per user that builds the tools for that user only; `store.js` and `approvals.js` keep the change log, audit log and approval codes in that user's own SQLite database (the server is rebuilt for every request, so nothing may live in memory); `crypto.js` derives the user id and encrypts the Snapchat refresh token. `remote/e2e.mjs` runs the whole flow against a fake Snapchat in the local Workers runtime (not part of `npm test`). Details and known gaps: `remote/README.md`, `remote/DESIGN.md`.
41
41
 
42
42
  ## Not built
43
- - A public hosted service: the hosted version is an invitation-only test (no rate limits, no independent review, operator can decrypt stored tokens). It needs those and Snap's confirmation that a shared app may serve other advertisers before it is opened up.
43
+ - Independent review and Snap's confirmation: the hosted version is open to anyone with a Snapchat login and has per-IP and per-person rate limits, but it has had no independent security review, the operator can decrypt stored tokens, and Snap has not confirmed that one shared app may serve other advertisers.
44
44
  - Non-WEB_VIEW creatives (Collection, Story, video formats), product set creation, position-level reports, lifetime / reach-and-frequency budgets, custom location targeting.
45
45
  - Not run live on their own: `snap_create_creative`, `snap_create_ad` (ran inside the influencer flow), campaign-level `snap_set_daily_budget`, a successful `snap_delete` of an ad squad / ad / audience, real-data customer-list upload.
46
46
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.11.1 (2026-11-26)
4
+ Fixes from the release audit (read tools that did not match Snapchat's published API).
5
+
6
+ - **Invoices**: amounts (`amount_cent`, in cents), document numbers and statuses are now read, so an overdue invoice shows its amount and the unpaid total is right. Invoices are listed per ad account; the old note saying they belong to the billing center was wrong. The invoice PDF is no longer included in answers.
7
+ - **Transactions**: amounts (`total_amount`) are kept instead of dropped.
8
+ - **Public profiles**: the list is now requested from Snapchat's business API host, where it lives. It needs the `snapchat-profile-api` permission, which is off by default so a login can never fail for an app without it. To turn it on, set `SNAP_PROFILE_SCOPE=1` and connect again. Without it, profile ids are still read from existing creatives.
9
+ - **Removed** the lead count and sponsored content options of `snap_account_details`: Snapchat documents no such endpoints (use lead forms, and `snap_competitor_ads` for ads from the Ads Library).
10
+ - Lists ask Snapchat for at least 50 rows, its minimum page size.
11
+
12
+ ## 0.11.0 (2026-11-26)
13
+ The hosted version grew up and the local one gets everything it learned: shorter answers, a first-run guide, more tools, and fixes found by real accounts.
14
+
15
+ **New**
16
+ - **`snap_start_here`**: a first-run guide (who is connected, read-only or not, limits, ad account or a list to pick from, a snapshot, warnings, eight things to say next). In apps that draw cards it shows a start card with a progress bar and one-tap first wins.
17
+ - **`snap_find`**: find campaigns, ad squads or ads by name (Arabic spellings are treated alike). `snap_connect` takes an ad account name as well as an id.
18
+ - **`snap_account_details`**: one tool for many read-only lists: invoices, transactions, lead forms, a lead count (no lead details), mobile apps, event details, interaction zones, offer disclaimers, phone numbers (masked), sponsored content, organizations, organization pixels, media stats, catalog products.
19
+ - **`snap_account_admin`** (settings, billing centers, who has access with which role, emails masked) and **`snap_list_profiles`** (public profiles; if Snapchat offers no list, read from the account's own creatives). Creatives now pick the only public profile automatically.
20
+ - **`snap_upload_media_from_url`**: upload a JPEG, PNG, MP4 or MOV (up to 32 MB) from a public https link, for the hosted version. https only, public domain names, redirects checked.
21
+ - **More targeting lookups**: genders, advanced demographics, carriers, connection types, iOS and Android versions, device models, postal codes.
22
+ - **Lite tool set** (`SNAP_TOOLSETS=lite`: 24 tools, about 7,800 tokens instead of about 25,500) and `SNAP_COMPACT=1` for short descriptions in any set.
23
+ - **Overdue invoice warning** in `snap_billing_check`.
24
+ - **Short answers**: the server tells the AI to answer with the finding first, a few bullets and one next step. `snap_spend_pacing` lists only the ad squads that need attention (`show_all` for everything).
25
+ - **Cards**: a start card; the preview card shows "Already applied" instead of an error plus Apply when an approval was already used.
26
+ - **Hosted**: one switch (`PAID_PLAN = "1"`) raises the request and rate limits after subscribing to Cloudflare's paid plan; sign-in errors explain what to do.
27
+
28
+ **Fixed**
29
+ - Daily reports start at midnight in the ad account's own time zone, including across clock changes (daylight saving). Without this the hosted dashboard failed for any account outside UTC.
30
+ - `snap_delivery_check`, `snap_spend_pacing` and the dashboard no longer fail on accounts with thousands of campaigns (fewer requests per call, scoped reads).
31
+ - `snap_account_admin` and `snap_list_profiles` crashed on unregistered list types; found on a real account and now guarded by tests.
32
+
33
+ **Tests**: a sweep runs every tool through the real client on empty and filled lists and fails on any crash inside our own code; another check makes sure every list type the code asks for is registered; the hosted end-to-end check runs the recent read tools in the real Worker runtime.
34
+
35
+ **Counts**: 87 tools in all, 62 in the default core set.
36
+
3
37
  ## 0.10.0 (2026-11-25)
4
38
  The biggest release so far. It also contains 0.9.10, which was never published on its own.
5
39
 
package/PRIVACY.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Privacy
2
2
 
3
- Ads MCP for Snapchat is open-source software that runs **on your own computer**. This page covers the optional **shared login service**, the tool itself, and the separate **hosted private test**.
3
+ Ads MCP for Snapchat is open-source software that runs **on your own computer**. This page covers the optional **shared login service**, the tool itself, and the separate **hosted version**.
4
4
 
5
5
  ## The tool (on your computer)
6
6
  - Your settings, the change log and exports stay on your computer. Nothing is sent to the maintainer.
@@ -27,8 +27,8 @@ The service lets you log in with Snapchat without creating your own Snapchat app
27
27
  - If you prefer, skip the shared login and use your own Snapchat OAuth app (see the README). You can also run your own copy of the service (`broker/README.md`).
28
28
  - To stop access: revoke the app in Snapchat Business Manager and delete your settings file.
29
29
 
30
- ## The hosted version (private test, invitation only)
31
- This is separate from the local tool. It runs on the maintainer's Cloudflare account. The operator may limit who can sign in. If you use it:
30
+ ## The hosted version
31
+ This is separate from the local tool. It runs on the maintainer's Cloudflare account and is open to anyone with a Snapchat login; the operator may block a person or switch changes off for everyone. If you use it:
32
32
 
33
33
  **What is stored for you** (in a private database that only your own connection reads)
34
34
  - Your Snapchat **refresh token, encrypted**, so the service can act on your ad account for you.
package/README.md CHANGED
@@ -1,11 +1,38 @@
1
1
  # Ads MCP for Snapchat
2
2
 
3
- An [MCP](https://modelcontextprotocol.io) server that runs on your own computer, and lets an AI assistant (Claude Code, Claude Desktop and other MCP clients) work with **your own** Snapchat ad account: read performance, audit campaigns, and make careful, reviewable changes. It also turns creators' **ad codes** into paused ads. There is also a **hosted private test** that needs no install (see [Hosted version](#hosted-version-private-test)).
3
+ An [MCP](https://modelcontextprotocol.io) server, available as a **hosted connector (nothing to install)** or **on your own computer**, that lets an AI assistant (Claude Code, Claude Desktop and other MCP clients) work with **your own** Snapchat ad account: read performance, audit campaigns, and make careful, reviewable changes. It also turns creators' **ad codes** into paused ads.
4
4
 
5
5
  > **Unofficial.** Not affiliated with or endorsed by Snap Inc. This tool can change real ad campaigns that spend real money. You use it at your own risk (see LICENSE). Check Snap's developer terms for your own use. Review every preview before approving.
6
6
 
7
7
  ## Get started in 2 minutes
8
- **Claude Desktop (no terminal):** download `ads-mcp-for-snapchat-<version>.mcpb` from the [latest release](https://github.com/Usame794/snapchat-ads-mcp/releases/latest), open it, leave Client ID and secret empty, then ask Claude: "Connect my Snapchat ad account." Log in with Snapchat and pick the ad account. In the Desktop extension, changes are **allowed from the start** (Read-only is off by default): each one is previewed and needs your approval, everything created starts paused, and the daily budget limit starts at 500 (change it in the extension's settings). Switch Read-only on there if you only want to look. It also starts with the **core** tool set (55 everyday tools); type `all` in its Tool set field to see all 81.
8
+
9
+ ### Option 1 (easiest): the hosted connector, nothing to install
10
+ 1. In your AI app, add this address as a **custom connector**:
11
+ ```
12
+ https://ads-mcp-remote.ads-mcp.workers.dev/mcp
13
+ ```
14
+ In Claude: **Settings, Connectors, Add custom connector**, name it `Ads MCP for Snapchat`, and paste the address. Other apps that support remote MCP servers with sign-in use the same address (only Claude has been tested so far).
15
+ 2. Press **Connect** and sign in with the same Snapchat login you use for Ads Manager. It is **read-only** unless you tick "allow changes" on the page. Finish it in one tab within a few minutes.
16
+ 3. In a new chat say: **"Use snap_start_here"**. Pick your ad account by name, then ask in plain words: "How is my account doing this week?", "Which active ad squads are not spending, and why?", "Show my campaigns".
17
+
18
+ This is **unofficial** and run by one independent maintainer. Before you sign in, read [what the hosted version stores](#hosted-version) (your Snapchat login token is kept, encrypted, so the service can act for you; you can delete everything with `snap_disconnect` and revoke the app in Snapchat at any time).
19
+
20
+ #### Using the hosted connector in ChatGPT (not tested yet)
21
+ ChatGPT can add a remote MCP server by its address. The menu names change from version to version, so look for the closest match. You need a ChatGPT plan that allows custom connectors (the paid plans; an organization admin may have to allow it on Business and Enterprise).
22
+ 1. Open **Settings**, then **Apps** (called **Connectors** in some versions), then **Advanced settings**, and turn on **Developer mode**.
23
+ 2. Choose **Create** (or **Add a custom app / connector**), and fill in:
24
+ - **Name:** `Ads MCP for Snapchat`
25
+ - **MCP server URL:** `https://ads-mcp-remote.ads-mcp.workers.dev/mcp`
26
+ - **Authentication:** **OAuth** (it registers itself automatically; leave any client ID and secret empty)
27
+ 3. Tick the box that says you trust the application, and press **Create**. ChatGPT sends you to the sign-in page: sign in with Snapchat and finish within a few minutes, in one tab. Changes stay off unless you tick "allow changes" there.
28
+ 4. In a **new chat**, open the **+** menu, choose **Developer mode** (or **More**), and switch on **Ads MCP for Snapchat**. Then ask: "Use snap_start_here".
29
+
30
+ This server works with ChatGPT's standard sign-in as far as we can check (the discovery and registration pages are tested), but **nobody has run it in ChatGPT yet**. If a step fails, please open an issue with the exact words ChatGPT shows. Cards may not appear in ChatGPT; every answer also arrives as text.
31
+
32
+ ### Option 2: on your own computer (private, no third-party server)
33
+ Pick this if you do not want any server run by someone else to hold your Snapchat login.
34
+
35
+ **Claude Desktop (no terminal):** download `ads-mcp-for-snapchat-<version>.mcpb` from the [latest release](https://github.com/Usame794/snapchat-ads-mcp/releases/latest), open it, leave Client ID and secret empty, then ask Claude: "Connect my Snapchat ad account." You log in with Snapchat in your browser and pick your ad account.
9
36
 
10
37
  **Claude Code, Cursor, VS Code or a terminal:**
11
38
  ```bash
@@ -13,6 +40,14 @@ npx -y ads-mcp-for-snapchat setup
13
40
  ```
14
41
  Choose **1. Shared login**, log in with Snapchat, pick the ad account, and press Enter at the safety question (it starts read-only; nothing can be changed until you allow it). Then check everything with `npx -y ads-mcp-for-snapchat verify`.
15
42
 
43
+ | | Hosted (Option 1) | On your computer (Option 2) |
44
+ |---|---|---|
45
+ | Install | none | one file or one command |
46
+ | Where your login token lives | encrypted on the maintainer's Cloudflare account | only on your computer |
47
+ | Interactive cards in Claude | yes | not in the Claude Desktop extension |
48
+ | Works with ChatGPT and other remote-only apps | designed for it, [setup steps](#using-the-hosted-connector-in-chatgpt-not-tested-yet), not tested yet | no |
49
+ | Folder uploads and customer-list files | no | yes |
50
+
16
51
  ## How this relates to Snap's own Ads MCP server
17
52
  Snap runs its own hosted **Ads MCP server** (see Snap's developer documentation). According to Snap's documentation it is **read-only**: an agent can read Snapchat Ads data but cannot create, update or delete anything, and it works with several AI apps without installing anything.
18
53
 
@@ -25,7 +60,7 @@ This project is unofficial and is not made, endorsed or supported by Snap. It ru
25
60
  ## What it is, and what it is not
26
61
  - **The local version runs on your machine, with your own ad account.** You connect with a normal Snapchat login (the shared login service) or with your own Snapchat OAuth app. No ad account data leaves your computer except to Snap's API.
27
62
  - **It is a safety-first tool, not an autopilot.** Writes are previewed first, created things start paused, and there are hard limits on money. See "Safety rules" below, and read "What the approval token is not".
28
- - **The local version is not a public service.** Do not expose it on the internet. For apps that only accept remote MCP servers there is the separate, invitation-only [hosted test](#hosted-version-private-test); ChatGPT is not tested yet.
63
+ - **The local version is not a public service.** Do not expose it on the internet. For apps that only accept remote MCP servers there is the separate [hosted version](#hosted-version), open to anyone with a Snapchat login; ChatGPT is not tested yet.
29
64
  - **Money limits are in your account's currency.** Defaults (`SNAP_MAX_DAILY_BUDGET=1000`, `SNAP_MAX_BID=50`) are deliberately conservative; set your own in `.env`.
30
65
 
31
66
  ## Snap's terms and data
@@ -134,7 +169,9 @@ With this setting the server asks **you**, through the MCP client's own dialog (
134
169
  | `SNAP_BROKER_URL` | the maintainer's login service (`off` turns the shared login off) | The shared login service: connect with a normal Snapchat login and no OAuth app. https only. A refresh token is sent there, so use only a service you trust (see `PRIVACY.md`, `broker/README.md`). `setup` saves it for you. |
135
170
  | `SNAP_HOME` | `~/.ads-mcp-for-snapchat` for an npm install, the project folder for a git checkout | Where the settings file, the change log and `exports/` live. Set it to keep them somewhere else. |
136
171
  | `SNAP_PORTFOLIO_FILES` | (none) | Absolute paths of the settings files of the accounts for `snap_portfolio_summary`, comma-separated (up to 10). Only you can set it: the AI app cannot pick files. |
137
- | `SNAP_TOOLSETS` | all | Show only some tool groups to the AI app: `core` (55 everyday tools: read, check and launch campaigns), or `setup, read, reports, checks, changes, create` (comma-separated, can be combined with core). The Claude Desktop extension starts with `core`; type `all` in its Tool set field to see every tool. Fewer tools make some apps faster and less error-prone, e.g. `setup,reports,checks` for an analyst. It only hides tools. |
172
+ | `SNAP_REQUEST_BUDGET` | 44 | The most requests to Snapchat one run of `snap_delivery_check` makes. The hosted version sets it from its plan (see `remote/README.md`); on your own computer you can raise it. |
173
+ | `SNAP_COMPACT` | (off) | `1` shortens every tool and parameter description to its first sentence, so the tool list costs the AI fewer tokens (the hosted version uses it). The `lite` tool set turns it on by itself. |
174
+ | `SNAP_TOOLSETS` | all | Show only some tool groups to the AI app: `lite` (24 tools with short descriptions, about a third of the context cost: look, find, check delivery, pause, change budgets and bids, undo, start a campaign), `core` (62 everyday tools: read, check and launch campaigns), or `setup, read, reports, checks, changes, create` (comma-separated, can be combined with core). The Claude Desktop extension starts with `core`; type `all` in its Tool set field to see every tool. Fewer tools make some apps faster and less error-prone, e.g. `setup,reports,checks` for an analyst. It only hides tools. |
138
175
  | `SNAP_HUMAN_APPROVAL` | off | `elicit` = ask the user through the MCP client before every write |
139
176
  | `SNAP_APPROVAL_TTL_SECONDS` | 600 | Lifetime of an approval token |
140
177
  | `SNAP_REPEAT_WINDOW_SECONDS` | 600 | An identical create, copy, claim or upload is refused within this time |
@@ -177,6 +214,10 @@ Ready-made instructions in Claude's prompt menu (the "+" or "/" menu). They only
177
214
  | `snap_creative_compare` | read: the ads of a campaign or ad squad ranked against the median ROAS (WINNER / LAGGING), grouped by call to action |
178
215
  | `snap_budget_advice` | read: suggested daily-budget moves (lower the weak, raise the proven, funded by what is freed, inside your limits), each naming the tool that applies it |
179
216
  | `snap_billing_check` | read: ad account status, funding sources (card expiry, daily limit vs budgets, credit left) and a verdict |
217
+ | `snap_account_admin` | read: the ad account's settings (status, currency, time zone, billing type, spend cap), the organization's billing centers, and how many people have access with which role (emails masked); never changes anything |
218
+ | `snap_list_profiles` | read: the public profiles (brand identities) this login can use for creatives, with their ids; with only one, new creatives use it automatically |
219
+ | `snap_account_details` | read: pick one list with `what`: invoices, transactions, lead forms, mobile apps, event details, interaction zones, offer disclaimers, phone numbers (masked), organizations, organization pixels, media stats, catalog products; contact details masked, and if Snapchat does not answer it says which paths were tried |
220
+ | `snap_upload_media_from_url` | write: upload a JPEG, PNG, MP4 or MOV (up to 32 MB) from a public https link, for the hosted version; previews first, and only public https addresses are fetched |
180
221
  | `snap_unused_media` | read: uploaded images and videos no creative uses (never deletes) |
181
222
  | `snap_audience_health` | read: audiences that are not targetable, tiny, stale, or unused by active ad squads |
182
223
  | `snap_funnel` | read: impressions → swipes → views → add to cart → checkout → purchases with the rate at each step and the weakest step |
@@ -190,6 +231,8 @@ Ready-made instructions in Claude's prompt menu (the "+" or "/" menu). They only
190
231
  | `snap_report` | read: performance reports. `view` = `table` (ROAS, CPA, swipe rate, frequency by ad squad or ad; the default), `daily` (day by day, up to 31 days), `hourly` (by local hour of the day, last 1-7 days, best and worst hours), `compare` (two time windows side by side) or `audience` (by country, gender, age, region, dma or make) |
191
232
  | `snap_health_check` | read: audits every active squad for missing buyer exclusion, high frequency, low swipe rate, low ROAS, spend with no purchases, paused parents |
192
233
  | `snap_review_issues` | read: rejected / pending ads with Snap's reasons |
234
+ | `snap_start_here` | read: the first-run guide: who is connected (masked), whether changes are allowed, the limits, the active ad account (or the list to choose from), a snapshot of campaigns and ad squads, a warning about active ad squads under paused campaigns, and what to say next |
235
+ | `snap_find` | read: find campaigns, ad squads or ads by (part of) their name and get their ids, with parent names and ad squad budgets; accents and Arabic letter variants are ignored |
193
236
  | `snap_delivery_check` | read: why an active ad squad is not spending: paused campaign, schedule not started or ended, no ads or none approved, no budget, missing pixel, inactive account; passes Snap's own delivery status through |
194
237
  | `snap_pixel_health` | read: pixel signal readiness and event-quality issues, top priority first |
195
238
  | `snap_creative_fatigue` | read: which ads are tired (ROAS down 30%+ with higher frequency or lower swipe rate), which to replace first |
@@ -225,7 +268,7 @@ Ready-made instructions in Claude's prompt menu (the "+" or "/" menu). They only
225
268
  | `snap_influencer_ad` | the whole influencer flow in one step: claim, wait for media, creative, paused ad |
226
269
 
227
270
  ## Interactive cards (MCP Apps)
228
- In AI apps that support [MCP Apps](https://modelcontextprotocol.io), some tools show a small interactive card inside the chat instead of only text. **Where they appear:** Claude Desktop shows them with the [hosted version](#hosted-version-private-test); with the local Claude Desktop extension it shows the plain data instead, and other apps may do either, because card support is up to each app and is still new. Nothing depends on them: every answer also arrives as text and data.
271
+ In AI apps that support [MCP Apps](https://modelcontextprotocol.io), some tools show a small interactive card inside the chat instead of only text. **Where they appear:** Claude Desktop shows them with the [hosted version](#hosted-version); with the local Claude Desktop extension it shows the plain data instead, and other apps may do either, because card support is up to each app and is still new. Nothing depends on them: every answer also arrives as text and data.
229
272
  - **`snap_dashboard`**: spend, ROAS, purchases, cost per purchase and swipe rate for 7, 14 or 30 days (switch with the buttons), spend by day, and this month's pacing.
230
273
  - **`snap_dashboard`** also lists alerts from the same days (a spend spike or drop, missing purchases, ROAS or cost per purchase moving sharply), each one dismissible.
231
274
  - **`snap_campaign_board`**: campaigns or ad squads (switch with the buttons) with spend, ROAS and purchases for 7, 14 or 30 days, sorting and a "needs a look" filter. **Pause**, **Resume** and, on ad squads, **−20% / +20%** budget buttons first show the change and its spending effect (the daily budget that would start delivering, and the 24-hour total), and nothing happens until you press **Confirm**.
@@ -299,7 +342,7 @@ This is a local MCP server (stdio). Credentials stay in your `.env`; the AI app
299
342
  ```
300
343
  Use the absolute path to `node` as `command` if the app cannot find it. The server reads `.env` from its own folder (an npm install reads `~/.ads-mcp-for-snapchat/.env`), so no secrets go in this file.
301
344
 
302
- **ChatGPT**: ChatGPT connects to *remote* MCP servers (an https URL) through its connectors / developer mode, not to local stdio programs. This server is local only, so it cannot be added to ChatGPT as it is. Doing that would need a hosted version with per-user OAuth and encrypted token storage (see "Not built"). Do not expose this server publicly as it is: it can change real ad campaigns. Other desktop MCP clients that launch local stdio servers (Cursor, VS Code, Cline) work with the same `command` and `args` as above.
345
+ **ChatGPT**: ChatGPT connects to *remote* MCP servers (an https URL) through its connectors / developer mode, not to local stdio programs. Use the [hosted version](#hosted-version) for that (untested in ChatGPT so far; if it fails, please open an issue with the exact error). Do not expose the local server publicly: it can change real ad campaigns. Other desktop MCP clients that launch local stdio servers (Cursor, VS Code, Cline) work with the same `command` and `args` as above.
303
346
 
304
347
  ## Several ad accounts
305
348
  Run one server per ad account, each with its own settings file. Each server only touches its own account, and keeps its own change log (`<settings file>.log.jsonl`), so limits, undo and the audit trail never mix.
@@ -346,7 +389,7 @@ Verified on the maintainer's own ad account. Anything not listed here is covered
346
389
  - The 24-hour spend limit and absolute limits on real writes (mocked tests only), `SNAP_HUMAN_APPROVAL=elicit` in Claude Code, `snap_create_creative` with a WEB_VIEW link, a campaign-level `snap_set_daily_budget`, a successful `snap_delete` of an ad squad, ad or audience, a customer-list upload of real data, and Node 18 / 20 outside CI.
347
390
 
348
391
  ## Not built
349
- - A hosted multi-user MCP server, which ChatGPT would need. The optional shared login service (`broker/`) only passes Snapchat logins along; the tool itself always runs on your own computer.
392
+ - An independent security review of the hosted version, and Snap's confirmation that one shared app may serve other advertisers (see "Hosted version"). The optional shared login service (`broker/`) only passes Snapchat logins along; the local tool always runs on your own computer.
350
393
  - Lens, App Install, Deep Link and lead-form creatives; ad squad goals for app installs and lead generation; custom location and radius targeting; reach-and-frequency budgets; position-level reports; custom placement on ad squads that use content inclusion or exclusion lists; switching an ad squad to auto-bid (it would remove the bid cap).
351
394
  - Anything that spends money without a separate, explicit enable step.
352
395
 
package/SECURITY.md CHANGED
@@ -19,6 +19,7 @@ Everything runs on your computer. These are the only outside addresses it contac
19
19
  | Address | What for | What is sent |
20
20
  |---|---|---|
21
21
  | `adsapi.snapchat.com`, `accounts.snapchat.com` | The Snapchat Marketing API and login | Your requests, with your access token |
22
+ | `businessapi.snapchat.com` | Snapchat's Public Profile API (read-only list of public profiles) | The organization id, with your access token |
22
23
  | `tr.snapchat.com` | Conversions API **test** events and their status (`snap_capi_*`) | Your access token and one test event; an email is hashed first. Real conversion events are never sent. |
23
24
  | `adsapi.snapchat.com/v1/ads_library/...` | Competitor ads (`snap_competitor_ads`) | The advertiser name you search for. **No token**, nothing about your account. |
24
25
  | The links of your own active ads | `snap_check_landing_pages` opens each link once | A plain request. Only `https`, never private, loopback or link-local addresses, and every redirect is checked again. No credentials. |
@@ -29,7 +30,7 @@ Text that comes back from outside (competitors' ads, page contents, ad review re
29
30
  ## Safety design
30
31
  Write tools need the approval token of a preview of the exact same request, create objects paused, enforce absolute and relative money limits that fail closed, only touch the configured ad account, and record every write in an audit log. The approval token is not a human signature: keep your MCP client's permission prompt on for write tools (see README, "What the approval token is not"). This tool edits real campaigns: review each preview before approving.
31
32
 
32
- ## Hosted version (private test)
33
+ ## Hosted version (unofficial, open to anyone with a Snapchat login)
33
34
  The hosted version in `remote/` may be open to anyone with a Snapchat login and has **not** had an independent security review. The operator can restrict sign-in (`ALLOWED_MEMBERS`), block a person (`BLOCKED_MEMBERS`) and switch changes off for everyone (`HOSTED_READ_ONLY=1`). What it does for safety: sign-in through Cloudflare's OAuth library, an allowlist of approved Snapchat members, read-only unless the person opts in to changes, one private database per user, the stored Snapchat token encrypted with a key derived per user, approval codes kept per user, and the same previews, limits and paused-by-default creation as the local version. Rate limits: sign-in endpoints per IP address (registrations 10 an hour, other sign-in paths 60 a minute) and 120 tool calls a minute per person; logs are trimmed to 90 days and 20,000 lines. What it does **not** have yet: independent review, and the operator can decrypt stored tokens. `DEV_FAKE_SNAP_URL` exists for the local test only and must never be set on a deployed Worker. Report problems with it the same way as for the local tool (below).
34
35
 
35
36
  ## Known limits (from the independent audit of 0.9.6)
package/broker/worker.js CHANGED
@@ -78,7 +78,7 @@ async function login(request, env) {
78
78
  if (!validPort(port) || !checkPublicKey(pk) || !validNonce(nonce)) return page("Cannot start", "<h1>Cannot start the login</h1><p>The link is not valid. Start again from the setup command or the Claude Desktop extension.</p>", 400);
79
79
  const state = await signState(env, { p: Number(port), k: pk, n: nonce, e: Date.now() + STATE_MINUTES * 60_000 });
80
80
  const auth = new URL(AUTHORIZE);
81
- auth.search = new URLSearchParams({ response_type: "code", client_id: env.SNAP_CLIENT_ID, redirect_uri: `${origin(request, env)}/callback`, scope: "snapchat-marketing-api", state }).toString();
81
+ auth.search = new URLSearchParams({ response_type: "code", client_id: env.SNAP_CLIENT_ID, redirect_uri: `${origin(request, env)}/callback`, scope: String(env.SNAP_PROFILE_SCOPE ?? "") === "1" ? "snapchat-marketing-api snapchat-profile-api" : "snapchat-marketing-api", state }).toString();
82
82
  return new Response(null, { status: 302, headers: { Location: auth.toString(), "Set-Cookie": `${COOKIE}=${nonce}; Path=/callback; Max-Age=${STATE_MINUTES * 60}; HttpOnly; Secure; SameSite=None`, ...SECURITY_HEADERS } });
83
83
  }
84
84
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ads-mcp-for-snapchat",
3
- "version": "0.10.0",
3
+ "version": "0.11.1",
4
4
  "description": "Unofficial local MCP server for the Snapchat Marketing API: reports, audits and safe, previewed changes to campaigns, ad squads and ads.",
5
5
  "mcpName": "io.github.Usame794/ads-mcp-for-snapchat",
6
6
  "adsMcpBroker": "https://ads-mcp-for-snapchat-login.ads-mcp.workers.dev",
package/src/admin.js ADDED
@@ -0,0 +1,65 @@
1
+ // Account and billing admin, read-only: the ad account's settings, its billing centers and who has access with which role. It never
2
+ // changes anything. Names, emails and addresses are masked or left out: the answer lands in a chat history. Each part is read on
3
+ // its own, because a login may be allowed to see some of them and not others; a part that cannot be read says why.
4
+ import { maskLogin } from "./identity.js";
5
+
6
+ const one = (row, key) => (row && typeof row === "object" && row[key] && typeof row[key] === "object" ? row[key] : row);
7
+ const reason = (e) => String(e?.message ?? e).replace(/\s+/g, " ").slice(0, 160);
8
+ const money = (micro) => (micro == null ? null : Number(micro) / 1e6);
9
+
10
+ async function section(fn) {
11
+ try {
12
+ return { ok: true, value: await fn() };
13
+ } catch (e) {
14
+ return { ok: false, why: reason(e) };
15
+ }
16
+ }
17
+
18
+ export async function accountAdmin(client, { adAccountId, maxPeople = 40 }) {
19
+ const acct = (await client.request("GET", `/adaccounts/${adAccountId}`)).adaccounts?.[0]?.adaccount ?? {};
20
+ const org = acct.organization_id ?? null;
21
+ const out = {
22
+ ad_account: {
23
+ name: acct.name ?? null,
24
+ status: acct.status ?? null,
25
+ currency: acct.currency ?? null,
26
+ timezone: acct.timezone ?? null,
27
+ billing_type: acct.billing_type ?? null,
28
+ type: acct.type ?? null,
29
+ lifetime_spend_cap: money(acct.lifetime_spend_cap_micro),
30
+ funding_sources: (acct.funding_source_ids ?? []).length,
31
+ created_at: acct.created_at ?? null,
32
+ },
33
+ };
34
+ const unavailable = {};
35
+
36
+ if (org) {
37
+ const bc = await section(async () => (await client.listPaged(`/organizations/${org}/billingcenters`, "billingcenter")).items.map((b) => one(b, "billingcenter")));
38
+ if (bc.ok) out.billing_centers = bc.value.map((b) => ({ id: b.id, name: b.name ?? null, currency: b.currency ?? null, country: b.country ?? null }));
39
+ else unavailable.billing_centers = bc.why;
40
+
41
+ const members = await section(async () => (await client.listPaged(`/organizations/${org}/members`, "member")).items.map((m) => one(m, "member")));
42
+ const roles = await section(async () => (await client.listPaged(`/adaccounts/${adAccountId}/roles`, "role")).items.map((r) => one(r, "role")));
43
+ if (members.ok || roles.ok) {
44
+ const byId = new Map((members.ok ? members.value : []).map((m) => [m.id, m]));
45
+ const rows = [];
46
+ if (roles.ok) {
47
+ for (const r of roles.value) {
48
+ const m = byId.get(r.member_id) ?? {};
49
+ rows.push({ person: maskLogin(m) ?? "(a member, details not visible to this login)", role: r.type ?? r.role ?? null, status: m.member_status ?? null });
50
+ }
51
+ } else {
52
+ for (const m of byId.values()) rows.push({ person: maskLogin(m), role: null, status: m.member_status ?? null });
53
+ }
54
+ const count = {};
55
+ for (const r of rows) count[r.role ?? "unknown"] = (count[r.role ?? "unknown"] ?? 0) + 1;
56
+ out.access = { people: rows.length, by_role: count, list: rows.slice(0, maxPeople), ...(rows.length > maxPeople ? { note: `${rows.length} people; the first ${maxPeople} are shown.` } : {}), ...(roles.ok ? {} : { note: "Roles could not be read, so only the organization's members are listed." }) };
57
+ }
58
+ if (!members.ok && !roles.ok) unavailable.access = `${members.why}${roles.why !== members.why ? ` / ${roles.why}` : ""}`;
59
+ } else {
60
+ unavailable.organization = "This ad account did not say which organization it belongs to, so billing centers and access could not be looked up.";
61
+ }
62
+ if (Object.keys(unavailable).length) out.could_not_read = unavailable;
63
+ out.note = "Read-only. Emails and addresses are masked or left out. Funding sources, card expiry and credit: use snap_billing_check. Invoices and payments are managed in Ads Manager.";
64
+ return out;
65
+ }
@@ -203,6 +203,8 @@ button:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline
203
203
  try {
204
204
  const r = await window.snapApp.run(state.tool, Object.assign({}, state.input, { confirm: true, approval_token: state.result.approval_token }, isDelete() ? { confirm_name: state.typed } : {}));
205
205
  if (r.ok) { state.phase = "applied"; state.message = { text: "Applied" + (r.data && r.data.verified === false ? ", but Snap did not show the new value yet. Check it." : " and checked back with Snap.") }; if (r.data) state.result = Object.assign({}, state.result, r.data, { applied: true }); }
206
+ // The same approval was already used (the chat applied it, or it was clicked twice). Nothing was repeated; do not offer Apply again.
207
+ else if (/already used/i.test(r.text || "")) { state.phase = "applied"; state.message = { text: "Already applied: this approval was used before (from the chat or an earlier click). Nothing was repeated. Ask in the chat to check the result." }; }
206
208
  else { state.phase = "preview"; state.message = { err: true, text: r.text }; }
207
209
  } catch (e) { state.phase = "preview"; state.message = { err: true, text: "Could not apply: " + e.message }; }
208
210
  render();
@@ -0,0 +1,138 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>Start here</title>
7
+ <style>
8
+ :root{--fb-bg:#fff;--fb-bg2:#f4f5f7;--fb-text:#14171c;--fb-muted:#5b6270;--fb-border:#d9dce2;--fb-good:#1a8a5a;--fb-bad:#c92a2a;--fb-warn:#9a5b00;--accent:#3b5bdb;--fb-warnbg:#fff7e8;--fb-warnline:#f0d9ad}
9
+ @media (prefers-color-scheme:dark){:root{--fb-bg:#1b1d22;--fb-bg2:#252830;--fb-text:#eceef2;--fb-muted:#9aa1ad;--fb-border:#3a3e48;--fb-good:#4cd38e;--fb-bad:#ff7b7b;--fb-warn:#ffc15a;--accent:#8aa0ff;--fb-warnbg:#3a2f1c;--fb-warnline:#6b5527}}
10
+ :root[data-theme=light]{--fb-bg:#fff;--fb-bg2:#f4f5f7;--fb-text:#14171c;--fb-muted:#5b6270;--fb-border:#d9dce2;--fb-good:#1a8a5a;--fb-bad:#c92a2a;--fb-warn:#9a5b00;--accent:#3b5bdb;--fb-warnbg:#fff7e8;--fb-warnline:#f0d9ad}
11
+ :root[data-theme=dark]{--fb-bg:#1b1d22;--fb-bg2:#252830;--fb-text:#eceef2;--fb-muted:#9aa1ad;--fb-border:#3a3e48;--fb-good:#4cd38e;--fb-bad:#ff7b7b;--fb-warn:#ffc15a;--accent:#8aa0ff;--fb-warnbg:#3a2f1c;--fb-warnline:#6b5527}
12
+ :root{--bg:var(--color-background-primary,var(--fb-bg));--bg2:var(--color-background-secondary,var(--fb-bg2));--text:var(--color-text-primary,var(--fb-text));--muted:var(--color-text-secondary,var(--fb-muted));--border:var(--color-border-primary,var(--fb-border));--good:var(--color-text-success,var(--fb-good));--bad:var(--color-text-danger,var(--fb-bad));--warn:var(--color-text-warning,var(--fb-warn));--warnbg:var(--fb-warnbg);--warnline:var(--fb-warnline)}
13
+ *{box-sizing:border-box}
14
+ body{margin:0;padding:16px;background:var(--bg);color:var(--text);font:14px/1.45 var(--font-sans,system-ui,-apple-system,"Segoe UI",sans-serif)}
15
+ h1{font-size:17px;margin:0}.sub{color:var(--muted);font-size:12px}
16
+ .card{background:var(--bg2);border:1px solid var(--border);border-radius:12px;padding:14px}
17
+ .badge{display:inline-block;padding:1px 10px;border-radius:999px;font-size:11px;border:1px solid var(--warn);color:var(--warn)}
18
+ .badge.done{border-color:var(--good);color:var(--good)}.badge.off{border-color:var(--border);color:var(--muted)}
19
+ .pill{display:inline-block;padding:1px 8px;border-radius:999px;font-size:11px;border:1px solid var(--border);margin-right:6px}
20
+ .pill.on{color:var(--good);border-color:var(--good)}.pill.flag{border-color:var(--warn);color:var(--warn)}
21
+ .impact{background:var(--warnbg);border:1px solid var(--warnline);border-radius:10px;padding:10px 12px;font-weight:600;margin:10px 0}
22
+ .impact.calm{background:var(--bg);border-color:var(--border);font-weight:500}
23
+ dl{margin:10px 0;display:grid;grid-template-columns:max-content 1fr;gap:4px 14px}
24
+ dt{color:var(--muted)}dd{margin:0;overflow-wrap:anywhere}
25
+ pre{margin:6px 0 0;white-space:pre-wrap;overflow-wrap:anywhere;font:12px/1.4 ui-monospace,Menlo,monospace;background:var(--bg);border:1px solid var(--border);border-radius:8px;padding:8px}
26
+ .track{height:10px;background:var(--border);border-radius:999px;overflow:hidden;display:flex}
27
+ .track span{display:block;height:100%}
28
+ .warn{color:var(--warn);margin:6px 0}.err{color:var(--bad);margin:6px 0}.ok{color:var(--good);margin:6px 0}
29
+ .btns{display:flex;gap:8px;flex-wrap:wrap;margin-top:12px;align-items:center}
30
+ button{min-height:44px;min-width:44px;padding:0 16px;border-radius:10px;border:1px solid var(--border);background:var(--bg);color:var(--text);font:inherit;cursor:pointer}
31
+ button.primary{background:var(--accent);border-color:var(--accent);color:#fff;font-weight:600}
32
+ button.link{border:0;background:none;color:var(--accent);padding:0;min-height:32px}
33
+ button.chip{min-height:36px;border-radius:999px;padding:0 12px}
34
+ button[aria-pressed=true]{background:var(--accent);border-color:var(--accent);color:#fff}
35
+ button:disabled{opacity:.55;cursor:default}
36
+ button:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
37
+ .row{background:var(--bg2);border:1px solid var(--border);border-radius:12px;padding:12px;margin-bottom:10px}
38
+ .row.open{border-color:var(--accent)}
39
+ .top{display:flex;gap:10px;align-items:center;justify-content:space-between;flex-wrap:wrap}
40
+ .name{font-weight:650;overflow-wrap:anywhere}.meta{color:var(--muted);font-size:12px;margin-top:2px}
41
+ .panel{margin-top:10px;border-top:1px dashed var(--border);padding-top:10px}
42
+ .bar{display:flex;flex-wrap:wrap;gap:8px;align-items:center;justify-content:space-between;margin-bottom:12px}
43
+ .seg{display:flex;gap:6px;flex-wrap:wrap}
44
+ .stepper{display:flex;align-items:center;border:1px solid var(--border);border-radius:10px;background:var(--bg)}
45
+ .stepper button{border:0;background:none;font-size:18px}
46
+ .skeleton{background:linear-gradient(90deg,var(--bg2),var(--border),var(--bg2));background-size:200% 100%;animation:sk 1.2s linear infinite;border-radius:12px;min-height:72px;margin-bottom:10px}
47
+ @keyframes sk{to{background-position:-200% 0}}
48
+ @media (prefers-reduced-motion:reduce){.skeleton{animation:none}}
49
+
50
+
51
+ .hero{margin-bottom:12px}.hero h1{font-size:18px;margin:0 0 4px}
52
+ .prog{display:flex;justify-content:space-between;align-items:center;margin:12px 0 6px;font-weight:650}
53
+ .bar2{height:8px;background:var(--border);border-radius:999px;overflow:hidden}.bar2 span{display:block;height:100%;background:var(--accent);transition:width .3s}
54
+ .tiles{display:flex;gap:10px;overflow-x:auto;padding:10px 0 12px;scroll-snap-type:x proximity}
55
+ .tile{flex:0 0 172px;scroll-snap-align:start;background:var(--bg2);border:1px solid var(--border);border-radius:12px;padding:12px;display:flex;flex-direction:column;gap:6px;min-height:170px}
56
+ .tile.done{border-color:var(--good)}.tile h2{font-size:14px;margin:0}.tile .sub{flex:1}
57
+ .tick{color:var(--good);font-weight:700;font-size:12px}
58
+ .res{font-size:12px;color:var(--text);background:var(--bg);border:1px solid var(--border);border-radius:8px;padding:6px 8px;overflow-wrap:anywhere}
59
+ .chips{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}
60
+ input.q{min-height:36px;border:1px solid var(--border);border-radius:8px;background:var(--bg);color:var(--text);padding:0 8px;font:inherit;width:100%}
61
+ .say{margin-top:8px;font-size:13px}.say code{background:var(--bg);border:1px solid var(--border);border-radius:6px;padding:1px 6px}
62
+
63
+ </style>
64
+ </head>
65
+ <body>
66
+ <main id="app"><div class="skeleton"></div><div class="skeleton"></div></main>
67
+ <!--BRIDGE-->
68
+ <script>
69
+ (function () {
70
+ const { el } = window.snapApp;
71
+ const $ = (id) => document.getElementById(id);
72
+ const state = { d: null, done: {}, out: {}, busy: {} };
73
+
74
+ // One line from whatever a tool returns, using only fields that are plain text or numbers.
75
+ function oneLine(data, text) {
76
+ if (data && typeof data === "object") {
77
+ for (const k of ["verdict", "summary", "headline", "answer", "message"]) if (typeof data[k] === "string" && data[k]) return data[k].slice(0, 220);
78
+ if (Array.isArray(data.items)) return data.items.length + " found" + (data.items[0] && data.items[0].name ? ": " + data.items.slice(0, 3).map((x) => x.name).join(", ") : "");
79
+ if (Array.isArray(data.matches)) return data.matches.length + " found" + (data.matches[0] && data.matches[0].name ? ": " + data.matches.slice(0, 3).map((x) => x.name).join(", ") : "");
80
+ }
81
+ return (text || "Done.").replace(/\s+/g, " ").slice(0, 220);
82
+ }
83
+
84
+ async function runTile(key, tool, args) {
85
+ state.busy[key] = true; render();
86
+ try { const r = await window.snapApp.run(tool, args || {}); state.out[key] = r.ok ? oneLine(r.data, r.text) : "Could not run: " + r.text.slice(0, 160); if (r.ok) state.done[key] = true; }
87
+ catch (e) { state.out[key] = "Could not run: " + String(e && e.message || e).slice(0, 160); }
88
+ state.busy[key] = false; render();
89
+ }
90
+
91
+ function tile(key, title, sub, btn, onclick, extra) {
92
+ const done = !!state.done[key];
93
+ return el("div", { class: "tile" + (done ? " done" : "") },
94
+ el("h2", null, title), el("div", { class: "sub" }, sub), extra || null,
95
+ state.out[key] ? el("div", { class: "res", dir: "auto" }, state.out[key]) : null,
96
+ done ? el("div", { class: "tick" }, "\u2713 DONE") : null,
97
+ btn ? el("button", { type: "button", disabled: !!state.busy[key], onclick }, state.busy[key] ? "Working\u2026" : (done ? "Run again" : btn)) : null);
98
+ }
99
+
100
+ function render() {
101
+ const d = state.d, root = $("app"); root.textContent = "";
102
+ if (!d) return;
103
+ const connected = d.connected !== false, acct = d.ad_account;
104
+ state.done.connect = connected; state.done.account = !!(acct && (acct.name || acct.id));
105
+ const qInput = el("input", { class: "q", id: "q", placeholder: "Part of a name\u2026", "aria-label": "Name to find" });
106
+ const tiles = [
107
+ tile("connect", "Connect Snapchat", connected ? "Signed in" + (d.signed_in && d.signed_in.login ? " as " + d.signed_in.login : "") + "." : (d.problem || "Not connected."), null),
108
+ tile("account", "Choose your ad account", acct ? (acct.name || acct.id) + (acct.currency ? " \u00b7 " + acct.currency : "") : "Pick the account to work in.", null,
109
+ null, !acct && d.choose_from ? el("div", { class: "chips" }, ...d.choose_from.slice(0, 6).map((a) => el("button", { type: "button", class: "chip", onclick: () => runTile("account", "snap_connect", { ad_account_name: a.name }).then(() => window.snapApp.run("snap_start_here", {}).then((r) => { if (r.ok) { state.d = r.data; render(); } })) }, a.name))) : null),
110
+ tile("perf", "See performance", "Spend, results and pacing for this account.", "Run", () => runTile("perf", "snap_dashboard", {})),
111
+ tile("deliv", "Why isn\u2019t it delivering?", "Checks active ad squads that are not spending.", "Run", () => runTile("deliv", "snap_delivery_check", {})),
112
+ tile("find", "Find by name", "Search campaigns, squads and ads. Arabic works.", "Find", () => { const v = (qInput.value || "").trim(); if (v) runTile("find", "snap_find", { query: v }); }, qInput),
113
+ tile("track", "Check tracking", "Is your pixel healthy and firing?", "Run", () => runTile("track", "snap_pixel_health", {})),
114
+ tile("budget", "Where to move budget", "Suggestions you can approve one by one.", "Run", () => runTile("budget", "snap_budget_advice", {})),
115
+ tile("create", "Create something", "Everything starts paused, with a preview first.", null, null, el("div", { class: "say" }, "Say: ", el("code", null, "Create a paused test campaign called \u2026"))),
116
+ ];
117
+ const total = tiles.length, n = Object.keys(state.done).filter((k) => state.done[k]).length;
118
+ const mode = d.mode || "";
119
+ const hero = el("div", { class: "card hero" },
120
+ el("h1", null, connected ? "You\u2019re connected \u2014 let\u2019s get a first win." : "Not connected yet"),
121
+ el("div", { class: "sub" }, acct ? (acct.name || acct.id) + (acct.status ? " \u00b7 " + acct.status : "") : "No ad account chosen yet"),
122
+ el("div", { class: "sub", style: "margin-top:4px" }, mode.startsWith("READ-ONLY") ? "Read-only: nothing can be changed." : "Changes are previewed first and everything created starts paused."),
123
+ d.warning ? el("div", { class: "warn" }, d.warning) : null,
124
+ d.worth_a_look ? el("div", { class: "warn" }, d.worth_a_look) : null,
125
+ d.snapshot ? el("div", { class: "sub", style: "margin-top:6px" }, "Campaigns: " + d.snapshot.campaigns.active + " active, " + d.snapshot.campaigns.paused + " paused \u00b7 Ad squads: " + d.snapshot.ad_squads.active + " active, " + d.snapshot.ad_squads.paused + " paused") : null,
126
+ el("div", { class: "prog" }, el("span", null, "First wins"), el("span", { class: "sub" }, n + " of " + total + " done")),
127
+ el("div", { class: "bar2", role: "progressbar", "aria-valuemin": "0", "aria-valuemax": String(total), "aria-valuenow": String(n) }, el("span", { style: "width:" + Math.round((n / total) * 100) + "%" })));
128
+ root.append(hero, el("div", { class: "tiles" }, ...tiles));
129
+ window.snapApp.resize();
130
+ }
131
+
132
+ window.snapApp.connect({
133
+ "ui/notifications/tool-result": (r) => { if (r && r.isError) { $("app").textContent = ""; $("app").append(el("div", { class: "card err" }, window.snapApp.textOf(r))); return; } state.d = window.snapApp.dataOf(r); render(); },
134
+ });
135
+ })();
136
+ </script>
137
+ </body>
138
+ </html>
package/src/apps.js CHANGED
@@ -7,7 +7,7 @@ import { readFileSync } from "node:fs";
7
7
  export const UI_MIME = "text/html;profile=mcp-app";
8
8
  // Chat apps keep a card page by its address, so a card that was redesigned but kept its address can go on showing the old page. Raise
9
9
  // CARD_REVISION whenever a card page, the shared theme or the bridge changes, and every card gets a new address.
10
- export const CARD_REVISION = 3;
10
+ export const CARD_REVISION = 5;
11
11
  const uri = (name) => `ui://snap-ads/${name}-r${CARD_REVISION}`;
12
12
  export const APP_URIS = {
13
13
  dashboard: uri("dashboard"),
@@ -16,9 +16,10 @@ export const APP_URIS = {
16
16
  history: uri("history"),
17
17
  setup: uri("setup"),
18
18
  advice: uri("advice"),
19
+ start: uri("start"),
19
20
  };
20
21
  // Which tool shows which card. Every tool that previews a change (it has `confirm`) shows the preview card.
21
- export const APP_TOOLS = { snap_dashboard: APP_URIS.dashboard, snap_campaign_board: APP_URIS.board, snap_change_history: APP_URIS.history, snap_setup_check: APP_URIS.setup, snap_budget_advice: APP_URIS.advice };
22
+ export const APP_TOOLS = { snap_dashboard: APP_URIS.dashboard, snap_campaign_board: APP_URIS.board, snap_change_history: APP_URIS.history, snap_setup_check: APP_URIS.setup, snap_budget_advice: APP_URIS.advice, snap_start_here: APP_URIS.start };
22
23
 
23
24
  // The card pages come from the apps/ folder. A hosted build has no folder: it hands the same pages over as text with useAssets().
24
25
  let assets = null;
@@ -60,6 +61,7 @@ export function registerApps(server) {
60
61
  ["snap-ads-history", APP_URIS.history, "history.html", "Change history with before and after values and Undo buttons that go through the usual preview and approval."],
61
62
  ["snap-ads-setup", APP_URIS.setup, "setup.html", "Connection and safety checklist with how to fix anything missing."],
62
63
  ["snap-ads-advice", APP_URIS.advice, "advice.html", "Budget suggestions to tick and apply together; each still previews and uses its approval token."],
64
+ ["snap-ads-start", APP_URIS.start, "start.html", "First-run guide: connection, ad account, and one-tap first wins with a progress bar."],
63
65
  ];
64
66
  for (const [name, uri, file, description] of pages) {
65
67
  server.registerResource(name, uri, { description, mimeType: UI_MIME }, async () => ({ contents: [{ uri, mimeType: UI_MIME, text: pageFor(file), _meta: { ui: { csp: { connectDomains: [], resourceDomains: [] }, ...(appDomain ? { domain: appDomain } : {}) } } }] }));