desearch-mcp-server 0.6.0 → 0.8.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/CHANGELOG.md +28 -0
- package/README.md +73 -5
- package/build/companies.d.ts +6 -3
- package/build/companies.d.ts.map +1 -1
- package/build/companies.js +8 -4
- package/build/desearch-api.d.ts +36 -0
- package/build/desearch-api.d.ts.map +1 -0
- package/build/desearch-api.js +72 -0
- package/build/people.d.ts +65 -16
- package/build/people.d.ts.map +1 -1
- package/build/people.js +152 -68
- package/build/server.d.ts +4 -1
- package/build/server.d.ts.map +1 -1
- package/build/server.js +281 -6
- package/build/social.d.ts +309 -0
- package/build/social.d.ts.map +1 -0
- package/build/social.js +364 -0
- package/package.json +7 -3
package/build/people.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DESEARCH_API_BASE_URL, createDesearchApi } from "./desearch-api.js";
|
|
2
2
|
/**
|
|
3
3
|
* People Search on the Desearch API (`/desearch/people/*`).
|
|
4
4
|
*
|
|
5
5
|
* desearch-js 1.5 has no People Search methods, so this module calls the routes
|
|
6
|
-
* directly with the same base URL, `Authorization: <key>`
|
|
7
|
-
* `HTTP <status>: <detail>` error text that desearch-js uses.
|
|
6
|
+
* directly through `desearch-api.ts`, with the same base URL, `Authorization: <key>`
|
|
7
|
+
* header, and `HTTP <status>: <detail>` error text that desearch-js uses.
|
|
8
8
|
*
|
|
9
9
|
* - `POST /desearch/people/search/{platform}` starts a background search and is billed:
|
|
10
10
|
* it reserves `count` people at the route price and settles to what it delivers.
|
|
11
|
-
* - Every other route (tasks, results, pause/resume/cancel, profiles) is free.
|
|
11
|
+
* - Every other route (tasks, results, pause/resume/cancel, profiles, exports) is free.
|
|
12
12
|
*/
|
|
13
|
-
export const PEOPLE_API_BASE_URL =
|
|
13
|
+
export const PEOPLE_API_BASE_URL = DESEARCH_API_BASE_URL;
|
|
14
14
|
export const PEOPLE_PLATFORMS = ["x", "youtube", "linkedin", "tiktok"];
|
|
15
15
|
export const PEOPLE_TASK_STATUSES = [
|
|
16
16
|
"queued",
|
|
@@ -82,90 +82,44 @@ export const PEOPLE_SEARCH_FILTER_NAMES = [
|
|
|
82
82
|
"keywords",
|
|
83
83
|
"exclude_keywords",
|
|
84
84
|
];
|
|
85
|
+
export const PEOPLE_EXPORT_FORMATS = ["csv", "jsonl"];
|
|
85
86
|
function isPlainObject(value) {
|
|
86
87
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
87
88
|
}
|
|
88
|
-
function errorDetail(data, text) {
|
|
89
|
-
if (isPlainObject(data) && data.detail !== undefined) {
|
|
90
|
-
const detail = typeof data.detail === "string" ? data.detail : JSON.stringify(data.detail);
|
|
91
|
-
const task = isPlainObject(data.task) ? data.task : undefined;
|
|
92
|
-
return typeof task?.status === "string" ? `${detail} Task status: ${task.status}.` : detail;
|
|
93
|
-
}
|
|
94
|
-
return text.length > 500 ? `${text.slice(0, 500)}...` : text;
|
|
95
|
-
}
|
|
96
|
-
export function withQuery(path, params) {
|
|
97
|
-
const search = new URLSearchParams();
|
|
98
|
-
for (const [key, value] of Object.entries(params)) {
|
|
99
|
-
if (value !== undefined) {
|
|
100
|
-
search.append(key, String(value));
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
const qs = search.toString();
|
|
104
|
-
return qs ? `${path}?${qs}` : path;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* One Desearch API request with the desearch-js conventions: `Authorization: <key>`,
|
|
108
|
-
* a JSON body, and `HTTP <status>: <detail>` on an error status. People Search and
|
|
109
|
-
* Company Search (companies.ts) share it.
|
|
110
|
-
*/
|
|
111
|
-
export function createApiCall(apiKey, baseUrl = PEOPLE_API_BASE_URL) {
|
|
112
|
-
return async function call(method, path, options = {}) {
|
|
113
|
-
const headers = { Authorization: apiKey, ...options.headers };
|
|
114
|
-
if (options.body) {
|
|
115
|
-
headers["Content-Type"] = "application/json";
|
|
116
|
-
}
|
|
117
|
-
let response;
|
|
118
|
-
let text;
|
|
119
|
-
try {
|
|
120
|
-
response = await fetch(`${baseUrl}${path}`, {
|
|
121
|
-
method,
|
|
122
|
-
headers,
|
|
123
|
-
body: options.body ? JSON.stringify(options.body) : undefined,
|
|
124
|
-
});
|
|
125
|
-
text = await response.text();
|
|
126
|
-
}
|
|
127
|
-
catch (error) {
|
|
128
|
-
throw new Error(`Unexpected Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
129
|
-
}
|
|
130
|
-
let data = text;
|
|
131
|
-
if (text) {
|
|
132
|
-
try {
|
|
133
|
-
data = JSON.parse(text);
|
|
134
|
-
}
|
|
135
|
-
catch {
|
|
136
|
-
// Not JSON: keep the text.
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
if (!response.ok) {
|
|
140
|
-
throw new Error(`HTTP ${response.status}: ${errorDetail(data, text)}`);
|
|
141
|
-
}
|
|
142
|
-
return { status: response.status, data };
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
89
|
export function createPeopleClient(apiKey, baseUrl = PEOPLE_API_BASE_URL) {
|
|
146
|
-
|
|
90
|
+
return peopleClientFor(createDesearchApi(apiKey, baseUrl));
|
|
91
|
+
}
|
|
92
|
+
/** A People Search client on an existing API caller, so the server shares one per key. */
|
|
93
|
+
export function peopleClientFor(call) {
|
|
147
94
|
const taskPath = (taskId) => `/desearch/people/tasks/${encodeURIComponent(taskId)}`;
|
|
148
95
|
return {
|
|
149
|
-
startSearch(platform, body, idempotencyKey) {
|
|
150
|
-
|
|
96
|
+
async startSearch(platform, body, idempotencyKey) {
|
|
97
|
+
const { status, data } = await call("POST", `/desearch/people/search/${platform}`, {
|
|
151
98
|
body,
|
|
152
99
|
headers: idempotencyKey ? { "Idempotency-Key": idempotencyKey } : undefined,
|
|
153
100
|
});
|
|
101
|
+
return { status, data };
|
|
154
102
|
},
|
|
155
103
|
async getTask(taskId) {
|
|
156
104
|
return (await call("GET", taskPath(taskId))).data;
|
|
157
105
|
},
|
|
158
106
|
async getResults(taskId, params) {
|
|
159
|
-
return (await call("GET",
|
|
107
|
+
return (await call("GET", `${taskPath(taskId)}/results`, { query: params })).data;
|
|
160
108
|
},
|
|
161
109
|
async controlTask(taskId, action) {
|
|
162
110
|
return (await call("POST", `${taskPath(taskId)}/${action}`)).data;
|
|
163
111
|
},
|
|
164
112
|
async listTasks(params) {
|
|
165
|
-
return (await call("GET",
|
|
113
|
+
return (await call("GET", "/desearch/people/tasks", { query: params })).data;
|
|
166
114
|
},
|
|
167
115
|
async listProfiles(params) {
|
|
168
|
-
return (await call("GET",
|
|
116
|
+
return (await call("GET", "/desearch/people/profiles", { query: params })).data;
|
|
117
|
+
},
|
|
118
|
+
async exportTask(taskId, params) {
|
|
119
|
+
return (await call("GET", `${taskPath(taskId)}/export`, { query: params })).text;
|
|
120
|
+
},
|
|
121
|
+
async exportProfiles(params) {
|
|
122
|
+
return (await call("GET", "/desearch/people/profiles/export", { query: params })).text;
|
|
169
123
|
},
|
|
170
124
|
};
|
|
171
125
|
}
|
|
@@ -497,3 +451,133 @@ export async function listPeopleProfiles(client, args) {
|
|
|
497
451
|
profiles: arrayOf(page.profiles).map(compactPerson),
|
|
498
452
|
};
|
|
499
453
|
}
|
|
454
|
+
/** Rows `people-search-export` returns when the caller does not set `max_rows`. */
|
|
455
|
+
export const PEOPLE_EXPORT_DEFAULT_ROWS = 100;
|
|
456
|
+
export const PEOPLE_EXPORT_MAX_ROWS = 1000;
|
|
457
|
+
/** Most characters of file text one reply carries; whole rows only. */
|
|
458
|
+
export const PEOPLE_EXPORT_MAX_CHARS = 50_000;
|
|
459
|
+
/**
|
|
460
|
+
* End offset (after the line break) of each non-blank record. CSV fields in quotes
|
|
461
|
+
* may hold line breaks, so a CSV line break only ends a record outside quotes; a
|
|
462
|
+
* doubled quote inside a field toggles twice and changes nothing. JSON Lines escape
|
|
463
|
+
* line breaks, so every line is a record.
|
|
464
|
+
*/
|
|
465
|
+
export function exportRecordEnds(text, format) {
|
|
466
|
+
const ends = [];
|
|
467
|
+
const csv = format === "csv";
|
|
468
|
+
let inQuotes = false;
|
|
469
|
+
let start = 0;
|
|
470
|
+
for (let i = 0; i < text.length; i++) {
|
|
471
|
+
const ch = text[i];
|
|
472
|
+
if (csv && ch === '"') {
|
|
473
|
+
inQuotes = !inQuotes;
|
|
474
|
+
}
|
|
475
|
+
else if (ch === "\n" && !inQuotes) {
|
|
476
|
+
if (text.slice(start, i).trim() !== "") {
|
|
477
|
+
ends.push(i + 1);
|
|
478
|
+
}
|
|
479
|
+
start = i + 1;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
if (text.slice(start).trim() !== "") {
|
|
483
|
+
ends.push(text.length);
|
|
484
|
+
}
|
|
485
|
+
return ends;
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Keep the CSV header and at most `maxRows` whole rows that fit in `maxChars`.
|
|
489
|
+
* The kept text is a prefix of the file, so it parses the same way the file does.
|
|
490
|
+
*/
|
|
491
|
+
export function truncateExport(text, format, maxRows, maxChars = PEOPLE_EXPORT_MAX_CHARS) {
|
|
492
|
+
const ends = exportRecordEnds(text, format);
|
|
493
|
+
const headerRecords = format === "csv" && ends.length > 0 ? 1 : 0;
|
|
494
|
+
const totalRows = ends.length - headerRecords;
|
|
495
|
+
let end = headerRecords ? ends[0] : 0;
|
|
496
|
+
let kept = 0;
|
|
497
|
+
let charLimited = false;
|
|
498
|
+
for (let i = headerRecords; i < ends.length && kept < maxRows; i++) {
|
|
499
|
+
if (ends[i] > maxChars) {
|
|
500
|
+
charLimited = true;
|
|
501
|
+
break;
|
|
502
|
+
}
|
|
503
|
+
end = ends[i];
|
|
504
|
+
kept++;
|
|
505
|
+
}
|
|
506
|
+
const cut = totalRows - kept;
|
|
507
|
+
return {
|
|
508
|
+
// A file without rows (only a header, or empty) comes back unchanged.
|
|
509
|
+
text: cut === 0 ? text : text.slice(0, end),
|
|
510
|
+
total_rows: totalRows,
|
|
511
|
+
returned_rows: kept,
|
|
512
|
+
cut_rows: cut,
|
|
513
|
+
char_limited: charLimited,
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
function exportQuery(args) {
|
|
517
|
+
return {
|
|
518
|
+
format: args.format,
|
|
519
|
+
has: args.has?.length ? args.has.join(",") : undefined,
|
|
520
|
+
min_audience: args.min_audience,
|
|
521
|
+
max_audience: args.max_audience,
|
|
522
|
+
min_score: args.min_score,
|
|
523
|
+
location: args.location,
|
|
524
|
+
verified: args.verified,
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* `people-search-export`: one search's people (`task_id`) or everyone the caller's
|
|
529
|
+
* searches found on a platform (`platform`), as CSV or JSON Lines text cut to
|
|
530
|
+
* `max_rows` rows and PEOPLE_EXPORT_MAX_CHARS characters.
|
|
531
|
+
*/
|
|
532
|
+
export async function exportPeople(client, args) {
|
|
533
|
+
const format = args.format ?? "csv";
|
|
534
|
+
const maxRows = args.max_rows ?? PEOPLE_EXPORT_DEFAULT_ROWS;
|
|
535
|
+
let text;
|
|
536
|
+
let what;
|
|
537
|
+
let route;
|
|
538
|
+
if (args.task_id !== undefined) {
|
|
539
|
+
const profileOnly = ["platform", "q", "sort"].filter((key) => args[key] !== undefined);
|
|
540
|
+
if (profileOnly.length > 0) {
|
|
541
|
+
throw new Error(`${profileOnly.join(", ")} ${profileOnly.length === 1 ? "applies" : "apply"} only to a platform export. Send task_id to export one search, or platform (without task_id) to export everyone your searches found on it.`);
|
|
542
|
+
}
|
|
543
|
+
text = await client.exportTask(args.task_id, exportQuery({ ...args, format }));
|
|
544
|
+
what = `task ${args.task_id}`;
|
|
545
|
+
route = `/desearch/people/tasks/${args.task_id}/export?format=${format}`;
|
|
546
|
+
}
|
|
547
|
+
else {
|
|
548
|
+
if (args.platform === undefined) {
|
|
549
|
+
throw new Error("Send task_id to export one search, or platform to export everyone your searches found on it.");
|
|
550
|
+
}
|
|
551
|
+
text = await client.exportProfiles({
|
|
552
|
+
platform: args.platform,
|
|
553
|
+
q: args.q,
|
|
554
|
+
sort: args.sort,
|
|
555
|
+
...exportQuery({ ...args, format }),
|
|
556
|
+
});
|
|
557
|
+
what = `everyone found on ${args.platform}`;
|
|
558
|
+
route = `/desearch/people/profiles/export?platform=${args.platform}&format=${format}`;
|
|
559
|
+
}
|
|
560
|
+
const kept = truncateExport(text, format, maxRows);
|
|
561
|
+
const label = format === "csv" ? "CSV" : "JSON Lines";
|
|
562
|
+
const rows = (n) => `${n} ${n === 1 ? "row" : "rows"}`;
|
|
563
|
+
let note;
|
|
564
|
+
if (kept.cut_rows === 0) {
|
|
565
|
+
note = `${label} export of ${what}: ${rows(kept.total_rows)}, all shown.`;
|
|
566
|
+
}
|
|
567
|
+
else {
|
|
568
|
+
const reason = kept.char_limited
|
|
569
|
+
? `to keep this reply under ${PEOPLE_EXPORT_MAX_CHARS.toLocaleString("en-US")} characters`
|
|
570
|
+
: `by max_rows ${maxRows}`;
|
|
571
|
+
note =
|
|
572
|
+
`${label} export of ${what}: ${rows(kept.total_rows)}. Showing the first ${rows(kept.returned_rows)}; ` +
|
|
573
|
+
`${rows(kept.cut_rows)} ${kept.cut_rows === 1 ? "was" : "were"} cut ${reason}. ` +
|
|
574
|
+
`For the whole file, call GET ${PEOPLE_API_BASE_URL}${route} (plus the same filters) with your API key, or page through people with people-search-status or people-profiles.`;
|
|
575
|
+
}
|
|
576
|
+
return {
|
|
577
|
+
note,
|
|
578
|
+
text: kept.text,
|
|
579
|
+
total_rows: kept.total_rows,
|
|
580
|
+
returned_rows: kept.returned_rows,
|
|
581
|
+
cut_rows: kept.cut_rows,
|
|
582
|
+
};
|
|
583
|
+
}
|
package/build/server.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { type Icon } from "@modelcontextprotocol/sdk/types.js";
|
|
|
3
3
|
import { type PeopleClient } from "./people.js";
|
|
4
4
|
import { type CompanyClient } from "./companies.js";
|
|
5
5
|
export declare const SERVER_NAME = "Desearch";
|
|
6
|
-
export declare const SERVER_VERSION = "0.
|
|
6
|
+
export declare const SERVER_VERSION = "0.8.0";
|
|
7
7
|
export declare const SERVER_TITLE = "Desearch";
|
|
8
8
|
export declare const SERVER_WEBSITE_URL = "https://www.desearch.ai";
|
|
9
9
|
export declare const MCP_PUBLIC_BASE_URL: string;
|
|
@@ -106,6 +106,9 @@ export declare function presentSearchBody(value: unknown): unknown;
|
|
|
106
106
|
* `client`, `peopleClient`, and `companyClient` are test seams. Production callers omit
|
|
107
107
|
* them and the server builds a desearch-js client, a People Search client (people.ts), and
|
|
108
108
|
* a Company Search client (companies.ts) from `apiKey`.
|
|
109
|
+
* The routes desearch-js 1.5 does not cover (People Search, Company Search, TikTok,
|
|
110
|
+
* Facebook, Instagram, YouTube, Reddit, Threads, `POST /search`) share one direct API caller (desearch-api.ts)
|
|
111
|
+
* for that key.
|
|
109
112
|
*/
|
|
110
113
|
export declare function createDesearchMcpServer(apiKey: string, client?: DesearchClient, peopleClient?: PeopleClient, companyClient?: CompanyClient): McpServer;
|
|
111
114
|
export {};
|
package/build/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAKH,KAAK,IAAI,EAEZ,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../server.ts"],"names":[],"mappings":"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"}
|
package/build/server.js
CHANGED
|
@@ -2,11 +2,13 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
2
2
|
import { ListPromptsRequestSchema, ListResourcesRequestSchema, ListResourceTemplatesRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
3
3
|
import DesearchImport from "desearch-js";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { createDesearchApi } from "./desearch-api.js";
|
|
6
|
+
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";
|
|
7
|
+
import { COMPANY_COUNTRIES_MAX, COMPANY_DOMAINS_MAX, COMPANY_EXCLUDE_MAX, COMPANY_REQUIREMENTS, COMPANY_ROLES, COMPANY_TASK_STATUSES, COMPANY_TASK_TYPES, companyClientFor, controlCompanyTask, listCompanyTasks, readCompanyStatus, startCompanyEnrich, startCompanySearch, } from "./companies.js";
|
|
8
|
+
import { runSocialAction, socialActionNames } from "./social.js";
|
|
7
9
|
import { AI_SEARCH_TOOLS, WEB_LINK_TOOLS, toolIdSchema } from "./tool-sources.js";
|
|
8
10
|
export const SERVER_NAME = "Desearch";
|
|
9
|
-
export const SERVER_VERSION = "0.
|
|
11
|
+
export const SERVER_VERSION = "0.8.0";
|
|
10
12
|
export const SERVER_TITLE = "Desearch";
|
|
11
13
|
export const SERVER_WEBSITE_URL = "https://www.desearch.ai";
|
|
12
14
|
// Public origin of the hosted server, which serves the icons below.
|
|
@@ -118,6 +120,50 @@ const peoplePlatform = z
|
|
|
118
120
|
function strictArgs(shape) {
|
|
119
121
|
return z.object(shape).strict();
|
|
120
122
|
}
|
|
123
|
+
// Social tool arguments. A new schema per field, like peopleKeywordList: one shared
|
|
124
|
+
// instance in a tool's schema would serialize as a JSON Schema $ref.
|
|
125
|
+
function socialTarget(description) {
|
|
126
|
+
return z.string().min(1).max(2048).optional().describe(description);
|
|
127
|
+
}
|
|
128
|
+
function socialCount() {
|
|
129
|
+
return z
|
|
130
|
+
.number()
|
|
131
|
+
.int()
|
|
132
|
+
.min(1)
|
|
133
|
+
.max(100)
|
|
134
|
+
.optional()
|
|
135
|
+
.describe("Most items to return (1-100). API default: 10 for search, 20 for the other list actions. One page may hold fewer.");
|
|
136
|
+
}
|
|
137
|
+
function socialCursor() {
|
|
138
|
+
return z
|
|
139
|
+
.string()
|
|
140
|
+
.min(1)
|
|
141
|
+
.max(4096)
|
|
142
|
+
.optional()
|
|
143
|
+
.describe("next_cursor from the previous page of the same action and target, sent back unchanged. Omit it for the first page.");
|
|
144
|
+
}
|
|
145
|
+
function socialQuery(example, maxLength = 1000, note = "") {
|
|
146
|
+
return z
|
|
147
|
+
.string()
|
|
148
|
+
.min(1)
|
|
149
|
+
.max(maxLength)
|
|
150
|
+
.optional()
|
|
151
|
+
.describe(`search: keyword or phrase, example: '${example}'.${note}`);
|
|
152
|
+
}
|
|
153
|
+
function socialDate(description) {
|
|
154
|
+
return z
|
|
155
|
+
.string()
|
|
156
|
+
.regex(/^\d{4}-\d{2}-\d{2}$/)
|
|
157
|
+
.optional()
|
|
158
|
+
.describe(description);
|
|
159
|
+
}
|
|
160
|
+
function socialTag() {
|
|
161
|
+
return socialTarget("hashtag: the hashtag without #, example: 'ai'. A leading # is removed.");
|
|
162
|
+
}
|
|
163
|
+
function socialAction(platform, description) {
|
|
164
|
+
return z.enum(socialActionNames(platform)).describe(description);
|
|
165
|
+
}
|
|
166
|
+
const SOCIAL_PAGING = "List actions return { results, next_cursor, next }. For the next page, call again with the same action and target and cursor set to next_cursor, unchanged; next_cursor is null on the last page. A cursor lasts 24 hours.";
|
|
121
167
|
// A new schema per field: one shared instance would serialize as a JSON Schema $ref.
|
|
122
168
|
function peopleKeywordList() {
|
|
123
169
|
return z.array(z.string().min(1).max(120)).max(20);
|
|
@@ -412,11 +458,15 @@ function registerTool(server, apiKey, name, title, description, inputSchema, han
|
|
|
412
458
|
* `client`, `peopleClient`, and `companyClient` are test seams. Production callers omit
|
|
413
459
|
* them and the server builds a desearch-js client, a People Search client (people.ts), and
|
|
414
460
|
* a Company Search client (companies.ts) from `apiKey`.
|
|
461
|
+
* The routes desearch-js 1.5 does not cover (People Search, Company Search, TikTok,
|
|
462
|
+
* Facebook, Instagram, YouTube, Reddit, Threads, `POST /search`) share one direct API caller (desearch-api.ts)
|
|
463
|
+
* for that key.
|
|
415
464
|
*/
|
|
416
465
|
export function createDesearchMcpServer(apiKey, client, peopleClient, companyClient) {
|
|
417
466
|
const desearch = client ?? new Desearch(apiKey);
|
|
418
|
-
const
|
|
419
|
-
const
|
|
467
|
+
const api = createDesearchApi(apiKey);
|
|
468
|
+
const people = peopleClient ?? peopleClientFor(api);
|
|
469
|
+
const companies = companyClient ?? companyClientFor(api);
|
|
420
470
|
const serverInfo = {
|
|
421
471
|
name: SERVER_NAME,
|
|
422
472
|
version: SERVER_VERSION,
|
|
@@ -425,7 +475,7 @@ export function createDesearchMcpServer(apiKey, client, peopleClient, companyCli
|
|
|
425
475
|
icons: SERVER_ICONS,
|
|
426
476
|
};
|
|
427
477
|
const server = new McpServer(serverInfo, {
|
|
428
|
-
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. Other tools cover AI search, X posts, and page extraction. 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,
|
|
478
|
+
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 returns ranked pages with the passage that best matches the query. Other tools cover AI search, 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. Calls need a Desearch API key.",
|
|
429
479
|
});
|
|
430
480
|
registerTool(server, apiKey, "ai-search", "AI Search", "AI search and analysis on web using Desearch AI", {
|
|
431
481
|
prompt: z.string().describe("Question, example: 'What is the latest news on AI?'"),
|
|
@@ -716,6 +766,179 @@ export function createDesearchMcpServer(apiKey, client, peopleClient, companyCli
|
|
|
716
766
|
return fail("X Trends error", error);
|
|
717
767
|
}
|
|
718
768
|
});
|
|
769
|
+
registerTool(server, apiKey, "search-api", "Search API", "Search the web with the Desearch Search API and return ranked pages, each with its title, URL, publication date when known, and the passage that best matches the query. Set page_text to add each page's full text. Returns { results, cost_usd, usage_count, service, currency }. Use search for titles and links only, and web-search for SERP-style snippets.", {
|
|
770
|
+
query: z.string().min(1).max(2000).describe("Search query, example: 'Who won the 2024 Nobel Prize in Physics?'"),
|
|
771
|
+
mode: z
|
|
772
|
+
.enum(["fast", "balanced"])
|
|
773
|
+
.optional()
|
|
774
|
+
.describe("'fast' returns results sooner; 'balanced' (API default) favors relevance."),
|
|
775
|
+
count: z
|
|
776
|
+
.number()
|
|
777
|
+
.int()
|
|
778
|
+
.min(10)
|
|
779
|
+
.max(20)
|
|
780
|
+
.multipleOf(5)
|
|
781
|
+
.optional()
|
|
782
|
+
.describe("Number of results: 10 (API default), 15, or 20."),
|
|
783
|
+
start_date: z
|
|
784
|
+
.string()
|
|
785
|
+
.regex(/^\d{4}-\d{2}-\d{2}$/, "Use YYYY-MM-DD")
|
|
786
|
+
.optional()
|
|
787
|
+
.describe("Only pages published on or after this date (YYYY-MM-DD)."),
|
|
788
|
+
end_date: z
|
|
789
|
+
.string()
|
|
790
|
+
.regex(/^\d{4}-\d{2}-\d{2}$/, "Use YYYY-MM-DD")
|
|
791
|
+
.optional()
|
|
792
|
+
.describe("Only pages published on or before this date (YYYY-MM-DD)."),
|
|
793
|
+
highlights: z
|
|
794
|
+
.boolean()
|
|
795
|
+
.optional()
|
|
796
|
+
.describe("Include the passage that best matches the query (API default true)."),
|
|
797
|
+
page_text: z.boolean().optional().describe("Include each page's full text (API default false)."),
|
|
798
|
+
}, async ({ query, mode, count, start_date, end_date, highlights, page_text }) => {
|
|
799
|
+
try {
|
|
800
|
+
const body = { query, ...definedFields({ mode, count, start_date, end_date, highlights, page_text }) };
|
|
801
|
+
return ok((await api("POST", "/search", { body })).data);
|
|
802
|
+
}
|
|
803
|
+
catch (error) {
|
|
804
|
+
return fail("Search API error", error);
|
|
805
|
+
}
|
|
806
|
+
});
|
|
807
|
+
registerTool(server, apiKey, "tiktok", "TikTok", "Read public TikTok data with Desearch. Set action and that action's arguments. search (query; optional count, sort, cursor): videos that match a keyword. post (id): one video by its ID. profile (username): one profile. profile_posts (username; optional count, cursor): a user's videos. comments (video_id; optional count, cursor): a video's comments. hashtag (tag; optional count, cursor): videos with a hashtag. trending (optional region, count): trending videos for a region, one page. A video id from search can be passed to post or comments. post and profile return the item itself. " +
|
|
808
|
+
SOCIAL_PAGING, strictArgs({
|
|
809
|
+
action: socialAction("tiktok", "What to read: 'search', 'post', 'profile', 'profile_posts', 'comments', 'hashtag', or 'trending'."),
|
|
810
|
+
query: socialQuery("bittensor"),
|
|
811
|
+
sort: socialTarget("search: sort option, when TikTok supports one."),
|
|
812
|
+
id: socialTarget("post: the TikTok video ID, example: '7620891413932166433'."),
|
|
813
|
+
username: socialTarget("profile, profile_posts: TikTok username, example: 'tiktok'. A leading @ is removed."),
|
|
814
|
+
video_id: socialTarget("comments: the TikTok video ID."),
|
|
815
|
+
tag: socialTag(),
|
|
816
|
+
region: z
|
|
817
|
+
.string()
|
|
818
|
+
.length(2)
|
|
819
|
+
.optional()
|
|
820
|
+
.describe("trending: two-letter region code, example: 'US' (API default)."),
|
|
821
|
+
count: socialCount(),
|
|
822
|
+
cursor: socialCursor(),
|
|
823
|
+
}), async (args) => {
|
|
824
|
+
try {
|
|
825
|
+
return ok(await runSocialAction(api, "tiktok", args));
|
|
826
|
+
}
|
|
827
|
+
catch (error) {
|
|
828
|
+
return fail("TikTok error", error);
|
|
829
|
+
}
|
|
830
|
+
});
|
|
831
|
+
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. " +
|
|
832
|
+
SOCIAL_PAGING, strictArgs({
|
|
833
|
+
action: socialAction("facebook", "What to read: 'search', 'post', 'profile', 'profile_posts', 'comments', or 'hashtag'."),
|
|
834
|
+
query: socialQuery("running shoes"),
|
|
835
|
+
id: socialTarget("post: the public Facebook post or media ID."),
|
|
836
|
+
profile_id: socialTarget("profile, profile_posts: page or profile ID, or its public handle, example: 'facebook'."),
|
|
837
|
+
post_id: socialTarget("comments: the public Facebook post or media ID."),
|
|
838
|
+
tag: socialTag(),
|
|
839
|
+
count: socialCount(),
|
|
840
|
+
cursor: socialCursor(),
|
|
841
|
+
}), async (args) => {
|
|
842
|
+
try {
|
|
843
|
+
return ok(await runSocialAction(api, "facebook", args));
|
|
844
|
+
}
|
|
845
|
+
catch (error) {
|
|
846
|
+
return fail("Facebook error", error);
|
|
847
|
+
}
|
|
848
|
+
});
|
|
849
|
+
registerTool(server, apiKey, "instagram", "Instagram", "Read public Instagram data with Desearch. Set action and that action's arguments. search (query; optional count): profiles that match, one page with no cursor. media (id): one post by shortcode, numeric ID, or URL. profile (username): one profile. profile_posts (username; optional count, cursor): a user's posts. comments (shortcode; optional count, cursor): a post's comments. hashtag (tag; optional count, cursor): posts with a hashtag. media and profile return the item itself. " +
|
|
850
|
+
SOCIAL_PAGING, strictArgs({
|
|
851
|
+
action: socialAction("instagram", "What to read: 'search', 'media', 'profile', 'profile_posts', 'comments', or 'hashtag'."),
|
|
852
|
+
query: socialQuery("desearch"),
|
|
853
|
+
id: socialTarget("media: the post shortcode, numeric media ID, or public URL."),
|
|
854
|
+
username: socialTarget("profile, profile_posts: Instagram username, example: 'instagram'. A leading @ is removed."),
|
|
855
|
+
shortcode: socialTarget("comments: the code in the post URL, such as 'DeuOR-CjKE9' in https://www.instagram.com/p/DeuOR-CjKE9/. Numeric media IDs return 404."),
|
|
856
|
+
tag: socialTag(),
|
|
857
|
+
count: socialCount(),
|
|
858
|
+
cursor: socialCursor(),
|
|
859
|
+
}), async (args) => {
|
|
860
|
+
try {
|
|
861
|
+
return ok(await runSocialAction(api, "instagram", args));
|
|
862
|
+
}
|
|
863
|
+
catch (error) {
|
|
864
|
+
return fail("Instagram error", error);
|
|
865
|
+
}
|
|
866
|
+
});
|
|
867
|
+
registerTool(server, apiKey, "youtube", "YouTube", "Read public YouTube data with Desearch. Set action and that action's arguments. search (query; optional type, upload_date, sort_by, duration, cursor): videos, Shorts, live streams, channels, and playlists that match a keyword; each result has a type. video (id): one video or Short by ID or URL, with its channel, counts, chapters, and caption languages. transcript (video_id; optional language): its captions as plain text and timestamped segments; a video without captions returns 404. comments (video_id; optional order, cursor): its top-level comments. channel (handle): one channel by handle or channel ID. channel_videos (handle; optional sort, cursor): the channel's videos. A video id from search or channel_videos can be passed to video, transcript, or comments. video, transcript, and channel return the item itself. " +
|
|
868
|
+
SOCIAL_PAGING, strictArgs({
|
|
869
|
+
action: socialAction("youtube", "What to read: 'search', 'video', 'transcript', 'comments', 'channel', or 'channel_videos'."),
|
|
870
|
+
query: socialQuery("bittensor", 500, " Use intitle:\"...\" for stricter title matching."),
|
|
871
|
+
type: z
|
|
872
|
+
.enum(["videos", "shorts", "channels", "playlists"])
|
|
873
|
+
.optional()
|
|
874
|
+
.describe("search: only this kind of result. Omit for mixed results."),
|
|
875
|
+
upload_date: z
|
|
876
|
+
.enum(["today", "this_week", "this_month", "this_year"])
|
|
877
|
+
.optional()
|
|
878
|
+
.describe("search: only videos uploaded in this window."),
|
|
879
|
+
sort_by: z.enum(["relevance", "popular"]).optional().describe("search: result order."),
|
|
880
|
+
duration: z
|
|
881
|
+
.enum(["under_3_min", "between_3_and_20_min", "over_20_min"])
|
|
882
|
+
.optional()
|
|
883
|
+
.describe("search: video length. Applies to videos, not Shorts."),
|
|
884
|
+
id: socialTarget("video: YouTube video or Short ID, or its full URL, example: 'dQw4w9WgXcQ'."),
|
|
885
|
+
video_id: socialTarget("transcript, comments: YouTube video or Short ID, or its full URL."),
|
|
886
|
+
language: z
|
|
887
|
+
.string()
|
|
888
|
+
.regex(/^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,4})?$/)
|
|
889
|
+
.optional()
|
|
890
|
+
.describe("transcript: caption language code, example: 'en' or 'es'. Omit for YouTube's default track."),
|
|
891
|
+
order: z.enum(["top", "newest"]).optional().describe("comments: comment order."),
|
|
892
|
+
handle: socialTarget("channel, channel_videos: channel handle (with or without @) or channel ID (UC...), example: '@MrBeast'."),
|
|
893
|
+
sort: z.enum(["latest", "popular"]).optional().describe("channel_videos: video order (API default latest)."),
|
|
894
|
+
cursor: socialCursor(),
|
|
895
|
+
}), async (args) => {
|
|
896
|
+
try {
|
|
897
|
+
return ok(await runSocialAction(api, "youtube", args));
|
|
898
|
+
}
|
|
899
|
+
catch (error) {
|
|
900
|
+
return fail("YouTube error", error);
|
|
901
|
+
}
|
|
902
|
+
});
|
|
903
|
+
registerTool(server, apiKey, "reddit", "Reddit", "Read public Reddit data with Desearch. Set action and that action's arguments. search (query; optional sort, timeframe, cursor): posts across all subreddits that match a keyword. subreddit (name): a subreddit's description, rules, and weekly activity; the name is case-sensitive ('AskReddit', not 'askreddit'). subreddit_posts (name; optional sort, timeframe, cursor): its posts. post (id): one post by ID or URL, without comments. comments (post_id; optional cursor): a post's comments as a tree, with the replies Reddit loaded alongside them. A post id from search or subreddit_posts can be passed to post or comments. subreddit and post return the item itself. " +
|
|
904
|
+
SOCIAL_PAGING, strictArgs({
|
|
905
|
+
action: socialAction("reddit", "What to read: 'search', 'subreddit', 'subreddit_posts', 'post', or 'comments'."),
|
|
906
|
+
query: socialQuery("bittensor", 500),
|
|
907
|
+
sort: z
|
|
908
|
+
.enum(["relevance", "new", "top", "comment_count", "best", "hot", "rising"])
|
|
909
|
+
.optional()
|
|
910
|
+
.describe("search: 'relevance', 'new', 'top', or 'comment_count'. subreddit_posts: 'best', 'hot', 'new', 'top', or 'rising'."),
|
|
911
|
+
timeframe: z
|
|
912
|
+
.enum(["all", "day", "week", "month", "year"])
|
|
913
|
+
.optional()
|
|
914
|
+
.describe("search: only posts from this window. subreddit_posts: the window for sort 'top' (ignored with another sort; without a sort it means top)."),
|
|
915
|
+
name: socialTarget("subreddit, subreddit_posts: subreddit name, case-sensitive, example: 'AskReddit'. A leading r/ is removed."),
|
|
916
|
+
id: socialTarget("post: Reddit post ID (example: '1q6pxwn', with or without t3_) or its full URL."),
|
|
917
|
+
post_id: socialTarget("comments: Reddit post ID (with or without t3_) or its full URL."),
|
|
918
|
+
cursor: socialCursor(),
|
|
919
|
+
}), async (args) => {
|
|
920
|
+
try {
|
|
921
|
+
return ok(await runSocialAction(api, "reddit", args));
|
|
922
|
+
}
|
|
923
|
+
catch (error) {
|
|
924
|
+
return fail("Reddit error", error);
|
|
925
|
+
}
|
|
926
|
+
});
|
|
927
|
+
registerTool(server, apiKey, "threads", "Threads", "Read public Threads data with Desearch. Set action and that action's arguments. search (query; optional start_date, end_date): one page of posts that match a keyword. search_users (query): accounts that match a username or name. profile (username): one profile with bio, followers, and links. profile_posts (username): the account's latest public posts (Threads shows only the most recent ones). post (id): one post by URL or shortcode, with its replies (comments) and the author's own continuation posts (threadItems). profile and post return the item itself. List actions return { results, next_cursor, next }; Threads returns no further pages, so next_cursor is always null and no action takes a cursor.", strictArgs({
|
|
928
|
+
action: socialAction("threads", "What to read: 'search', 'search_users', 'profile', 'profile_posts', or 'post'."),
|
|
929
|
+
query: socialQuery("bittensor", 500, " search_users: username or name, up to 100 characters, example: 'zuck'."),
|
|
930
|
+
start_date: socialDate("search: only posts on or after this date (YYYY-MM-DD), example: '2026-01-01'."),
|
|
931
|
+
end_date: socialDate("search: only posts on or before this date (YYYY-MM-DD)."),
|
|
932
|
+
username: socialTarget("profile, profile_posts: Threads username, example: 'zuck'. A leading @ is removed."),
|
|
933
|
+
id: socialTarget("post: Threads post URL or shortcode, example: 'DK-BydcJHkF' or 'https://www.threads.com/@zuck/post/DK-BydcJHkF'."),
|
|
934
|
+
}), async (args) => {
|
|
935
|
+
try {
|
|
936
|
+
return ok(await runSocialAction(api, "threads", args));
|
|
937
|
+
}
|
|
938
|
+
catch (error) {
|
|
939
|
+
return fail("Threads error", error);
|
|
940
|
+
}
|
|
941
|
+
});
|
|
719
942
|
registerTool(server, apiKey, "search", "Search", "Search the public web and return titles and links. Use fetch with a result URL to read the page.", {
|
|
720
943
|
query: z.string().describe("Search query."),
|
|
721
944
|
}, async ({ query }) => {
|
|
@@ -988,6 +1211,58 @@ export function createDesearchMcpServer(apiKey, client, peopleClient, companyCli
|
|
|
988
1211
|
return fail("People Profiles error", error);
|
|
989
1212
|
}
|
|
990
1213
|
}, undefined, READ_ONLY_OPEN_WORLD);
|
|
1214
|
+
registerTool(server, apiKey, "people-search-export", "Export People Found", `The people your own People Searches found, as CSV or JSON Lines text: one search (task_id), or everyone found on one platform (platform, with the same q, sort, and filters as people-profiles). Free: it reads people your earlier searches found and runs no new search. The reply is a note with the row count, then the file text cut at a row boundary to max_rows rows and ${PEOPLE_EXPORT_MAX_CHARS.toLocaleString("en-US")} characters; the note says how many rows were cut and where to get the whole file. CSV keeps its header row. The data came from public profiles and posts, with only the contacts each person lists publicly.`, strictArgs({
|
|
1215
|
+
task_id: z
|
|
1216
|
+
.string()
|
|
1217
|
+
.uuid()
|
|
1218
|
+
.optional()
|
|
1219
|
+
.describe("Export one search: the task_id returned by people-search. Omit it and set platform to export everyone your searches found on that platform."),
|
|
1220
|
+
platform: z
|
|
1221
|
+
.enum(PEOPLE_PLATFORMS)
|
|
1222
|
+
.optional()
|
|
1223
|
+
.describe("Without task_id: export everyone found on 'x', 'youtube', 'linkedin', or 'tiktok'."),
|
|
1224
|
+
format: z
|
|
1225
|
+
.enum(PEOPLE_EXPORT_FORMATS)
|
|
1226
|
+
.default("csv")
|
|
1227
|
+
.describe("'csv' (default) or 'jsonl' (one JSON object per line)."),
|
|
1228
|
+
q: z
|
|
1229
|
+
.string()
|
|
1230
|
+
.max(200)
|
|
1231
|
+
.optional()
|
|
1232
|
+
.describe("Platform export only: text in the name, handle, bio, or location."),
|
|
1233
|
+
sort: z
|
|
1234
|
+
.enum(PEOPLE_PROFILE_SORTS)
|
|
1235
|
+
.optional()
|
|
1236
|
+
.describe("Platform export only: 'score' (API default), 'recent', or 'audience'."),
|
|
1237
|
+
has: z
|
|
1238
|
+
.array(z.enum(PEOPLE_FILTER_CHANNELS))
|
|
1239
|
+
.optional()
|
|
1240
|
+
.describe("Channels every person must have, example: ['email']. 'email' is a public email; the others are a link of that type."),
|
|
1241
|
+
min_audience: z.number().int().min(0).optional().describe("Minimum followers (subscribers on YouTube)."),
|
|
1242
|
+
max_audience: z.number().int().min(0).optional().describe("Maximum followers (subscribers on YouTube)."),
|
|
1243
|
+
min_score: z.number().int().min(0).max(100).optional().describe("Minimum fit score (0-100)."),
|
|
1244
|
+
location: z.string().max(100).optional().describe("Text in the location, example: 'united states'."),
|
|
1245
|
+
verified: z.boolean().optional().describe("Only verified accounts. Only X and TikTok people carry a verified flag."),
|
|
1246
|
+
max_rows: z
|
|
1247
|
+
.number()
|
|
1248
|
+
.int()
|
|
1249
|
+
.min(1)
|
|
1250
|
+
.max(PEOPLE_EXPORT_MAX_ROWS)
|
|
1251
|
+
.default(PEOPLE_EXPORT_DEFAULT_ROWS)
|
|
1252
|
+
.describe(`Most rows to return (1-${PEOPLE_EXPORT_MAX_ROWS}, default ${PEOPLE_EXPORT_DEFAULT_ROWS}). The reply also stops before ${PEOPLE_EXPORT_MAX_CHARS.toLocaleString("en-US")} characters of file text.`),
|
|
1253
|
+
}), async (args) => {
|
|
1254
|
+
try {
|
|
1255
|
+
const exported = await exportPeople(people, args);
|
|
1256
|
+
const content = [{ type: "text", text: exported.note }];
|
|
1257
|
+
if (exported.text) {
|
|
1258
|
+
content.push({ type: "text", text: exported.text });
|
|
1259
|
+
}
|
|
1260
|
+
return { content };
|
|
1261
|
+
}
|
|
1262
|
+
catch (error) {
|
|
1263
|
+
return fail("People Search Export error", error);
|
|
1264
|
+
}
|
|
1265
|
+
}, undefined, READ_ONLY_OPEN_WORLD);
|
|
991
1266
|
registerTool(server, apiKey, "company-search", "Company Search", "Start a paid job billed to the user's Desearch balance: find companies on the web that match a plain-language description, and collect each one's public contact data. Returns a task_id at once, with the task's status and reserved_cost_usd. " +
|
|
992
1267
|
"Cost: the call reserves count companies at the Company Search per-company price at the time of the call (reserved_cost_usd; prices at https://desearch.ai/pricing). When the task ends you pay only for the companies it delivered (final_cost_usd; a minimum of 2 when it delivers any; a task that delivers none is free) and the rest of the reservation is returned. A company left out by min_score or require is not billed. " +
|
|
993
1268
|
"Each company has a fit score (0-100) and why it matched, plus fully_verified and unverified_criteria (what its own pages do and do not confirm). " +
|