socialcrawl-mcp 2.2.0 → 2.3.0

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.
Files changed (43) hide show
  1. package/README.md +42 -20
  2. package/dist/app.d.ts +3 -3
  3. package/dist/app.js +5 -1
  4. package/dist/client-tag.d.ts +13 -0
  5. package/dist/client-tag.js +17 -0
  6. package/dist/client.js +6 -4
  7. package/dist/constants.d.ts +1 -1
  8. package/dist/constants.js +1 -1
  9. package/dist/context.d.ts +6 -0
  10. package/dist/context.js +1 -0
  11. package/dist/data/docs-async.d.ts +2 -2
  12. package/dist/data/docs-async.js +137 -116
  13. package/dist/data/docs-handwritten.js +46 -5
  14. package/dist/data/docs.js +2 -0
  15. package/dist/data/endpoints.js +13111 -10305
  16. package/dist/data/examples.js +2 -2
  17. package/dist/data/guide.d.ts +2 -2
  18. package/dist/data/guide.js +2 -2
  19. package/dist/data/outputs.js +324 -219
  20. package/dist/data/platforms.js +207 -48
  21. package/dist/data/recipes.js +1 -1
  22. package/dist/data/registry-meta.d.ts +8 -8
  23. package/dist/data/registry-meta.js +8 -8
  24. package/dist/hydration.js +21 -3
  25. package/dist/oauth/config.d.ts +19 -4
  26. package/dist/oauth/config.js +31 -6
  27. package/dist/schemas/async.d.ts +37 -27
  28. package/dist/schemas/async.js +28 -9
  29. package/dist/schemas/outputs.d.ts +2 -2
  30. package/dist/schemas/tools.d.ts +18 -6
  31. package/dist/schemas/tools.js +24 -4
  32. package/dist/server.js +6 -5
  33. package/dist/tools/account.d.ts +4 -1
  34. package/dist/tools/account.js +1 -1
  35. package/dist/tools/async-common.js +3 -1
  36. package/dist/tools/check-balance.d.ts +4 -2
  37. package/dist/tools/check-balance.js +9 -0
  38. package/dist/tools/discover-runs.js +117 -11
  39. package/dist/tools/estimate.js +10 -1
  40. package/dist/tools/manage.js +2 -0
  41. package/dist/tools/monitors.d.ts +7 -1
  42. package/dist/tools/monitors.js +26 -2
  43. package/package.json +75 -75
package/dist/server.js CHANGED
@@ -66,7 +66,7 @@ export function createServer(baseCtx, options = {}) {
66
66
  server.registerTool = (name, config, cb) => registerTool(name, config, async (...args) => withFreshness((await cb(...args))));
67
67
  server.registerTool("socialcrawl_find", {
68
68
  title: "Find the Endpoint for a Task",
69
- description: `Start here: a task in plain words -> the best endpoints (3 by default) of ${ENDPOINTS.length}, each with the params the task supplies (URLs and @handles resolved), the params still missing, the credit cost and the exact call. With no task it lists platforms, or one platform's endpoints. Free; no key needed.`,
69
+ description: `Start here: a task in plain words -> the best endpoints (3 by default) of ${ENDPOINTS.length}, each with the params the task supplies (URLs and @handles resolved), the params still missing, the credit cost and the exact call. Free; no key needed.`,
70
70
  inputSchema: withNormalizedArgs(FindInputSchema, "find"),
71
71
  outputSchema: FindOutputShape,
72
72
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
@@ -76,7 +76,7 @@ export function createServer(baseCtx, options = {}) {
76
76
  });
77
77
  server.registerTool("socialcrawl_endpoint", {
78
78
  title: "Endpoint Contract",
79
- description: "Read before calling: one endpoint's purpose, params, where the rows are and up to 25 response fields, cost rule, paging, latency, timeout, next endpoints and a sample link. id (or platform+resource, path), a platform slug (its endpoints) or a guide topic. Free.",
79
+ description: "Read before calling: one endpoint's purpose, params, where the rows are and up to 25 response fields, cost rule, paging, latency, timeout, next endpoints and a sample link. By id, platform+resource or path. Free.",
80
80
  inputSchema: withNormalizedArgs(EndpointInputSchema, "endpoint"),
81
81
  outputSchema: EndpointOutputShape,
82
82
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
@@ -86,7 +86,7 @@ export function createServer(baseCtx, options = {}) {
86
86
  });
87
87
  server.registerTool("socialcrawl_estimate", {
88
88
  title: "Estimate Credit Cost",
89
- description: "Exact credits before you spend: one call (id, platform+resource or path, plus the params you will send; calls for a job total; items for a walk) or a plan of several calls. Uses the API's estimator when available, else the bundled pricing. A platform slug gives its price table; no id gives the pricing overview. Free.",
89
+ description: "Exact credits before you spend: one call (id, platform+resource or path, plus the params you will send; calls for a job total; items for a walk) or a plan of several calls. Uses the API's estimator when available, else the bundled pricing. Free.",
90
90
  inputSchema: withNormalizedArgs(EstimateInputSchema, "estimate"),
91
91
  outputSchema: EstimateOutputShape,
92
92
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
@@ -134,7 +134,7 @@ export function createServer(baseCtx, options = {}) {
134
134
  });
135
135
  server.registerTool("socialcrawl_collect", {
136
136
  title: "Collect Rows Across Pages",
137
- description: "Walk a paged endpoint (id, platform+resource or path) to `items` unique rows, the last page or max_credits: cursors supplied, duplicates dropped, stops on a 402, refused free when one page exceeds max_credits. Small results come back whole. result_id (+offset, limit, format) reads a stored result, free. Spends credits.",
137
+ description: "Walk a paged endpoint (id, platform+resource or path) to `items` unique rows, the last page or max_credits: cursors supplied, duplicates dropped, stops on a 402, refused free when one page exceeds max_credits. Small results come back whole. Spends credits.",
138
138
  inputSchema: withNormalizedArgs(CollectInputSchema, "collect"),
139
139
  outputSchema: CollectOutputShape,
140
140
  annotations: {
@@ -161,7 +161,7 @@ export function createServer(baseCtx, options = {}) {
161
161
  });
162
162
  server.registerTool("socialcrawl_account", {
163
163
  title: "Account and Service Status",
164
- description: "Free: balance (default, with this session's spend), transactions (ledger), usage (per key per day; from/to YYYY-MM-DD, ≤92 days), status (health; check before retrying a 502/503), freshness (vs live catalogue), notifications (inbox).",
164
+ description: "Free: balance (default, with this session's spend), transactions (ledger), usage (by api_key, day, endpoint or tag; ≤92 days), status (health; check before retrying a 502/503), freshness (vs live catalogue), notifications (inbox).",
165
165
  inputSchema: withNormalizedArgs(AccountInputSchema, "account"),
166
166
  outputSchema: AccountOutputShape,
167
167
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
@@ -175,6 +175,7 @@ export function createServer(baseCtx, options = {}) {
175
175
  to: params.to,
176
176
  group_by: params.group_by,
177
177
  api_key_id: params.api_key_id,
178
+ tag: params.tag,
178
179
  unread: params.unread,
179
180
  kind: params.kind,
180
181
  });
@@ -20,8 +20,11 @@ export interface AccountParams {
20
20
  /** usage: first and last UTC day (YYYY-MM-DD), at most 92 days apart. */
21
21
  from?: string;
22
22
  to?: string;
23
- group_by?: "api_key" | "day" | "api_key,day";
23
+ /** usage: any comma-separated mix of api_key, day, endpoint, tag. */
24
+ group_by?: string;
24
25
  api_key_id?: string;
26
+ /** transactions: only receipts with this x-client-tag. */
27
+ tag?: string;
25
28
  }
26
29
  export declare function accountStructured(ctx: ApiContext, params: AccountParams): Promise<ToolOutput>;
27
30
  /** The kinds GET /v1/notifications filters on (packages/db notification-kinds.ts). */
@@ -5,7 +5,7 @@ import { discover } from "./discover.js";
5
5
  export async function accountStructured(ctx, params) {
6
6
  const view = params.view ?? "balance";
7
7
  if (view === "balance" || view === "transactions") {
8
- return checkBalanceStructured(ctx, { view, limit: params.limit, cursor: params.cursor, requestId: params.request_id });
8
+ return checkBalanceStructured(ctx, { view, limit: params.limit, cursor: params.cursor, requestId: params.request_id, tag: params.tag });
9
9
  }
10
10
  if (view === "usage") {
11
11
  return checkBalanceStructured(ctx, {
@@ -84,7 +84,9 @@ const FOLLOWABLE = [
84
84
  new RegExp(`^/v1/(search/everywhere|prism/creators)/runs/run_${ID}(/legs|/results\\.jsonl)?$`),
85
85
  /^\/v1\/search\/everywhere\/watches$/,
86
86
  /^\/v1\/search\/everywhere\/watches\/[A-Za-z0-9_-]{1,80}$/,
87
- new RegExp(`^/v1/(trustpilot|tripadvisor)/reviews/history/job_${ID}$`),
87
+ new RegExp(`^/v1/(trustpilot|tripadvisor|google/business|yelp/business)/reviews/history/job_${ID}$`),
88
+ // Bulk review jobs: the read only; its /cancel is a POST and stays refused.
89
+ new RegExp(`^/v1/prism/reviews/bulk/job_${ID}$`),
88
90
  /^\/v1\/events$/,
89
91
  /^\/v1\/webhook-endpoints$/,
90
92
  new RegExp(`^/v1/webhook-endpoints/we_${ID}(/attempts)?$`),
@@ -16,10 +16,12 @@ export interface CheckBalanceParams {
16
16
  from?: string;
17
17
  /** usage: last UTC day (YYYY-MM-DD), default today. A range covers at most 92 days. */
18
18
  to?: string;
19
- /** usage: `api_key`, `day`, or `api_key,day` (default). */
20
- groupBy?: "api_key" | "day" | "api_key,day";
19
+ /** usage: any comma-separated mix of `api_key`, `day`, `endpoint`, `tag` (default `api_key,day`). */
20
+ groupBy?: string;
21
21
  /** usage: scope to one API key id. */
22
22
  apiKeyId?: string;
23
+ /** transactions: only receipts carrying this `x-client-tag` (last 92 days). */
24
+ tag?: string;
23
25
  }
24
26
  /**
25
27
  * The account meta endpoints (api-key auth, 0 credits):
@@ -1,4 +1,5 @@
1
1
  import { makeRequest } from "../client.js";
2
+ import { clientTagOf } from "../client-tag.js";
2
3
  import { sessionTotal } from "../session-spend.js";
3
4
  import { errorFromText, structureEnvelope, summaryLine } from "../result.js";
4
5
  /**
@@ -53,6 +54,14 @@ export async function checkBalanceStructured(ctx, params = {}) {
53
54
  query.cursor = params.cursor;
54
55
  if (params.requestId)
55
56
  query.request_id = params.requestId;
57
+ if (params.tag !== undefined) {
58
+ const tag = clientTagOf(params.tag);
59
+ if (!tag) {
60
+ const text = `Error: Invalid parameter value(s): \`tag\` "${params.tag}". A tag is 1-64 letters, digits, '.', '_', ':' or '-'. Nothing was sent or charged.`;
61
+ return { text, structured: errorFromText(text) };
62
+ }
63
+ query.tag = tag;
64
+ }
56
65
  const response = await makeRequest(ctx, {
57
66
  platform: "meta",
58
67
  resource: "credits/transactions",
@@ -1,4 +1,4 @@
1
- import { REVIEW_JOB_ID_RE, RUN_ID_RE, SCHEDULE_ID_RE } from "../schemas/async.js";
1
+ import { DISCOVER_INPUT_ID_RE, REVIEW_HISTORY_PLATFORMS, REVIEW_JOB_ID_RE, RUN_ID_RE, SCHEDULE_ID_RE } from "../schemas/async.js";
2
2
  import { EVENTS_CURSOR_EXPIRED_HINT, LONG_READ_TIMEOUT_MS, dataOf, pruneQuery, render, resolveFollowUrl, sendRequest, } from "./async-common.js";
3
3
  const RUN_ACTIONS_WITH_ID = new Set(["run_get", "run_export", "run_legs", "run_cancel", "run_resume", "run_more"]);
4
4
  const SCHEDULE_ACTIONS_WITH_ID = new Set(["schedule_get", "schedule_pause", "schedule_resume", "schedule_delete"]);
@@ -54,6 +54,12 @@ export async function discoverRuns(ctx, input) {
54
54
  if (input.schedule_id !== undefined && !SCHEDULE_ID_RE.test(input.schedule_id)) {
55
55
  return `Error: Invalid parameter value(s): schedule id "${input.schedule_id}". It is dsch_ followed by letters and digits (data.schedule.schedule_id). Nothing was sent.`;
56
56
  }
57
+ if (input.list_id !== undefined && !DISCOVER_INPUT_ID_RE.test(input.list_id)) {
58
+ return `Error: Invalid parameter value(s): list id "${input.list_id}". It is din_ followed by letters and digits (data.exclude_list_id or data.author_list_id). Nothing was sent.`;
59
+ }
60
+ if ((action === "input_append" || action === "input_delete") && !input.list_id) {
61
+ return 'Error: Missing required parameter(s): `id` (the din_ list id; "input_list" finds it). Nothing was sent.';
62
+ }
57
63
  if (RUN_ACTIONS_WITH_ID.has(action) && !input.run_id) {
58
64
  return `Error: Missing required parameter(s): \`id\` (the run_id, data.run.run_id of a prism/discover answer; "run_list" finds it). Nothing was sent.`;
59
65
  }
@@ -267,6 +273,46 @@ export async function discoverRuns(ctx, input) {
267
273
  }
268
274
  return render({ title: "SocialCrawl Discover Schedule", label, cost, response });
269
275
  }
276
+ // ── stored inputs (author and exclude lists) ──────────────────────
277
+ case "input_list": {
278
+ const response = await sendRequest(ctx, { method: "GET", path: "/v1/prism/discover/inputs", errorPlatform: "prism" });
279
+ return render({
280
+ title: "SocialCrawl Discover Stored Lists",
281
+ label: "GET /v1/prism/discover/inputs",
282
+ cost: "0 credits",
283
+ response,
284
+ notes: ["**Limits:** at most 500 live lists per account (`live` of `limit`), each kept 30 days; an exclude list holds up to 50,000 entries. Entries are never listed here."],
285
+ });
286
+ }
287
+ case "input_append": {
288
+ if (!input.exclude) {
289
+ return "Error: Missing required parameter(s): `exclude` in input (1 to 50,000 entries to add). Nothing was sent.";
290
+ }
291
+ const response = await sendRequest(ctx, {
292
+ method: "POST",
293
+ path: `/v1/prism/discover/inputs/${encodeURIComponent(input.list_id)}/entries`,
294
+ body: { exclude: input.exclude },
295
+ errorPlatform: "prism",
296
+ });
297
+ return render({
298
+ title: "SocialCrawl Discover Stored Lists — append",
299
+ label: `POST /v1/prism/discover/inputs/${input.list_id}/entries`,
300
+ cost: "0 credits — duplicates are skipped and the list's expiry moves to 31 days from now",
301
+ response,
302
+ errorHints: {
303
+ exclude_list_full: "The list would pass 50,000 entries: start a new exclude list with POST prism/discover/inputs.",
304
+ input_not_found: 'The list expired, belongs to another account, or is an author list (only exclude lists take entries). "input_list" shows the live ones.',
305
+ },
306
+ });
307
+ }
308
+ case "input_delete": {
309
+ const response = await sendRequest(ctx, {
310
+ method: "DELETE",
311
+ path: `/v1/prism/discover/inputs/${encodeURIComponent(input.list_id)}`,
312
+ errorPlatform: "prism",
313
+ });
314
+ return render({ title: "SocialCrawl Discover Stored Lists — delete", label: `DELETE /v1/prism/discover/inputs/${input.list_id}`, cost: "0 credits", response });
315
+ }
270
316
  // ── follow ─────────────────────────────────────────────────────────
271
317
  case "follow": {
272
318
  if (!input.url) {
@@ -293,36 +339,96 @@ export async function discoverRuns(ctx, input) {
293
339
  return `Error: Unknown action "${action}".`;
294
340
  }
295
341
  }
342
+ /**
343
+ * Where each platform's history job is polled (review-history/http.ts,
344
+ * yelp-review-history/http.ts). Google and Yelp live under `business/`.
345
+ */
346
+ const REVIEW_HISTORY_ROUTES = {
347
+ trustpilot: "trustpilot/reviews/history",
348
+ tripadvisor: "tripadvisor/reviews/history",
349
+ google: "google/business/reviews/history",
350
+ yelp: "yelp/business/reviews/history",
351
+ };
296
352
  export async function reviewHistory(ctx, input) {
297
353
  if (!input.job_id) {
298
- return "Error: Missing required parameter(s): `id` (the job_id, data.job_id of POST trustpilot/reviews/history via socialcrawl_request). Nothing was sent.";
354
+ return "Error: Missing required parameter(s): `id` (the job_id, data.job_id of the POST that started the job via socialcrawl_request). Nothing was sent.";
299
355
  }
300
356
  if (!REVIEW_JOB_ID_RE.test(input.job_id)) {
301
357
  return `Error: Invalid parameter value(s): job id "${input.job_id}". A review history job id is job_ followed by letters and digits. Nothing was sent.`;
302
358
  }
359
+ if (input.action === "bulk_get" || input.action === "bulk_cancel")
360
+ return reviewsBulk(ctx, input);
303
361
  const platform = input.platform ?? "trustpilot";
304
- if (platform !== "trustpilot" && platform !== "tripadvisor") {
305
- return `Error: Invalid parameter value(s): platform is "trustpilot" (default) or "tripadvisor", not "${String(platform)}". Nothing was sent.`;
362
+ if (!REVIEW_HISTORY_PLATFORMS.includes(platform)) {
363
+ return `Error: Invalid parameter value(s): platform is one of ${REVIEW_HISTORY_PLATFORMS.join(", ")} (default trustpilot), not "${String(platform)}". Nothing was sent.`;
306
364
  }
365
+ const route = REVIEW_HISTORY_ROUTES[platform];
307
366
  const response = await sendRequest(ctx, {
308
367
  method: "GET",
309
- path: `/v1/${platform}/reviews/history/${encodeURIComponent(input.job_id)}`,
368
+ path: `/v1/${route}/${encodeURIComponent(input.job_id)}`,
310
369
  query: pruneQuery({ offset: input.offset?.toString(), limit: input.limit?.toString() }),
311
370
  errorPlatform: platform,
312
371
  });
313
372
  return render({
314
373
  title: "SocialCrawl Review History",
315
- label: `GET /v1/${platform}/reviews/history/${input.job_id}`,
374
+ label: `GET /v1/${route}/${input.job_id}`,
316
375
  cost: "0 credits (the POST held the price; `credits_charged` is the settled charge and the rest was refunded)",
317
376
  response,
318
377
  successNotes: (parsed) => {
319
378
  const data = dataOf(parsed);
320
- if (Array.isArray(data.items)) {
321
- const n = data.items.length;
322
- const lim = input.limit ?? 100;
323
- return n >= lim ? [`**More reviews:** call again with offset ${(input.offset ?? 0) + n}.`] : ["**Done:** this is the last page."];
379
+ const job = typeof data.job === "object" && data.job !== null ? data.job : undefined;
380
+ const charged = job && job.credits_charged !== null && job.credits_charged !== undefined ? [`**Charged:** credits_charged ${String(job.credits_charged)} of credits_hold ${String(job.credits_hold ?? "?")}.`] : [];
381
+ if (!Array.isArray(data.items)) {
382
+ return ["**Not ready:** status is queued, running or polling. Poll again in a few seconds; reviews appear here once status is succeeded."];
383
+ }
384
+ // Yelp pages say where the next one starts (rows are readable while it runs).
385
+ if ("next_offset" in data) {
386
+ const next = data.next_offset;
387
+ const running = job && job.status !== "succeeded" && job.status !== "failed" ? " The job is still collecting, so later pages may grow; poll again." : "";
388
+ return [
389
+ ...charged,
390
+ typeof next === "number" ? `**More reviews:** call again with offset ${next}.${running}` : `**Done:** this is the last page so far.${running}`,
391
+ ];
324
392
  }
325
- return ["**Not ready:** status is queued, running or polling. Poll again in a few seconds; reviews appear here once status is succeeded."];
393
+ const n = data.items.length;
394
+ const lim = input.limit ?? 100;
395
+ return [...charged, n >= lim ? `**More reviews:** call again with offset ${(input.offset ?? 0) + n}.` : "**Done:** this is the last page."];
396
+ },
397
+ });
398
+ }
399
+ /** `GET /v1/prism/reviews/bulk/{job_id}` and `POST …/cancel` (reviews-bulk/http.ts). Both free. */
400
+ async function reviewsBulk(ctx, input) {
401
+ const path = `/v1/prism/reviews/bulk/${encodeURIComponent(input.job_id)}`;
402
+ if (input.action === "bulk_cancel") {
403
+ const response = await sendRequest(ctx, { method: "POST", path: `${path}/cancel`, body: {}, errorPlatform: "prism" });
404
+ return render({
405
+ title: "SocialCrawl Bulk Reviews — cancel",
406
+ label: `POST /v1/prism/reviews/bulk/${input.job_id}/cancel`,
407
+ cost: "0 credits — pages already read are kept, written to the files and billed; the rest of the reservation is refunded",
408
+ response,
409
+ notes: [
410
+ '**Status:** right after a cancel the job can still read `running`; it moves to `cancelled` when the job next settles. `cancel: "already_settled"` means it had finished.',
411
+ ],
412
+ });
413
+ }
414
+ const response = await sendRequest(ctx, {
415
+ method: "GET",
416
+ path,
417
+ query: pruneQuery({ offset: input.offset?.toString(), limit: input.limit?.toString() }),
418
+ errorPlatform: "prism",
419
+ });
420
+ return render({
421
+ title: "SocialCrawl Bulk Reviews",
422
+ label: `GET /v1/prism/reviews/bulk/${input.job_id}`,
423
+ cost: "0 credits (the job bills 1 credit per started 4 pages, reserved 25 at a time)",
424
+ response,
425
+ notes: [
426
+ "**Files:** `combined_url`, `manifest_url`, `businesses_url` and each item's `file_url` are signed links that work for 1 hour (3,600 s) and are null until the file exists; read the job again for fresh ones.",
427
+ ],
428
+ successNotes: (parsed) => {
429
+ const data = dataOf(parsed);
430
+ const next = data.next_offset;
431
+ return typeof next === "number" ? [`**More items:** call again with offset ${next}.`] : [];
326
432
  },
327
433
  });
328
434
  }
@@ -42,7 +42,12 @@ async function single(ctx, input, e) {
42
42
  endpoint: id,
43
43
  method: e.method,
44
44
  valid: data.valid !== false,
45
+ // API-205 (21/11/2026): `hold` is the most the call can bill (every
46
+ // page of a walk, legs that bill themselves); `upfront_hold` is what is
47
+ // deducted when it starts; `quote_basis` says why they differ.
45
48
  hold,
49
+ ...(num(data.upfront_hold) !== undefined ? { upfront_hold: data.upfront_hold } : {}),
50
+ ...(typeof data.quote_basis === "string" ? { quote_basis: data.quote_basis } : {}),
46
51
  ...(num(data.expected_min) !== undefined ? { expected_min: data.expected_min } : {}),
47
52
  ...(num(data.expected_max) !== undefined ? { expected_max: data.expected_max } : {}),
48
53
  ...(typeof data.unit === "string" ? { unit: data.unit } : {}),
@@ -139,9 +144,13 @@ function walkWarnings(warnings, walk) {
139
144
  return rest;
140
145
  }
141
146
  function renderApi(q, warnings) {
147
+ const hold = Number(q.hold);
148
+ const upfront = q.upfront_hold === undefined ? undefined : Number(q.upfront_hold);
142
149
  const lines = [
143
- `Quote for ${String(q.endpoint)} (API): holds ${String(q.hold)} credits${q.pages !== undefined ? ` (${String(q.pages)} pages)` : ""}${q.expected_min !== undefined ? `; expect ${String(q.expected_min)}-${String(q.expected_max)} after refunds` : ""}.`,
150
+ `Quote for ${String(q.endpoint)} (API): can bill at most ${String(q.hold)} credit${hold === 1 ? "" : "s"}${q.pages !== undefined ? ` (${String(q.pages)} pages)` : ""}${upfront !== undefined && upfront !== hold && q.pages === undefined ? `, ${upfront} deducted when it starts` : ""}${q.expected_min !== undefined ? `; expect ${String(q.expected_min)}-${String(q.expected_max)} after refunds` : ""}.`,
144
151
  ];
152
+ if (typeof q.quote_basis === "string")
153
+ lines.push(`Basis: ${q.quote_basis}`);
145
154
  if (q.valid === false) {
146
155
  const r = q.rejection;
147
156
  lines.push(`The API would refuse this call${r?.message ? `: ${String(r.message)}` : ""}. Nothing would be billed.`);
@@ -126,6 +126,8 @@ function asyncIdKey(area, action) {
126
126
  return action.startsWith("endpoint_") ? "endpoint_id" : "consumer";
127
127
  if (action === "follow")
128
128
  return "url";
129
+ if (action.startsWith("input_"))
130
+ return "list_id";
129
131
  // run_list takes a schedule id: it lists that schedule's runs.
130
132
  return action.startsWith("schedule_") || action === "run_list" ? "schedule_id" : "run_id";
131
133
  }
@@ -15,7 +15,7 @@ import type { ApiContext } from "../context.js";
15
15
  * Source of truth: packages/api/src/modules/monitors/ (router.ts, schema.ts,
16
16
  * create.ts, track-paths.ts, plan-caps.ts, params.ts, run-lifecycle.ts).
17
17
  */
18
- export type MonitorAction = "create" | "list" | "get" | "runs" | "timeseries" | "export" | "pause" | "resume" | "delete";
18
+ export type MonitorAction = "create" | "list" | "get" | "runs" | "timeseries" | "export" | "pause" | "resume" | "update" | "delete";
19
19
  export interface MonitorTrack {
20
20
  /** 1-20 paths: `items[].<dot.path>` (one number per row) or `<dot.path>` (one off the page). */
21
21
  metrics: string[];
@@ -39,6 +39,10 @@ export interface MonitorsParams {
39
39
  track?: MonitorTrack;
40
40
  webhook_format?: "full" | "rows";
41
41
  webhook_rows?: "all" | "new";
42
+ /** create/update/pause/resume: whole credits a month, 1-10,000,000; null (update) removes the cap. */
43
+ max_credits_per_month?: number | null;
44
+ /** create/update/pause/resume: a daily email digest of runs, or off (default). */
45
+ email_digest?: "off" | "daily";
42
46
  status?: string;
43
47
  cursor?: string;
44
48
  limit?: number;
@@ -48,6 +52,8 @@ export interface MonitorsParams {
48
52
  metric?: string;
49
53
  row?: string;
50
54
  format?: "csv" | "ndjson";
55
+ /** export: "long" (default, one line per run, row and metric) or "rows" (one line per run and row). */
56
+ shape?: "long" | "rows";
51
57
  }
52
58
  /** Limits from track-paths.ts, enforced locally so a bad body costs no round trip. */
53
59
  export declare const MONITOR_TRACK_LIMITS: {
@@ -9,6 +9,7 @@ const ACTIONS = [
9
9
  "export",
10
10
  "pause",
11
11
  "resume",
12
+ "update",
12
13
  "delete",
13
14
  ];
14
15
  const ID_ACTIONS = new Set([
@@ -18,8 +19,18 @@ const ID_ACTIONS = new Set([
18
19
  "export",
19
20
  "pause",
20
21
  "resume",
22
+ "update",
21
23
  "delete",
22
24
  ]);
25
+ /** The PATCH fields beside `status` (api modules/monitors/schema.ts). */
26
+ function capAndDigest(input) {
27
+ const out = {};
28
+ if (input.max_credits_per_month !== undefined)
29
+ out.max_credits_per_month = input.max_credits_per_month;
30
+ if (input.email_digest !== undefined)
31
+ out.email_digest = input.email_digest;
32
+ return out;
33
+ }
23
34
  /** Limits from track-paths.ts, enforced locally so a bad body costs no round trip. */
24
35
  export const MONITOR_TRACK_LIMITS = { maxMetrics: 20, maxRows: 200 };
25
36
  /** The pseudo-metric a `track` monitor can alert on (schema.ts ROWS_NEW_METRIC). */
@@ -177,6 +188,10 @@ export async function monitors(ctx, input, opts = {}) {
177
188
  body.webhook_format = input.webhook_format;
178
189
  if (input.webhook_rows)
179
190
  body.webhook_rows = input.webhook_rows;
191
+ if (input.max_credits_per_month === null) {
192
+ return "Error: `max_credits_per_month` on create is a whole number from 1 to 10,000,000; leave it out for no cap (null only removes a cap on update).";
193
+ }
194
+ Object.assign(body, capAndDigest(input));
180
195
  response = await send({ method: "POST", path: "/v1/monitors", body });
181
196
  label = "POST /v1/monitors";
182
197
  break;
@@ -224,7 +239,7 @@ export async function monitors(ctx, input, opts = {}) {
224
239
  return "Error: `format` for export is 'csv' (default) or 'ndjson'.";
225
240
  }
226
241
  const format = input.format ?? "csv";
227
- const query = pruneQuery({ format, from: input.from, to: input.to });
242
+ const query = pruneQuery({ format, shape: input.shape, from: input.from, to: input.to });
228
243
  response = await send({ method: "GET", path: `/v1/monitors/${id}/export`, query });
229
244
  label = `GET /v1/monitors/${input.id}/export (${format})`;
230
245
  break;
@@ -235,11 +250,20 @@ export async function monitors(ctx, input, opts = {}) {
235
250
  response = await send({
236
251
  method: "PATCH",
237
252
  path: `/v1/monitors/${id}`,
238
- body: { status },
253
+ body: { status, ...capAndDigest(input) },
239
254
  });
240
255
  label = `PATCH /v1/monitors/${input.id} (${status})`;
241
256
  break;
242
257
  }
258
+ case "update": {
259
+ const body = capAndDigest(input);
260
+ if (Object.keys(body).length === 0) {
261
+ return "Error: Missing required parameter(s): update changes `max_credits_per_month` (null removes the cap) and/or `email_digest` (off | daily); use pause/resume for the status. Nothing was sent.";
262
+ }
263
+ response = await send({ method: "PATCH", path: `/v1/monitors/${id}`, body });
264
+ label = `PATCH /v1/monitors/${input.id}`;
265
+ break;
266
+ }
243
267
  case "delete": {
244
268
  response = await send({ method: "DELETE", path: `/v1/monitors/${id}` });
245
269
  label = `DELETE /v1/monitors/${input.id}`;
package/package.json CHANGED
@@ -1,75 +1,75 @@
1
- {
2
- "name": "socialcrawl-mcp",
3
- "version": "2.2.0",
4
- "description": "One unified API for social and web data — social media (incl. Weibo, Douyin, Xiaohongshu, Telegram, Quora, Bluesky, Apple Music, Product Hunt), commerce, marketplaces & product reviews, retail (Amazon, Walmart, Target, Home Depot, eBay, Klarna, AliExpress, Etsy, Sephora, H&M, Kohl's, Wayfair, Gumtree, Google Shopping), app stores (Google Play, App Store), places, travel & stays (Airbnb, Booking.com, Tripadvisor, Yelp, Google Business/Hotels), books (Goodreads), business & software reputation (Trustpilot, G2), jobs & salaries (LinkedIn, Indeed, Bing, Xing), markets & finance, US congressional trading disclosures, on-page SEO audits, web search & research (Bing, DuckDuckGo, Tavily, Perplexity), full web scraping & browser automation (scrape, crawl, agent, monitors, sessions), audience-filtered mention search over a panel you supply (cohorts), Korean search (Naver + Data Lab), content/sentiment analysis, Google News/Trends, GitHub, Hacker News, Polymarket, AI X-search via Grok, cross-platform Prism composites, and a universal /search/everywhere meta-search with background lists and scheduled watches — with exact per-endpoint credit pricing (ladder, flat, and metered bands), free default row judgments with metered label/relevance quotes, and itemised per-call and per-job cost quotes for every one.",
5
- "type": "module",
6
- "main": "dist/index.js",
7
- "bin": {
8
- "socialcrawl-mcp": "dist/index.js",
9
- "socialcrawl-mcp-http": "dist/http.js"
10
- },
11
- "files": [
12
- "dist",
13
- "!dist/**/*.map",
14
- "!dist/__tests__"
15
- ],
16
- "scripts": {
17
- "build": "tsc && node -e \"require('fs').copyFileSync('src/instructions.md','dist/instructions.md')\"",
18
- "dev": "tsx watch src/index.ts",
19
- "start": "node dist/index.js",
20
- "start:http": "node dist/http.js",
21
- "dev:http": "tsx watch src/http.ts",
22
- "clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
23
- "generate:data": "tsx scripts/generate-data.ts",
24
- "test": "vitest run",
25
- "test:watch": "vitest",
26
- "prepublishOnly": "npm run build"
27
- },
28
- "keywords": [
29
- "mcp",
30
- "social-media",
31
- "api",
32
- "ai-agents",
33
- "socialcrawl",
34
- "tiktok",
35
- "instagram",
36
- "youtube",
37
- "twitter",
38
- "linkedin",
39
- "reddit",
40
- "model-context-protocol",
41
- "pricing",
42
- "credits",
43
- "amazon",
44
- "walmart",
45
- "web-scraping",
46
- "cohorts",
47
- "jobs-api",
48
- "finance",
49
- "ecommerce",
50
- "marketplace"
51
- ],
52
- "license": "MIT",
53
- "repository": {
54
- "type": "git",
55
- "url": "git+https://github.com/RidioDevelopment/socialcrawl-mcp.git"
56
- },
57
- "mcpName": "io.github.RidioDevelopment/socialcrawl",
58
- "dependencies": {
59
- "@modelcontextprotocol/sdk": "^1.29.0",
60
- "express": "^5.2.1",
61
- "express-rate-limit": "^8.5.2",
62
- "jose": "^6.2.12",
63
- "zod": "^3.23.8"
64
- },
65
- "devDependencies": {
66
- "@types/express": "^5.0.6",
67
- "@types/node": "^22.10.0",
68
- "tsx": "^4.19.2",
69
- "typescript": "^5.7.2",
70
- "vitest": "^3.1.1"
71
- },
72
- "engines": {
73
- "node": ">=18.0.0"
74
- }
75
- }
1
+ {
2
+ "name": "socialcrawl-mcp",
3
+ "version": "2.3.0",
4
+ "description": "One unified API for social and web data — social media (incl. Weibo, Douyin, Xiaohongshu, Telegram, Quora, Bluesky, Apple Music, Product Hunt), commerce, marketplaces & product reviews, retail (Amazon, Walmart, Target, Home Depot, eBay, Klarna, AliExpress, Etsy, Sephora, H&M, Kohl's, Wayfair, Gumtree, Google Shopping), app stores (Google Play, App Store), places, travel & stays (Airbnb, Booking.com, Tripadvisor, Yelp, Google Business/Hotels), books (Goodreads), business & software reputation (Trustpilot, G2), jobs & salaries (LinkedIn, Indeed, Bing, Xing), markets & finance, US congressional trading disclosures, on-page SEO audits, web search & research (Bing, DuckDuckGo, Tavily, Perplexity), full web scraping & browser automation (scrape, crawl, agent, monitors, sessions), audience-filtered mention search over a panel you supply (cohorts), Korean search (Naver + Data Lab), content/sentiment analysis, Google News/Trends, GitHub, Hacker News, Polymarket, AI X-search via Grok, cross-platform Prism composites, and a universal /search/everywhere meta-search with background lists and scheduled watches — with exact per-endpoint credit pricing (ladder, flat, and metered bands), free default row judgments with metered label/relevance quotes, and itemised per-call and per-job cost quotes for every one.",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "bin": {
8
+ "socialcrawl-mcp": "dist/index.js",
9
+ "socialcrawl-mcp-http": "dist/http.js"
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "!dist/**/*.map",
14
+ "!dist/__tests__"
15
+ ],
16
+ "scripts": {
17
+ "build": "tsc && node -e \"require('fs').copyFileSync('src/instructions.md','dist/instructions.md')\"",
18
+ "dev": "tsx watch src/index.ts",
19
+ "start": "node dist/index.js",
20
+ "start:http": "node dist/http.js",
21
+ "dev:http": "tsx watch src/http.ts",
22
+ "clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
23
+ "generate:data": "tsx scripts/generate-data.ts",
24
+ "test": "vitest run",
25
+ "test:watch": "vitest",
26
+ "prepublishOnly": "npm run build"
27
+ },
28
+ "keywords": [
29
+ "mcp",
30
+ "social-media",
31
+ "api",
32
+ "ai-agents",
33
+ "socialcrawl",
34
+ "tiktok",
35
+ "instagram",
36
+ "youtube",
37
+ "twitter",
38
+ "linkedin",
39
+ "reddit",
40
+ "model-context-protocol",
41
+ "pricing",
42
+ "credits",
43
+ "amazon",
44
+ "walmart",
45
+ "web-scraping",
46
+ "cohorts",
47
+ "jobs-api",
48
+ "finance",
49
+ "ecommerce",
50
+ "marketplace"
51
+ ],
52
+ "license": "MIT",
53
+ "repository": {
54
+ "type": "git",
55
+ "url": "git+https://github.com/RidioDevelopment/socialcrawl-mcp.git"
56
+ },
57
+ "mcpName": "io.github.RidioDevelopment/socialcrawl",
58
+ "dependencies": {
59
+ "@modelcontextprotocol/sdk": "^1.29.0",
60
+ "express": "^5.2.1",
61
+ "express-rate-limit": "^8.5.2",
62
+ "jose": "^6.2.12",
63
+ "zod": "^3.23.8"
64
+ },
65
+ "devDependencies": {
66
+ "@types/express": "^5.0.6",
67
+ "@types/node": "^22.10.0",
68
+ "tsx": "^4.19.2",
69
+ "typescript": "^5.7.2",
70
+ "vitest": "^3.1.1"
71
+ },
72
+ "engines": {
73
+ "node": ">=18.0.0"
74
+ }
75
+ }