ads-mcp-for-snapchat 0.9.2 → 0.9.3

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/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.9.3 (2026-11-16)
6
+
7
+ - **Shared login is live.** The login service is deployed and the package uses it by default (`npx -y ads-mcp-for-snapchat setup`, choose 1). Verified on a real Snapchat login: login, account list, saving the access, renewing it through the service, and `verify` (20 of 24 checks ran; the rest need optional settings). Snap has not yet been asked to confirm a shared app for other advertisers; own-app setup still works.
8
+ - `setup` checks the name given for the server in Claude (letters, numbers, - and _) instead of passing a pasted command to Claude Code.
9
+
10
+ - Login service: the browser cookie that ties a login to the browser that started it is now sent after Snapchat's redirect in every browser (SameSite=None instead of Lax), and the error page says whether the link expired or the browser did not start the login.
11
+
12
+ - A GitHub Action builds the Claude Desktop file and creates the GitHub Release when a version tag is pushed.
13
+
5
14
  ## 0.9.2 (2026-11-15)
6
15
 
7
16
  - README: the "Not built" list no longer names things that now exist (product sets, dynamic product creatives, other ad squad goals); "Verified live" now says what the real-account `verify` run covered and what is still only tested against a fake Snap; the shared login is marked as not available until a service is deployed.
package/README.md CHANGED
@@ -30,9 +30,11 @@ In every case `snap_create_ad` picks the matching ad type (REMOTE_WEBPAGE, SNAP_
30
30
  `npx -y ads-mcp-for-snapchat verify` (or `node src/cli.js verify` in a git checkout; add `--details` to also list the specific problems it found: broken links, pixel issues, feed errors, audience problems, rejected ads) runs every read-only tool on your real account, one by one, and prints a short list: what worked, what failed and why, what was skipped (and which setting it needs). It changes nothing: it only calls tools that declare themselves read-only and forces read-only mode. The output contains no tokens and only shortened ids, so it is safe to paste into an issue.
31
31
 
32
32
  ## Easiest: log in with Snapchat (no OAuth app)
33
- **Not available yet.** The code is built and tested, but no shared login service has been deployed and Snap has not yet been asked whether a shared app may serve other advertisers. Until then, connect with your own Snapchat app (next section: about 5 minutes, and `setup` walks you through it).
33
+ Run `npx -y ads-mcp-for-snapchat setup` and choose **1. Shared login**, or install the Claude Desktop file, leave Client ID and secret empty, and ask Claude: "Connect my Snapchat ad account." You log in with Snapchat in your browser and pick your ad account. No OAuth app to create.
34
34
 
35
- Once a service exists (see `broker/README.md` and `PRIVACY.md`; you can also run your own), you will not need an OAuth app: run `npx -y ads-mcp-for-snapchat setup` and choose **1. Shared login**, or install the Claude Desktop file, leave Client ID and secret empty, and ask Claude: "Connect my Snapchat ad account." You log in with Snapchat in your browser and pick your ad account. The service only passes your login along: it stores nothing, and your access is sealed so only your own computer can read it.
35
+ How it works: a small login service (`broker/`, code in this repository) passes your login along and stores nothing, and your access is sealed so only your own computer can read it. Read `PRIVACY.md` first. The tool itself still runs only on your computer.
36
+
37
+ **Status: new.** It works end to end on the maintainer's real login and ad accounts, but Snap has not yet been asked to confirm that one shared app may serve other advertisers. If the login is refused for you, or you prefer not to rely on a shared service, use your own Snapchat app (next section: about 5 minutes, and `setup` walks you through it) or run your own copy of the service (`broker/README.md`).
36
38
 
37
39
  ## Easy setup (about 5 minutes)
38
40
  First, once: in [Snap Business Manager](https://business.snapchat.com) open **Business Details > OAuth Apps > + OAuth App**, use the Redirect URI `https://127.0.0.1/callback`, and copy the **Client ID** and **Client Secret** (the secret is shown only once).
@@ -92,7 +94,7 @@ With this setting the server asks **you**, through the MCP client's own dialog (
92
94
  | `SNAP_ACCOUNT_CURRENCY` | not set | If set (e.g. `USD`), writes are refused unless the ad account uses that currency |
93
95
  | `SNAP_READ_ONLY` | 0 | `1` = previews and reads only |
94
96
  | `SNAP_CAPI_TOKEN` | (none) | Only for the Conversions API test tools (`snap_capi_*`): a Conversions API token made in Ads Manager (Events Manager > Conversions API > Generate token), used if Snap does not accept your normal login there. Sent only to `tr.snapchat.com`. |
95
- | `SNAP_BROKER_URL` | (none) | 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. |
97
+ | `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. |
96
98
  | `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. |
97
99
  | `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. |
98
100
  | `SNAP_TOOLSETS` | all | Show only some tool groups to the AI app: `setup, read, reports, checks, changes, create` (comma-separated). Fewer tools make some apps faster and less error-prone, e.g. `setup,reports,checks` for an analyst. It only hides tools. |
@@ -275,7 +277,7 @@ Verified on the maintainer's own ad account. Anything not listed here is covered
275
277
  **Not verified live:**
276
278
  - Everything that **writes** and was added in 0.7.0 or later: catalog ad creation (product sets, templates, campaign, ad squad, creative, ad), frequency cap, ad schedule, placement, bid-strategy switching, and the new ad squad goals. Built from Snap's documentation and mocked tests.
277
279
  - The Conversions API test tools (they need a Conversions API token: `SNAP_CAPI_TOKEN`), the portfolio summary (needs a second settings file), blended ROAS (needs your store's revenue), creative comparison, ad preview, and the playbooks.
278
- - The shared login service against the real Snapchat login (it is tested against a fake one; deploy it and follow `broker/README.md` step 5).
280
+ - The shared login for people **outside** the maintainer's organization, and the Claude Desktop extension's login. (Setup's shared login, the account list and renewing the login through the service were run live on the maintainer's account.)
279
281
  - 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.
280
282
 
281
283
  ## Not built
package/broker/worker.js CHANGED
@@ -79,16 +79,19 @@ async function login(request, env) {
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
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();
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=Lax`, ...SECURITY_HEADERS } });
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
 
85
85
  async function callback(request, env, fetchImpl) {
86
86
  need(env, "SNAP_CLIENT_ID", "SNAP_CLIENT_SECRET", "STATE_KEY");
87
87
  const u = new URL(request.url);
88
- const clear = { "Set-Cookie": `${COOKIE}=; Path=/callback; Max-Age=0; HttpOnly; Secure; SameSite=Lax` };
88
+ const clear = { "Set-Cookie": `${COOKIE}=; Path=/callback; Max-Age=0; HttpOnly; Secure; SameSite=None` };
89
89
  const state = await readState(env, u.searchParams.get("state"));
90
- if (!state || !state.k || !validPort(String(state.p)) || !validNonce(state.n) || getCookie(request, COOKIE) !== state.n) {
91
- return page("Login expired", "<h1>This login link is not valid any more</h1><p>It may have expired, or it was opened in a different browser. Start again from the setup command.</p>", 400, clear);
90
+ if (!state || !state.k || !validPort(String(state.p)) || !validNonce(state.n)) {
91
+ return page("Login expired", "<h1>This login link is not valid any more</h1><p>It has expired or was changed. Start again from the setup command.</p>", 400, clear);
92
+ }
93
+ if (getCookie(request, COOKIE) !== state.n) {
94
+ return page("Login expired", "<h1>This browser did not start the login</h1><p>The login must finish in the same browser window it started in, and the address must not be reloaded or opened a second time. Allow cookies for this site, then start again from the setup command.</p>", 400, clear);
92
95
  }
93
96
  if (u.searchParams.get("error")) return page("Login cancelled", "<h1>Snapchat did not approve the login</h1><p>Nothing was saved. You can close this tab and start again.</p>", 400, clear);
94
97
  const code = u.searchParams.get("code");
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "ads-mcp-for-snapchat",
3
- "version": "0.9.2",
3
+ "version": "0.9.3",
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
- "adsMcpBroker": "",
6
+ "adsMcpBroker": "https://ads-mcp-for-snapchat-login.ads-mcp.workers.dev",
7
7
  "type": "module",
8
8
  "main": "src/index.js",
9
9
  "bin": {
package/src/broker.js CHANGED
@@ -22,7 +22,7 @@ function packageDefault() {
22
22
  // sent to this address, so a plain http address to anything else is refused.
23
23
  export function brokerUrlFrom(env = process.env, fallback = packageDefault()) {
24
24
  const raw = String(env.SNAP_BROKER_URL ?? "").trim() || String(fallback ?? "").trim();
25
- if (!raw) return null;
25
+ if (!raw || /^(off|none|no)$/i.test(raw)) return null; // SNAP_BROKER_URL=off turns the shared login off
26
26
  let u;
27
27
  try {
28
28
  u = new URL(raw);
package/src/cli.js CHANGED
File without changes
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.2" });
23
+ const server = new McpServer({ name: "ads-mcp-for-snapchat", version: "0.9.3" });
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/setup.js CHANGED
@@ -224,7 +224,15 @@ export async function runSetup({ io, file = envFile(), fetchImpl = fetch, open =
224
224
  const launch = launchCommand(root);
225
225
  const defaultFile = join(dataDir({ root }), ".env");
226
226
  const envArgs = file === defaultFile ? [] : ["-e", `SNAP_ENV_FILE=${file}`];
227
- const name = (await io.ask(" Name for this server in Claude [snapchat-ads]: ")) || "snapchat-ads";
227
+ let name = "snapchat-ads";
228
+ for (let tries = 0; tries < 3; tries++) {
229
+ const answer = ((await io.ask(" Name for this server in Claude [snapchat-ads]: ")) || "snapchat-ads").trim();
230
+ if (/^[A-Za-z0-9_-]{1,64}$/.test(answer)) {
231
+ name = answer;
232
+ break;
233
+ }
234
+ say(" Use only letters, numbers, - and _ (for example snapchat-ads).");
235
+ }
228
236
  let registered = false;
229
237
  if (claudeAvailable(exec)) {
230
238
  try {