@companyenrich/mcp 0.0.0-stage → 3.0.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/LICENSE +21 -0
- package/README.md +651 -2
- package/dist/stdio.js +1047 -0
- package/package.json +54 -4
package/dist/stdio.js
ADDED
|
@@ -0,0 +1,1047 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/stdio.ts
|
|
4
|
+
import { serveStdio } from "@modelcontextprotocol/server/stdio";
|
|
5
|
+
|
|
6
|
+
// src/mcp.ts
|
|
7
|
+
import { McpServer } from "@modelcontextprotocol/server";
|
|
8
|
+
import { z as z2 } from "zod";
|
|
9
|
+
|
|
10
|
+
// package.json
|
|
11
|
+
var version = "3.0.0";
|
|
12
|
+
|
|
13
|
+
// src/schema.ts
|
|
14
|
+
import { z } from "zod";
|
|
15
|
+
var CompanyCategoryEnum = z.enum([
|
|
16
|
+
"b2b",
|
|
17
|
+
"b2c",
|
|
18
|
+
"b2g",
|
|
19
|
+
"e-commerce",
|
|
20
|
+
"media",
|
|
21
|
+
"service-provider",
|
|
22
|
+
"mobile",
|
|
23
|
+
"saas",
|
|
24
|
+
"local-business"
|
|
25
|
+
]);
|
|
26
|
+
var CompanyEmployeesEnum = z.enum([
|
|
27
|
+
"1-10",
|
|
28
|
+
"11-50",
|
|
29
|
+
"51-200",
|
|
30
|
+
"201-500",
|
|
31
|
+
"501-1K",
|
|
32
|
+
"1K-5K",
|
|
33
|
+
"5K-10K",
|
|
34
|
+
"over-10K"
|
|
35
|
+
]);
|
|
36
|
+
var CompanyRevenueEnum = z.enum([
|
|
37
|
+
"under-1m",
|
|
38
|
+
"1m-10m",
|
|
39
|
+
"10m-50m",
|
|
40
|
+
"50m-100m",
|
|
41
|
+
"100m-200m",
|
|
42
|
+
"200m-1b",
|
|
43
|
+
"over-1b"
|
|
44
|
+
]);
|
|
45
|
+
var CompanyTypeEnum = z.enum([
|
|
46
|
+
"private",
|
|
47
|
+
"public",
|
|
48
|
+
"self-employed",
|
|
49
|
+
"self-owned",
|
|
50
|
+
"partnership",
|
|
51
|
+
"nonprofit",
|
|
52
|
+
"educational",
|
|
53
|
+
"government"
|
|
54
|
+
]);
|
|
55
|
+
var CompanyFundingRoundEnum = z.enum([
|
|
56
|
+
"seed",
|
|
57
|
+
"debt_financing",
|
|
58
|
+
"angel",
|
|
59
|
+
"venture",
|
|
60
|
+
"series_a",
|
|
61
|
+
"series_b",
|
|
62
|
+
"series_c",
|
|
63
|
+
"series_d",
|
|
64
|
+
"series_e",
|
|
65
|
+
"series_f",
|
|
66
|
+
"series_g",
|
|
67
|
+
"series_h",
|
|
68
|
+
"other"
|
|
69
|
+
]);
|
|
70
|
+
var FeatureRequirementEnum = z.enum([
|
|
71
|
+
"linkedin",
|
|
72
|
+
"twitter",
|
|
73
|
+
"facebook",
|
|
74
|
+
"instagram",
|
|
75
|
+
"angellist",
|
|
76
|
+
"crunchbase",
|
|
77
|
+
"youtube",
|
|
78
|
+
"country",
|
|
79
|
+
"city",
|
|
80
|
+
"state",
|
|
81
|
+
"revenue",
|
|
82
|
+
"foundedYear",
|
|
83
|
+
"anyFunding"
|
|
84
|
+
]);
|
|
85
|
+
var WorkforceDepartmentEnum = z.enum([
|
|
86
|
+
"overall",
|
|
87
|
+
"c_suite",
|
|
88
|
+
"product_management",
|
|
89
|
+
"engineering_technical",
|
|
90
|
+
"design",
|
|
91
|
+
"education",
|
|
92
|
+
"finance",
|
|
93
|
+
"human_resources",
|
|
94
|
+
"information_technology",
|
|
95
|
+
"legal",
|
|
96
|
+
"marketing",
|
|
97
|
+
"medical_health",
|
|
98
|
+
"operations",
|
|
99
|
+
"sales",
|
|
100
|
+
"consulting"
|
|
101
|
+
]);
|
|
102
|
+
var WorkforceGrowthPeriodEnum = z.enum(["m6", "y1", "y2"]);
|
|
103
|
+
var CompanyExpandEnum = z.enum([
|
|
104
|
+
"financial",
|
|
105
|
+
"keywords",
|
|
106
|
+
"naicsCodes",
|
|
107
|
+
"technologies",
|
|
108
|
+
"workforce"
|
|
109
|
+
]);
|
|
110
|
+
var PersonExpandEnum = z.enum(["education", "company"]);
|
|
111
|
+
var PersonSeniorityEnum = z.enum([
|
|
112
|
+
"owner",
|
|
113
|
+
"founder",
|
|
114
|
+
"c-suite",
|
|
115
|
+
"partner",
|
|
116
|
+
"vp",
|
|
117
|
+
"head",
|
|
118
|
+
"director",
|
|
119
|
+
"manager",
|
|
120
|
+
"senior",
|
|
121
|
+
"entry",
|
|
122
|
+
"intern"
|
|
123
|
+
]);
|
|
124
|
+
var PersonDepartmentEnum = z.enum([
|
|
125
|
+
"c-suite",
|
|
126
|
+
"c-suite/executive",
|
|
127
|
+
"c-suite/finance-executive",
|
|
128
|
+
"c-suite/founder",
|
|
129
|
+
"c-suite/human-resources-executive",
|
|
130
|
+
"c-suite/information-technology-executive",
|
|
131
|
+
"c-suite/legal-executive",
|
|
132
|
+
"c-suite/marketing-executive",
|
|
133
|
+
"c-suite/medical-health-executive",
|
|
134
|
+
"c-suite/operations-executive",
|
|
135
|
+
"c-suite/sales-executive",
|
|
136
|
+
"product-management",
|
|
137
|
+
"product-management/product-development",
|
|
138
|
+
"product-management/product-management",
|
|
139
|
+
"engineering-technical",
|
|
140
|
+
"engineering-technical/artificial-intelligence-machine-learning",
|
|
141
|
+
"engineering-technical/bioengineering",
|
|
142
|
+
"engineering-technical/biometrics",
|
|
143
|
+
"engineering-technical/business-intelligence",
|
|
144
|
+
"engineering-technical/chemical-engineering",
|
|
145
|
+
"engineering-technical/cloud-mobility",
|
|
146
|
+
"engineering-technical/data-science",
|
|
147
|
+
"engineering-technical/devops",
|
|
148
|
+
"engineering-technical/digital-transformation",
|
|
149
|
+
"engineering-technical/emerging-technology-innovation",
|
|
150
|
+
"engineering-technical/engineering-technical",
|
|
151
|
+
"engineering-technical/industrial-engineering",
|
|
152
|
+
"engineering-technical/mechanic",
|
|
153
|
+
"engineering-technical/mobile-development",
|
|
154
|
+
"engineering-technical/project-management",
|
|
155
|
+
"engineering-technical/research-development",
|
|
156
|
+
"engineering-technical/scrum-master-agile-coach",
|
|
157
|
+
"engineering-technical/software-development",
|
|
158
|
+
"engineering-technical/support-technical-services",
|
|
159
|
+
"engineering-technical/technician",
|
|
160
|
+
"engineering-technical/technology-operations",
|
|
161
|
+
"engineering-technical/test-quality-assurance",
|
|
162
|
+
"engineering-technical/ui-ux",
|
|
163
|
+
"engineering-technical/web-development",
|
|
164
|
+
"design",
|
|
165
|
+
"design/all-design",
|
|
166
|
+
"design/product-ui-ux-design",
|
|
167
|
+
"design/graphic-design",
|
|
168
|
+
"education",
|
|
169
|
+
"education/teacher",
|
|
170
|
+
"education/principal",
|
|
171
|
+
"education/superintendent",
|
|
172
|
+
"education/professor",
|
|
173
|
+
"finance",
|
|
174
|
+
"finance/accounting",
|
|
175
|
+
"finance/finance",
|
|
176
|
+
"finance/financial-planning-analysis",
|
|
177
|
+
"finance/financial-reporting",
|
|
178
|
+
"finance/financial-strategy",
|
|
179
|
+
"finance/financial-systems",
|
|
180
|
+
"finance/internal-audit-control",
|
|
181
|
+
"finance/investor-relations",
|
|
182
|
+
"finance/mergers-acquisitions",
|
|
183
|
+
"finance/real-estate-finance",
|
|
184
|
+
"finance/financial-risk",
|
|
185
|
+
"finance/shared-services",
|
|
186
|
+
"finance/sourcing-procurement",
|
|
187
|
+
"finance/tax",
|
|
188
|
+
"finance/treasury",
|
|
189
|
+
"human-resources",
|
|
190
|
+
"human-resources/compensation-benefits",
|
|
191
|
+
"human-resources/culture-diversity-inclusion",
|
|
192
|
+
"human-resources/employee-labor-relations",
|
|
193
|
+
"human-resources/health-safety",
|
|
194
|
+
"human-resources/human-resource-information-system",
|
|
195
|
+
"human-resources/human-resources",
|
|
196
|
+
"human-resources/hr-business-partner",
|
|
197
|
+
"human-resources/learning-development",
|
|
198
|
+
"human-resources/organizational-development",
|
|
199
|
+
"human-resources/recruiting-talent-acquisition",
|
|
200
|
+
"human-resources/talent-management",
|
|
201
|
+
"human-resources/workforce-management",
|
|
202
|
+
"human-resources/people-operations",
|
|
203
|
+
"information-technology",
|
|
204
|
+
"information-technology/application-development",
|
|
205
|
+
"information-technology/business-service-management-itsm",
|
|
206
|
+
"information-technology/collaboration-web-app",
|
|
207
|
+
"information-technology/data-center",
|
|
208
|
+
"information-technology/data-warehouse",
|
|
209
|
+
"information-technology/database-administration",
|
|
210
|
+
"information-technology/ecommerce-development",
|
|
211
|
+
"information-technology/enterprise-architecture",
|
|
212
|
+
"information-technology/help-desk-desktop-services",
|
|
213
|
+
"information-technology/hr-financial-erp-systems",
|
|
214
|
+
"information-technology/information-security",
|
|
215
|
+
"information-technology/information-technology",
|
|
216
|
+
"information-technology/infrastructure",
|
|
217
|
+
"information-technology/it-asset-management",
|
|
218
|
+
"information-technology/it-audit-it-compliance",
|
|
219
|
+
"information-technology/it-operations",
|
|
220
|
+
"information-technology/it-procurement",
|
|
221
|
+
"information-technology/it-strategy",
|
|
222
|
+
"information-technology/it-training",
|
|
223
|
+
"information-technology/networking",
|
|
224
|
+
"information-technology/project-program-management",
|
|
225
|
+
"information-technology/quality-assurance",
|
|
226
|
+
"information-technology/retail-store-systems",
|
|
227
|
+
"information-technology/servers",
|
|
228
|
+
"information-technology/storage-disaster-recovery",
|
|
229
|
+
"information-technology/telecommunications",
|
|
230
|
+
"information-technology/virtualization",
|
|
231
|
+
"legal",
|
|
232
|
+
"legal/acquisitions",
|
|
233
|
+
"legal/compliance",
|
|
234
|
+
"legal/contracts",
|
|
235
|
+
"legal/corporate-secretary",
|
|
236
|
+
"legal/ediscovery",
|
|
237
|
+
"legal/ethics",
|
|
238
|
+
"legal/governance",
|
|
239
|
+
"legal/governmental-affairs-regulatory-law",
|
|
240
|
+
"legal/intellectual-property-patent",
|
|
241
|
+
"legal/labor-employment",
|
|
242
|
+
"legal/lawyer-attorney",
|
|
243
|
+
"legal/legal",
|
|
244
|
+
"legal/legal-counsel",
|
|
245
|
+
"legal/legal-operations",
|
|
246
|
+
"legal/litigation",
|
|
247
|
+
"legal/privacy",
|
|
248
|
+
"marketing",
|
|
249
|
+
"marketing/advertising",
|
|
250
|
+
"marketing/brand-management",
|
|
251
|
+
"marketing/content-marketing",
|
|
252
|
+
"marketing/customer-experience",
|
|
253
|
+
"marketing/customer-marketing",
|
|
254
|
+
"marketing/demand-generation",
|
|
255
|
+
"marketing/digital-marketing",
|
|
256
|
+
"marketing/ecommerce-marketing",
|
|
257
|
+
"marketing/event-marketing",
|
|
258
|
+
"marketing/field-marketing",
|
|
259
|
+
"marketing/lead-generation",
|
|
260
|
+
"marketing/marketing",
|
|
261
|
+
"marketing/marketing-analytics-insights",
|
|
262
|
+
"marketing/marketing-communications",
|
|
263
|
+
"marketing/marketing-operations",
|
|
264
|
+
"marketing/product-marketing",
|
|
265
|
+
"marketing/public-relations",
|
|
266
|
+
"marketing/search-engine-optimization-pay-per-click",
|
|
267
|
+
"marketing/social-media-marketing",
|
|
268
|
+
"marketing/strategic-communications",
|
|
269
|
+
"marketing/technical-marketing",
|
|
270
|
+
"medical-health",
|
|
271
|
+
"medical-health/anesthesiology",
|
|
272
|
+
"medical-health/chiropractics",
|
|
273
|
+
"medical-health/clinical-systems",
|
|
274
|
+
"medical-health/dentistry",
|
|
275
|
+
"medical-health/dermatology",
|
|
276
|
+
"medical-health/doctors-physicians",
|
|
277
|
+
"medical-health/epidemiology",
|
|
278
|
+
"medical-health/first-responder",
|
|
279
|
+
"medical-health/infectious-disease",
|
|
280
|
+
"medical-health/medical-administration",
|
|
281
|
+
"medical-health/medical-education-training",
|
|
282
|
+
"medical-health/medical-research",
|
|
283
|
+
"medical-health/medicine",
|
|
284
|
+
"medical-health/neurology",
|
|
285
|
+
"medical-health/nursing",
|
|
286
|
+
"medical-health/nutrition-dietetics",
|
|
287
|
+
"medical-health/obstetrics-gynecology",
|
|
288
|
+
"medical-health/oncology",
|
|
289
|
+
"medical-health/opthalmology",
|
|
290
|
+
"medical-health/optometry",
|
|
291
|
+
"medical-health/orthopedics",
|
|
292
|
+
"medical-health/pathology",
|
|
293
|
+
"medical-health/pediatrics",
|
|
294
|
+
"medical-health/pharmacy",
|
|
295
|
+
"medical-health/physical-therapy",
|
|
296
|
+
"medical-health/psychiatry",
|
|
297
|
+
"medical-health/psychology",
|
|
298
|
+
"medical-health/public-health",
|
|
299
|
+
"medical-health/radiology",
|
|
300
|
+
"medical-health/social-work",
|
|
301
|
+
"operations",
|
|
302
|
+
"operations/call-center",
|
|
303
|
+
"operations/construction",
|
|
304
|
+
"operations/corporate-strategy",
|
|
305
|
+
"operations/customer-service-support",
|
|
306
|
+
"operations/enterprise-resource-planning",
|
|
307
|
+
"operations/facilities-management",
|
|
308
|
+
"operations/leasing",
|
|
309
|
+
"operations/logistics",
|
|
310
|
+
"operations/office-operations",
|
|
311
|
+
"operations/operations",
|
|
312
|
+
"operations/physical-security",
|
|
313
|
+
"operations/project-development",
|
|
314
|
+
"operations/quality-management",
|
|
315
|
+
"operations/real-estate",
|
|
316
|
+
"operations/safety",
|
|
317
|
+
"operations/store-operations",
|
|
318
|
+
"operations/supply-chain",
|
|
319
|
+
"sales",
|
|
320
|
+
"sales/account-management",
|
|
321
|
+
"sales/business-development",
|
|
322
|
+
"sales/channel-sales",
|
|
323
|
+
"sales/customer-retention-development",
|
|
324
|
+
"sales/customer-success",
|
|
325
|
+
"sales/field-outside-sales",
|
|
326
|
+
"sales/inside-sales",
|
|
327
|
+
"sales/partnerships",
|
|
328
|
+
"sales/revenue-operations",
|
|
329
|
+
"sales/sales",
|
|
330
|
+
"sales/sales-enablement",
|
|
331
|
+
"sales/sales-engineering",
|
|
332
|
+
"sales/sales-operations",
|
|
333
|
+
"sales/sales-training",
|
|
334
|
+
"consulting",
|
|
335
|
+
"consulting/consultant"
|
|
336
|
+
]);
|
|
337
|
+
var DEPARTMENT_VALUES_HINT = "Same values as filter.department.in: a root such as `sales`, or `root/sub-department`.";
|
|
338
|
+
var personDepartments = new Set(PersonDepartmentEnum.options);
|
|
339
|
+
var PersonDepartmentValue = z.string().refine((value) => personDepartments.has(value), {
|
|
340
|
+
error: `Unknown department. ${DEPARTMENT_VALUES_HINT}`
|
|
341
|
+
});
|
|
342
|
+
function hasDefinedValue(value) {
|
|
343
|
+
return Object.values(value).some((entry) => entry !== void 0);
|
|
344
|
+
}
|
|
345
|
+
function valueList(item) {
|
|
346
|
+
return z.array(item).min(1).optional();
|
|
347
|
+
}
|
|
348
|
+
function rules(shape) {
|
|
349
|
+
return z.strictObject(shape).refine(hasDefinedValue, {
|
|
350
|
+
error: `Provide at least one of: ${Object.keys(shape).join(", ")}.`
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
function valueFilter(item, exclude = item) {
|
|
354
|
+
return rules({ in: valueList(item), notIn: valueList(exclude) });
|
|
355
|
+
}
|
|
356
|
+
function multiValueFilter(item) {
|
|
357
|
+
return rules({
|
|
358
|
+
in: valueList(item),
|
|
359
|
+
all: valueList(item),
|
|
360
|
+
notIn: valueList(item)
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
function includeFilter(item) {
|
|
364
|
+
return z.strictObject({ in: z.array(item).min(1) });
|
|
365
|
+
}
|
|
366
|
+
var searchText = z.string().min(1).max(250);
|
|
367
|
+
var domainName = z.string().min(1).max(1024);
|
|
368
|
+
var companyId = z.guid();
|
|
369
|
+
var countryCode = z.string().length(2);
|
|
370
|
+
var integerId = z.number().int().positive();
|
|
371
|
+
var naicsCode = z.string().regex(/^[1-9]\d{1,5}$/, "A NAICS code has 2 to 6 digits and no leading zero.");
|
|
372
|
+
var YearRangeSchema = z.strictObject({
|
|
373
|
+
min: z.number().int().optional(),
|
|
374
|
+
max: z.number().int().optional()
|
|
375
|
+
});
|
|
376
|
+
var AmountRangeSchema = z.strictObject({
|
|
377
|
+
min: z.number().optional(),
|
|
378
|
+
max: z.number().optional()
|
|
379
|
+
});
|
|
380
|
+
var DateRangeSchema = z.strictObject({
|
|
381
|
+
after: z.iso.datetime({ offset: true }).optional(),
|
|
382
|
+
before: z.iso.datetime({ offset: true }).optional()
|
|
383
|
+
});
|
|
384
|
+
var WorkforceGrowthFilterSchema = z.strictObject({
|
|
385
|
+
period: WorkforceGrowthPeriodEnum.optional().describe(
|
|
386
|
+
"Period to measure growth over: m6, y1 or y2."
|
|
387
|
+
),
|
|
388
|
+
department: WorkforceDepartmentEnum.optional().describe(
|
|
389
|
+
"Department to measure. Use overall for the whole company."
|
|
390
|
+
),
|
|
391
|
+
min: z.number().optional().describe("Minimum growth ratio, inclusive. 0.15 is 15% growth; negative values are declines."),
|
|
392
|
+
max: z.number().optional().describe("Maximum growth ratio, inclusive.")
|
|
393
|
+
});
|
|
394
|
+
var WorkforceSizeFilterSchema = z.strictObject({
|
|
395
|
+
department: WorkforceDepartmentEnum.optional().describe(
|
|
396
|
+
"Department to count. Use overall for the whole company."
|
|
397
|
+
),
|
|
398
|
+
min: z.number().int().min(0).optional().describe("Minimum headcount, inclusive."),
|
|
399
|
+
max: z.number().int().min(0).optional().describe("Maximum headcount, inclusive.")
|
|
400
|
+
});
|
|
401
|
+
var CompanySearchFilterSchema = z.strictObject({
|
|
402
|
+
query: valueFilter(searchText).optional().describe("Text matched against company names, keywords and domain prefixes."),
|
|
403
|
+
id: valueFilter(companyId).optional().describe("CompanyEnrich company IDs."),
|
|
404
|
+
domain: valueFilter(domainName).optional().describe("Company domains."),
|
|
405
|
+
keywords: multiValueFilter(z.string().min(1)).optional().describe("Company keywords."),
|
|
406
|
+
technologies: multiValueFilter(z.string().min(1)).optional().describe("Technologies the company uses."),
|
|
407
|
+
region: valueFilter(z.string().min(1)).optional().describe("Region IDs."),
|
|
408
|
+
country: valueFilter(countryCode).optional().describe("2-letter country codes."),
|
|
409
|
+
state: valueFilter(integerId).optional().describe("State IDs."),
|
|
410
|
+
city: valueFilter(integerId).optional().describe("City IDs."),
|
|
411
|
+
type: valueFilter(CompanyTypeEnum).optional().describe("Company types."),
|
|
412
|
+
employees: valueFilter(CompanyEmployeesEnum).optional().describe("Employee count ranges."),
|
|
413
|
+
reportedEmployees: valueFilter(CompanyEmployeesEnum).optional().describe("Employee count ranges as reported by external sources."),
|
|
414
|
+
revenue: valueFilter(CompanyRevenueEnum).optional().describe("Revenue ranges in USD."),
|
|
415
|
+
workforceGrowth: WorkforceGrowthFilterSchema.optional().describe(
|
|
416
|
+
"Workforce growth over a period."
|
|
417
|
+
),
|
|
418
|
+
workforceSize: z.array(WorkforceSizeFilterSchema).min(1).optional().describe("Headcount ranges, one entry per department."),
|
|
419
|
+
naicsCodes: multiValueFilter(naicsCode).optional().describe('NAICS codes as strings of 2 to 6 digits, for example "5112".'),
|
|
420
|
+
categories: multiValueFilter(CompanyCategoryEnum).optional().describe("Company categories."),
|
|
421
|
+
foundedYear: YearRangeSchema.optional().describe("Founded year range, inclusive."),
|
|
422
|
+
fundingRounds: valueFilter(CompanyFundingRoundEnum).optional().describe("Funding rounds."),
|
|
423
|
+
fundingAmount: AmountRangeSchema.optional().describe("Funding amount range, inclusive."),
|
|
424
|
+
fundingYear: YearRangeSchema.optional().describe("Latest funding year range, inclusive."),
|
|
425
|
+
require: z.strictObject({ all: z.array(FeatureRequirementEnum).min(1) }).optional().describe("Data the company must have, for example a LinkedIn profile.")
|
|
426
|
+
});
|
|
427
|
+
var CompanySemanticQuerySchema = z.strictObject({
|
|
428
|
+
query: z.string().min(1).max(500).describe('Natural-language description of the companies to find, for example "saas companies in Turkey".'),
|
|
429
|
+
weight: z.number().min(0).max(1).optional().describe("Semantic relevance weight from 0 to 1. Larger values favor semantic similarity."),
|
|
430
|
+
autoFilter: z.boolean().optional().describe(
|
|
431
|
+
"Whether to infer filters such as location, size and funding from the query. Defaults to true. The response `interpretation` reports what was inferred."
|
|
432
|
+
)
|
|
433
|
+
});
|
|
434
|
+
var CompanyLookalikeQuerySchema = z.strictObject({
|
|
435
|
+
domains: z.array(domainName).min(1).max(10).describe("Seed company domains to find lookalikes for. Up to 10."),
|
|
436
|
+
weight: z.number().min(-1).max(1).optional().describe("Ranking weight from -1 to 1. Larger values favor more similar companies."),
|
|
437
|
+
minScore: z.number().min(0).max(1).optional().describe("Minimum similarity score from 0 to 1.")
|
|
438
|
+
});
|
|
439
|
+
var CompanyQueryShape = {
|
|
440
|
+
filter: CompanySearchFilterSchema.optional().describe("Company filters."),
|
|
441
|
+
semantic: CompanySemanticQuerySchema.optional().describe(
|
|
442
|
+
"Natural-language company search. Cannot be combined with lookalike."
|
|
443
|
+
),
|
|
444
|
+
lookalike: CompanyLookalikeQuerySchema.optional().describe(
|
|
445
|
+
"Finds companies similar to seed companies. Cannot be combined with semantic."
|
|
446
|
+
)
|
|
447
|
+
};
|
|
448
|
+
var CompanyQuerySchema = z.strictObject(CompanyQueryShape);
|
|
449
|
+
var EnrichCompanyByPropertiesShape = {
|
|
450
|
+
name: z.string().min(1).max(250).optional().describe("Company name."),
|
|
451
|
+
linkedinUrl: z.url().max(2048).optional().describe("Company LinkedIn URL."),
|
|
452
|
+
linkedinId: z.string().min(1).max(100).optional().describe("Company LinkedIn ID."),
|
|
453
|
+
twitterUrl: z.url().max(2048).optional().describe("Company Twitter/X URL."),
|
|
454
|
+
facebookUrl: z.url().max(2048).optional().describe("Company Facebook URL."),
|
|
455
|
+
instagramUrl: z.url().max(2048).optional().describe("Company Instagram URL."),
|
|
456
|
+
youtubeUrl: z.url().max(2048).optional().describe("Company YouTube URL.")
|
|
457
|
+
};
|
|
458
|
+
var PersonEducationFilterSchema = z.strictObject({
|
|
459
|
+
institutionLinkedinHandle: valueFilter(z.string().min(1)).optional().describe("LinkedIn handles or URLs of schools."),
|
|
460
|
+
institutionName: valueFilter(z.string().min(1)).optional().describe("Phrases matched against school names.")
|
|
461
|
+
});
|
|
462
|
+
var PersonPastExperienceFilterSchema = z.strictObject({
|
|
463
|
+
companyId: valueFilter(companyId).optional().describe("Past company IDs."),
|
|
464
|
+
domain: valueFilter(domainName).optional().describe("Past company domains."),
|
|
465
|
+
companyLinkedinHandle: valueFilter(z.string().min(1)).optional().describe("LinkedIn handles or URLs of past companies."),
|
|
466
|
+
seniority: includeFilter(PersonSeniorityEnum).optional().describe("Seniority in the past role."),
|
|
467
|
+
department: includeFilter(PersonDepartmentValue).optional().describe(`Department of the past role. ${DEPARTMENT_VALUES_HINT}`),
|
|
468
|
+
position: includeFilter(z.string().min(1)).optional().describe("Phrases matched against the past job title."),
|
|
469
|
+
startDate: DateRangeSchema.optional().describe("When the past role started."),
|
|
470
|
+
endDate: DateRangeSchema.optional().describe("When the past role ended.")
|
|
471
|
+
});
|
|
472
|
+
var PersonSearchFilterSchema = z.strictObject({
|
|
473
|
+
query: valueFilter(searchText).optional().describe("Text matched against person names."),
|
|
474
|
+
companyId: valueFilter(companyId).optional().describe("Current company IDs."),
|
|
475
|
+
domain: valueFilter(domainName).optional().describe("Current company domains."),
|
|
476
|
+
companyLinkedinHandle: valueFilter(z.string().min(1)).optional().describe("LinkedIn handles or URLs of current companies."),
|
|
477
|
+
seniority: valueFilter(PersonSeniorityEnum).optional().describe("Current seniority levels."),
|
|
478
|
+
department: valueFilter(PersonDepartmentEnum, PersonDepartmentValue).optional().describe("Current departments. A root department includes its sub-departments."),
|
|
479
|
+
country: valueFilter(countryCode).optional().describe("2-letter country codes of the person."),
|
|
480
|
+
position: valueFilter(z.string().min(1)).optional().describe("Phrases matched against current job titles."),
|
|
481
|
+
currentCompanyStartDate: DateRangeSchema.optional().describe(
|
|
482
|
+
"When the person joined their current company."
|
|
483
|
+
),
|
|
484
|
+
currentPositionStartDate: DateRangeSchema.optional().describe(
|
|
485
|
+
"When the person started their current position."
|
|
486
|
+
),
|
|
487
|
+
education: PersonEducationFilterSchema.optional().describe("Education history filters."),
|
|
488
|
+
pastExperience: PersonPastExperienceFilterSchema.optional().describe(
|
|
489
|
+
"Finds people by a previous job. All rules must match the same past role, and people still at an included company are left out."
|
|
490
|
+
)
|
|
491
|
+
});
|
|
492
|
+
var PersonSemanticQuerySchema = z.strictObject({
|
|
493
|
+
query: z.string().min(1).max(500).describe(
|
|
494
|
+
'Natural-language description of the people to find, for example "VP of sales at Series A SaaS startups in Germany".'
|
|
495
|
+
)
|
|
496
|
+
});
|
|
497
|
+
var PersonQueryShape = {
|
|
498
|
+
filter: PersonSearchFilterSchema.optional().describe("Person filters."),
|
|
499
|
+
semantic: PersonSemanticQuerySchema.optional().describe(
|
|
500
|
+
"Natural-language people search."
|
|
501
|
+
),
|
|
502
|
+
company: CompanyQuerySchema.optional().describe(
|
|
503
|
+
"Limits results to people whose current company matches this company query."
|
|
504
|
+
)
|
|
505
|
+
};
|
|
506
|
+
var PersonQuerySchema = z.strictObject(PersonQueryShape);
|
|
507
|
+
var PersonIdSchema = z.union([
|
|
508
|
+
z.number().int().positive(),
|
|
509
|
+
z.string().regex(/^[1-9]\d*$/, "Person ID must be a positive integer.")
|
|
510
|
+
]);
|
|
511
|
+
function unwrapSchema(schema) {
|
|
512
|
+
let current = schema;
|
|
513
|
+
while (current instanceof z.ZodOptional || current instanceof z.ZodDefault) {
|
|
514
|
+
current = current.unwrap();
|
|
515
|
+
}
|
|
516
|
+
return current;
|
|
517
|
+
}
|
|
518
|
+
function keysAt(schema, path) {
|
|
519
|
+
let current = unwrapSchema(schema);
|
|
520
|
+
for (const key of path) {
|
|
521
|
+
if (current instanceof z.ZodObject) {
|
|
522
|
+
current = unwrapSchema(current.shape[String(key)]);
|
|
523
|
+
} else if (current instanceof z.ZodArray) {
|
|
524
|
+
current = unwrapSchema(current.element);
|
|
525
|
+
} else {
|
|
526
|
+
return [];
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
return current instanceof z.ZodObject ? Object.keys(current.shape) : [];
|
|
530
|
+
}
|
|
531
|
+
function explainIssues(schema, error) {
|
|
532
|
+
return error.issues.map((issue) => {
|
|
533
|
+
const where = issue.path.length > 0 ? `${issue.path.join(".")}: ` : "";
|
|
534
|
+
if (issue.code !== "unrecognized_keys") {
|
|
535
|
+
return `${where}${issue.message}`;
|
|
536
|
+
}
|
|
537
|
+
const accepted = keysAt(schema, issue.path);
|
|
538
|
+
const hint = accepted.length > 0 ? ` Accepted keys: ${accepted.join(", ")}.` : "";
|
|
539
|
+
return `${where}${issue.message}.${hint}`;
|
|
540
|
+
}).join(" ");
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
// src/utils.ts
|
|
544
|
+
async function apiRequest(baseUrl, accessToken, path, options = {}) {
|
|
545
|
+
try {
|
|
546
|
+
const response = await fetch(buildUrl(baseUrl, path, options.query), {
|
|
547
|
+
method: options.method ?? "GET",
|
|
548
|
+
headers: buildHeaders(accessToken, options.body !== void 0),
|
|
549
|
+
body: options.body === void 0 ? void 0 : JSON.stringify(options.body)
|
|
550
|
+
});
|
|
551
|
+
const errorResponse = await handleHttpError(
|
|
552
|
+
response,
|
|
553
|
+
options.notFoundMessage
|
|
554
|
+
);
|
|
555
|
+
if (errorResponse) {
|
|
556
|
+
return errorResponse;
|
|
557
|
+
}
|
|
558
|
+
const data = await readJson(response);
|
|
559
|
+
const result = attachCreditInfo(data, parseCreditHeaders(response.headers));
|
|
560
|
+
return jsonToolResult(result);
|
|
561
|
+
} catch (error) {
|
|
562
|
+
return toolError(
|
|
563
|
+
`Error calling CompanyEnrich API: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
564
|
+
);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
function toolError(message) {
|
|
568
|
+
return {
|
|
569
|
+
content: [
|
|
570
|
+
{
|
|
571
|
+
type: "text",
|
|
572
|
+
text: message
|
|
573
|
+
}
|
|
574
|
+
],
|
|
575
|
+
isError: true
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
function buildUrl(baseUrl, path, query) {
|
|
579
|
+
const normalizedBase = baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
|
|
580
|
+
const normalizedPath = path.startsWith("/") ? path : `/${path}`;
|
|
581
|
+
const url = new URL(`${normalizedBase}${normalizedPath}`);
|
|
582
|
+
for (const [key, value] of Object.entries(query ?? {})) {
|
|
583
|
+
appendQueryValue(url.searchParams, key, value);
|
|
584
|
+
}
|
|
585
|
+
return url.toString();
|
|
586
|
+
}
|
|
587
|
+
function appendQueryValue(searchParams, key, value) {
|
|
588
|
+
if (value === void 0 || value === null) {
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
if (Array.isArray(value)) {
|
|
592
|
+
for (const item of value) {
|
|
593
|
+
if (item !== void 0 && item !== null) {
|
|
594
|
+
searchParams.append(key, String(item));
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
searchParams.append(key, String(value));
|
|
600
|
+
}
|
|
601
|
+
function buildHeaders(accessToken, hasBody) {
|
|
602
|
+
const headers = {
|
|
603
|
+
Authorization: `Bearer ${accessToken ?? ""}`,
|
|
604
|
+
"x-companyenrich-app": "mcp"
|
|
605
|
+
};
|
|
606
|
+
if (hasBody) {
|
|
607
|
+
headers["Content-Type"] = "application/json";
|
|
608
|
+
}
|
|
609
|
+
return headers;
|
|
610
|
+
}
|
|
611
|
+
async function handleHttpError(response, notFoundMessage) {
|
|
612
|
+
if (response.ok) {
|
|
613
|
+
return null;
|
|
614
|
+
}
|
|
615
|
+
if (response.status === 404 && notFoundMessage) {
|
|
616
|
+
return toolError(notFoundMessage);
|
|
617
|
+
}
|
|
618
|
+
const bodyMessage = await readErrorMessage(response);
|
|
619
|
+
const statusMessage = getStatusMessage(response.status);
|
|
620
|
+
const message = bodyMessage ? `${statusMessage} (${bodyMessage})` : statusMessage;
|
|
621
|
+
return toolError(message);
|
|
622
|
+
}
|
|
623
|
+
function getStatusMessage(status) {
|
|
624
|
+
if (status === 400 || status === 422) {
|
|
625
|
+
return "Invalid request.";
|
|
626
|
+
}
|
|
627
|
+
if (status === 401) {
|
|
628
|
+
return "Authentication failed. Please check your API key.";
|
|
629
|
+
}
|
|
630
|
+
if (status === 402) {
|
|
631
|
+
return "Insufficient credits. Please check your account balance.";
|
|
632
|
+
}
|
|
633
|
+
if (status === 403) {
|
|
634
|
+
return "Forbidden. Your plan or API key does not have access to this feature.";
|
|
635
|
+
}
|
|
636
|
+
if (status === 404) {
|
|
637
|
+
return "Not found.";
|
|
638
|
+
}
|
|
639
|
+
if (status === 429) {
|
|
640
|
+
return "Rate limit exceeded. Please try again later.";
|
|
641
|
+
}
|
|
642
|
+
return `Error ${status}.`;
|
|
643
|
+
}
|
|
644
|
+
async function readErrorMessage(response) {
|
|
645
|
+
const text = await response.text();
|
|
646
|
+
if (!text) {
|
|
647
|
+
return void 0;
|
|
648
|
+
}
|
|
649
|
+
try {
|
|
650
|
+
const parsed = JSON.parse(text);
|
|
651
|
+
return extractProblemMessage(parsed) ?? text;
|
|
652
|
+
} catch {
|
|
653
|
+
return text;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
function extractProblemMessage(value) {
|
|
657
|
+
if (!isRecord(value)) {
|
|
658
|
+
return void 0;
|
|
659
|
+
}
|
|
660
|
+
const errors = value.errors;
|
|
661
|
+
if (isRecord(errors)) {
|
|
662
|
+
const messages = Object.entries(errors).flatMap(([field, fieldErrors]) => {
|
|
663
|
+
if (Array.isArray(fieldErrors)) {
|
|
664
|
+
return fieldErrors.map((error) => `${field}: ${String(error)}`);
|
|
665
|
+
}
|
|
666
|
+
return [`${field}: ${String(fieldErrors)}`];
|
|
667
|
+
});
|
|
668
|
+
if (messages.length > 0) {
|
|
669
|
+
return messages.join("; ");
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
return readString(value.detail) ?? readString(value.title);
|
|
673
|
+
}
|
|
674
|
+
async function readJson(response) {
|
|
675
|
+
const text = await response.text();
|
|
676
|
+
if (!text) {
|
|
677
|
+
return {};
|
|
678
|
+
}
|
|
679
|
+
return JSON.parse(text);
|
|
680
|
+
}
|
|
681
|
+
function parseCreditHeaders(headers) {
|
|
682
|
+
const balance = readNumberHeader(headers, "x-credit-balance");
|
|
683
|
+
const cost = readNumberHeader(headers, "x-credit-cost");
|
|
684
|
+
const remaining = readNumberHeader(headers, "x-credit-remaining");
|
|
685
|
+
if (balance === void 0 && cost === void 0 && remaining === void 0) {
|
|
686
|
+
return void 0;
|
|
687
|
+
}
|
|
688
|
+
return { balance, cost, remaining };
|
|
689
|
+
}
|
|
690
|
+
function readNumberHeader(headers, name) {
|
|
691
|
+
const raw = headers.get(name);
|
|
692
|
+
if (raw === null) {
|
|
693
|
+
return void 0;
|
|
694
|
+
}
|
|
695
|
+
const num = Number(raw);
|
|
696
|
+
return Number.isFinite(num) ? num : void 0;
|
|
697
|
+
}
|
|
698
|
+
function attachCreditInfo(data, creditInfo) {
|
|
699
|
+
if (!creditInfo) {
|
|
700
|
+
return data;
|
|
701
|
+
}
|
|
702
|
+
if (isRecord(data)) {
|
|
703
|
+
return {
|
|
704
|
+
...data,
|
|
705
|
+
creditInfo
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
return {
|
|
709
|
+
data,
|
|
710
|
+
creditInfo
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
function jsonToolResult(data) {
|
|
714
|
+
const structuredContent = isRecord(data) ? data : { data };
|
|
715
|
+
return {
|
|
716
|
+
content: [
|
|
717
|
+
{
|
|
718
|
+
type: "text",
|
|
719
|
+
text: JSON.stringify(data)
|
|
720
|
+
}
|
|
721
|
+
],
|
|
722
|
+
structuredContent
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
function readString(value) {
|
|
726
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
727
|
+
}
|
|
728
|
+
function isRecord(value) {
|
|
729
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
// src/mcp.ts
|
|
733
|
+
var API_PREFIX = "/v2";
|
|
734
|
+
var FILTER_RULES_HELP = "Each value filter is an object: `in` matches any listed value, `notIn` excludes matches, and `all` (keywords, technologies, naicsCodes and categories only) requires every listed value.";
|
|
735
|
+
var COMPANY_EXPAND_HELP = "Each expansion (financial, keywords, naicsCodes, technologies, workforce) adds 1 credit per returned company.";
|
|
736
|
+
var PERSON_EXPAND_HELP = "Expansions: education adds 1 credit per returned person; company adds 1 credit per unique company whose profile is included.";
|
|
737
|
+
var CURSOR_HELP = "Results are paged with a cursor: pass `nextCursor` from the previous response as `cursor` and keep the rest of the query the same. Cursors expire after 24 hours.";
|
|
738
|
+
var SEMANTIC_AND_LOOKALIKE_ERROR = "A company query can use semantic or lookalike, not both. Remove one of them.";
|
|
739
|
+
var COUNT_RESULT_HELP = "Returns `count`, the matches your plan can access, and `total`, all matches. A semantic query also returns `interpretation`, the filters inferred from it.";
|
|
740
|
+
function sameAs(tool, argument) {
|
|
741
|
+
return z2.looseObject({}).optional().describe(`Same as \`${argument}\` in ${tool}.`);
|
|
742
|
+
}
|
|
743
|
+
var companyExpandShape = {
|
|
744
|
+
expand: z2.array(CompanyExpandEnum).min(1).optional().describe(`Extra company data to include. ${COMPANY_EXPAND_HELP}`)
|
|
745
|
+
};
|
|
746
|
+
var personExpandShape = {
|
|
747
|
+
expand: z2.array(PersonExpandEnum).min(1).optional().describe(`Extra person data to include. ${PERSON_EXPAND_HELP}`)
|
|
748
|
+
};
|
|
749
|
+
var cursorPageShape = {
|
|
750
|
+
pageSize: z2.number().int().min(1).max(100).optional().default(20).describe("Maximum number of results to return, from 1 to 100."),
|
|
751
|
+
cursor: z2.string().min(1).max(1024).optional().describe("`nextCursor` from the previous response. Omit for the first page.")
|
|
752
|
+
};
|
|
753
|
+
var serverInfo = {
|
|
754
|
+
name: "CompanyEnrich MCP Server",
|
|
755
|
+
version
|
|
756
|
+
};
|
|
757
|
+
var toolsListCacheHint = {
|
|
758
|
+
ttlMs: 60 * 60 * 1e3,
|
|
759
|
+
cacheScope: "private"
|
|
760
|
+
};
|
|
761
|
+
function withToolAnnotations(config, annotations) {
|
|
762
|
+
return {
|
|
763
|
+
...config,
|
|
764
|
+
annotations: {
|
|
765
|
+
title: config.title,
|
|
766
|
+
...annotations
|
|
767
|
+
}
|
|
768
|
+
};
|
|
769
|
+
}
|
|
770
|
+
function paidTool(config) {
|
|
771
|
+
return withToolAnnotations(config, {
|
|
772
|
+
readOnlyHint: false,
|
|
773
|
+
destructiveHint: false
|
|
774
|
+
});
|
|
775
|
+
}
|
|
776
|
+
function readOnlyTool(config) {
|
|
777
|
+
return withToolAnnotations(config, { readOnlyHint: true });
|
|
778
|
+
}
|
|
779
|
+
function createCompanyEnrichMcpServer({
|
|
780
|
+
apiEndpoint: apiEndpoint2,
|
|
781
|
+
getAccessToken
|
|
782
|
+
}) {
|
|
783
|
+
const server = new McpServer(serverInfo, {
|
|
784
|
+
cacheHints: { "tools/list": toolsListCacheHint }
|
|
785
|
+
});
|
|
786
|
+
const request = (path, options = {}) => apiRequest(apiEndpoint2, getAccessToken(), `${API_PREFIX}${path}`, options);
|
|
787
|
+
server.registerTool(
|
|
788
|
+
"enrich_company",
|
|
789
|
+
paidTool({
|
|
790
|
+
title: "Enrich Company Information",
|
|
791
|
+
description: `Enriches a company by domain. Costs 1 credit per successful enrichment. ${COMPANY_EXPAND_HELP} A company that cannot be found costs nothing.`,
|
|
792
|
+
inputSchema: z2.strictObject({
|
|
793
|
+
domain: z2.string().min(1).max(1024).describe(
|
|
794
|
+
"The domain name of the company to enrich, for example example.com."
|
|
795
|
+
),
|
|
796
|
+
...companyExpandShape,
|
|
797
|
+
waitForEnrichment: z2.boolean().optional().describe(
|
|
798
|
+
"Whether to wait for on-demand enrichment when the company is not stored yet. Defaults to true. Set false to return only stored data right away; a miss then schedules enrichment in the background."
|
|
799
|
+
)
|
|
800
|
+
})
|
|
801
|
+
}),
|
|
802
|
+
async ({ domain, expand, waitForEnrichment }) => request("/companies/enrich", {
|
|
803
|
+
query: { domain, expand, waitForEnrichment },
|
|
804
|
+
notFoundMessage: waitForEnrichment === false ? `Company with domain "${domain}" is not stored yet. Enrichment was scheduled in the background where eligible, so try again later. No credits were charged.` : `Company with domain "${domain}" was not found. No credits were charged.`
|
|
805
|
+
})
|
|
806
|
+
);
|
|
807
|
+
server.registerTool(
|
|
808
|
+
"get_company_by_id",
|
|
809
|
+
paidTool({
|
|
810
|
+
title: "Get Company By ID",
|
|
811
|
+
description: `Retrieves a stored company by CompanyEnrich company ID. Costs 1 credit per company returned. ${COMPANY_EXPAND_HELP} A company that cannot be found costs nothing.`,
|
|
812
|
+
inputSchema: z2.strictObject({
|
|
813
|
+
id: z2.guid().describe("CompanyEnrich company ID."),
|
|
814
|
+
...companyExpandShape
|
|
815
|
+
})
|
|
816
|
+
}),
|
|
817
|
+
async ({ id, expand }) => request(`/companies/${encodeURIComponent(id)}`, {
|
|
818
|
+
query: { expand },
|
|
819
|
+
notFoundMessage: `Company with ID "${id}" was not found. No credits were charged.`
|
|
820
|
+
})
|
|
821
|
+
);
|
|
822
|
+
server.registerTool(
|
|
823
|
+
"enrich_company_by_properties",
|
|
824
|
+
paidTool({
|
|
825
|
+
title: "Enrich Company By Properties",
|
|
826
|
+
description: `Resolves and enriches a company from identifying properties such as its name or a social profile URL. When several properties are given, all of them must match. Prefer enrich_company when the domain is known. Costs 1 credit when a company is returned or when the properties cannot be resolved to a company domain. ${COMPANY_EXPAND_HELP}`,
|
|
827
|
+
inputSchema: z2.strictObject({
|
|
828
|
+
...EnrichCompanyByPropertiesShape,
|
|
829
|
+
...companyExpandShape
|
|
830
|
+
})
|
|
831
|
+
}),
|
|
832
|
+
async ({ expand, ...properties }) => {
|
|
833
|
+
if (Object.values(properties).every((value) => value === void 0)) {
|
|
834
|
+
return toolError(
|
|
835
|
+
`Provide at least one company property: ${Object.keys(EnrichCompanyByPropertiesShape).join(", ")}.`
|
|
836
|
+
);
|
|
837
|
+
}
|
|
838
|
+
return request("/companies/enrich", {
|
|
839
|
+
method: "POST",
|
|
840
|
+
body: { ...properties, expand },
|
|
841
|
+
notFoundMessage: "No company matched the provided properties."
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
);
|
|
845
|
+
server.registerTool(
|
|
846
|
+
"get_company_workforce",
|
|
847
|
+
paidTool({
|
|
848
|
+
title: "Get Company Workforce Insights",
|
|
849
|
+
description: "Returns the current employee count, department headcounts and the latest 12 months of workforce history for one company, looked up by CompanyEnrich company ID or domain. Pass `nextCursor` from the response as `cursor`, with the same company, to get the preceding 12 months. Costs 1 credit per successful page. Cursors expire after 30 minutes.",
|
|
850
|
+
inputSchema: z2.strictObject({
|
|
851
|
+
id: z2.guid().optional().describe(
|
|
852
|
+
"CompanyEnrich company ID. Provide either id or domain."
|
|
853
|
+
),
|
|
854
|
+
domain: z2.string().min(1).max(1024).optional().describe("Company domain. Provide either id or domain."),
|
|
855
|
+
cursor: z2.string().min(1).max(1024).optional().describe(
|
|
856
|
+
"`nextCursor` from a previous workforce response or from a company's workforce expansion. Omit for the latest 12 months."
|
|
857
|
+
)
|
|
858
|
+
})
|
|
859
|
+
}),
|
|
860
|
+
async ({ id, domain, cursor }) => {
|
|
861
|
+
if (id && domain || !id && !domain) {
|
|
862
|
+
return toolError(
|
|
863
|
+
"Provide exactly one lookup parameter: id or domain."
|
|
864
|
+
);
|
|
865
|
+
}
|
|
866
|
+
return request("/companies/workforce", {
|
|
867
|
+
query: { id, domain, cursor },
|
|
868
|
+
notFoundMessage: `Workforce insights for "${id ?? domain}" were not found. No credits were charged.`
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
);
|
|
872
|
+
server.registerTool(
|
|
873
|
+
"search_companies",
|
|
874
|
+
paidTool({
|
|
875
|
+
title: "Search Companies",
|
|
876
|
+
description: `Searches companies in one of three ways: by filters alone, by a natural-language \`semantic\` query, or by \`lookalike\` seed domains (companies similar to the ones given). Filters can be combined with either; semantic and lookalike cannot be combined. A semantic query infers filters such as location, size and funding by default and reports them in \`interpretation\`. Costs per returned company: 1 credit for a filter search, 2 for semantic, 5 for lookalike; an empty result costs one result's price. ${COMPANY_EXPAND_HELP} ${FILTER_RULES_HELP} ${CURSOR_HELP}`,
|
|
877
|
+
inputSchema: z2.strictObject({
|
|
878
|
+
...CompanyQueryShape,
|
|
879
|
+
...companyExpandShape,
|
|
880
|
+
...cursorPageShape
|
|
881
|
+
})
|
|
882
|
+
}),
|
|
883
|
+
async ({ filter, semantic, lookalike, expand, pageSize = 20, cursor }) => {
|
|
884
|
+
if (semantic && lookalike) {
|
|
885
|
+
return toolError(SEMANTIC_AND_LOOKALIKE_ERROR);
|
|
886
|
+
}
|
|
887
|
+
return request("/companies/search", {
|
|
888
|
+
method: "POST",
|
|
889
|
+
body: { filter, semantic, lookalike, expand, pageSize, cursor }
|
|
890
|
+
});
|
|
891
|
+
}
|
|
892
|
+
);
|
|
893
|
+
server.registerTool(
|
|
894
|
+
"count_companies",
|
|
895
|
+
readOnlyTool({
|
|
896
|
+
title: "Count Companies",
|
|
897
|
+
description: `Counts the companies a search_companies query would match, without returning them. Free; no credits deducted. Use it to size or check a query before running the paid search. Takes the same \`filter\`, \`semantic\` and \`lookalike\` arguments as search_companies. ${COUNT_RESULT_HELP}`,
|
|
898
|
+
inputSchema: z2.strictObject({
|
|
899
|
+
filter: sameAs("search_companies", "filter"),
|
|
900
|
+
semantic: sameAs("search_companies", "semantic"),
|
|
901
|
+
lookalike: sameAs("search_companies", "lookalike")
|
|
902
|
+
})
|
|
903
|
+
}),
|
|
904
|
+
async (input) => {
|
|
905
|
+
const query = CompanyQuerySchema.safeParse(input);
|
|
906
|
+
if (!query.success) {
|
|
907
|
+
return toolError(
|
|
908
|
+
`Invalid arguments for tool count_companies: ${explainIssues(CompanyQuerySchema, query.error)}`
|
|
909
|
+
);
|
|
910
|
+
}
|
|
911
|
+
if (query.data.semantic && query.data.lookalike) {
|
|
912
|
+
return toolError(SEMANTIC_AND_LOOKALIKE_ERROR);
|
|
913
|
+
}
|
|
914
|
+
return request("/companies/search/count", {
|
|
915
|
+
method: "POST",
|
|
916
|
+
body: query.data
|
|
917
|
+
});
|
|
918
|
+
}
|
|
919
|
+
);
|
|
920
|
+
server.registerTool(
|
|
921
|
+
"get_person_by_id",
|
|
922
|
+
paidTool({
|
|
923
|
+
title: "Get Person By ID",
|
|
924
|
+
description: `Retrieves a stored person by CompanyEnrich person ID. Costs 2 credits per person returned. ${PERSON_EXPAND_HELP} A person that cannot be found costs nothing.`,
|
|
925
|
+
inputSchema: z2.strictObject({
|
|
926
|
+
id: PersonIdSchema.describe("CompanyEnrich person ID."),
|
|
927
|
+
...personExpandShape
|
|
928
|
+
})
|
|
929
|
+
}),
|
|
930
|
+
async ({ id, expand }) => request(`/people/${encodeURIComponent(String(id))}`, {
|
|
931
|
+
query: { expand },
|
|
932
|
+
notFoundMessage: `Person with ID "${id}" was not found. No credits were charged.`
|
|
933
|
+
})
|
|
934
|
+
);
|
|
935
|
+
server.registerTool(
|
|
936
|
+
"lookup_person_by_email",
|
|
937
|
+
paidTool({
|
|
938
|
+
title: "Lookup Person By Email",
|
|
939
|
+
description: `Identifies a person from an email address. The API resolves the company from the email domain and matches the person by common address patterns. Costs 5 credits when a person is returned. ${PERSON_EXPAND_HELP} No match costs nothing.`,
|
|
940
|
+
inputSchema: z2.strictObject({
|
|
941
|
+
email: z2.email().max(320).describe("The email address of the person to look up."),
|
|
942
|
+
...personExpandShape
|
|
943
|
+
})
|
|
944
|
+
}),
|
|
945
|
+
async ({ email, expand }) => request("/people/enrich", {
|
|
946
|
+
method: "POST",
|
|
947
|
+
body: { email, expand },
|
|
948
|
+
notFoundMessage: `No person matched the email "${email}". No credits were charged.`
|
|
949
|
+
})
|
|
950
|
+
);
|
|
951
|
+
server.registerTool(
|
|
952
|
+
"enrich_person_email",
|
|
953
|
+
paidTool({
|
|
954
|
+
title: "Find Person Work Email",
|
|
955
|
+
description: "Finds the work email address of a person on a company domain. The response `status` is found, not-found, unavailable or pending; `email` is present only when found, and a pending lookup is still running, so call again later. Costs 10 credits when it finds an email your account has not accessed before; every other outcome is free.",
|
|
956
|
+
inputSchema: z2.strictObject({
|
|
957
|
+
id: PersonIdSchema.describe("CompanyEnrich person ID."),
|
|
958
|
+
domain: z2.string().min(1).max(1024).optional().describe(
|
|
959
|
+
"Company domain to find the email on. It must belong to one of the person's companies. If omitted, the person's current companies are tried."
|
|
960
|
+
)
|
|
961
|
+
})
|
|
962
|
+
}),
|
|
963
|
+
async ({ id, domain }) => request(`/people/${encodeURIComponent(String(id))}/email`, {
|
|
964
|
+
query: { domain },
|
|
965
|
+
notFoundMessage: `Person with ID "${id}" was not found. No credits were charged.`
|
|
966
|
+
})
|
|
967
|
+
);
|
|
968
|
+
server.registerTool(
|
|
969
|
+
"search_people",
|
|
970
|
+
paidTool({
|
|
971
|
+
title: "Search People",
|
|
972
|
+
description: `Searches people by person filters, a natural-language \`semantic\` query, and an optional \`company\` query that limits results to people whose current company matches. \`company\` takes the same filter, semantic and lookalike inputs as search_companies. A semantic query infers person filters and the kind of company to look in, and reports them in \`interpretation\`; it is rejected when nothing can be inferred. Top-level filters match current roles; use \`filter.pastExperience\` for previous jobs. Costs 2 credits per returned person; an empty result costs one result's price. ${PERSON_EXPAND_HELP} ${FILTER_RULES_HELP} ${CURSOR_HELP}`,
|
|
973
|
+
inputSchema: z2.strictObject({
|
|
974
|
+
...PersonQueryShape,
|
|
975
|
+
...personExpandShape,
|
|
976
|
+
...cursorPageShape
|
|
977
|
+
})
|
|
978
|
+
}),
|
|
979
|
+
async ({ filter, semantic, company, expand, pageSize = 20, cursor }) => {
|
|
980
|
+
if (company?.semantic && company.lookalike) {
|
|
981
|
+
return toolError(SEMANTIC_AND_LOOKALIKE_ERROR);
|
|
982
|
+
}
|
|
983
|
+
return request("/people/search", {
|
|
984
|
+
method: "POST",
|
|
985
|
+
body: { filter, semantic, company, expand, pageSize, cursor }
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
);
|
|
989
|
+
server.registerTool(
|
|
990
|
+
"count_people",
|
|
991
|
+
readOnlyTool({
|
|
992
|
+
title: "Count People",
|
|
993
|
+
description: `Counts the people a search_people query would match, without returning them. Free; no credits deducted. Use it to size or check a query before running the paid search. Takes the same \`filter\`, \`semantic\` and \`company\` arguments as search_people. ${COUNT_RESULT_HELP}`,
|
|
994
|
+
inputSchema: z2.strictObject({
|
|
995
|
+
filter: sameAs("search_people", "filter"),
|
|
996
|
+
semantic: sameAs("search_people", "semantic"),
|
|
997
|
+
company: sameAs("search_people", "company")
|
|
998
|
+
})
|
|
999
|
+
}),
|
|
1000
|
+
async (input) => {
|
|
1001
|
+
const query = PersonQuerySchema.safeParse(input);
|
|
1002
|
+
if (!query.success) {
|
|
1003
|
+
return toolError(
|
|
1004
|
+
`Invalid arguments for tool count_people: ${explainIssues(PersonQuerySchema, query.error)}`
|
|
1005
|
+
);
|
|
1006
|
+
}
|
|
1007
|
+
if (query.data.company?.semantic && query.data.company.lookalike) {
|
|
1008
|
+
return toolError(SEMANTIC_AND_LOOKALIKE_ERROR);
|
|
1009
|
+
}
|
|
1010
|
+
return request("/people/search/count", {
|
|
1011
|
+
method: "POST",
|
|
1012
|
+
body: query.data
|
|
1013
|
+
});
|
|
1014
|
+
}
|
|
1015
|
+
);
|
|
1016
|
+
server.registerTool(
|
|
1017
|
+
"get_current_user",
|
|
1018
|
+
readOnlyTool({
|
|
1019
|
+
title: "Get Current User",
|
|
1020
|
+
description: "Returns the authenticated user's credit usage and allowance and the account's capabilities and limits. Free; no credits deducted.",
|
|
1021
|
+
inputSchema: z2.strictObject({})
|
|
1022
|
+
}),
|
|
1023
|
+
async () => request("/me")
|
|
1024
|
+
);
|
|
1025
|
+
return server;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
// src/stdio.ts
|
|
1029
|
+
var DEFAULT_API_URL = "https://api.companyenrich.com";
|
|
1030
|
+
var apiKey = process.env.COMPANYENRICH_API_KEY?.trim();
|
|
1031
|
+
if (!apiKey) {
|
|
1032
|
+
console.error(
|
|
1033
|
+
"COMPANYENRICH_API_KEY is not set. Create an API key at https://app.companyenrich.com/access-keys and pass it in this server's environment."
|
|
1034
|
+
);
|
|
1035
|
+
process.exit(1);
|
|
1036
|
+
}
|
|
1037
|
+
var apiEndpoint = process.env.COMPANYENRICH_API_URL?.trim() || DEFAULT_API_URL;
|
|
1038
|
+
serveStdio(
|
|
1039
|
+
() => createCompanyEnrichMcpServer({
|
|
1040
|
+
apiEndpoint,
|
|
1041
|
+
getAccessToken: () => apiKey
|
|
1042
|
+
}),
|
|
1043
|
+
{
|
|
1044
|
+
legacy: "serve",
|
|
1045
|
+
onerror: (error) => console.error("MCP stdio:", error.message)
|
|
1046
|
+
}
|
|
1047
|
+
);
|