desearch-mcp-server 0.11.1 → 0.13.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.
package/build/server.js CHANGED
@@ -6,10 +6,11 @@ import { recordCost, withCostMeter } from "./cost-meta.js";
6
6
  import { createDesearchApi } from "./desearch-api.js";
7
7
  import { PEOPLE_EXPORT_DEFAULT_ROWS, PEOPLE_EXPORT_FORMATS, PEOPLE_EXPORT_MAX_CHARS, PEOPLE_EXPORT_MAX_ROWS, PEOPLE_FILTER_CHANNELS, PEOPLE_METADATA_KEY_PATTERN, PEOPLE_METADATA_MAX_FILTERS, PEOPLE_METADATA_MAX_KEYS, PEOPLE_METADATA_VALUE_MAX, PEOPLE_PLATFORMS, PEOPLE_PROFILE_SORTS, PEOPLE_SEARCH_FILTERS, PEOPLE_TASK_STATUSES, controlPeopleTask, exportPeople, listPeopleProfiles, listPeopleTasks, peopleClientFor, readPeopleStatus, startPeopleSearch, } from "./people.js";
8
8
  import { COMPANY_COUNTRIES_MAX, COMPANY_DOMAINS_MAX, COMPANY_EXCLUDE_MAX, COMPANY_REQUIREMENTS, COMPANY_ROLES, COMPANY_SEARCH_MAX_BUDGET_USD, COMPANY_TASK_STATUSES, COMPANY_TASK_TYPES, companyClientFor, controlCompanyTask, listCompanyTasks, readCompanyStatus, startCompanyEnrich, startCompanySearch, } from "./companies.js";
9
- import { runSocialAction, socialActionNames } from "./social.js";
9
+ import { MONITOR_ACCOUNTS_MAX, MONITOR_CRITERIA_MAX, MONITOR_CRITERION_MAX, MONITOR_EVENTS, MONITOR_INTERVALS, MONITOR_META_ADS_COUNTS, MONITOR_METADATA_KEY_MAX, MONITOR_METADATA_MAX_KEYS, MONITOR_METADATA_VALUE_MAX, MONITOR_NAME_MAX, MONITOR_QUERY_MAX, MONITOR_QUERY_MIN, MONITOR_SOURCES, MONITOR_STATUSES, MONITOR_TIKTOK_COUNTS, MONITOR_WEB_COUNTS, MONITOR_X_COUNT_MAX, createMonitor, listMonitorItems, listMonitorRuns, listMonitors, monitorClientFor, monitorEstimateBody, readMonitorRun, rotateMonitorSecret, triggerMonitor, updateMonitor, } from "./monitors.js";
10
+ import { FACEBOOK_SEARCH_SORTS, runSocialAction, socialActionNames } from "./social.js";
10
11
  import { AI_SEARCH_TOOLS, WEB_LINK_TOOLS, toolIdSchema } from "./tool-sources.js";
11
12
  export const SERVER_NAME = "Desearch";
12
- export const SERVER_VERSION = "0.11.1";
13
+ export const SERVER_VERSION = "0.13.0";
13
14
  export const SERVER_TITLE = "Desearch";
14
15
  export const SERVER_WEBSITE_URL = "https://www.desearch.ai";
15
16
  // Public origin of the hosted server, which serves the icons below.
@@ -123,6 +124,43 @@ const TASK_CANCEL = {
123
124
  idempotentHint: true,
124
125
  openWorldHint: true,
125
126
  };
127
+ /**
128
+ * `monitor-create` and `monitor-trigger` use BILLED_TASK: create adds a monitor and, with
129
+ * run_now (the API default), queues its first billed run; trigger queues one billed run.
130
+ * Neither deletes or overwrites anything, and calling either again creates another monitor
131
+ * or queues another run (the API answers 409 while a run is queued or running).
132
+ *
133
+ * `monitor-update` overwrites settings (the old query, criteria, or per-source options are
134
+ * not kept, and remove_webhook drops the webhook) and `monitor-delete` removes a monitor
135
+ * with its runs and items for good, so both are destructive. Repeating either has no further
136
+ * effect (the same settings again; a second delete answers 404).
137
+ */
138
+ const MONITOR_OVERWRITE = {
139
+ readOnlyHint: false,
140
+ destructiveHint: true,
141
+ idempotentHint: true,
142
+ openWorldHint: true,
143
+ };
144
+ /**
145
+ * `monitor-webhook-rotate-secret` replaces the signing secret: the old one stops verifying
146
+ * deliveries and cannot be restored, and each call makes a new secret.
147
+ */
148
+ const MONITOR_SECRET_ROTATE = {
149
+ readOnlyHint: false,
150
+ destructiveHint: true,
151
+ idempotentHint: false,
152
+ openWorldHint: true,
153
+ };
154
+ /**
155
+ * `monitor-webhook-test` sends a signed test event to the caller's webhook. It changes
156
+ * nothing on Desearch, but each call is one more delivery to the caller's endpoint.
157
+ */
158
+ const MONITOR_WEBHOOK_TEST = {
159
+ readOnlyHint: false,
160
+ destructiveHint: false,
161
+ idempotentHint: false,
162
+ openWorldHint: true,
163
+ };
126
164
  const optionalPostCount = z
127
165
  .number()
128
166
  .int()
@@ -276,6 +314,160 @@ function companyTaskFields() {
276
314
  }
277
315
  const COMPANY_DATA = "Data: Desearch reads public data only: each company's own website (its homepage and its contact, about, team, and imprint pages), public web search results, and public LinkedIn profiles of its leaders. Each company comes back with its location, public emails, phones, and social profiles, and its leaders (roles) with their title, LinkedIn profile, and emails. Every contact keeps the page it came from (source_url). Leader emails can be inferred from the company's address pattern (source: inferred, with a confidence), and every email is checked (verification: valid, invalid, risky, or unknown). Companies stay readable for 30 days after the task ends. ";
278
316
  const COMPANY_RUNS = "The task runs in the background: poll company-search-status with the task_id to read progress and the companies delivered so far. Each company is delivered first with enrichment status partial, and the later stages (contact pages, leaders, inferred emails, email checks) fill it in until it is complete. Use company-search-pause, company-search-resume, or company-search-cancel to pause, resume, or cancel it. Do not start the same task twice; send idempotency_key so a retry returns the first task instead of charging again.";
317
+ const monitorId = z
318
+ .string()
319
+ .uuid()
320
+ .describe("monitor_id returned by monitor-create or monitor-list, example: '6f1d0c9e-0d55-4b8e-9a3c-3c4d9b8e2a10'.");
321
+ function monitorRunId() {
322
+ return z.string().uuid().describe("run_id from monitor-runs or monitor-trigger.");
323
+ }
324
+ function monitorSources() {
325
+ return z
326
+ .array(z.enum(MONITOR_SOURCES))
327
+ .min(1)
328
+ .describe("Where to look: any of 'web', 'x', 'reddit', 'youtube', 'threads', 'tiktok', 'instagram', 'facebook', 'meta_ads' (API default ['web', 'x']). Each run searches each source once, or reads its watched accounts and hashtags (x_accounts, reddit_subreddits, youtube_channels, tiktok_accounts, tiktok_hashtags, threads_accounts, instagram_accounts, instagram_hashtags, facebook_pages). 'instagram' and 'facebook' only read watched feeds: 'instagram' needs instagram_accounts or instagram_hashtags and 'facebook' needs facebook_pages (422 otherwise). 'meta_ads' searches the Meta Ad Library (ads) with the query as keywords.");
329
+ }
330
+ function monitorInterval() {
331
+ return z
332
+ .enum(MONITOR_INTERVALS)
333
+ .describe("How often it runs: '1h', '3h', '6h', '12h', '1d' (API default), or '7d'. Each run is billed.");
334
+ }
335
+ const MONITOR_KEPT_NOTE = "the query and criteria still decide what is kept (min_score 0 keeps every new post). Names are sent as given and the API returns them cleaned; a name it cannot read is a 422.";
336
+ const MONITOR_ACCOUNTS_NOTE = `the source reads their newest posts each run instead of searching by keyword; ${MONITOR_KEPT_NOTE}`;
337
+ const MONITOR_HASHTAGS_NOTE = "A hashtag feed lists popular posts before recent ones from any account, so it finds posts outside the watched accounts, and since a new post can reach it days late, a run keeps the hashtag posts from the last 7 days that the monitor has not seen; with accounts or hashtags, the source reads those feeds each run instead of searching by keyword, and the query and criteria still decide what is kept (min_score 0 keeps every new post). Hashtags are sent as given and the API returns them without # (a tag URL becomes its tag); one it cannot read is a 422.";
338
+ /** A watched-accounts (or watched-hashtags) list. A new schema per field. */
339
+ function monitorAccounts(description) {
340
+ return z.array(z.string().min(1).max(200)).max(MONITOR_ACCOUNTS_MAX).optional().describe(description);
341
+ }
342
+ // Per-source options, flat here and nested in `options` by monitors.ts. A new schema per field.
343
+ // The counts and watched accounts change what a run costs, so monitor-estimate takes them too;
344
+ // x_lang and x_min_likes only filter.
345
+ function monitorSourceOptions(withFilters) {
346
+ const costly = {
347
+ web_count: z
348
+ .union([z.literal(MONITOR_WEB_COUNTS[0]), z.literal(MONITOR_WEB_COUNTS[1]), z.literal(MONITOR_WEB_COUNTS[2])])
349
+ .optional()
350
+ .describe("Web pages read per run: 10 (API default), 15, or 20. Sent as options.web.count."),
351
+ x_count: z
352
+ .number()
353
+ .int()
354
+ .min(1)
355
+ .max(MONITOR_X_COUNT_MAX)
356
+ .optional()
357
+ .describe(`Newest X posts read per run (1-${MONITOR_X_COUNT_MAX}, API default 20). Not used with x_accounts (a timeline page is 20 posts). Sent as options.x.count.`),
358
+ x_accounts: monitorAccounts(`Up to ${MONITOR_ACCOUNTS_MAX} X usernames (1-15 characters) to watch, example: ['OpenAI', '@sama', 'https://x.com/opentensor']. With accounts, ${MONITOR_ACCOUNTS_NOTE} x_lang and x_min_likes still filter the timelines. Sent as options.x.accounts.`),
359
+ reddit_subreddits: monitorAccounts(`Up to ${MONITOR_ACCOUNTS_MAX} subreddits to watch, example: ['LocalLLaMA', 'r/bittensor_']. With subreddits, ${MONITOR_ACCOUNTS_NOTE} Sent as options.reddit.subreddits.`),
360
+ youtube_channels: monitorAccounts(`Up to ${MONITOR_ACCOUNTS_MAX} YouTube channels to watch: an @handle, a UC... channel ID, or a channel URL, example: ['@OpenAI']. With channels, ${MONITOR_ACCOUNTS_NOTE} Sent as options.youtube.channels.`),
361
+ tiktok_count: z
362
+ .union([
363
+ z.literal(MONITOR_TIKTOK_COUNTS[0]),
364
+ z.literal(MONITOR_TIKTOK_COUNTS[1]),
365
+ z.literal(MONITOR_TIKTOK_COUNTS[2]),
366
+ ])
367
+ .optional()
368
+ .describe("TikTok posts read per run: 10 (API default), 20, or 30; per account and per hashtag with tiktok_accounts or tiktok_hashtags. Billed per read, not per post (see the billing note). Sent as options.tiktok.count."),
369
+ tiktok_accounts: monitorAccounts(`Up to ${MONITOR_ACCOUNTS_MAX} TikTok usernames to watch, example: ['openai', '@tiktok']. With accounts, ${MONITOR_ACCOUNTS_NOTE} Sent as options.tiktok.accounts.`),
370
+ tiktok_hashtags: monitorAccounts(`Up to ${MONITOR_ACCOUNTS_MAX} TikTok hashtags to watch, in any script, example: ['skincare', '#სილამაზე', 'https://www.tiktok.com/tag/skincare']. ${MONITOR_HASHTAGS_NOTE} Each hashtag is one read per run ($0.003), whatever the number of posts. Sent as options.tiktok.hashtags.`),
371
+ threads_accounts: monitorAccounts(`Up to ${MONITOR_ACCOUNTS_MAX} Threads usernames to watch, example: ['zuck', '@mosseri', 'https://www.threads.com/@zuck']. Threads keyword search returns loosely matched posts, so accounts work better. With accounts, ${MONITOR_ACCOUNTS_NOTE} Each account is one request per run ($0.00207). Sent as options.threads.accounts.`),
372
+ instagram_accounts: monitorAccounts(`Up to ${MONITOR_ACCOUNTS_MAX} Instagram usernames to watch, example: ['openai', '@nasa', 'https://www.instagram.com/nasa/']. The 'instagram' source has no keyword search and reads only watched accounts and hashtags, so it needs instagram_accounts or instagram_hashtags (422 without either). Each run reads up to 12 newest posts per account; ${MONITOR_KEPT_NOTE} Each account is one read per run ($0.003), whatever the number of posts. Sent as options.instagram.accounts.`),
373
+ instagram_hashtags: monitorAccounts(`Up to ${MONITOR_ACCOUNTS_MAX} Instagram hashtags to watch, in any script, example: ['skincare', '#სილამაზე', 'https://www.instagram.com/explore/tags/skincare/']. ${MONITOR_HASHTAGS_NOTE} Each run reads up to 12 posts per hashtag; each hashtag is one read per run ($0.003), whatever the number of posts. Sent as options.instagram.hashtags.`),
374
+ facebook_pages: monitorAccounts(`Facebook pages to watch, 1-${MONITOR_ACCOUNTS_MAX}: a page name, a numeric page ID, or a page URL (profile.php?id=... and /pages/Name/123... URLs are read as the ID), example: ['NASA', '100064869009429']. Required with the 'facebook' source, which has no keyword search or hashtag feed and reads only these pages (422 without any); for ads by keyword use the 'meta_ads' source. Each run reads up to 10 newest posts per page; ${MONITOR_KEPT_NOTE} Each page is one read per run ($0.003), whatever the number of posts. Sent as options.facebook.pages.`),
375
+ meta_ads_count: z
376
+ .union([
377
+ z.literal(MONITOR_META_ADS_COUNTS[0]),
378
+ z.literal(MONITOR_META_ADS_COUNTS[1]),
379
+ z.literal(MONITOR_META_ADS_COUNTS[2]),
380
+ ])
381
+ .optional()
382
+ .describe("Meta Ad Library ads read per run with the 'meta_ads' source: 10 (API default), 20, or 30. The search is one read per run ($0.003), whatever the count. The Ad Library is searched with the query as keywords (a brand, product, or short phrase). Sent as options.meta_ads.count."),
383
+ };
384
+ if (!withFilters) {
385
+ return costly;
386
+ }
387
+ return {
388
+ ...costly,
389
+ x_lang: z
390
+ .string()
391
+ .min(2)
392
+ .max(3)
393
+ .optional()
394
+ .describe("Only X posts in this language, example: 'en'. Sent as options.x.lang."),
395
+ x_min_likes: z
396
+ .number()
397
+ .int()
398
+ .min(0)
399
+ .optional()
400
+ .describe("Only X posts with at least this many likes. Sent as options.x.min_likes."),
401
+ };
402
+ }
403
+ /**
404
+ * `metadata` labels: at most 20 keys of 1-64 characters to strings of up to 500. Like
405
+ * peopleMetadata, the key rules are checked in a refinement rather than advertised as
406
+ * `propertyNames`/`maxProperties`, which some MCP clients do not accept.
407
+ */
408
+ function monitorMetadata() {
409
+ return z
410
+ .record(z.string(), z.string().max(MONITOR_METADATA_VALUE_MAX))
411
+ .superRefine((value, ctx) => {
412
+ const keys = Object.keys(value);
413
+ if (keys.length > MONITOR_METADATA_MAX_KEYS) {
414
+ ctx.addIssue({ code: z.ZodIssueCode.custom, message: `At most ${MONITOR_METADATA_MAX_KEYS} metadata keys` });
415
+ }
416
+ for (const key of keys) {
417
+ if (key.length < 1 || key.length > MONITOR_METADATA_KEY_MAX) {
418
+ ctx.addIssue({
419
+ code: z.ZodIssueCode.custom,
420
+ path: [key],
421
+ message: `metadata keys are 1-${MONITOR_METADATA_KEY_MAX} characters`,
422
+ });
423
+ }
424
+ }
425
+ })
426
+ .describe(`Your own labels, example: {"team": "growth"}. Up to ${MONITOR_METADATA_MAX_KEYS} keys of 1-${MONITOR_METADATA_KEY_MAX} characters; values are strings of up to ${MONITOR_METADATA_VALUE_MAX} characters. Echoed in webhook deliveries; the monitor does not use them.`);
427
+ }
428
+ // Fields monitor-create and monitor-update share. A new schema per field.
429
+ function monitorSettingsFields() {
430
+ return {
431
+ name: z.string().max(MONITOR_NAME_MAX).optional().describe("A label for the console and webhook deliveries."),
432
+ criteria: z
433
+ .array(z.string().min(1).max(MONITOR_CRITERION_MAX))
434
+ .max(MONITOR_CRITERIA_MAX)
435
+ .optional()
436
+ .describe(`Up to ${MONITOR_CRITERIA_MAX} conditions a new item must meet to be kept, each up to ${MONITOR_CRITERION_MAX} characters, example: ['Announces a new subnet, release or partnership']. Each is one yes/no question in the screen.`),
437
+ sources: monitorSources().optional(),
438
+ interval: monitorInterval().optional(),
439
+ ...monitorSourceOptions(true),
440
+ min_score: z
441
+ .number()
442
+ .int()
443
+ .min(0)
444
+ .max(100)
445
+ .optional()
446
+ .describe("Score (0-100) an item needs to be kept (API default 60). The score is the lowest of relevant and each criterion."),
447
+ summary: z
448
+ .boolean()
449
+ .optional()
450
+ .describe("Write a short digest of the items each run keeps (API default false). Billed as its LLM usage plus 50%."),
451
+ webhook_url: z
452
+ .string()
453
+ .url()
454
+ .max(2000)
455
+ .optional()
456
+ .describe("HTTPS URL on a public address that receives new items as signed POSTs (redirects are not followed). A new or changed URL gets a new webhook_secret, returned only in this response."),
457
+ webhook_events: z
458
+ .array(z.enum(MONITOR_EVENTS))
459
+ .min(1)
460
+ .optional()
461
+ .describe("Events sent to webhook_url: 'monitor.items.found' (a run kept at least one item), 'monitor.run.completed' (every completed run), 'monitor.run.failed'. API default ['monitor.items.found', 'monitor.run.failed']. Needs webhook_url."),
462
+ metadata: monitorMetadata().optional(),
463
+ };
464
+ }
465
+ const MONITOR_BILLING = "Creating, reading, changing, and deleting monitors is free. Each run is billed when it ends: its searches at their list price (TikTok, Instagram, Facebook, and Meta ads per read, $3.00 per 1,000 reads ($0.003 a read), whatever the number of posts: one read per watched account, hashtag, or Facebook page, per TikTok keyword search, and per Ad Library search; an empty or private TikTok account takes two reads, so the hold counts two per TikTok account; a watched X account about $0.003, its 20-post timeline; a watched subreddit, YouTube channel, or Threads account $0.00207 each; ten watched accounts cost about ten searches), AI screening at $0.05 per 1,000 new items screened, and the summary's LLM usage plus 50% when summary is on. A run with no new items still pays for its searches. While a run is queued or running, its most (max_run_cost_usd) is held on the balance; it is billed what it used and the rest is released. A run that cannot be held fails with insufficient_credits and pauses the monitor. Use monitor-estimate for the cost of a configuration.";
466
+ const MONITOR_HOW = "Each run searches its sources inside a window that starts where the previous run ended (or, for a source with watched accounts or hashtags, reads each feed's newest posts), drops everything the monitor has already seen, and screens the new items with an AI classifier: relevant (about what the query watches), new_info (news rather than an evergreen page), and one yes/no question per criterion. score is the lowest of relevant and the criteria x 100; an item is kept at min_score (0 keeps every new post). Read kept items with monitor-items or monitor-run; with a webhook they are also POSTed to it, signed with webhook_secret.";
467
+ const MONITOR_TIKTOK_NOTE = "TikTok search has no working date filter and ranks by relevance, so a TikTok keyword monitor finds a new video only when it reaches TikTok's top results; to follow creators or a tag, watch their accounts (tiktok_accounts) or the hashtag (tiktok_hashtags).";
468
+ const MONITOR_SOCIAL_NOTE = "'instagram' and 'facebook' have no keyword search: they read only watched feeds, so a monitor with 'instagram' needs instagram_accounts or instagram_hashtags and one with 'facebook' needs facebook_pages, or the API answers 422. Facebook has no organic hashtag feed. 'meta_ads' searches the Meta Ad Library with the query, so write the query as keywords (a brand, product, or short phrase such as 'ChatGPT'); a sentence finds nothing. An ad counts as new the first time a run sees it if it started within the last 30 days, and ads are screened with their own relevance question and no new_info. Threads keyword search returns loosely matched posts, so watch accounts there (threads_accounts).";
469
+ const MONITOR_WEBHOOK_VIEW = "webhook (null without one; never the secret): url, events, consecutive_failures, and last_delivery, the newest delivery (null before the first): event, status ('pending' while it waits for its first or next attempt at next_attempt_at, with the last answer in status_code and error; 'delivered'; or 'failed' after every retry, at 1, 5, 30, 120, and 360 minutes), attempts, status_code, error, created_at, next_attempt_at, delivered_at. 5 failed deliveries in a row pause the monitor (paused_reason webhook_failing)";
470
+ const MONITOR_ITEM_FIELDS = "Each item has item_id, run_id, source, url, title, text (cut to 1000 characters), author, published_at, score (0-100), signals (relevant and new_info, plus criteria, the lowest answer across the criteria, when the monitor has criteria; Meta ads have no new_info), found_at, and data by source: X likes, reposts, replies, views; Reddit subreddit, score, comments; YouTube channel, views, thumbnail; TikTok views, likes, comments, shares, saves, duration_s; Threads likes; Instagram likes, comments, views, media_type; Facebook reactions, comments, shares, views; Meta ads page, active, cta, link (the ad's landing page), platforms, thumbnail, with the ad headline as title and url the Ad Library record; web highlights, domain. TikTok, Instagram, and Facebook items also have post_id (the ID the API's GET /desearch/social/post gives the same post; an Instagram shortcode), type (video, image, carousel, reel, ...), hashtags, mentions (TikTok and Instagram), media (links to the post's videos and pictures), and thumbnail; media and thumbnail links expire after a few days. The metrics are the post's when the run found it. An item read from a watched account also has data.account, the name it was watched as, and one read from a watched hashtag has data.hashtag.";
279
471
  function platformFilterList() {
280
472
  return Object.entries(PEOPLE_SEARCH_FILTERS)
281
473
  .map(([platform, filters]) => `${platform}: ${filters.join(", ")}`)
@@ -516,18 +708,20 @@ function registerTool(server, apiKey, name, title, description, inputSchema, han
516
708
  * One MCP server bound to a single Desearch API key.
517
709
  * Stdio uses the process env key. Remote HTTP builds a new server per request
518
710
  * so each caller spends their own key.
519
- * `client`, `peopleClient`, and `companyClient` are test seams. Production callers omit
520
- * them and the server builds a desearch-js client, a People Search client (people.ts), and
521
- * a Company Search client (companies.ts) from `apiKey`.
522
- * The routes desearch-js 1.5 does not cover (People Search, Company Search, TikTok,
523
- * Facebook, Instagram, YouTube, Reddit, Threads, `POST /search`) share one direct API caller (desearch-api.ts)
711
+ * `client`, `peopleClient`, `companyClient`, and `monitorClient` are test seams. Production
712
+ * callers omit them and the server builds a desearch-js client, a People Search client
713
+ * (people.ts), a Company Search client (companies.ts), and a Monitors client (monitors.ts)
714
+ * from `apiKey`.
715
+ * The routes desearch-js 1.5 does not cover (People Search, Company Search, Monitors, TikTok,
716
+ * Facebook, Instagram, YouTube, Reddit, Threads, `POST /search`, `GET /desearch/balance`) share one direct API caller (desearch-api.ts)
524
717
  * for that key.
525
718
  */
526
- export function createDesearchMcpServer(apiKey, client, peopleClient, companyClient) {
719
+ export function createDesearchMcpServer(apiKey, client, peopleClient, companyClient, monitorClient) {
527
720
  const desearch = meteredClient(client ?? new Desearch(apiKey));
528
721
  const api = createDesearchApi(apiKey);
529
722
  const people = peopleClient ?? peopleClientFor(api);
530
723
  const companies = companyClient ?? companyClientFor(api);
724
+ const monitors = monitorClient ?? monitorClientFor(api);
531
725
  const serverInfo = {
532
726
  name: SERVER_NAME,
533
727
  version: SERVER_VERSION,
@@ -536,7 +730,7 @@ export function createDesearchMcpServer(apiKey, client, peopleClient, companyCli
536
730
  icons: SERVER_ICONS,
537
731
  };
538
732
  const server = new McpServer(serverInfo, {
539
- instructions: "Search the public web and X with Desearch. Use search for titles and links, then fetch with a result URL to read the page. search-api is web search on the Desearch index: ranked pages with the passage that best matches the query, and with summary: true a short answer with numbered citations. ai-search covers X posts and web with an optional AI summary. Other tools cover X posts and page extraction. tiktok, facebook, instagram, youtube, reddit, and threads read public social data (posts, profiles, comments, hashtags, YouTube transcripts and channels, subreddits); list actions return next_cursor for the next page where the platform has one. People Search finds people and creators on X, YouTube, LinkedIn, and TikTok: people-search starts a paid job billed to the user's Desearch balance, people-search-status reads progress, people-search-pause, people-search-resume, and people-search-cancel pause, resume, or cancel it, and people-search-export returns the people found as CSV or JSON Lines. Company Search finds companies on the web from a description and Company Enrich reads the domains you send; both collect public emails, phones, social profiles, and leaders (CEO, founders, CTO, CFO): company-search and company-enrich start paid jobs billed to the user's Desearch balance, company-search-status reads progress and the companies, and company-search-pause, company-search-resume, and company-search-cancel pause, resume, or cancel a task. Set company-search's max_cost_usd only when the user agreed to that budget: it bills search effort even when few companies are found. Calls need a Desearch API key.",
733
+ instructions: "Search the public web and X with Desearch. Use search for titles and links, then fetch with a result URL to read the page. search-api is web search on the Desearch index: ranked pages with the passage that best matches the query, and with summary: true a short answer with numbered citations. ai-search covers X posts and web with an optional AI summary. Other tools cover X posts and page extraction. tiktok, facebook, instagram, youtube, reddit, and threads read public social data (posts, profiles, comments, hashtags, YouTube transcripts and channels, subreddits); list actions return next_cursor for the next page where the platform has one. People Search finds people and creators on X, YouTube, LinkedIn, and TikTok: people-search starts a paid job billed to the user's Desearch balance, people-search-status reads progress, people-search-pause, people-search-resume, and people-search-cancel pause, resume, or cancel it, and people-search-export returns the people found as CSV or JSON Lines. Company Search finds companies on the web from a description and Company Enrich reads the domains you send; both collect public emails, phones, social profiles, and leaders (CEO, founders, CTO, CFO): company-search and company-enrich start paid jobs billed to the user's Desearch balance, company-search-status reads progress and the companies, and company-search-pause, company-search-resume, and company-search-cancel pause, resume, or cancel a task. Set company-search's max_cost_usd only when the user agreed to that budget: it bills search effort even when few companies are found. Monitors rerun a search over web, X, Reddit, YouTube, Threads, TikTok, and Meta Ad Library ads (or watch chosen accounts there and on Instagram and Facebook) on a schedule and keep only new, relevant items: monitor-create sets one up (free; each run is billed to the user's Desearch balance), monitor-items and monitor-runs read what it found, monitor-update changes or pauses it, monitor-trigger runs it now, and monitor-delete removes it. balance returns what the account can still spend in USD (free). Calls need a Desearch API key.",
540
734
  });
541
735
  registerTool(server, apiKey, "ai-search", "AI Search", "AI Search over X (Twitter) posts and web (from the Desearch index), with an optional AI summary. Web results are capped at 20 per request. For web-only search, use search-api.", {
542
736
  prompt: z.string().describe("Question, example: 'What is the latest news on AI?'"),
@@ -916,10 +1110,14 @@ export function createDesearchMcpServer(apiKey, client, peopleClient, companyCli
916
1110
  return fail("TikTok error", error);
917
1111
  }
918
1112
  });
919
- registerTool(server, apiKey, "facebook", "Facebook", "Read public Facebook data with Desearch. Set action and that action's arguments. search (query; optional count, cursor) and hashtag (tag; optional count, cursor) return Meta Ad Library ads that match, not organic posts. post (id): one public post. profile (profile_id): a page or profile by ID or public handle. profile_posts (profile_id; optional count, cursor): its posts. comments (post_id; optional count, cursor): a post's comments, about 10 per page. post and profile return the item itself. " +
1113
+ registerTool(server, apiKey, "facebook", "Facebook", "Read public Facebook data with Desearch. Set action and that action's arguments. search (query; optional count, sort, cursor) and hashtag (tag; optional count, cursor) return Meta Ad Library ads that match, not organic posts. post (id): one public post. profile (profile_id): a page or profile by ID or public handle. profile_posts (profile_id; optional count, cursor): its posts. comments (post_id; optional count, cursor): a post's comments, about 10 per page. post and profile return the item itself. " +
920
1114
  SOCIAL_PAGING, strictArgs({
921
1115
  action: socialAction("facebook", "What to read: 'search', 'post', 'profile', 'profile_posts', 'comments', or 'hashtag'."),
922
1116
  query: socialQuery("running shoes"),
1117
+ sort: z
1118
+ .enum(FACEBOOK_SEARCH_SORTS)
1119
+ .optional()
1120
+ .describe("search: 'impressions' (API default: most seen first) or 'recent' (Meta's monthly relevance grouping, which puts recently started ads first)."),
923
1121
  id: socialTarget("post: the public Facebook post or media ID."),
924
1122
  profile_id: socialTarget("profile, profile_posts: page or profile ID, or its public handle, example: 'facebook'."),
925
1123
  post_id: socialTarget("comments: the public Facebook post or media ID."),
@@ -1520,6 +1718,185 @@ export function createDesearchMcpServer(apiKey, client, peopleClient, companyCli
1520
1718
  return fail("Company Search Tasks error", error);
1521
1719
  }
1522
1720
  }, undefined, READ_ONLY_OPEN_WORLD);
1721
+ registerTool(server, apiKey, "monitor-create", "Create Monitor", "Create a monitor: a search that reruns on a schedule over web, X, Reddit, YouTube, Threads, TikTok, and Meta Ad Library ads (or watches up to 10 X, TikTok, Threads, or Instagram users, subreddits, YouTube channels, or Facebook pages per source, and up to 10 TikTok or Instagram hashtags) and keeps only the new items that match. Returns the monitor (monitor_id, settings, max_run_cost_usd, next_run_at) and, when webhook_url is set, webhook_secret, which is shown only here. With run_now (the API default) the first run is queued at once and billed when it ends; set run_now false to wait for the schedule. " +
1722
+ MONITOR_BILLING +
1723
+ " " +
1724
+ MONITOR_HOW +
1725
+ " " +
1726
+ MONITOR_TIKTOK_NOTE +
1727
+ " " +
1728
+ MONITOR_SOCIAL_NOTE +
1729
+ " Limits: 25 monitors per account (409 too_many_monitors); 402 when the balance cannot hold one run, even with run_now false.", strictArgs({
1730
+ query: z
1731
+ .string()
1732
+ .min(MONITOR_QUERY_MIN)
1733
+ .max(MONITOR_QUERY_MAX)
1734
+ .describe(`What to watch, in plain words (${MONITOR_QUERY_MIN}-${MONITOR_QUERY_MAX} characters). Each source is searched with it. Example: 'Bittensor subnet launches and updates'. With 'meta_ads', use keywords (a brand, product, or short phrase such as 'ChatGPT'): the Ad Library finds nothing for a sentence.`),
1735
+ ...monitorSettingsFields(),
1736
+ run_now: z
1737
+ .boolean()
1738
+ .optional()
1739
+ .describe("Queue the first run at once (API default true; billed when it ends). False waits for next_run_at."),
1740
+ }), async (args) => {
1741
+ try {
1742
+ return ok(await createMonitor(monitors, args));
1743
+ }
1744
+ catch (error) {
1745
+ return fail("Create Monitor error", error);
1746
+ }
1747
+ }, undefined, BILLED_TASK);
1748
+ registerTool(server, apiKey, "monitor-estimate", "Estimate Monitor Cost", "The most one run of a monitor with these sources, counts, and watched accounts and hashtags can cost (max_run_cost_usd, the amount held while it runs), how many runs a month its interval makes, the most a month can cost, and a breakdown in USD per source plus screening and summary. Free: it creates nothing and runs no search. A run is billed only what it used, which is usually less. Unlike monitor-create, it does not refuse 'instagram' or 'facebook' without accounts or hashtags. " +
1749
+ MONITOR_BILLING, strictArgs({
1750
+ sources: monitorSources().optional(),
1751
+ ...monitorSourceOptions(false),
1752
+ summary: z.boolean().optional().describe("Include the summary's LLM cost (API default false)."),
1753
+ interval: monitorInterval().optional(),
1754
+ }), async (args) => {
1755
+ try {
1756
+ return ok(await monitors.estimate(monitorEstimateBody(args)));
1757
+ }
1758
+ catch (error) {
1759
+ return fail("Estimate Monitor Cost error", error);
1760
+ }
1761
+ }, undefined, READ_ONLY_OPEN_WORLD);
1762
+ registerTool(server, apiKey, "monitor-list", "List Monitors", "Your monitors, newest first, with their settings, status (active or paused, and paused_reason: user, insufficient_credits, or webhook_failing), webhook (url, events, consecutive_failures, and last_delivery, the newest delivery with its status, as on monitor-get; never the secret), next_run_at, last_run, and totals (runs, items, spent_usd). Free. Returns { monitors, next_cursor }; next_cursor is null on the last page.", strictArgs({
1763
+ status: z
1764
+ .array(z.enum(MONITOR_STATUSES))
1765
+ .optional()
1766
+ .describe("Only monitors in these statuses: 'active', 'paused'."),
1767
+ limit: z.number().int().min(1).max(100).optional().describe("Monitors per page (1-100, API default 20)."),
1768
+ cursor: z
1769
+ .string()
1770
+ .min(1)
1771
+ .max(512)
1772
+ .optional()
1773
+ .describe("next_cursor from the previous page. Keep the same status filter when you page."),
1774
+ }), async (args) => {
1775
+ try {
1776
+ return ok(await listMonitors(monitors, args));
1777
+ }
1778
+ catch (error) {
1779
+ return fail("List Monitors error", error);
1780
+ }
1781
+ }, undefined, READ_ONLY_OPEN_WORLD);
1782
+ registerTool(server, apiKey, "monitor-get", "Get Monitor", "One monitor: settings, status and paused_reason, " +
1783
+ MONITOR_WEBHOOK_VIEW +
1784
+ ", max_run_cost_usd, next_run_at, last_run (run_id, status, item_count, cost_usd), and totals (runs, items, spent_usd). Free. Use webhook.last_delivery to tell whether deliveries reach the endpoint: a 'pending' delivery with an error is being retried.", strictArgs({ monitor_id: monitorId }), async (args) => {
1785
+ try {
1786
+ return ok(await monitors.get(args.monitor_id));
1787
+ }
1788
+ catch (error) {
1789
+ return fail("Get Monitor error", error);
1790
+ }
1791
+ }, undefined, READ_ONLY_OPEN_WORLD);
1792
+ registerTool(server, apiKey, "monitor-update", "Update Monitor", "Change a monitor's settings and return it. Free. Send only what changes. status 'paused' stops scheduled runs (monitor-trigger still runs it once) and 'active' resumes them, also after a pause for credits or a failing webhook. The per-source options (web_count, x_count, x_lang, x_min_likes, x_accounts, reddit_subreddits, youtube_channels, tiktok_count, tiktok_accounts, tiktok_hashtags, threads_accounts, instagram_accounts, instagram_hashtags, facebook_pages, meta_ads_count) replace the monitor's options as a whole: send every option you want to keep, including its watched accounts and hashtags (an empty list watches none). The API checks the monitor as changed: an update that leaves 'instagram' without instagram_accounts or instagram_hashtags or 'facebook' without facebook_pages (new sources with the current options, or new options with the current sources) is a 422. A new webhook_url gets a new webhook_secret, returned only in this response; remove_webhook removes the webhook. The old values are not kept.", strictArgs({
1793
+ monitor_id: monitorId,
1794
+ query: z
1795
+ .string()
1796
+ .min(MONITOR_QUERY_MIN)
1797
+ .max(MONITOR_QUERY_MAX)
1798
+ .optional()
1799
+ .describe(`New query (${MONITOR_QUERY_MIN}-${MONITOR_QUERY_MAX} characters).`),
1800
+ ...monitorSettingsFields(),
1801
+ status: z
1802
+ .enum(MONITOR_STATUSES)
1803
+ .optional()
1804
+ .describe("'paused' stops scheduled runs; 'active' resumes them."),
1805
+ remove_webhook: z
1806
+ .boolean()
1807
+ .optional()
1808
+ .describe("true removes the webhook (sent as webhook: null). Do not combine with webhook_url."),
1809
+ }), async (args) => {
1810
+ try {
1811
+ return ok(await updateMonitor(monitors, args));
1812
+ }
1813
+ catch (error) {
1814
+ return fail("Update Monitor error", error);
1815
+ }
1816
+ }, undefined, MONITOR_OVERWRITE);
1817
+ registerTool(server, apiKey, "monitor-delete", "Delete Monitor", "Delete a monitor for good. Free. A queued run is cancelled and its hold released; its runs and items are no longer readable. This cannot be undone: to stop it for a while, use monitor-update with status 'paused' instead.", strictArgs({ monitor_id: monitorId }), async (args) => {
1818
+ try {
1819
+ return ok(await monitors.remove(args.monitor_id));
1820
+ }
1821
+ catch (error) {
1822
+ return fail("Delete Monitor error", error);
1823
+ }
1824
+ }, undefined, MONITOR_OVERWRITE);
1825
+ registerTool(server, apiKey, "monitor-trigger", "Run Monitor Now", "Queue one run of a monitor now, outside its schedule, and return the run (run_id, status queued). It costs one run, billed when it ends (at most the monitor's max_run_cost_usd); it works on a paused monitor too. 409 run_in_progress while a run is queued or running; 402 when the balance cannot hold the run. Poll monitor-run with the run_id.", strictArgs({ monitor_id: monitorId }), async (args) => {
1826
+ try {
1827
+ return ok(await triggerMonitor(monitors, args));
1828
+ }
1829
+ catch (error) {
1830
+ return fail("Run Monitor Now error", error);
1831
+ }
1832
+ }, undefined, BILLED_TASK);
1833
+ registerTool(server, apiKey, "monitor-runs", "List Monitor Runs", "A monitor's runs, newest first: trigger (schedule or manual), status (queued, running, completed, failed, cancelled) and fail_reason, the window it searched, item_count, stats per source (fetched, in_window, new, passed, error, accounts_failed and hashtags_failed: watched accounts and hashtags that could not be read; the source fails only when all of them do) and how items were screened (stats.screen: ai, by an AI classifier, or keyword when it fell back), summary, reserved_usd, and cost_usd (null until billed). Free. Returns { runs, next_cursor }; next_cursor is null on the last page.", strictArgs({
1834
+ monitor_id: monitorId,
1835
+ limit: z.number().int().min(1).max(100).optional().describe("Runs per page (1-100, API default 20)."),
1836
+ cursor: z.string().min(1).max(512).optional().describe("next_cursor from the previous page."),
1837
+ }), async (args) => {
1838
+ try {
1839
+ return ok(await listMonitorRuns(monitors, args));
1840
+ }
1841
+ catch (error) {
1842
+ return fail("List Monitor Runs error", error);
1843
+ }
1844
+ }, undefined, READ_ONLY_OPEN_WORLD);
1845
+ registerTool(server, apiKey, "monitor-run", "Get Monitor Run", "One run with the items it kept, most relevant first, plus its status, stats, summary, and cost. Free. " +
1846
+ MONITOR_ITEM_FIELDS +
1847
+ " The run's stats.sources.<source>.accounts_failed and hashtags_failed list watched accounts and hashtags it could not read.", strictArgs({ monitor_id: monitorId, run_id: monitorRunId() }), async (args) => {
1848
+ try {
1849
+ return ok(await readMonitorRun(monitors, args));
1850
+ }
1851
+ catch (error) {
1852
+ return fail("Get Monitor Run error", error);
1853
+ }
1854
+ }, undefined, READ_ONLY_OPEN_WORLD);
1855
+ registerTool(server, apiKey, "monitor-items", "List Monitor Items", "Everything a monitor kept across its runs, newest first. Free. Filter by source. Returns { items, next_cursor }; next_cursor is null on the last page. To get only what is new since your last read, keep the first item_id you saw and stop paging when you reach it. " +
1856
+ MONITOR_ITEM_FIELDS, strictArgs({
1857
+ monitor_id: monitorId,
1858
+ source: z
1859
+ .enum(MONITOR_SOURCES)
1860
+ .optional()
1861
+ .describe("Only items from this source: 'web', 'x', 'reddit', 'youtube', 'threads', 'tiktok', 'instagram', 'facebook', 'meta_ads'."),
1862
+ limit: z.number().int().min(1).max(200).optional().describe("Items per page (1-200, API default 50)."),
1863
+ cursor: z
1864
+ .string()
1865
+ .regex(/^\d+$/)
1866
+ .optional()
1867
+ .describe("next_cursor from the previous page. Keep the same source filter when you page."),
1868
+ }), async (args) => {
1869
+ try {
1870
+ return ok(await listMonitorItems(monitors, args));
1871
+ }
1872
+ catch (error) {
1873
+ return fail("List Monitor Items error", error);
1874
+ }
1875
+ }, undefined, READ_ONLY_OPEN_WORLD);
1876
+ registerTool(server, apiKey, "monitor-webhook-test", "Test Monitor Webhook", "Send a signed monitor.test event with one sample item to the monitor's webhook and report what the endpoint answered: { delivered (a 2xx within 10 seconds), status_code, error, duration_ms }. Free; it is not retried, does not count toward webhook_failing, and does not change webhook.last_delivery. 400 when the monitor has no webhook.", strictArgs({ monitor_id: monitorId }), async (args) => {
1877
+ try {
1878
+ return ok(await monitors.testWebhook(args.monitor_id));
1879
+ }
1880
+ catch (error) {
1881
+ return fail("Test Monitor Webhook error", error);
1882
+ }
1883
+ }, undefined, MONITOR_WEBHOOK_TEST);
1884
+ registerTool(server, apiKey, "monitor-webhook-rotate-secret", "Rotate Monitor Webhook Secret", "Replace the monitor's webhook signing secret and return the new webhook_secret, shown only here. Free. Deliveries from now on are signed with it, and the old secret no longer verifies them: update your endpoint before the next run. 400 when the monitor has no webhook.", strictArgs({ monitor_id: monitorId }), async (args) => {
1885
+ try {
1886
+ return ok(await rotateMonitorSecret(monitors, args));
1887
+ }
1888
+ catch (error) {
1889
+ return fail("Rotate Monitor Webhook Secret error", error);
1890
+ }
1891
+ }, undefined, MONITOR_SECRET_ROTATE);
1892
+ registerTool(server, apiKey, "balance", "Get Balance", "What the Desearch account behind this API key can still spend, in US dollars: { balance_usd, currency }. Free, and not counted as usage. It already subtracts charges from the last minute and shows top-ups (card, TAO, Gamma) as soon as they are credited. A paid tool the balance cannot cover fails with 'HTTP 402: Insufficient balance'. Check it before starting a large People Search, Company Search, or monitor.", strictArgs({}), async () => {
1893
+ try {
1894
+ return ok((await api("GET", "/desearch/balance")).data);
1895
+ }
1896
+ catch (error) {
1897
+ return fail("Get Balance error", error);
1898
+ }
1899
+ }, undefined, READ_ONLY_OPEN_WORLD);
1523
1900
  // Scanners ask for these lists during discovery. There is nothing to return,
1524
1901
  // but an empty list is a successful response. Method-not-found looks like a
1525
1902
  // broken server to some directory crawlers.
package/build/social.d.ts CHANGED
@@ -18,6 +18,8 @@ import type { DesearchApi } from "./desearch-api.js";
18
18
  export declare const SOCIAL_PLATFORMS: readonly ["tiktok", "facebook", "instagram", "youtube", "reddit", "threads"];
19
19
  export type SocialPlatform = (typeof SOCIAL_PLATFORMS)[number];
20
20
  export declare const NEXT_CURSOR_HEADER = "x-desearch-next-cursor";
21
+ /** `sort` on Facebook search (desearch-public-api model/facebook.py FacebookSearchRequest). */
22
+ export declare const FACEBOOK_SEARCH_SORTS: readonly ["impressions", "recent"];
21
23
  export interface SocialActionSpec {
22
24
  method: "GET" | "POST";
23
25
  /** Route, with `{name}` for each path argument. */
@@ -86,7 +88,7 @@ export declare const SOCIAL_ACTIONS: {
86
88
  readonly method: "POST";
87
89
  readonly path: "/desearch/facebook/search";
88
90
  readonly required: readonly ["query"];
89
- readonly optional: readonly ["count", "cursor"];
91
+ readonly optional: readonly ["count", "sort", "cursor"];
90
92
  readonly list: true;
91
93
  };
92
94
  readonly post: {
@@ -1 +1 @@
1
- {"version":3,"file":"social.d.ts","sourceRoot":"","sources":["../social.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,gBAAgB,8EAA+E,CAAC;AAC7G,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/D,eAAO,MAAM,kBAAkB,2BAA2B,CAAC;AAE3D,MAAM,WAAW,gBAAgB;IAC7B,MAAM,EAAE,KAAK,GAAG,MAAM,CAAC;IACvB,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,iCAAiC;IACjC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,8EAA8E;IAC9E,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,8CAA8C;IAC9C,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ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tube", "reddit", "threads"];
18
18
  export const NEXT_CURSOR_HEADER = "x-desearch-next-cursor";
19
+ /** `sort` on Facebook search (desearch-public-api model/facebook.py FacebookSearchRequest). */
20
+ export const FACEBOOK_SEARCH_SORTS = ["impressions", "recent"];
19
21
  export const SOCIAL_ACTIONS = {
20
22
  tiktok: {
21
23
  search: {
@@ -61,7 +63,7 @@ export const SOCIAL_ACTIONS = {
61
63
  method: "POST",
62
64
  path: "/desearch/facebook/search",
63
65
  required: ["query"],
64
- optional: ["count", "cursor"],
66
+ optional: ["count", "sort", "cursor"],
65
67
  list: true,
66
68
  },
67
69
  post: { method: "GET", path: "/desearch/facebook/post/{id}", required: ["id"], optional: [] },
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "desearch-mcp-server",
3
- "version": "0.11.1",
3
+ "version": "0.13.0",
4
4
  "mcpName": "io.github.Desearch-ai/mcp-desearch",
5
- "description": "AI search (web, Reddit, Hacker News, arXiv, Wikipedia, and Twitter), X (Twitter) search, web search, the Search API, public TikTok, Facebook, Instagram, YouTube (including transcripts), Reddit, and Threads data, People Search exports, page extraction, X data, People Search (find people and creators on X, YouTube, LinkedIn, and TikTok), and Company Search (find companies and their public contacts and leaders, or enrich domains you send) tools for AI agents. Includes 39 tools.",
5
+ "description": "AI search (web, Reddit, Hacker News, arXiv, Wikipedia, and Twitter), X (Twitter) search, web search, the Search API, public TikTok, Facebook, Instagram, YouTube (including transcripts), Reddit, and Threads data, People Search exports, page extraction, X data, People Search (find people and creators on X, YouTube, LinkedIn, and TikTok), Company Search (find companies and their public contacts and leaders, or enrich domains you send), and Monitors (searches that rerun on a schedule and keep only new, relevant items) tools for AI agents. Includes 52 tools.",
6
6
  "license": "MIT",
7
7
  "homepage": "https://desearch.ai",
8
8
  "type": "module",
@@ -54,7 +54,11 @@
54
54
  "instagram",
55
55
  "facebook",
56
56
  "threads",
57
- "youtube-transcript"
57
+ "youtube-transcript",
58
+ "monitors",
59
+ "web-monitoring",
60
+ "brand-monitoring",
61
+ "webhooks"
58
62
  ],
59
63
  "scripts": {
60
64
  "build": "tsc && node -e \"require('fs').chmodSync('build/index.js', '755')\"",