socialcrawl-mcp 2.0.0 → 2.0.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.
Files changed (51) hide show
  1. package/README.md +94 -112
  2. package/dist/client.d.ts +2 -0
  3. package/dist/client.js +4 -0
  4. package/dist/constants.d.ts +10 -1
  5. package/dist/constants.js +10 -1
  6. package/dist/cost-guard.d.ts +8 -1
  7. package/dist/cost-guard.js +21 -9
  8. package/dist/data/docs-handwritten.js +1 -1
  9. package/dist/data/docs.js +1 -1
  10. package/dist/data/endpoints.js +25 -22
  11. package/dist/data/examples.js +1 -1
  12. package/dist/data/guide.d.ts +1 -1
  13. package/dist/data/guide.js +1 -1
  14. package/dist/data/outputs.js +217 -217
  15. package/dist/data/registry-meta.d.ts +1 -1
  16. package/dist/data/registry-meta.js +1 -1
  17. package/dist/endpoint-resolve.d.ts +10 -0
  18. package/dist/endpoint-resolve.js +34 -0
  19. package/dist/format/shape.d.ts +6 -0
  20. package/dist/format/shape.js +64 -0
  21. package/dist/freshness.d.ts +27 -4
  22. package/dist/freshness.js +42 -19
  23. package/dist/result.d.ts +2 -0
  24. package/dist/result.js +8 -0
  25. package/dist/schemas/normalize.d.ts +27 -0
  26. package/dist/schemas/normalize.js +189 -0
  27. package/dist/schemas/outputs.d.ts +51 -31
  28. package/dist/schemas/outputs.js +10 -4
  29. package/dist/schemas/tools.d.ts +43 -8
  30. package/dist/schemas/tools.js +20 -7
  31. package/dist/server.js +17 -12
  32. package/dist/tools/cohorts.d.ts +3 -1
  33. package/dist/tools/cohorts.js +11 -10
  34. package/dist/tools/collect.d.ts +7 -3
  35. package/dist/tools/collect.js +110 -9
  36. package/dist/tools/discover.js +22 -27
  37. package/dist/tools/endpoint.js +8 -4
  38. package/dist/tools/estimate.js +53 -9
  39. package/dist/tools/find.d.ts +1 -0
  40. package/dist/tools/find.js +171 -8
  41. package/dist/tools/manage.d.ts +4 -0
  42. package/dist/tools/manage.js +106 -4
  43. package/dist/tools/monitors.d.ts +8 -1
  44. package/dist/tools/monitors.js +17 -12
  45. package/dist/tools/pricing.d.ts +1 -5
  46. package/dist/tools/pricing.js +17 -0
  47. package/dist/tools/request.d.ts +2 -11
  48. package/dist/tools/request.js +123 -74
  49. package/dist/tools/web.d.ts +3 -1
  50. package/dist/tools/web.js +4 -3
  51. package/package.json +2 -2
@@ -71,33 +71,34 @@ export declare const RequestOutputShape: {
71
71
  arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
72
72
  after_s: z.ZodNumber;
73
73
  }, "strip", z.ZodTypeAny, {
74
- tool: string;
75
74
  arguments: Record<string, unknown>;
75
+ tool: string;
76
76
  after_s: number;
77
77
  }, {
78
- tool: string;
79
78
  arguments: Record<string, unknown>;
79
+ tool: string;
80
80
  after_s: number;
81
81
  }>;
82
82
  }, "strip", z.ZodTypeAny, {
83
83
  id: string;
84
84
  poll: {
85
- tool: string;
86
85
  arguments: Record<string, unknown>;
86
+ tool: string;
87
87
  after_s: number;
88
88
  };
89
89
  status?: string | undefined;
90
90
  }, {
91
91
  id: string;
92
92
  poll: {
93
- tool: string;
94
93
  arguments: Record<string, unknown>;
94
+ tool: string;
95
95
  after_s: number;
96
96
  };
97
97
  status?: string | undefined;
98
98
  }>>;
99
99
  csv_rows: z.ZodOptional<z.ZodNumber>;
100
100
  summary: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
101
+ result_id: z.ZodOptional<z.ZodString>;
101
102
  };
102
103
  export declare const RequestOutputSchema: z.ZodObject<{
103
104
  code: z.ZodOptional<z.ZodString>;
@@ -171,33 +172,34 @@ export declare const RequestOutputSchema: z.ZodObject<{
171
172
  arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
172
173
  after_s: z.ZodNumber;
173
174
  }, "strip", z.ZodTypeAny, {
174
- tool: string;
175
175
  arguments: Record<string, unknown>;
176
+ tool: string;
176
177
  after_s: number;
177
178
  }, {
178
- tool: string;
179
179
  arguments: Record<string, unknown>;
180
+ tool: string;
180
181
  after_s: number;
181
182
  }>;
182
183
  }, "strip", z.ZodTypeAny, {
183
184
  id: string;
184
185
  poll: {
185
- tool: string;
186
186
  arguments: Record<string, unknown>;
187
+ tool: string;
187
188
  after_s: number;
188
189
  };
189
190
  status?: string | undefined;
190
191
  }, {
191
192
  id: string;
192
193
  poll: {
193
- tool: string;
194
194
  arguments: Record<string, unknown>;
195
+ tool: string;
195
196
  after_s: number;
196
197
  };
197
198
  status?: string | undefined;
198
199
  }>>;
199
200
  csv_rows: z.ZodOptional<z.ZodNumber>;
200
201
  summary: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
202
+ result_id: z.ZodOptional<z.ZodString>;
201
203
  }, "strip", z.ZodTypeAny, {
202
204
  ok: boolean;
203
205
  data?: unknown;
@@ -213,20 +215,18 @@ export declare const RequestOutputSchema: z.ZodObject<{
213
215
  warnings?: string[] | undefined;
214
216
  partial?: boolean | undefined;
215
217
  page?: Record<string, unknown> | undefined;
218
+ result_id?: string | undefined;
216
219
  endpoint?: string | undefined;
217
220
  rows?: unknown[] | undefined;
218
221
  job?: {
219
222
  id: string;
220
223
  poll: {
221
- tool: string;
222
224
  arguments: Record<string, unknown>;
225
+ tool: string;
223
226
  after_s: number;
224
227
  };
225
228
  status?: string | undefined;
226
229
  } | undefined;
227
- retryable?: boolean | undefined;
228
- reason?: string | undefined;
229
- fix?: string | undefined;
230
230
  credits?: {
231
231
  used?: number | undefined;
232
232
  remaining?: number | undefined;
@@ -235,6 +235,9 @@ export declare const RequestOutputSchema: z.ZodObject<{
235
235
  estimated?: boolean | undefined;
236
236
  session_total?: number | undefined;
237
237
  } | undefined;
238
+ reason?: string | undefined;
239
+ retryable?: boolean | undefined;
240
+ fix?: string | undefined;
238
241
  did_you_mean?: string[] | undefined;
239
242
  retry_after_s?: number | undefined;
240
243
  paging?: {
@@ -258,20 +261,18 @@ export declare const RequestOutputSchema: z.ZodObject<{
258
261
  warnings?: string[] | undefined;
259
262
  partial?: boolean | undefined;
260
263
  page?: Record<string, unknown> | undefined;
264
+ result_id?: string | undefined;
261
265
  endpoint?: string | undefined;
262
266
  rows?: unknown[] | undefined;
263
267
  job?: {
264
268
  id: string;
265
269
  poll: {
266
- tool: string;
267
270
  arguments: Record<string, unknown>;
271
+ tool: string;
268
272
  after_s: number;
269
273
  };
270
274
  status?: string | undefined;
271
275
  } | undefined;
272
- retryable?: boolean | undefined;
273
- reason?: string | undefined;
274
- fix?: string | undefined;
275
276
  credits?: {
276
277
  used?: number | undefined;
277
278
  remaining?: number | undefined;
@@ -280,6 +281,9 @@ export declare const RequestOutputSchema: z.ZodObject<{
280
281
  estimated?: boolean | undefined;
281
282
  session_total?: number | undefined;
282
283
  } | undefined;
284
+ reason?: string | undefined;
285
+ retryable?: boolean | undefined;
286
+ fix?: string | undefined;
283
287
  did_you_mean?: string[] | undefined;
284
288
  retry_after_s?: number | undefined;
285
289
  paging?: {
@@ -347,7 +351,11 @@ export declare const CollectOutputShape: {
347
351
  next_cursor?: string | null | undefined;
348
352
  }>>;
349
353
  resource: z.ZodOptional<z.ZodString>;
354
+ result_id: z.ZodOptional<z.ZodString>;
355
+ rows: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
350
356
  sample: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
357
+ offset: z.ZodOptional<z.ZodNumber>;
358
+ total: z.ZodOptional<z.ZodNumber>;
351
359
  warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
352
360
  };
353
361
  export declare const CollectOutputSchema: z.ZodObject<{
@@ -408,7 +416,11 @@ export declare const CollectOutputSchema: z.ZodObject<{
408
416
  next_cursor?: string | null | undefined;
409
417
  }>>;
410
418
  resource: z.ZodOptional<z.ZodString>;
419
+ result_id: z.ZodOptional<z.ZodString>;
420
+ rows: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
411
421
  sample: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
422
+ offset: z.ZodOptional<z.ZodNumber>;
423
+ total: z.ZodOptional<z.ZodNumber>;
412
424
  warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
413
425
  }, "strip", z.ZodTypeAny, {
414
426
  ok: boolean;
@@ -420,12 +432,13 @@ export declare const CollectOutputSchema: z.ZodObject<{
420
432
  code?: string | undefined;
421
433
  warnings?: string[] | undefined;
422
434
  resource?: string | undefined;
435
+ offset?: number | undefined;
423
436
  format?: "json" | "csv" | "jsonl" | undefined;
437
+ result_id?: string | undefined;
424
438
  endpoint?: string | undefined;
439
+ rows?: unknown[] | undefined;
425
440
  sample?: unknown[] | undefined;
426
- retryable?: boolean | undefined;
427
- reason?: string | undefined;
428
- fix?: string | undefined;
441
+ total?: number | undefined;
429
442
  credits?: {
430
443
  used?: number | undefined;
431
444
  remaining?: number | undefined;
@@ -434,6 +447,9 @@ export declare const CollectOutputSchema: z.ZodObject<{
434
447
  estimated?: boolean | undefined;
435
448
  session_total?: number | undefined;
436
449
  } | undefined;
450
+ reason?: string | undefined;
451
+ retryable?: boolean | undefined;
452
+ fix?: string | undefined;
437
453
  did_you_mean?: string[] | undefined;
438
454
  retry_after_s?: number | undefined;
439
455
  paging?: {
@@ -452,12 +468,13 @@ export declare const CollectOutputSchema: z.ZodObject<{
452
468
  code?: string | undefined;
453
469
  warnings?: string[] | undefined;
454
470
  resource?: string | undefined;
471
+ offset?: number | undefined;
455
472
  format?: "json" | "csv" | "jsonl" | undefined;
473
+ result_id?: string | undefined;
456
474
  endpoint?: string | undefined;
475
+ rows?: unknown[] | undefined;
457
476
  sample?: unknown[] | undefined;
458
- retryable?: boolean | undefined;
459
- reason?: string | undefined;
460
- fix?: string | undefined;
477
+ total?: number | undefined;
461
478
  credits?: {
462
479
  used?: number | undefined;
463
480
  remaining?: number | undefined;
@@ -466,6 +483,9 @@ export declare const CollectOutputSchema: z.ZodObject<{
466
483
  estimated?: boolean | undefined;
467
484
  session_total?: number | undefined;
468
485
  } | undefined;
486
+ reason?: string | undefined;
487
+ retryable?: boolean | undefined;
488
+ fix?: string | undefined;
469
489
  did_you_mean?: string[] | undefined;
470
490
  retry_after_s?: number | undefined;
471
491
  paging?: {
@@ -571,9 +591,6 @@ export declare const BalanceOutputSchema: z.ZodObject<{
571
591
  code?: string | undefined;
572
592
  view?: "balance" | "transactions" | undefined;
573
593
  rows?: unknown[] | undefined;
574
- retryable?: boolean | undefined;
575
- reason?: string | undefined;
576
- fix?: string | undefined;
577
594
  credits?: {
578
595
  used?: number | undefined;
579
596
  remaining?: number | undefined;
@@ -582,6 +599,9 @@ export declare const BalanceOutputSchema: z.ZodObject<{
582
599
  estimated?: boolean | undefined;
583
600
  session_total?: number | undefined;
584
601
  } | undefined;
602
+ reason?: string | undefined;
603
+ retryable?: boolean | undefined;
604
+ fix?: string | undefined;
585
605
  did_you_mean?: string[] | undefined;
586
606
  retry_after_s?: number | undefined;
587
607
  paging?: {
@@ -595,9 +615,6 @@ export declare const BalanceOutputSchema: z.ZodObject<{
595
615
  code?: string | undefined;
596
616
  view?: "balance" | "transactions" | undefined;
597
617
  rows?: unknown[] | undefined;
598
- retryable?: boolean | undefined;
599
- reason?: string | undefined;
600
- fix?: string | undefined;
601
618
  credits?: {
602
619
  used?: number | undefined;
603
620
  remaining?: number | undefined;
@@ -606,6 +623,9 @@ export declare const BalanceOutputSchema: z.ZodObject<{
606
623
  estimated?: boolean | undefined;
607
624
  session_total?: number | undefined;
608
625
  } | undefined;
626
+ reason?: string | undefined;
627
+ retryable?: boolean | undefined;
628
+ fix?: string | undefined;
609
629
  did_you_mean?: string[] | undefined;
610
630
  retry_after_s?: number | undefined;
611
631
  paging?: {
@@ -702,8 +722,8 @@ export declare const PricingOutputSchema: z.ZodObject<{
702
722
  min_credits: number;
703
723
  rule?: string | undefined;
704
724
  } | undefined;
705
- retryable?: boolean | undefined;
706
725
  reason?: string | undefined;
726
+ retryable?: boolean | undefined;
707
727
  fix?: string | undefined;
708
728
  did_you_mean?: string[] | undefined;
709
729
  retry_after_s?: number | undefined;
@@ -721,8 +741,8 @@ export declare const PricingOutputSchema: z.ZodObject<{
721
741
  min_credits: number;
722
742
  rule?: string | undefined;
723
743
  } | undefined;
724
- retryable?: boolean | undefined;
725
744
  reason?: string | undefined;
745
+ retryable?: boolean | undefined;
726
746
  fix?: string | undefined;
727
747
  did_you_mean?: string[] | undefined;
728
748
  retry_after_s?: number | undefined;
@@ -789,7 +809,7 @@ export declare const EstimateOutputShape: {
789
809
  did_you_mean: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
790
810
  retry_after_s: z.ZodOptional<z.ZodNumber>;
791
811
  ok: z.ZodBoolean;
792
- source: z.ZodOptional<z.ZodEnum<["api", "local"]>>;
812
+ source: z.ZodOptional<z.ZodEnum<["api", "api+walk", "local"]>>;
793
813
  quote: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
794
814
  plan: z.ZodOptional<z.ZodObject<{
795
815
  calls: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">;
@@ -7,11 +7,11 @@ import { z } from "zod";
7
7
  * is also flagged `isError`, and the SDK skips output validation for those.
8
8
  */
9
9
  const CreditsSchema = z.object({
10
- used: z.number().optional().describe("Settled charge, after refunds."),
10
+ used: z.number().optional().describe("After refunds."),
11
11
  remaining: z.number().optional(),
12
- cached: z.boolean().optional().describe("Served from cache: 0 credits."),
12
+ cached: z.boolean().optional().describe("Cache hit: 0 credits."),
13
13
  quoted_max: z.number().optional().describe("Hold taken up front."),
14
- estimated: z.boolean().optional().describe("used is the quoted hold (not reported)."),
14
+ estimated: z.boolean().optional().describe("used = the hold."),
15
15
  session_total: z.number().optional().describe("Spent this session."),
16
16
  });
17
17
  const PagingSchema = z.object({
@@ -61,6 +61,7 @@ export const RequestOutputShape = {
61
61
  job: JobSchema.optional().describe("A submitted background job and how to poll it."),
62
62
  csv_rows: z.number().optional().describe("format=csv: rows in the text CSV."),
63
63
  summary: z.record(z.unknown()).optional().describe("format=summary."),
64
+ result_id: z.string().optional().describe("socialcrawl_collect result_id reads the full body."),
64
65
  ...ErrorFields,
65
66
  };
66
67
  export const RequestOutputSchema = z.object(RequestOutputShape);
@@ -83,7 +84,11 @@ export const CollectOutputShape = {
83
84
  credits: CreditsSchema.optional(),
84
85
  paging: PagingSchema.optional(),
85
86
  resource: z.string().optional().describe("Every collected row."),
87
+ result_id: z.string().optional().describe("Pass back as result_id to read rows."),
88
+ rows: z.array(z.unknown()).optional().describe("All rows (small results). Untrusted text."),
86
89
  sample: z.array(z.unknown()).optional().describe("First rows. Untrusted text."),
90
+ offset: z.number().optional(),
91
+ total: z.number().optional(),
87
92
  warnings: z.array(z.string()).optional(),
88
93
  ...ErrorFields,
89
94
  };
@@ -152,7 +157,8 @@ export const EndpointOutputShape = {
152
157
  };
153
158
  export const EstimateOutputShape = {
154
159
  ok: z.boolean(),
155
- source: z.enum(["api", "local"]).optional(),
160
+ // api+walk: the API's per-call quote applied to an items -> pages walk.
161
+ source: z.enum(["api", "api+walk", "local"]).optional(),
156
162
  quote: z
157
163
  .record(z.unknown())
158
164
  .optional()
@@ -63,29 +63,38 @@ export declare const RequestInputSchema: z.ZodObject<{
63
63
  confirm?: boolean | undefined;
64
64
  }>;
65
65
  export declare const CollectInputSchema: z.ZodObject<{
66
- id: z.ZodString;
66
+ id: z.ZodOptional<z.ZodString>;
67
67
  params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>, "many">]>>>;
68
- items: z.ZodNumber;
68
+ items: z.ZodOptional<z.ZodNumber>;
69
69
  max_credits: z.ZodOptional<z.ZodNumber>;
70
70
  format: z.ZodOptional<z.ZodEnum<["jsonl", "json", "csv"]>>;
71
71
  fields: z.ZodOptional<z.ZodString>;
72
72
  confirm: z.ZodOptional<z.ZodBoolean>;
73
+ result_id: z.ZodOptional<z.ZodString>;
74
+ offset: z.ZodOptional<z.ZodNumber>;
75
+ limit: z.ZodOptional<z.ZodNumber>;
73
76
  }, "strict", z.ZodTypeAny, {
74
- items: number;
75
- id: string;
77
+ items?: number | undefined;
76
78
  params?: Record<string, string | number | boolean | (string | number | boolean)[]> | undefined;
79
+ offset?: number | undefined;
77
80
  fields?: string | undefined;
78
81
  format?: "json" | "csv" | "jsonl" | undefined;
79
82
  max_credits?: number | undefined;
80
83
  confirm?: boolean | undefined;
84
+ id?: string | undefined;
85
+ result_id?: string | undefined;
86
+ limit?: number | undefined;
81
87
  }, {
82
- items: number;
83
- id: string;
88
+ items?: number | undefined;
84
89
  params?: Record<string, string | number | boolean | (string | number | boolean)[]> | undefined;
90
+ offset?: number | undefined;
85
91
  fields?: string | undefined;
86
92
  format?: "json" | "csv" | "jsonl" | undefined;
87
93
  max_credits?: number | undefined;
88
94
  confirm?: boolean | undefined;
95
+ id?: string | undefined;
96
+ result_id?: string | undefined;
97
+ limit?: number | undefined;
89
98
  }>;
90
99
  export declare const FindInputSchema: z.ZodObject<{
91
100
  task: z.ZodOptional<z.ZodString>;
@@ -93,12 +102,12 @@ export declare const FindInputSchema: z.ZodObject<{
93
102
  limit: z.ZodOptional<z.ZodNumber>;
94
103
  }, "strict", z.ZodTypeAny, {
95
104
  platform?: string | undefined;
96
- task?: string | undefined;
97
105
  limit?: number | undefined;
106
+ task?: string | undefined;
98
107
  }, {
99
108
  platform?: string | undefined;
100
- task?: string | undefined;
101
109
  limit?: number | undefined;
110
+ task?: string | undefined;
102
111
  }>;
103
112
  export declare const EndpointInputSchema: z.ZodObject<{
104
113
  id: z.ZodString;
@@ -190,16 +199,19 @@ export declare const ManageInputSchema: z.ZodObject<{
190
199
  id: z.ZodOptional<z.ZodString>;
191
200
  input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
192
201
  idempotencyKey: z.ZodOptional<z.ZodString>;
202
+ dry_run: z.ZodOptional<z.ZodBoolean>;
193
203
  }, "strict", z.ZodTypeAny, {
194
204
  area: "monitors" | "web" | "jobs" | "cohorts";
195
205
  action: string;
196
206
  idempotencyKey?: string | undefined;
207
+ dry_run?: boolean | undefined;
197
208
  id?: string | undefined;
198
209
  input?: Record<string, unknown> | undefined;
199
210
  }, {
200
211
  area: "monitors" | "web" | "jobs" | "cohorts";
201
212
  action: string;
202
213
  idempotencyKey?: string | undefined;
214
+ dry_run?: boolean | undefined;
203
215
  id?: string | undefined;
204
216
  input?: Record<string, unknown> | undefined;
205
217
  }>;
@@ -246,6 +258,19 @@ export declare const MonitorsInputSchema: z.ZodObject<{
246
258
  suppress_webhook_unless_alert: z.ZodOptional<z.ZodBoolean>;
247
259
  output_schema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
248
260
  webhook_secret: z.ZodOptional<z.ZodString>;
261
+ track: z.ZodOptional<z.ZodObject<{
262
+ metrics: z.ZodArray<z.ZodString, "many">;
263
+ row_key: z.ZodOptional<z.ZodString>;
264
+ max_rows: z.ZodOptional<z.ZodNumber>;
265
+ }, "strict", z.ZodTypeAny, {
266
+ metrics: string[];
267
+ row_key?: string | undefined;
268
+ max_rows?: number | undefined;
269
+ }, {
270
+ metrics: string[];
271
+ row_key?: string | undefined;
272
+ max_rows?: number | undefined;
273
+ }>>;
249
274
  status: z.ZodOptional<z.ZodString>;
250
275
  cursor: z.ZodOptional<z.ZodString>;
251
276
  limit: z.ZodOptional<z.ZodNumber>;
@@ -274,6 +299,11 @@ export declare const MonitorsInputSchema: z.ZodObject<{
274
299
  suppress_webhook_unless_alert?: boolean | undefined;
275
300
  output_schema?: Record<string, unknown> | undefined;
276
301
  webhook_secret?: string | undefined;
302
+ track?: {
303
+ metrics: string[];
304
+ row_key?: string | undefined;
305
+ max_rows?: number | undefined;
306
+ } | undefined;
277
307
  from?: string | undefined;
278
308
  to?: string | undefined;
279
309
  include?: "result" | undefined;
@@ -298,6 +328,11 @@ export declare const MonitorsInputSchema: z.ZodObject<{
298
328
  suppress_webhook_unless_alert?: boolean | undefined;
299
329
  output_schema?: Record<string, unknown> | undefined;
300
330
  webhook_secret?: string | undefined;
331
+ track?: {
332
+ metrics: string[];
333
+ row_key?: string | undefined;
334
+ max_rows?: number | undefined;
335
+ } | undefined;
301
336
  from?: string | undefined;
302
337
  to?: string | undefined;
303
338
  include?: "result" | undefined;
@@ -43,11 +43,11 @@ const MaxCreditsSchema = z
43
43
  .int()
44
44
  .min(1)
45
45
  .optional()
46
- .describe("Spend cap. Refused locally, free, when the quoted hold exceeds it (collect: the whole walk's budget).");
46
+ .describe("Spend cap: refused free when the quoted hold exceeds it (collect: the walk's budget).");
47
47
  const ConfirmSchema = z
48
48
  .boolean()
49
49
  .optional()
50
- .describe("true only after the user approved a spend above the confirmation threshold (default 100 credits).");
50
+ .describe("true only once the user approved spending above the threshold (default 100 credits).");
51
51
  export const RequestInputSchema = z.object({
52
52
  platform: z.string().min(1).describe("Platform slug, e.g. 'tiktok'. An unknown slug gets a did-you-mean."),
53
53
  resource: z
@@ -71,20 +71,23 @@ export const RequestInputSchema = z.object({
71
71
  .min(16, "Idempotency-Key should be at least 16 characters (UUIDv4 recommended)")
72
72
  .optional()
73
73
  .describe("Makes a retry safe: a replay returns the original response for 0 credits (24h)."),
74
- fields: z.string().optional().describe("Row paths exactly as socialcrawl_endpoint lists them, e.g. 'post.id,post.content.text,post.engagement.*'. Cuts tokens."),
74
+ fields: z.string().optional().describe("Row paths exactly as socialcrawl_endpoint lists them, e.g. 'post.id,post.content.text,post.engagement.*' (or an array). Cuts tokens."),
75
75
  max_items: z.number().int().min(1).optional().describe("Show at most this many rows; the full page stays behind the result link."),
76
76
  format: z.enum(["json", "csv", "summary"]).optional().describe("json (default), csv (canonical columns) or summary."),
77
77
  max_credits: MaxCreditsSchema,
78
78
  confirm: ConfirmSchema,
79
79
  }).strict();
80
80
  export const CollectInputSchema = z.object({
81
- id: z.string().min(3).describe("platform/resource of a paged endpoint, e.g. 'tiktok/post/comments'."),
81
+ id: z.string().min(3).optional().describe("platform/resource of a paged endpoint, e.g. 'tiktok/post/comments'."),
82
82
  params: z.record(ParamValueSchema).optional().describe("Params for every page, as in socialcrawl_request. No cursor."),
83
- items: z.number().int().min(1).max(10000).describe("Stop once this many unique rows are collected."),
83
+ items: z.number().int().min(1).max(10000).optional().describe("Stop once this many unique rows are collected."),
84
84
  max_credits: MaxCreditsSchema,
85
- format: z.enum(["jsonl", "json", "csv"]).optional().describe("Stored format: jsonl (default), json or csv."),
85
+ format: z.enum(["jsonl", "json", "csv"]).optional().describe("jsonl (default), json or csv."),
86
86
  fields: z.string().optional().describe("Row paths as socialcrawl_endpoint lists them, e.g. 'comment.text,comment.engagement.likes'."),
87
87
  confirm: ConfirmSchema,
88
+ result_id: z.string().optional().describe("Read a stored result instead of walking. Free."),
89
+ offset: z.number().int().optional().describe("result_id: first row."),
90
+ limit: z.number().int().optional().describe("result_id: rows (200)."),
88
91
  }).strict();
89
92
  const MethodSchema = z.enum(["GET", "POST", "PATCH", "DELETE"]);
90
93
  export const FindInputSchema = z.object({
@@ -119,7 +122,7 @@ export const EstimateInputSchema = z.object({
119
122
  method: MethodSchema.optional(),
120
123
  params: z.record(ParamValueSchema).optional().describe("The exact params you will send."),
121
124
  body: z.record(z.unknown()).optional().describe("POST body, for batch endpoints."),
122
- calls: z.number().int().min(1).max(1_000_000).optional().describe("Number of such calls."),
125
+ calls: z.number().int().min(1).max(1_000_000).optional().describe("Number of such calls (an array is read as plan)."),
123
126
  items: z.number().int().min(1).optional().describe("Rows wanted (prices a walk)."),
124
127
  plan: z.array(PlanCallSchema).max(50).optional().describe("Several calls to total, instead of id."),
125
128
  }).strict();
@@ -144,6 +147,7 @@ export const ManageInputSchema = z.object({
144
147
  .optional()
145
148
  .describe("The action's fields, e.g. { recipe, cadence }, { url }, { keywords }, or the job body (max_credits, confirm allowed). Monitor alert rules, incl. rows_new: socialcrawl_endpoint id=monitors."),
146
149
  idempotencyKey: z.string().min(16).optional().describe("For web crawl/batch, cohort writes and job submit."),
150
+ dry_run: z.boolean().optional(),
147
151
  }).strict();
148
152
  export const CheckBalanceInputSchema = z.object({
149
153
  view: z
@@ -221,6 +225,15 @@ export const MonitorsInputSchema = z.object({
221
225
  .string()
222
226
  .optional()
223
227
  .describe("create: optional signing secret (8-200 chars); otherwise one is generated and returned once."),
228
+ track: z
229
+ .object({
230
+ metrics: z.array(z.string()).min(1).max(20),
231
+ row_key: z.string().optional(),
232
+ max_rows: z.number().int().min(1).max(200).optional(),
233
+ })
234
+ .strict()
235
+ .optional()
236
+ .describe("create: a tracking monitor: the numbers to keep per row, e.g. { metrics: ['items[].post.engagement.views'] }. Needed for the rows_new alert; webhook_url becomes optional."),
224
237
  status: z
225
238
  .string()
226
239
  .optional()
package/dist/server.js CHANGED
@@ -3,6 +3,7 @@ import { ErrorCode, McpError } from "@modelcontextprotocol/sdk/types.js";
3
3
  import { RESULT_URI_PREFIX, resultsStore, scopeOf } from "./results-store.js";
4
4
  import { SERVER_NAME, SERVER_VERSION } from "./constants.js";
5
5
  import { FindInputSchema, EndpointInputSchema, EstimateInputSchema, RequestInputSchema, CollectInputSchema, AccountInputSchema, ManageInputSchema, } from "./schemas/tools.js";
6
+ import { withNormalizedArgs } from "./schemas/normalize.js";
6
7
  import { findStructured } from "./tools/find.js";
7
8
  import { endpointStructured } from "./tools/endpoint.js";
8
9
  import { estimateStructured } from "./tools/estimate.js";
@@ -66,7 +67,7 @@ export function createServer(baseCtx, options = {}) {
66
67
  server.registerTool("socialcrawl_find", {
67
68
  title: "Find the Endpoint for a Task",
68
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
- inputSchema: FindInputSchema,
70
+ inputSchema: withNormalizedArgs(FindInputSchema, "find"),
70
71
  outputSchema: FindOutputShape,
71
72
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
72
73
  }, async (params) => {
@@ -75,8 +76,8 @@ export function createServer(baseCtx, options = {}) {
75
76
  });
76
77
  server.registerTool("socialcrawl_endpoint", {
77
78
  title: "Endpoint Contract",
78
- 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. Also takes a platform slug (its endpoints) or a guide topic (errors, pricing, pagination, judgments). Free.",
79
- inputSchema: EndpointInputSchema,
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.",
80
+ inputSchema: withNormalizedArgs(EndpointInputSchema, "endpoint"),
80
81
  outputSchema: EndpointOutputShape,
81
82
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
82
83
  }, async (params) => {
@@ -85,8 +86,8 @@ export function createServer(baseCtx, options = {}) {
85
86
  });
86
87
  server.registerTool("socialcrawl_estimate", {
87
88
  title: "Estimate Credit Cost",
88
- description: "Exact credits before you spend: one call (id 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
- inputSchema: EstimateInputSchema,
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.",
90
+ inputSchema: withNormalizedArgs(EstimateInputSchema, "estimate"),
90
91
  outputSchema: EstimateOutputShape,
91
92
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
92
93
  }, async (params) => {
@@ -103,8 +104,8 @@ export function createServer(baseCtx, options = {}) {
103
104
  });
104
105
  server.registerTool("socialcrawl_request", {
105
106
  title: "Call an Endpoint",
106
- description: "Call one endpoint. structuredContent: rows, credits (used, remaining), paging (has_more, next_cursor). Validated locally first (a bad call is free), quoted, refused above max_credits and confirmed above the threshold. A large page is cut at row boundaries with a link to the full body. Spends credits; needs SOCIALCRAWL_API_KEY.",
107
- inputSchema: RequestInputSchema,
107
+ description: "Call one endpoint (platform+resource, or id, or path). Validated locally first (a bad call is free), quoted, refused above max_credits and confirmed above the threshold. A large page is cut at row boundaries; socialcrawl_collect result_id reads the rest. Spends credits; needs SOCIALCRAWL_API_KEY.",
108
+ inputSchema: withNormalizedArgs(RequestInputSchema, "request"),
108
109
  outputSchema: RequestOutputShape,
109
110
  annotations: {
110
111
  // Billable and not repeatable: each call can spend credits, and a repeat
@@ -133,8 +134,8 @@ export function createServer(baseCtx, options = {}) {
133
134
  });
134
135
  server.registerTool("socialcrawl_collect", {
135
136
  title: "Collect Rows Across Pages",
136
- description: "Walk a paged endpoint to `items` unique rows, the last page or max_credits in one call: cursors supplied, duplicates dropped, stops on a 402, refused free when one page exceeds max_credits. Returns a summary and a link to every row (JSONL, JSON or CSV). Spends credits.",
137
- inputSchema: CollectInputSchema,
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.",
138
+ inputSchema: withNormalizedArgs(CollectInputSchema, "collect"),
138
139
  outputSchema: CollectOutputShape,
139
140
  annotations: {
140
141
  // Spends credits page after page; a repeat spends again (cached pages are free).
@@ -152,13 +153,16 @@ export function createServer(baseCtx, options = {}) {
152
153
  format: params.format,
153
154
  fields: params.fields,
154
155
  confirm: params.confirm,
156
+ result_id: params.result_id,
157
+ offset: params.offset,
158
+ limit: params.limit,
155
159
  });
156
160
  return toResult(output.text, output.structured, output.links);
157
161
  });
158
162
  server.registerTool("socialcrawl_account", {
159
163
  title: "Account and Service Status",
160
164
  description: "Free checks: balance (with this session's spend), transactions (itemised ledger; the receipts for one request_id), status (platform health; read it before retrying a 502/503) and freshness (whether this server's bundled catalogue is behind the API).",
161
- inputSchema: AccountInputSchema,
165
+ inputSchema: withNormalizedArgs(AccountInputSchema, "account"),
162
166
  outputSchema: AccountOutputShape,
163
167
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
164
168
  }, async (params) => {
@@ -172,8 +176,8 @@ export function createServer(baseCtx, options = {}) {
172
176
  });
173
177
  server.registerTool("socialcrawl_manage", {
174
178
  title: "Manage Monitors, Cohorts, Web and Jobs",
175
- description: "Stateful work by area + action: monitors (scheduled recipes, webhooks, alerts), cohorts (mention search over your own panel of accounts), web (scrape, search, crawl and agent jobs, change monitors, browser sessions) and jobs (Prism background jobs). A wrong field is refused free with the rules. Managing is free; scrapes, jobs, queries and monitor runs bill credits.",
176
- inputSchema: ManageInputSchema,
179
+ description: "Stateful work by area + action: monitors (scheduled recipes, webhooks, alerts), cohorts (mention search over your own panel of accounts), web (scrape, search, crawl and agent jobs, change monitors, browser sessions) and jobs (Prism background jobs). A wrong field is refused free with the rules. Managing is free; scrapes, jobs, queries and monitor runs bill credits.\ndry_run: true validates and quotes a create/update and never creates it.",
180
+ inputSchema: withNormalizedArgs(ManageInputSchema, "manage"),
177
181
  annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
178
182
  }, async (params) => {
179
183
  const output = await manage(ctx, {
@@ -182,6 +186,7 @@ export function createServer(baseCtx, options = {}) {
182
186
  id: params.id,
183
187
  input: params.input,
184
188
  idempotencyKey: params.idempotencyKey,
189
+ dry_run: params.dry_run,
185
190
  });
186
191
  return toResult(output.text, output.structured, output.links);
187
192
  });
@@ -77,4 +77,6 @@ export declare function creditCeiling(counts: Record<string, number>, maxPagesPe
77
77
  subtotal: number;
78
78
  }[];
79
79
  };
80
- export declare function cohorts(ctx: ApiContext, input: CohortsParams): Promise<string>;
80
+ export declare function cohorts(ctx: ApiContext, input: CohortsParams, opts?: {
81
+ dryRun?: boolean;
82
+ }): Promise<string>;