@mambalabsdev/mcp-people-finder 1.0.1 → 1.1.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.
Files changed (3) hide show
  1. package/README.md +6 -6
  2. package/build/index.js +101 -39
  3. package/package.json +5 -4
package/README.md CHANGED
@@ -40,18 +40,18 @@ Give it a company domain, name or LinkedIn URL and it returns the people at that
40
40
  | `company_name` | string | no | Used when no domain is available, or as a disambiguation hint alongside a domain. |
41
41
  | `linkedin_company_url` | string | no | Example: https://www.linkedin.com/company/stripe. Skips internal company resolution when provided. |
42
42
  | `domains` | array | no | Optional list of bare domains. Takes precedence over the single domain field. Each domain is searched independently and every output row echoes its source domain. |
43
- | `targetCount` | integer | no | Maximum people to return per company. Billing is per person actually returned, so a lower number is a hard cost cap. |
43
+ | `targetCount` | integer | no | Maximum people to return per company. Billing is per person actually returned, so a lower number is a hard cost cap. Default: 5. |
44
44
  | `jobTitles` | array | no | Case-insensitive substring match against the person's current title. Any match qualifies. Leave empty for no title filter. Example: VP Sales, Head of Growth |
45
45
  | `excludeJobTitles` | array | no | Case-insensitive substring match. A person matching any of these is dropped even if they matched an include. Example: intern, assistant, former |
46
46
  | `seniority` | array | no | Filter to these normalized seniority levels. Leave empty for all. |
47
47
  | `departments` | array | no | Filter to these normalized departments. Leave empty for all. |
48
48
  | `countries` | array | no | ISO 3166-1 alpha-2 codes. Filters to people located in these countries. Example: US, GB, NL |
49
- | `includeEmails` | boolean | no | Discover a business email for each person found, using your Icypeas and/or Prospeo keys. Billed only when an email is actually returned. Turn off to build an org map cheaply. |
50
- | `verifyEmails` | boolean | no | Check deliverability of each email found, escalating catch-all domains to a second provider for a definitive answer. Requires a Reoon and/or BounceBan key. |
51
- | `verifyPosition` | boolean | no | Check that the person still holds the returned title at the target company, and report the reasoning. Reduces bounced outreach to people who have moved on. |
49
+ | `includeEmails` | boolean | no | Discover a business email for each person found, using your Icypeas and/or Prospeo keys. Billed only when an email is actually returned. Turn off to build an org map cheaply. Default: true. |
50
+ | `verifyEmails` | boolean | no | Check deliverability of each email found, escalating catch-all domains to a second provider for a definitive answer. Requires a Reoon and/or BounceBan key. Default: true. |
51
+ | `verifyPosition` | boolean | no | Check that the person still holds the returned title at the target company, and report the reasoning. Reduces bounced outreach to people who have moved on. Default: false. |
52
52
  | `suppressLinkedInUrls` | array | no | LinkedIn profile URLs to exclude from results. Use to suppress already-contacted prospects or honor data subject removal requests. |
53
- | `batchSize` | integer | no | How many companies to search concurrently in batch mode. Default 5, maximum 10. |
54
- | `skipCache` | boolean | no | Results are cached for 7 days and reused on repeat lookups. Set true to force a fresh search. |
53
+ | `batchSize` | integer | no | How many companies to search concurrently in batch mode. Default 5, maximum 10. Default: 5. |
54
+ | `skipCache` | boolean | no | Results are cached for 7 days and reused on repeat lookups. Set true to force a fresh search. Default: false. |
55
55
  | `serpApiKey` | string | no | Serper.dev API key. Unlocks the search layer, which is the highest-coverage source of LinkedIn profile URLs. Without it this actor falls back to company website parsing only, which returns far fewer people. Get a key at https://serper.dev. You are billed by Serper for searches; this actor does not mark them up. |
56
56
  | `prospeoApiKey` | string | no | Second provider in the email waterfall. Used only for people the first provider could not resolve. Get a key at https://prospeo.io. Billed to you by Prospeo; this actor does not mark it up. |
57
57
  | `reoonApiKey` | string | no | Primary email verification. Returns deliverability status for each discovered address. Get a key at https://emailverifier.reoon.com. Billed to you by Reoon. |
package/build/index.js CHANGED
@@ -18,6 +18,20 @@ function compact(obj) {
18
18
  }
19
19
  return out;
20
20
  }
21
+ // START AND POLL, NOT RUN-SYNC. Apify's synchronous endpoint carries a platform
22
+ // ceiling of 300 seconds on the HTTP wait and answers 408 past it while the run
23
+ // keeps going and keeps billing. Starting the run, polling it to a terminal
24
+ // status, and then reading the dataset waits as long as the actor needs.
25
+ //
26
+ // How long the actor run itself may take, in seconds: long enough for a large
27
+ // batch, short enough that a hung run cannot bill indefinitely.
28
+ const ACTOR_RUN_TIMEOUT_SECS = 1800;
29
+ // How long this wrapper waits: the run's own timeout plus two minutes, so the
30
+ // run's TIMED-OUT status is what the caller sees.
31
+ const WRAPPER_WAIT_MS = (ACTOR_RUN_TIMEOUT_SECS + 120) * 1000;
32
+ const POLL_INTERVAL_MS = Number(process.env.MAMBA_POLL_INTERVAL_MS ?? 3000);
33
+ const TERMINAL = new Set(["SUCCEEDED", "FAILED", "TIMED-OUT", "ABORTED", "ABORTING"]);
34
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
21
35
  // Shared caller. actorPath is the actor's immutable Apify actor ID (a stable key
22
36
  // that survives Store renames). The /v2/acts/{id} endpoint accepts it directly,
23
37
  // so a Store rename never breaks these calls.
@@ -30,24 +44,12 @@ async function runActor(actorPath, actorLabel, input) {
30
44
  if (!APIFY_TOKEN) {
31
45
  return { isError: true, content: [{ type: "text", text: "APIFY_TOKEN is not set. Create a token at https://console.apify.com/account/integrations and set it as the APIFY_TOKEN environment variable." }] };
32
46
  }
33
- const url = `https://api.apify.com/v2/acts/${actorPath}/run-sync-get-dataset-items?timeout=300`;
34
- let response;
35
- try {
36
- response = await fetch(url, {
37
- method: "POST",
38
- headers: {
39
- Authorization: `Bearer ${APIFY_TOKEN}`,
40
- "Content-Type": "application/json",
41
- "User-Agent": USER_AGENT,
42
- },
43
- body: JSON.stringify(input),
44
- });
45
- }
46
- catch (err) {
47
- const message = err instanceof Error ? err.message : String(err);
48
- return { isError: true, content: [{ type: "text", text: `Could not reach the Apify API: ${message}` }] };
49
- }
50
- if (!response.ok) {
47
+ const headers = {
48
+ Authorization: `Bearer ${APIFY_TOKEN}`,
49
+ "Content-Type": "application/json",
50
+ "User-Agent": USER_AGENT,
51
+ };
52
+ const httpError = async (response) => {
51
53
  let detail = "";
52
54
  try {
53
55
  const body = (await response.json());
@@ -57,33 +59,95 @@ async function runActor(actorPath, actorLabel, input) {
57
59
  catch {
58
60
  detail = "";
59
61
  }
60
- let message;
61
62
  switch (response.status) {
62
63
  case 400:
63
- message = `The ${actorLabel} run was rejected as invalid input.${detail}`;
64
- break;
64
+ return `The ${actorLabel} run was rejected as invalid input.${detail}`;
65
65
  case 401:
66
- message = "Invalid Apify token. Check your APIFY_TOKEN environment variable.";
67
- break;
66
+ return "Invalid Apify token. Check your APIFY_TOKEN environment variable.";
68
67
  case 402:
69
- message =
70
- "Insufficient Apify credits. Check your account balance at https://console.apify.com/billing";
71
- break;
72
- case 408:
73
- message = `The ${actorLabel} run timed out after 300 seconds. Ask for less per call, or run the actor on Apify directly for larger jobs.`;
74
- break;
68
+ return "Insufficient Apify credits. Check your account balance at https://console.apify.com/billing";
75
69
  default:
76
- message = `Apify request to ${actorLabel} failed with status ${response.status}.${detail}`;
70
+ return `Apify request to ${actorLabel} failed with status ${response.status}.${detail}`;
77
71
  }
78
- return { isError: true, content: [{ type: "text", text: message }] };
72
+ };
73
+ // 1. Start the run.
74
+ let started;
75
+ try {
76
+ started = await fetch(`https://api.apify.com/v2/acts/${actorPath}/runs?timeout=${ACTOR_RUN_TIMEOUT_SECS}`, { method: "POST", headers, body: JSON.stringify(input) });
77
+ }
78
+ catch (err) {
79
+ const message = err instanceof Error ? err.message : String(err);
80
+ return { isError: true, content: [{ type: "text", text: `Could not reach the Apify API: ${message}` }] };
81
+ }
82
+ if (!started.ok) {
83
+ return { isError: true, content: [{ type: "text", text: await httpError(started) }] };
84
+ }
85
+ let run;
86
+ try {
87
+ run = (await started.json()).data ?? {};
88
+ }
89
+ catch (err) {
90
+ const message = err instanceof Error ? err.message : String(err);
91
+ return { isError: true, content: [{ type: "text", text: `The ${actorLabel} run start returned a response that could not be parsed: ${message}` }] };
92
+ }
93
+ const runId = run.id;
94
+ if (!runId) {
95
+ return { isError: true, content: [{ type: "text", text: `The ${actorLabel} run start returned no run id, so there is nothing to wait for.` }] };
96
+ }
97
+ // 2. Poll to a terminal status.
98
+ const deadline = Date.now() + WRAPPER_WAIT_MS;
99
+ let status = run.status ?? "READY";
100
+ let datasetId = run.defaultDatasetId;
101
+ while (!TERMINAL.has(status)) {
102
+ if (Date.now() >= deadline) {
103
+ return {
104
+ isError: true,
105
+ content: [{ type: "text", text: `The ${actorLabel} run ${runId} was still ${status} after ${Math.round(WRAPPER_WAIT_MS / 1000)} seconds and this call stopped waiting. The run itself is still on Apify: read it at https://console.apify.com/actors/runs/${runId}` }],
106
+ };
107
+ }
108
+ await sleep(POLL_INTERVAL_MS);
109
+ let poll;
110
+ try {
111
+ poll = await fetch(`https://api.apify.com/v2/actor-runs/${runId}`, { headers });
112
+ }
113
+ catch (err) {
114
+ const message = err instanceof Error ? err.message : String(err);
115
+ return { isError: true, content: [{ type: "text", text: `Lost contact with the Apify API while waiting for ${actorLabel} run ${runId}: ${message}` }] };
116
+ }
117
+ if (!poll.ok) {
118
+ return { isError: true, content: [{ type: "text", text: await httpError(poll) }] };
119
+ }
120
+ const body = (await poll.json());
121
+ status = body.data?.status ?? status;
122
+ datasetId = body.data?.defaultDatasetId ?? datasetId;
123
+ }
124
+ // 3. A run that did not succeed is a failure the caller must see, never an
125
+ // empty success.
126
+ if (status !== "SUCCEEDED") {
127
+ return {
128
+ isError: true,
129
+ content: [{ type: "text", text: `The ${actorLabel} run did not succeed (run ID: ${runId}, status: ${status}).` }],
130
+ };
131
+ }
132
+ if (!datasetId) {
133
+ return { isError: true, content: [{ type: "text", text: `The ${actorLabel} run ${runId} succeeded but reported no dataset, so there is nothing to return.` }] };
134
+ }
135
+ // 4. Read the dataset. Pass actor output through unchanged: the wrapper never
136
+ // reinterprets a status field.
137
+ let ds;
138
+ try {
139
+ ds = await fetch(`https://api.apify.com/v2/datasets/${datasetId}/items?format=json`, { headers });
140
+ }
141
+ catch (err) {
142
+ const message = err instanceof Error ? err.message : String(err);
143
+ return { isError: true, content: [{ type: "text", text: `Could not read the ${actorLabel} dataset: ${message}` }] };
144
+ }
145
+ if (!ds.ok) {
146
+ return { isError: true, content: [{ type: "text", text: await httpError(ds) }] };
79
147
  }
80
- // A 2xx from run-sync-get-dataset-items normally carries the dataset array.
81
- // Anything else on this path is a failure the caller must see, never an empty
82
- // success: surfacing it here is what keeps a failed run from reading as "no
83
- // results found".
84
148
  let items;
85
149
  try {
86
- items = await response.json();
150
+ items = await ds.json();
87
151
  }
88
152
  catch (err) {
89
153
  const message = err instanceof Error ? err.message : String(err);
@@ -91,9 +155,7 @@ async function runActor(actorPath, actorLabel, input) {
91
155
  }
92
156
  if (!Array.isArray(items)) {
93
157
  const asObj = items;
94
- const detail = asObj?.error?.message
95
- ? `${asObj.error.message}`
96
- : JSON.stringify(items);
158
+ const detail = asObj?.error?.message ? `${asObj.error.message}` : JSON.stringify(items);
97
159
  return { isError: true, content: [{ type: "text", text: `The ${actorLabel} run did not return a dataset. ${detail}` }] };
98
160
  }
99
161
  return { content: [{ type: "text", text: JSON.stringify(items, null, 2) }] };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mambalabsdev/mcp-people-finder",
3
3
  "displayName": "People Finder & Email Verifier",
4
- "version": "1.0.1",
4
+ "version": "1.1.0",
5
5
  "description": "MCP server for the Mamba Labs People Finder & Email Verifier actor on Apify. Finds people at a company by role, seniority and department, and returns structured contact records with optional verified business email.",
6
6
  "type": "module",
7
7
  "bin": {
@@ -15,6 +15,7 @@
15
15
  ],
16
16
  "scripts": {
17
17
  "build": "tsc && chmod +x build/index.js",
18
+ "test": "npm run build && node --test test/*.test.js",
18
19
  "prepublishOnly": "npm run build"
19
20
  },
20
21
  "keywords": [
@@ -49,11 +50,11 @@
49
50
  },
50
51
  "dependencies": {
51
52
  "@modelcontextprotocol/sdk": "^1.12.0",
52
- "zod": "^3.23.8"
53
+ "zod": "^4.5.4"
53
54
  },
54
55
  "devDependencies": {
55
- "@types/node": "^20.14.0",
56
- "typescript": "^5.6.0"
56
+ "@types/node": "^26.4.1",
57
+ "typescript": "5.9.3"
57
58
  },
58
59
  "mcpServers": ".mcp.json",
59
60
  "mcpName": "com.mambabuilt/mcp-people-finder"