desearch-mcp-server 0.5.0 → 0.6.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 +29 -1
- package/README.md +149 -3
- package/build/companies.d.ts +130 -0
- package/build/companies.d.ts.map +1 -0
- package/build/companies.js +429 -0
- package/build/people.d.ts +17 -2
- package/build/people.d.ts.map +1 -1
- package/build/people.js +17 -9
- package/build/server.d.ts +6 -4
- package/build/server.d.ts.map +1 -1
- package/build/server.js +205 -12
- package/package.json +5 -2
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
import { PEOPLE_API_BASE_URL, PEOPLE_ENDED_STATUSES, PEOPLE_TASK_STATUSES, arrayOf, compact, createApiCall, numberOf, objectOf, stringOf, unverifiedCriteria, withQuery, } from "./people.js";
|
|
2
|
+
/**
|
|
3
|
+
* Company Search and Company Enrich on the Desearch API (`/desearch/companies/*`).
|
|
4
|
+
*
|
|
5
|
+
* desearch-js 1.5 has no Company Search methods, so this module calls the routes
|
|
6
|
+
* directly with the same base URL, `Authorization: <key>` header, and
|
|
7
|
+
* `HTTP <status>: <detail>` error text as People Search (people.ts).
|
|
8
|
+
*
|
|
9
|
+
* - `POST /desearch/companies/search` finds companies from a description and
|
|
10
|
+
* `POST /desearch/companies/enrich` reads the domains you send. Both are billed:
|
|
11
|
+
* they reserve companies at the route price and settle to what they deliver.
|
|
12
|
+
* - Every other route (tasks, results, pause/resume/cancel) is free. Both kinds of task
|
|
13
|
+
* run on the People Search engine, but a People Search task_id is a 404 on these
|
|
14
|
+
* routes and a company task_id is a 404 on People Search's.
|
|
15
|
+
*
|
|
16
|
+
* A company is published once the stages its request needs have run
|
|
17
|
+
* (`enrichment.status: "partial"`); later stages (contacts, people, email_patterns,
|
|
18
|
+
* email_check) fill it in place until it is `complete`. A results cursor returns only
|
|
19
|
+
* companies delivered after it; reading without a cursor returns every company in its
|
|
20
|
+
* latest version.
|
|
21
|
+
*/
|
|
22
|
+
/** Statuses are People Search's (desearch-public-api model/people.py TaskStatus). */
|
|
23
|
+
export const COMPANY_TASK_STATUSES = PEOPLE_TASK_STATUSES;
|
|
24
|
+
/** `roles` (desearch-public-api model/companies.py Role). */
|
|
25
|
+
export const COMPANY_ROLES = [
|
|
26
|
+
"ceo",
|
|
27
|
+
"founder",
|
|
28
|
+
"cto",
|
|
29
|
+
"cfo",
|
|
30
|
+
"coo",
|
|
31
|
+
"cmo",
|
|
32
|
+
"president",
|
|
33
|
+
"owner",
|
|
34
|
+
"managing_director",
|
|
35
|
+
];
|
|
36
|
+
/** `filters.require` (model/companies.py Requirement). */
|
|
37
|
+
export const COMPANY_REQUIREMENTS = ["email", "phone", "linkedin", "leader", "leader_email"];
|
|
38
|
+
/** `type` on `GET /desearch/companies/tasks` (routers/companies.py TYPE_SERVICES). */
|
|
39
|
+
export const COMPANY_TASK_TYPES = ["search", "enrich"];
|
|
40
|
+
/** Request limits (model/companies.py, model/people.py). */
|
|
41
|
+
export const COMPANY_DOMAINS_MAX = 200;
|
|
42
|
+
export const COMPANY_COUNTRIES_MAX = 20;
|
|
43
|
+
export const COMPANY_EXCLUDE_MAX = 1000;
|
|
44
|
+
export function createCompanyClient(apiKey, baseUrl = PEOPLE_API_BASE_URL) {
|
|
45
|
+
const call = createApiCall(apiKey, baseUrl);
|
|
46
|
+
const taskPath = (taskId) => `/desearch/companies/tasks/${encodeURIComponent(taskId)}`;
|
|
47
|
+
const start = (path, body, idempotencyKey) => call("POST", path, {
|
|
48
|
+
body,
|
|
49
|
+
headers: idempotencyKey ? { "Idempotency-Key": idempotencyKey } : undefined,
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
startSearch(body, idempotencyKey) {
|
|
53
|
+
return start("/desearch/companies/search", body, idempotencyKey);
|
|
54
|
+
},
|
|
55
|
+
startEnrich(body, idempotencyKey) {
|
|
56
|
+
return start("/desearch/companies/enrich", body, idempotencyKey);
|
|
57
|
+
},
|
|
58
|
+
async getTask(taskId) {
|
|
59
|
+
return (await call("GET", taskPath(taskId))).data;
|
|
60
|
+
},
|
|
61
|
+
async getResults(taskId, params) {
|
|
62
|
+
return (await call("GET", withQuery(`${taskPath(taskId)}/results`, params))).data;
|
|
63
|
+
},
|
|
64
|
+
async controlTask(taskId, action) {
|
|
65
|
+
return (await call("POST", `${taskPath(taskId)}/${action}`)).data;
|
|
66
|
+
},
|
|
67
|
+
async listTasks(params) {
|
|
68
|
+
return (await call("GET", withQuery("/desearch/companies/tasks", params))).data;
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/** `roles`, `infer_emails`, and `verify_emails`, only when the caller set them. */
|
|
73
|
+
function leaderFields(args, body) {
|
|
74
|
+
if (args.roles !== undefined)
|
|
75
|
+
body.roles = args.roles;
|
|
76
|
+
if (args.infer_emails !== undefined)
|
|
77
|
+
body.infer_emails = args.infer_emails;
|
|
78
|
+
if (args.verify_emails !== undefined)
|
|
79
|
+
body.verify_emails = args.verify_emails;
|
|
80
|
+
}
|
|
81
|
+
/** `metadata`, left out when empty. */
|
|
82
|
+
function metadataField(args, body) {
|
|
83
|
+
if (args.metadata !== undefined && Object.keys(args.metadata).length > 0)
|
|
84
|
+
body.metadata = args.metadata;
|
|
85
|
+
return body;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Request body for `POST /desearch/companies/search` (model/companies.py CompanySearchRequest).
|
|
89
|
+
* The tool takes `countries` and `require` as top-level arguments; they go in `filters`.
|
|
90
|
+
*/
|
|
91
|
+
export function companySearchBody(args) {
|
|
92
|
+
const body = { query: args.query };
|
|
93
|
+
if (args.count !== undefined)
|
|
94
|
+
body.count = args.count;
|
|
95
|
+
if (args.min_score !== undefined)
|
|
96
|
+
body.min_score = args.min_score;
|
|
97
|
+
if (args.exclude !== undefined)
|
|
98
|
+
body.exclude = args.exclude;
|
|
99
|
+
leaderFields(args, body);
|
|
100
|
+
const filters = {};
|
|
101
|
+
if (args.countries !== undefined)
|
|
102
|
+
filters.countries = args.countries;
|
|
103
|
+
if (args.require !== undefined)
|
|
104
|
+
filters.require = args.require;
|
|
105
|
+
if (Object.keys(filters).length > 0)
|
|
106
|
+
body.filters = filters;
|
|
107
|
+
return metadataField(args, body);
|
|
108
|
+
}
|
|
109
|
+
/** Request body for `POST /desearch/companies/enrich` (model/companies.py CompanyEnrichRequest). */
|
|
110
|
+
export function companyEnrichBody(args) {
|
|
111
|
+
const body = { domains: args.domains };
|
|
112
|
+
leaderFields(args, body);
|
|
113
|
+
return metadataField(args, body);
|
|
114
|
+
}
|
|
115
|
+
const MAX_DESCRIPTION_CHARS = 300;
|
|
116
|
+
const MAX_REASONS = 3;
|
|
117
|
+
function truncated(value, max) {
|
|
118
|
+
const text = stringOf(value);
|
|
119
|
+
return text && text.length > max ? `${text.slice(0, max - 3)}...` : text;
|
|
120
|
+
}
|
|
121
|
+
function strings(value) {
|
|
122
|
+
return arrayOf(value).filter((item) => typeof item === "string" && item !== "");
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* One email: the address, what kind it is, where it came from (`source`, `source_url`),
|
|
126
|
+
* the inference details (`confidence`, `pattern`) and `verification` (the check's status:
|
|
127
|
+
* valid, invalid, risky, or unknown; left out until the email checks ran).
|
|
128
|
+
*/
|
|
129
|
+
function compactEmail(value, withPerson = true) {
|
|
130
|
+
const e = objectOf(value);
|
|
131
|
+
return compact({
|
|
132
|
+
value: stringOf(e.value),
|
|
133
|
+
type: e.type,
|
|
134
|
+
source: e.source,
|
|
135
|
+
source_url: stringOf(e.source_url),
|
|
136
|
+
person: withPerson ? stringOf(e.person) : undefined,
|
|
137
|
+
confidence: e.confidence,
|
|
138
|
+
pattern: stringOf(e.pattern),
|
|
139
|
+
verification: stringOf(objectOf(e.verification).status),
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function compactEmails(value, withPerson = true) {
|
|
143
|
+
return arrayOf(value)
|
|
144
|
+
.map((email) => compactEmail(email, withPerson))
|
|
145
|
+
.filter((email) => email.value !== undefined);
|
|
146
|
+
}
|
|
147
|
+
function compactPhones(value) {
|
|
148
|
+
return arrayOf(value)
|
|
149
|
+
.map(objectOf)
|
|
150
|
+
.filter((phone) => stringOf(phone.value))
|
|
151
|
+
.map((phone) => compact({ value: phone.value, type: phone.type, source_url: stringOf(phone.source_url) }));
|
|
152
|
+
}
|
|
153
|
+
function compactSocials(value) {
|
|
154
|
+
return arrayOf(value)
|
|
155
|
+
.map(objectOf)
|
|
156
|
+
.filter((social) => stringOf(social.url))
|
|
157
|
+
.map((social) => compact({ type: social.type, url: social.url, source_url: stringOf(social.source_url) }));
|
|
158
|
+
}
|
|
159
|
+
/** One leader: who, which of the request's roles, where the role is shown, and how to reach them. */
|
|
160
|
+
function compactLeader(value) {
|
|
161
|
+
const p = objectOf(value);
|
|
162
|
+
return compact({
|
|
163
|
+
name: stringOf(p.name),
|
|
164
|
+
title: stringOf(p.title),
|
|
165
|
+
roles: strings(p.roles),
|
|
166
|
+
verified: typeof p.verified === "boolean" ? p.verified : undefined,
|
|
167
|
+
linkedin_url: stringOf(p.linkedin_url),
|
|
168
|
+
x_url: stringOf(p.x_url),
|
|
169
|
+
github_url: stringOf(p.github_url),
|
|
170
|
+
emails: compactEmails(p.emails, false),
|
|
171
|
+
phones: compactPhones(p.phones),
|
|
172
|
+
evidence_url: stringOf(objectOf(p.evidence).source_url),
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
function compactEnrichment(value) {
|
|
176
|
+
const e = objectOf(value);
|
|
177
|
+
const stages = objectOf(e.stages);
|
|
178
|
+
return compact({
|
|
179
|
+
status: stringOf(e.status),
|
|
180
|
+
stages: compact(stages),
|
|
181
|
+
errors: arrayOf(e.errors)
|
|
182
|
+
.map(objectOf)
|
|
183
|
+
.map((error) => compact({ stage: stringOf(error.stage), message: stringOf(error.message) }))
|
|
184
|
+
.filter((error) => Object.keys(error).length > 0),
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* One company as an agent needs it: what it is, how well it fits (Company Search; `score`
|
|
189
|
+
* is null for Company Enrich), how to reach it and its leaders, with the page each contact
|
|
190
|
+
* came from, and how far its enrichment has got.
|
|
191
|
+
*/
|
|
192
|
+
export function compactCompany(company) {
|
|
193
|
+
const c = objectOf(company);
|
|
194
|
+
const location = objectOf(c.location);
|
|
195
|
+
const score = objectOf(c.score);
|
|
196
|
+
const contact = objectOf(c.primary_contact);
|
|
197
|
+
const primaryEmail = compactEmail(c.primary_email);
|
|
198
|
+
return {
|
|
199
|
+
...compact({
|
|
200
|
+
domain: stringOf(c.domain) ?? stringOf(c.handle),
|
|
201
|
+
name: stringOf(c.name),
|
|
202
|
+
url: stringOf(c.url),
|
|
203
|
+
industry: stringOf(c.industry),
|
|
204
|
+
location: compact({
|
|
205
|
+
country: stringOf(location.country),
|
|
206
|
+
city: stringOf(location.city),
|
|
207
|
+
address: stringOf(location.address),
|
|
208
|
+
}),
|
|
209
|
+
description: truncated(c.description, MAX_DESCRIPTION_CHARS),
|
|
210
|
+
}),
|
|
211
|
+
// Always present: a number for Company Search, null for Company Enrich (no fit score).
|
|
212
|
+
score: numberOf(score.value) ?? null,
|
|
213
|
+
...compact({
|
|
214
|
+
why: stringOf(score.summary),
|
|
215
|
+
reasons: strings(score.reasons).slice(0, MAX_REASONS),
|
|
216
|
+
fully_verified: typeof score.fully_verified === "boolean" ? score.fully_verified : undefined,
|
|
217
|
+
unverified_criteria: unverifiedCriteria(score),
|
|
218
|
+
primary_email: primaryEmail.value !== undefined ? primaryEmail : undefined,
|
|
219
|
+
primary_contact: compact({
|
|
220
|
+
name: stringOf(contact.name),
|
|
221
|
+
title: stringOf(contact.title),
|
|
222
|
+
email: stringOf(contact.email),
|
|
223
|
+
linkedin_url: stringOf(contact.linkedin_url),
|
|
224
|
+
reason: stringOf(contact.reason),
|
|
225
|
+
}),
|
|
226
|
+
contact_coverage: compact(objectOf(c.contact_coverage)),
|
|
227
|
+
emails: compactEmails(c.emails),
|
|
228
|
+
phones: compactPhones(c.phones),
|
|
229
|
+
socials: compactSocials(c.socials),
|
|
230
|
+
leaders: arrayOf(c.people)
|
|
231
|
+
.map(compactLeader)
|
|
232
|
+
.filter((leader) => leader.name !== undefined),
|
|
233
|
+
enrichment: compactEnrichment(c.enrichment),
|
|
234
|
+
}),
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
/** Company task warnings are short (`code`, `message`), so both are kept. */
|
|
238
|
+
function compactWarning(warning) {
|
|
239
|
+
const w = objectOf(warning);
|
|
240
|
+
return compact({ code: stringOf(w.code), message: stringOf(w.message) });
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Task fields an agent polls on. `progress` is the worker's counters, passed through
|
|
244
|
+
* without its copy of `warnings` (listed once, at the top). `completion_reason` appears
|
|
245
|
+
* once the task has ended, `coverage_limited` only when true.
|
|
246
|
+
*/
|
|
247
|
+
export function compactCompanyTask(task, options = {}) {
|
|
248
|
+
const t = objectOf(task);
|
|
249
|
+
const status = typeof t.status === "string" ? t.status : undefined;
|
|
250
|
+
let progress;
|
|
251
|
+
if (options.progress) {
|
|
252
|
+
const { warnings: _warnings, ...rest } = objectOf(t.progress);
|
|
253
|
+
progress = rest;
|
|
254
|
+
}
|
|
255
|
+
return compact({
|
|
256
|
+
task_id: t.task_id,
|
|
257
|
+
search_type: t.search_type,
|
|
258
|
+
status,
|
|
259
|
+
stage: t.stage,
|
|
260
|
+
done: status ? PEOPLE_ENDED_STATUSES.has(status) : undefined,
|
|
261
|
+
query: t.query,
|
|
262
|
+
metadata: t.metadata,
|
|
263
|
+
count: t.count,
|
|
264
|
+
result_count: t.result_count,
|
|
265
|
+
completion_reason: stringOf(t.completion_reason),
|
|
266
|
+
coverage_limited: t.coverage_limited === true ? true : undefined,
|
|
267
|
+
warnings: arrayOf(t.warnings).map(compactWarning),
|
|
268
|
+
progress,
|
|
269
|
+
errors: options.progress ? t.errors : undefined,
|
|
270
|
+
reserved_cost_usd: t.reserved_cost_usd,
|
|
271
|
+
final_cost_usd: t.final_cost_usd,
|
|
272
|
+
refunded_usd: t.refunded_usd,
|
|
273
|
+
created_at: t.created_at,
|
|
274
|
+
finished_at: t.finished_at,
|
|
275
|
+
results_expire_at: t.results_expire_at,
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
const LATEST = "call company-search-status without cursor to read every company in its latest version";
|
|
279
|
+
/**
|
|
280
|
+
* One sentence (or two) on what to do next, so an agent does not have to infer it from the status.
|
|
281
|
+
* `nextCursor` is the results cursor when the caller just read a page of companies.
|
|
282
|
+
* `task` adds the stage (`enriching`) and why an ended task stopped.
|
|
283
|
+
* `page.partial` counts the companies on this page whose enrichment is still `partial`;
|
|
284
|
+
* `page.readAfterStart` is true when the caller passed a cursor, so it may hold older
|
|
285
|
+
* versions of companies it read before.
|
|
286
|
+
*/
|
|
287
|
+
export function companyNextStep(status, nextCursor, hasMore = false, task = {}, page = {}) {
|
|
288
|
+
const again = nextCursor === undefined
|
|
289
|
+
? "company-search-status again"
|
|
290
|
+
: `company-search-status again with cursor "${nextCursor}"`;
|
|
291
|
+
const partial = page.partial ?? 0;
|
|
292
|
+
if (hasMore) {
|
|
293
|
+
return `More companies are ready now: call ${again}.`;
|
|
294
|
+
}
|
|
295
|
+
const ended = (first) => {
|
|
296
|
+
const notes = [first];
|
|
297
|
+
if (partial > 0) {
|
|
298
|
+
notes.push(`${partial === 1 ? "1 company" : `${partial} companies`} on this page stayed partial: the task ended before every stage ran for ${partial === 1 ? "it" : "them"}.`);
|
|
299
|
+
}
|
|
300
|
+
if (page.readAfterStart) {
|
|
301
|
+
notes.push("If you read companies while it ran, call company-search-status without cursor to read every company in its final version.");
|
|
302
|
+
}
|
|
303
|
+
return notes.join(" ");
|
|
304
|
+
};
|
|
305
|
+
switch (status) {
|
|
306
|
+
case "queued":
|
|
307
|
+
case "running": {
|
|
308
|
+
if (task.stage === "enriching") {
|
|
309
|
+
return `Every company is delivered; later stages (leaders, inferred emails, email checks) are still filling some in. Wait 15 to 30 seconds, then ${LATEST}.`;
|
|
310
|
+
}
|
|
311
|
+
const wait = nextCursor === undefined
|
|
312
|
+
? `Still running. Wait 15 to 30 seconds, then call ${again}.`
|
|
313
|
+
: `Still running. Wait 15 to 30 seconds, then call ${again} to get only the companies delivered since this call.`;
|
|
314
|
+
return partial > 0 || page.readAfterStart
|
|
315
|
+
? `${wait} Companies with enrichment status "partial" are still being filled in; when the task is done, ${LATEST}.`
|
|
316
|
+
: wait;
|
|
317
|
+
}
|
|
318
|
+
case "pausing":
|
|
319
|
+
return "Pausing after the current batch. Resume it with company-search-resume.";
|
|
320
|
+
case "paused":
|
|
321
|
+
return "Paused. Resume it with company-search-resume, or cancel it with company-search-cancel.";
|
|
322
|
+
case "cancelling":
|
|
323
|
+
return "Cancelling. Call company-search-status again to read the final status.";
|
|
324
|
+
case "completed":
|
|
325
|
+
if (task.coverage_limited === true) {
|
|
326
|
+
const wanted = typeof task.count === "number" ? `${task.count} companies` : "the count you asked for";
|
|
327
|
+
return ended(`Finished early: a budget stopped it (${String(task.completion_reason)}) before it delivered ${wanted}, so more companies may match. You have every company it delivered.`);
|
|
328
|
+
}
|
|
329
|
+
if (task.completion_reason === "no_candidates") {
|
|
330
|
+
return "Finished: its searches found no company to check. Try a broader description.";
|
|
331
|
+
}
|
|
332
|
+
if (task.completion_reason === "zero_qualified") {
|
|
333
|
+
return "Finished: it checked the companies its searches found and none fit. Try a broader description, a lower min_score, or fewer require values.";
|
|
334
|
+
}
|
|
335
|
+
if (task.completion_reason === "all_domains_processed") {
|
|
336
|
+
return ended("Finished: it read every domain. You have every company it delivered.");
|
|
337
|
+
}
|
|
338
|
+
return ended("Finished. You have every company this task delivered.");
|
|
339
|
+
case "partial":
|
|
340
|
+
return ended("Finished with partial results: some searches failed. You have every company it delivered.");
|
|
341
|
+
case "failed":
|
|
342
|
+
return "The task failed. See errors. A task that delivers no companies is not charged.";
|
|
343
|
+
case "cancelled":
|
|
344
|
+
return ended("Cancelled. You pay only for the companies it delivered; the rest of the reservation is returned.");
|
|
345
|
+
case "expired":
|
|
346
|
+
return "Results expired 30 days after the task ended.";
|
|
347
|
+
default:
|
|
348
|
+
return `Call ${again} to check for changes.`;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
const POLL_HINT = "The task runs in the background. Poll company-search-status with this task_id every 15 to 30 seconds: companies appear while it runs, and later stages fill them in.";
|
|
352
|
+
async function startCompanyTask(start, body, idempotencyKey) {
|
|
353
|
+
const { status, data } = await start(body, idempotencyKey);
|
|
354
|
+
const raw = objectOf(data);
|
|
355
|
+
// 200 means the same Idempotency-Key already created this task; the API does not charge again.
|
|
356
|
+
const existing = status === 200;
|
|
357
|
+
return compact({
|
|
358
|
+
...compactCompanyTask(data),
|
|
359
|
+
cost_usd: numberOf(raw.cost_usd),
|
|
360
|
+
currency: stringOf(raw.currency),
|
|
361
|
+
existing_task: existing ? true : undefined,
|
|
362
|
+
next: existing
|
|
363
|
+
? `This idempotency_key already started this task, so it was not charged again. ${POLL_HINT}`
|
|
364
|
+
: POLL_HINT,
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
/** `company-search`: start a billed background Company Search and return the task to poll. */
|
|
368
|
+
export async function startCompanySearch(client, args) {
|
|
369
|
+
return startCompanyTask((body, key) => client.startSearch(body, key), companySearchBody(args), args.idempotency_key);
|
|
370
|
+
}
|
|
371
|
+
/** `company-enrich`: start a billed background Company Enrich and return the task to poll. */
|
|
372
|
+
export async function startCompanyEnrich(client, args) {
|
|
373
|
+
return startCompanyTask((body, key) => client.startEnrich(body, key), companyEnrichBody(args), args.idempotency_key);
|
|
374
|
+
}
|
|
375
|
+
/** `company-search-status`: task status and progress, plus a page of companies when there are any. */
|
|
376
|
+
export async function readCompanyStatus(client, args) {
|
|
377
|
+
const task = await client.getTask(args.task_id);
|
|
378
|
+
const summary = compactCompanyTask(task, { progress: true });
|
|
379
|
+
const status = typeof summary.status === "string" ? summary.status : undefined;
|
|
380
|
+
if (args.include_companies === false) {
|
|
381
|
+
return { ...summary, next: companyNextStep(status, undefined, false, summary) };
|
|
382
|
+
}
|
|
383
|
+
let nextCursor = args.cursor ?? "0";
|
|
384
|
+
let hasMore = false;
|
|
385
|
+
let partial = 0;
|
|
386
|
+
let companies = [];
|
|
387
|
+
const resultCount = numberOf(summary.result_count) ?? 0;
|
|
388
|
+
// No results yet, or expired (the results route answers 410): skip the second call.
|
|
389
|
+
if (resultCount > 0 && status !== "expired") {
|
|
390
|
+
const page = objectOf(await client.getResults(args.task_id, { cursor: args.cursor, limit: args.limit }));
|
|
391
|
+
const rows = arrayOf(page.results);
|
|
392
|
+
companies = rows.map(compactCompany);
|
|
393
|
+
partial = rows.filter((row) => objectOf(objectOf(row).enrichment).status === "partial").length;
|
|
394
|
+
nextCursor = stringOf(page.next_cursor) ?? nextCursor;
|
|
395
|
+
hasMore = page.has_more === true;
|
|
396
|
+
}
|
|
397
|
+
const readAfterStart = args.cursor !== undefined && args.cursor !== "0";
|
|
398
|
+
return {
|
|
399
|
+
...summary,
|
|
400
|
+
companies,
|
|
401
|
+
next_cursor: nextCursor,
|
|
402
|
+
has_more: hasMore,
|
|
403
|
+
next: companyNextStep(status, nextCursor, hasMore, summary, { partial, readAfterStart }),
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
/** `company-search-pause`, `company-search-resume`, `company-search-cancel`: change a task's state. */
|
|
407
|
+
export async function controlCompanyTask(client, args) {
|
|
408
|
+
const task = compactCompanyTask(await client.controlTask(args.task_id, args.action));
|
|
409
|
+
const status = typeof task.status === "string" ? task.status : undefined;
|
|
410
|
+
return { ...task, next: companyNextStep(status, undefined, false, task) };
|
|
411
|
+
}
|
|
412
|
+
/** `company-search-tasks`: the caller's Company Search and Company Enrich tasks, newest first. */
|
|
413
|
+
export async function listCompanyTasks(client, args) {
|
|
414
|
+
const params = {
|
|
415
|
+
type: args.type,
|
|
416
|
+
status: args.status?.length ? args.status.join(",") : undefined,
|
|
417
|
+
limit: args.limit,
|
|
418
|
+
cursor: args.cursor,
|
|
419
|
+
};
|
|
420
|
+
// The API reads metadata filters as `metadata.<key>=<value>`, one parameter per pair.
|
|
421
|
+
for (const [key, value] of Object.entries(args.metadata ?? {})) {
|
|
422
|
+
params[`metadata.${key}`] = value;
|
|
423
|
+
}
|
|
424
|
+
const page = objectOf(await client.listTasks(params));
|
|
425
|
+
return {
|
|
426
|
+
tasks: arrayOf(page.tasks).map((task) => compactCompanyTask(task)),
|
|
427
|
+
next_cursor: stringOf(page.next_cursor) ?? null,
|
|
428
|
+
};
|
|
429
|
+
}
|
package/build/people.d.ts
CHANGED
|
@@ -63,7 +63,7 @@ export interface PeopleApiResponse {
|
|
|
63
63
|
status: number;
|
|
64
64
|
data: unknown;
|
|
65
65
|
}
|
|
66
|
-
type QueryValue = string | number | boolean | undefined;
|
|
66
|
+
export type QueryValue = string | number | boolean | undefined;
|
|
67
67
|
export interface PeopleClient {
|
|
68
68
|
startSearch(platform: PeoplePlatform, body: Record<string, unknown>, idempotencyKey?: string): Promise<PeopleApiResponse>;
|
|
69
69
|
getTask(taskId: string): Promise<unknown>;
|
|
@@ -75,12 +75,28 @@ export interface PeopleClient {
|
|
|
75
75
|
listTasks(params: Record<string, QueryValue>): Promise<unknown>;
|
|
76
76
|
listProfiles(params: Record<string, QueryValue>): Promise<unknown>;
|
|
77
77
|
}
|
|
78
|
+
export declare function withQuery(path: string, params: Record<string, QueryValue>): string;
|
|
79
|
+
export type ApiCall = (method: "GET" | "POST", path: string, options?: {
|
|
80
|
+
body?: Record<string, unknown>;
|
|
81
|
+
headers?: Record<string, string>;
|
|
82
|
+
}) => Promise<PeopleApiResponse>;
|
|
83
|
+
/**
|
|
84
|
+
* One Desearch API request with the desearch-js conventions: `Authorization: <key>`,
|
|
85
|
+
* a JSON body, and `HTTP <status>: <detail>` on an error status. People Search and
|
|
86
|
+
* Company Search (companies.ts) share it.
|
|
87
|
+
*/
|
|
88
|
+
export declare function createApiCall(apiKey: string, baseUrl?: string): ApiCall;
|
|
78
89
|
export declare function createPeopleClient(apiKey: string, baseUrl?: string): PeopleClient;
|
|
79
90
|
/**
|
|
80
91
|
* Request body for `POST /desearch/people/search/{platform}`.
|
|
81
92
|
* Throws when a filter does not apply to the platform, so no billed call is made.
|
|
82
93
|
*/
|
|
83
94
|
export declare function peopleSearchBody(args: PeopleSearchArgs): Record<string, unknown>;
|
|
95
|
+
export declare function compact(fields: Record<string, unknown>): Record<string, unknown>;
|
|
96
|
+
export declare function objectOf(value: unknown): Record<string, unknown>;
|
|
97
|
+
export declare function arrayOf(value: unknown): unknown[];
|
|
98
|
+
export declare function numberOf(value: unknown): number | undefined;
|
|
99
|
+
export declare function stringOf(value: unknown): string | undefined;
|
|
84
100
|
/**
|
|
85
101
|
* The criteria a person's own profile and posts do not confirm, as short strings:
|
|
86
102
|
* a criterion that is not met ("(unknown)" or "(not met)"), or a disqualifier that
|
|
@@ -146,5 +162,4 @@ export interface PeopleProfilesArgs {
|
|
|
146
162
|
}
|
|
147
163
|
/** `people-profiles`: everyone the caller's searches found on one platform. */
|
|
148
164
|
export declare function listPeopleProfiles(client: PeopleClient, args: PeopleProfilesArgs): Promise<Record<string, unknown>>;
|
|
149
|
-
export {};
|
|
150
165
|
//# sourceMappingURL=people.d.ts.map
|
package/build/people.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"people.d.ts","sourceRoot":"","sources":["../people.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,mBAAmB,4BAA4B,CAAC;AAE7D,eAAO,MAAM,gBAAgB,iDAAkD,CAAC;AAChF,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/D,eAAO,MAAM,oBAAoB,6HAWvB,CAAC;AAEX,yDAAyD;AACzD,eAAO,MAAM,qBAAqB,EAAE,WAAW,CAAC,MAAM,CAMpD,CAAC;AAEH,uFAAuF;AACvF,eAAO,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,CACjC,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE;IACF,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC,GACF,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAgBlC;AAED,MAAM,WAAW,kBAAkB;IAC/B,QAAQ,EAAE,cAAc,CAAC;IACzB,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,+EAA+E;AAC/E,wBAAsB,kBAAkB,CACpC,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,kBAAkB,GACzB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAqBlC"}
|
package/build/people.js
CHANGED
|
@@ -93,7 +93,7 @@ function errorDetail(data, text) {
|
|
|
93
93
|
}
|
|
94
94
|
return text.length > 500 ? `${text.slice(0, 500)}...` : text;
|
|
95
95
|
}
|
|
96
|
-
function withQuery(path, params) {
|
|
96
|
+
export function withQuery(path, params) {
|
|
97
97
|
const search = new URLSearchParams();
|
|
98
98
|
for (const [key, value] of Object.entries(params)) {
|
|
99
99
|
if (value !== undefined) {
|
|
@@ -103,8 +103,13 @@ function withQuery(path, params) {
|
|
|
103
103
|
const qs = search.toString();
|
|
104
104
|
return qs ? `${path}?${qs}` : path;
|
|
105
105
|
}
|
|
106
|
-
|
|
107
|
-
|
|
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 = {}) {
|
|
108
113
|
const headers = { Authorization: apiKey, ...options.headers };
|
|
109
114
|
if (options.body) {
|
|
110
115
|
headers["Content-Type"] = "application/json";
|
|
@@ -135,7 +140,10 @@ export function createPeopleClient(apiKey, baseUrl = PEOPLE_API_BASE_URL) {
|
|
|
135
140
|
throw new Error(`HTTP ${response.status}: ${errorDetail(data, text)}`);
|
|
136
141
|
}
|
|
137
142
|
return { status: response.status, data };
|
|
138
|
-
}
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
export function createPeopleClient(apiKey, baseUrl = PEOPLE_API_BASE_URL) {
|
|
146
|
+
const call = createApiCall(apiKey, baseUrl);
|
|
139
147
|
const taskPath = (taskId) => `/desearch/people/tasks/${encodeURIComponent(taskId)}`;
|
|
140
148
|
return {
|
|
141
149
|
startSearch(platform, body, idempotencyKey) {
|
|
@@ -196,7 +204,7 @@ export function peopleSearchBody(args) {
|
|
|
196
204
|
body.metadata = args.metadata;
|
|
197
205
|
return body;
|
|
198
206
|
}
|
|
199
|
-
function compact(fields) {
|
|
207
|
+
export function compact(fields) {
|
|
200
208
|
const out = {};
|
|
201
209
|
for (const [key, value] of Object.entries(fields)) {
|
|
202
210
|
if (value === undefined || value === null || value === "")
|
|
@@ -209,16 +217,16 @@ function compact(fields) {
|
|
|
209
217
|
}
|
|
210
218
|
return out;
|
|
211
219
|
}
|
|
212
|
-
function objectOf(value) {
|
|
220
|
+
export function objectOf(value) {
|
|
213
221
|
return isPlainObject(value) ? value : {};
|
|
214
222
|
}
|
|
215
|
-
function arrayOf(value) {
|
|
223
|
+
export function arrayOf(value) {
|
|
216
224
|
return Array.isArray(value) ? value : [];
|
|
217
225
|
}
|
|
218
|
-
function numberOf(value) {
|
|
226
|
+
export function numberOf(value) {
|
|
219
227
|
return typeof value === "number" && Number.isFinite(value) ? value : undefined;
|
|
220
228
|
}
|
|
221
|
-
function stringOf(value) {
|
|
229
|
+
export function stringOf(value) {
|
|
222
230
|
return typeof value === "string" && value.trim() !== "" ? value : undefined;
|
|
223
231
|
}
|
|
224
232
|
// A check's `is_disqualifier` says whether it is a disqualifier. Checks scored before the
|
package/build/server.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import { type Icon } from "@modelcontextprotocol/sdk/types.js";
|
|
3
3
|
import { type PeopleClient } from "./people.js";
|
|
4
|
+
import { type CompanyClient } from "./companies.js";
|
|
4
5
|
export declare const SERVER_NAME = "Desearch";
|
|
5
|
-
export declare const SERVER_VERSION = "0.
|
|
6
|
+
export declare const SERVER_VERSION = "0.6.0";
|
|
6
7
|
export declare const SERVER_TITLE = "Desearch";
|
|
7
8
|
export declare const SERVER_WEBSITE_URL = "https://www.desearch.ai";
|
|
8
9
|
export declare const MCP_PUBLIC_BASE_URL: string;
|
|
@@ -102,9 +103,10 @@ export declare function presentSearchBody(value: unknown): unknown;
|
|
|
102
103
|
* One MCP server bound to a single Desearch API key.
|
|
103
104
|
* Stdio uses the process env key. Remote HTTP builds a new server per request
|
|
104
105
|
* so each caller spends their own key.
|
|
105
|
-
* `client` and `
|
|
106
|
-
* server builds a desearch-js client
|
|
106
|
+
* `client`, `peopleClient`, and `companyClient` are test seams. Production callers omit
|
|
107
|
+
* them and the server builds a desearch-js client, a People Search client (people.ts), and
|
|
108
|
+
* a Company Search client (companies.ts) from `apiKey`.
|
|
107
109
|
*/
|
|
108
|
-
export declare function createDesearchMcpServer(apiKey: string, client?: DesearchClient, peopleClient?: PeopleClient): McpServer;
|
|
110
|
+
export declare function createDesearchMcpServer(apiKey: string, client?: DesearchClient, peopleClient?: PeopleClient, companyClient?: CompanyClient): McpServer;
|
|
109
111
|
export {};
|
|
110
112
|
//# sourceMappingURL=server.d.ts.map
|
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;AAG5C,OAAO,EAgBH,KAAK,YAAY,EACpB,MAAM,aAAa,CAAC;
|
|
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;AAG5C,OAAO,EAgBH,KAAK,YAAY,EACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAcH,KAAK,aAAa,EACrB,MAAM,gBAAgB,CAAC;AAGxB,eAAO,MAAM,WAAW,aAAa,CAAC;AACtC,eAAO,MAAM,cAAc,UAAU,CAAC;AACtC,eAAO,MAAM,YAAY,aAAa,CAAC;AACvC,eAAO,MAAM,kBAAkB,4BAA4B,CAAC;AAG5D,eAAO,MAAM,mBAAmB,QAA6F,CAAC;AAE9H,eAAO,MAAM,YAAY,EAAE,IAAI,EAG9B,CAAC;AAEF,UAAU,cAAc;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE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