ads-mcp-for-snapchat 0.9.4 → 0.9.5

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
@@ -7,6 +7,8 @@ SNAP_REFRESH_TOKEN=
7
7
  SNAP_AD_ACCOUNT_ID=
8
8
  # Safety limits (optional; plain numbers in account currency; an invalid value stops the server; restart to apply)
9
9
  SNAP_MAX_DAILY_BUDGET=1000
10
+ # Optional: a warning (not a limit) in the preview when a change adds more daily budget than this.
11
+ # SNAP_WARN_DAILY_BUDGET=
10
12
  SNAP_MIN_DAILY_BUDGET=5
11
13
  SNAP_MAX_BID=50
12
14
  SNAP_MAX_BUDGET_INCREASE_PCT=100
package/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.9.5 (2026-11-17)
6
+
7
+ - **Claude Desktop extension starts with changes allowed** (Read-only is off by default) and a daily budget limit of 500. Every change is still previewed and needs approval, everything created starts paused, and the limit and the new budget warning apply. `npx ... setup` still starts read-only unless you choose otherwise.
8
+
9
+ - **Budget warning.** A preview that adds a daily budget unusually large for the account now shows a `budget_warning`: more than twice the largest running ad squad, more than half the limit when nothing is running, or above the optional `SNAP_WARN_DAILY_BUDGET`. It is a warning only; the limits still apply and nothing is blocked by it.
10
+
11
+ - README: a short section on how this project relates to Snap's own read-only Ads MCP server (use theirs to look, this one to launch and change campaigns, safely).
12
+
5
13
  ## 0.9.4 (2026-11-16)
6
14
 
7
15
  - Claude Desktop extension: an icon, a link to the privacy page, and the corrected description (the shared login needs no OAuth app).
package/README.md CHANGED
@@ -5,7 +5,7 @@ A local [MCP](https://modelcontextprotocol.io) server that lets an AI assistant
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.
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.
9
9
 
10
10
  **Claude Code, Cursor, VS Code or a terminal:**
11
11
  ```bash
@@ -13,6 +13,15 @@ npx -y ads-mcp-for-snapchat setup
13
13
  ```
14
14
  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
15
 
16
+ ## How this relates to Snap's own Ads MCP server
17
+ 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
+
19
+ - **Only need to look at your numbers?** Snap's own server is the simplest way, and you don't have to install anything.
20
+ - **Want to launch and change campaigns?** That is what this project is for: you can create campaigns, ad squads, creatives and ads and change budgets, bids, schedules and placements, with a **preview and your approval for every change**, spend limits, undo and a change log, and everything created starts **paused**. Turn on changes with `SNAP_READ_ONLY=0` (the safe default starts read-only; it is a switch, not a limit).
21
+ - You can use both side by side.
22
+
23
+ This project is unofficial and is not made, endorsed or supported by Snap. It runs on your own computer; it is not the hosted service Snap provides.
24
+
16
25
  ## What it is, and what it is not
17
26
  - **It 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. The tool itself is not hosted, and no ad account data leaves your computer except to Snap's API.
18
27
  - **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".
@@ -93,6 +102,7 @@ With this setting the server asks **you**, through the MCP client's own dialog (
93
102
  | Setting | Default | Meaning |
94
103
  |---|---|---|
95
104
  | `SNAP_MAX_DAILY_BUDGET` | 1000 | Highest daily budget any single campaign or ad squad may be given or enabled with |
105
+ | `SNAP_WARN_DAILY_BUDGET` | (none) | Optional **warning** level, not a limit: a change that adds more than this daily budget shows a `budget_warning` in the preview. Without it, the preview still warns when a change adds more than twice your largest running ad squad (or, on an account with none running, more than half of `SNAP_MAX_DAILY_BUDGET`). |
96
106
  | `SNAP_MIN_DAILY_BUDGET` | 5 | Lowest daily budget |
97
107
  | `SNAP_MAX_BID` | 50 | Highest max bid |
98
108
  | `SNAP_MAX_BUDGET_INCREASE_PCT` | 100 | Largest budget increase per step and per 24 hours |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ads-mcp-for-snapchat",
3
- "version": "0.9.4",
3
+ "version": "0.9.5",
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",
@@ -0,0 +1,43 @@
1
+ // A soft warning (not a limit): tells the person when a change adds a daily budget that is large compared with what this ad
2
+ // account normally runs. The hard limits in policy.js still apply; this only makes an unusual amount hard to miss in the preview.
3
+ const round = (n) => Math.round(n * 100) / 100;
4
+ const median = (xs) => {
5
+ const s = [...xs].sort((a, b) => a - b);
6
+ const m = s.length >> 1;
7
+ return s.length % 2 ? s[m] : (s[m - 1] + s[m]) / 2;
8
+ };
9
+
10
+ // Pure. `added` is the daily budget this change adds (a new ad squad's budget, or the size of an increase).
11
+ // `squadBudgets` are the daily budgets of the ad squads that are running now.
12
+ export function judgeBudget({ added, squadBudgets = [], maxDailyBudget, warnAbove = null, currency = "" }) {
13
+ if (!(added > 0)) return null;
14
+ const unit = currency ? ` ${currency}` : "";
15
+ const budgets = squadBudgets.filter((b) => b > 0);
16
+ const largest = budgets.length ? Math.max(...budgets) : null;
17
+ const typical = budgets.length ? round(median(budgets)) : null;
18
+ const reasons = [];
19
+ if (warnAbove && added > warnAbove) reasons.push(`it is above your own warning level of ${warnAbove}${unit} a day (SNAP_WARN_DAILY_BUDGET)`);
20
+ if (largest && added > 2 * largest) reasons.push(`it is more than twice your largest running ad squad (${round(largest)}${unit} a day; typical ${typical}${unit})`);
21
+ if (!largest && maxDailyBudget && added > maxDailyBudget / 2) reasons.push(`it is more than half of your limit of ${maxDailyBudget}${unit} a day and this account has no running ad squad to compare with`);
22
+ if (!reasons.length) return null;
23
+ return {
24
+ level: "HIGHER_THAN_NORMAL",
25
+ message: `This change adds ${round(added)}${unit} of daily budget, and ${reasons.join("; ")}. Check the amount before you approve.`,
26
+ added_daily_budget: round(added),
27
+ largest_running_daily_budget: largest == null ? null : round(largest),
28
+ typical_running_daily_budget: typical,
29
+ };
30
+ }
31
+
32
+ // Reads the running ad squads' daily budgets and judges. Never blocks a preview: if the account cannot be read, there is no warning.
33
+ export async function budgetWarning(client, adAccountId, { added, policy }) {
34
+ if (!(added > 0)) return null;
35
+ let squadBudgets = [];
36
+ try {
37
+ const { items } = await client.listPaged(`/adaccounts/${adAccountId}/adsquads`, "adsquad", { maxPages: 2 });
38
+ squadBudgets = items.filter((s) => s.status === "ACTIVE" && s.daily_budget_micro > 0).map((s) => s.daily_budget_micro / 1e6);
39
+ } catch {
40
+ squadBudgets = [];
41
+ }
42
+ return judgeBudget({ added, squadBudgets, maxDailyBudget: policy.maxDailyBudget, warnAbove: policy.warnDailyBudget, currency: policy.currency ?? "" });
43
+ }
package/src/index.js CHANGED
@@ -20,7 +20,7 @@ try {
20
20
  }
21
21
  // Snapshot of the non-secret settings taken at startup. Later edits to .env do not change limits or the target account.
22
22
  const settings = { ...process.env };
23
- const server = new McpServer({ name: "ads-mcp-for-snapchat", version: "0.9.4" });
23
+ const server = new McpServer({ name: "ads-mcp-for-snapchat", version: "0.9.5" });
24
24
  // Only the OAuth credentials are re-read from .env when a token is needed, so replacing them does not require a restart.
25
25
  const client = new SnapClient({ beforeToken: () => loadEnv(undefined, { override: true }), timeoutMs: policy.httpTimeoutMs });
26
26
  registerTools(server, client, settings);
package/src/policy.js CHANGED
@@ -67,7 +67,14 @@ export function loadPolicy(env = process.env) {
67
67
  } catch (e) {
68
68
  errors.push(e.message);
69
69
  }
70
+ let warnDailyBudget = null;
71
+ if (env.SNAP_WARN_DAILY_BUDGET !== undefined && String(env.SNAP_WARN_DAILY_BUDGET).trim() !== "") {
72
+ const w = Number(String(env.SNAP_WARN_DAILY_BUDGET).trim());
73
+ if (Number.isFinite(w) && w > 0 && w <= HARD_MAX) warnDailyBudget = w;
74
+ else errors.push("SNAP_WARN_DAILY_BUDGET must be a positive number (a budget above this shows a warning in the preview).");
75
+ }
70
76
  const policy = {
77
+ warnDailyBudget,
71
78
  toolsets,
72
79
  defaultCountry: country && /^[a-z]{2}$/.test(country) ? country : null,
73
80
  defaultPhoneCode: phoneCode && /^[1-9]\d{0,3}$/.test(phoneCode) ? phoneCode : null,
package/src/tools.js CHANGED
@@ -16,6 +16,7 @@ import { compareReport, healthCheck, pixelHealth, reviewIssues } from "./audit.j
16
16
  import { fatigueReport } from "./fatigue.js";
17
17
  import { buildDynamicCreative, buildDynamicTemplate, buildProductSet, creativeProductSet, describeFilter, squadProductSet, TEMPLATE_LAYOUTS, TEMPLATE_TEXT_FIELDS } from "./catalog-ads.js";
18
18
  import { brokerUrlFrom, startBrokerLogin } from "./broker.js";
19
+ import { budgetWarning } from "./budget-warning.js";
19
20
  import { audienceInsights, buildTestEvent, capiStatus, capiTest, CAPI_TEST_EVENTS, competitorAds, GALLERY_COUNTRIES, INSIGHT_CATEGORIES } from "./intel.js";
20
21
  import { anomalyCheck, blendedRoas, landingPageReport } from "./checks.js";
21
22
  import { toolAllowed } from "./toolsets.js";
@@ -206,8 +207,10 @@ export function registerTools(server, client, env = process.env) {
206
207
  if (p.blocked) return text(p.preview);
207
208
  const repeat = repeatGuard ? approvals.recentRepeat(requestDigest) : null;
208
209
  const issued = approvals.issue(name, binding, detail);
210
+ const budgetWarn = added > 0 ? await budgetWarning(client, account(), { added, policy }) : null;
209
211
  return text({
210
212
  ...p.preview,
213
+ ...(budgetWarn ? { budget_warning: budgetWarn } : {}),
211
214
  ...(repeat ? { duplicate_warning: `An identical request was executed ${repeat.seconds_ago}s ago and will be refused if confirmed: ${JSON.stringify(repeat.summary)}` } : {}),
212
215
  ...(ledger ? { spend_impact: ledger } : {}),
213
216
  ...(policy.readOnly ? { read_only: "SNAP_READ_ONLY is on: this preview cannot be applied." } : {}),