findymail-mcp 0.1.14 → 0.1.15

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/README.md CHANGED
@@ -15,8 +15,34 @@ This MCP server exposes the following tools:
15
15
  | `enrich_company` | Get company data from domain, LinkedIn URL, or name |
16
16
  | `reverse_email_lookup` | Find person info from an email |
17
17
  | `lookalike_search` | Find similar companies from a seed domain using vector similarity |
18
- | `generate_lead_list` | AI-powered lead list generation with natural language |
18
+ | `generate_lead_list` | AI-powered company discovery from a natural language description of your ideal customer |
19
19
  | `get_lead_list_results` | Retrieve results from a previously generated lead list |
20
+ | `list_exclusion_lists` | List the exclusion lists you own or that are shared with your team |
21
+ | `create_exclusion_list` | Create a new exclusion list |
22
+ | `list_exclusion_domains` | List the domains held by an exclusion list, with their ids |
23
+ | `add_exclusion_domains` | Add domains to an exclusion list (or to your global exclusions) |
24
+ | `remove_exclusion_domains` | Remove domains from an exclusion list, by domain id |
25
+
26
+ ### Exclusion lists
27
+
28
+ An exclusion list holds company domains that should never show up in search results — competitors, existing
29
+ customers, companies you already contacted. `generate_lead_list` and `lookalike_search` both accept
30
+ `exclusion_list_ids` to filter them out, and `generate_lead_list` additionally accepts
31
+ `add_to_exclusion_list_id` to automatically add every exported domain to a list, so a later search never
32
+ returns the same companies twice.
33
+
34
+ For `exclusion_list_ids`:
35
+
36
+ | Value | Behaviour |
37
+ |-------|-----------|
38
+ | *(omitted)* | Every exclusion source you can reach is applied — this is the default |
39
+ | `[0]` | Same as omitting it: your global exclusions **plus every list you own or share**, not just the global one |
40
+ | `[-1]` or `[]` | Exclusion filtering is disabled |
41
+ | `[12, 15]` | Only those lists are applied |
42
+ | mixed | Don't: `[0, 12]` ignores `12` and filters on everything, `[-1, 12]` disables filtering entirely |
43
+
44
+ `lookalike_search` takes a parameter with the same name but **not** the same semantics: it has no
45
+ `[0]`/`[-1]` markers, and an empty value means no filtering at all.
20
46
 
21
47
  ## Prerequisites
22
48
 
@@ -115,6 +141,8 @@ Once configured, you can ask your AI assistant:
115
141
  - "Get company information for stripe.com"
116
142
  - "Find me 10 marketing managers at SaaS companies in San Francisco"
117
143
  - "Find companies similar to stripe.com in the same country"
144
+ - "Create an exclusion list called Competitors and add stripe.com and brex.com to it"
145
+ - "Find 50 fintech companies in Europe, excluding my Competitors list, and add the results to it so I don't get them again"
118
146
 
119
147
  ## API Key
120
148
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "findymail-mcp",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "MCP server for Findymail - Find verified B2B emails, phone numbers, and company data",
5
5
  "type": "module",
6
6
  "main": "src/stdio.js",
package/src/api.js CHANGED
@@ -31,6 +31,35 @@ export function resolveApiKey(extra) {
31
31
  throw new Error("API key is required: set FINDYMAIL_API_KEY or pass Authorization header");
32
32
  }
33
33
 
34
+ // Laravel's abort(403) and abort(404) send an empty `message`, so a failure can
35
+ // carry no reason at all. Give the agent something actionable per status code.
36
+ const STATUS_REASONS = {
37
+ 401: "Unauthorized — the API key is missing, invalid or expired",
38
+ 403: "Forbidden — none of the resources you targeted belong to you, or your account may not edit them",
39
+ 404: "Not found — the resource does not exist",
40
+ 429: "Too many requests — rate limit reached, retry later",
41
+ };
42
+
43
+ /**
44
+ * Turn a failed response into an Error carrying the best reason available.
45
+ * The status is attached so callers can add their own context.
46
+ */
47
+ async function apiError(response) {
48
+ const payload = await response.json().catch(() => ({}));
49
+
50
+ // Some endpoints report the reason under `error` rather than `message`, and
51
+ // an aborted request reports an empty string under both.
52
+ const reason = [payload.message, payload.error]
53
+ .find(value => typeof value === "string" && value.trim() !== "")
54
+ ?.trim();
55
+
56
+ const error = new Error(
57
+ reason || `${STATUS_REASONS[response.status] ?? "API error"} (HTTP ${response.status})`
58
+ );
59
+ error.status = response.status;
60
+ return error;
61
+ }
62
+
34
63
  /**
35
64
  * Make authenticated POST request to Findymail API
36
65
  */
@@ -48,8 +77,7 @@ export async function apiPost(endpoint, body = {}, apiKey) {
48
77
  });
49
78
 
50
79
  if (!response.ok) {
51
- const error = await response.json().catch(() => ({}));
52
- throw new Error(error.message || `API error: ${response.status}`);
80
+ throw await apiError(response);
53
81
  }
54
82
 
55
83
  return response.json();
@@ -70,8 +98,30 @@ export async function apiGet(endpoint, apiKey) {
70
98
  });
71
99
 
72
100
  if (!response.ok) {
73
- const error = await response.json().catch(() => ({}));
74
- throw new Error(error.message || `API error: ${response.status}`);
101
+ throw await apiError(response);
102
+ }
103
+
104
+ return response.json();
105
+ }
106
+
107
+ /**
108
+ * Make authenticated DELETE request to Findymail API
109
+ */
110
+ export async function apiDelete(endpoint, body = {}, apiKey) {
111
+ if (!apiKey) apiKey = getApiKey();
112
+
113
+ const response = await fetch(`${API_BASE_URL}${endpoint}`, {
114
+ method: "DELETE",
115
+ headers: {
116
+ "Authorization": `Bearer ${apiKey}`,
117
+ "Content-Type": "application/json",
118
+ "Accept": "application/json",
119
+ },
120
+ body: JSON.stringify(body),
121
+ });
122
+
123
+ if (!response.ok) {
124
+ throw await apiError(response);
75
125
  }
76
126
 
77
127
  return response.json();
package/src/tools.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { log, apiPost, apiGet, resolveApiKey, formatResponse, formatError } from "./api.js";
2
+ import { log, apiPost, apiGet, apiDelete, resolveApiKey, formatResponse, formatError } from "./api.js";
3
3
 
4
4
  /**
5
5
  * Register all Findymail tools on an MCP server
@@ -188,7 +188,7 @@ export function registerTools(server) {
188
188
  same_country: z.boolean().optional().default(false).describe("When true, only return companies located in the same country as the seed company"),
189
189
  same_size: z.boolean().optional().default(false).describe("When true, only return companies with a similar employee count range as the seed company"),
190
190
  limit: z.number().optional().default(100).describe("Maximum number of results to return (min: 1, max: 10,000)"),
191
- exclusion_list_ids: z.array(z.number()).optional().default([]).describe("IDs of exclusion lists whose domains should be removed from results"),
191
+ exclusion_list_ids: z.array(z.number()).optional().default([]).describe("IDs of exclusion lists whose domains should be removed from results. Unlike `generate_lead_list`, this parameter does NOT accept the [0] / [-1] markers — pass real list IDs only (from `list_exclusion_lists`), or leave it empty for no filtering."),
192
192
  },
193
193
  async (params, extra) => {
194
194
  const {
@@ -226,7 +226,7 @@ export function registerTools(server) {
226
226
  // ===========================================================================
227
227
  server.tool(
228
228
  "generate_lead_list",
229
- "Lead list generation tool. Searches a B2B database of 100M+ companies and contacts to build targeted lead lists. Returns structured data including verified email addresses, phone numbers, company details, and LinkedIn profiles — data that web search cannot provide. This is the ONLY way to get verified contact emails and phone numbers. Use this for any request to find, search, list, or generate lists of companies, leads, contacts, or prospects. Accepts natural language queries (e.g., 'SaaS companies in the USA with 50+ employees', 'Marketing managers at tech startups in NYC'). Returns a hash — you MUST then call `get_lead_list_results` with that hash to retrieve results.",
229
+ "AI-powered company discovery from a natural language description of your ideal customer. This is a semantic search, not a database lookup: your query is parsed by an LLM into structured filters plus a semantic intent, which is then matched against company descriptions using vector similarity — so describe the kind of company you are looking for rather than listing exact filter values. In 'targeted' mode, each candidate company is additionally scraped and qualified by AI. Matching companies can be enriched with contacts, verified email addresses and phone numbers — this is the ONLY way to get verified contact emails and phone numbers. Use this for any request to find, search, list, or generate lists of companies, leads, contacts, or prospects. Accepts natural language queries (e.g., 'SaaS companies in the USA with 50+ employees', 'Marketing managers at tech startups in NYC'). Returns a hash — you MUST then call `get_lead_list_results` with that hash to retrieve results.",
230
230
  {
231
231
  query: z.string().describe("Natural language description of what you're looking for (max 1000 characters)"),
232
232
  limit: z.number().optional().default(100).describe("Maximum number of results (default: 100, max: 5000)"),
@@ -235,6 +235,8 @@ export function registerTools(server) {
235
235
  target_job_titles: z.array(z.string()).optional().default(["CEO"]).describe("Job titles to target when find_contact is true (e.g., ['CEO', 'CTO', 'VP Sales'])"),
236
236
  find_email: z.boolean().optional().default(true).describe("Enrich contacts with email (+1 credit/email found). Requires find_contact: true"),
237
237
  find_phone: z.boolean().optional().default(false).describe("Enrich contacts with phone (+10 credits/phone found). Requires find_contact: true"),
238
+ exclusion_list_ids: z.array(z.number()).optional().describe("IDs of exclusion lists whose domains must be filtered out of the results. Omit this parameter to keep the default behaviour. [0] means \"every exclusion source you can reach\" (your global exclusions plus every list you own or share) — NOT just the global one. [-1] disables exclusion filtering entirely, and so does an empty array. Never mix these markers with real list IDs: [0, 12] silently ignores 12 and filters on everything, and [-1, 12] silently disables filtering altogether. Pass either exactly [0], exactly [-1], or real list IDs — never a mixture. Get them from `list_exclusion_lists`."),
239
+ add_to_exclusion_list_id: z.number().optional().describe("ID of an exclusion list to automatically add every exported company domain to, so later searches never return them again. The domains are written once, at the very end of the export: nothing is added if the export fails, and if that final write itself fails the export is still reported as successful — check with `list_exclusion_domains` when it matters. The server does not verify that the list belongs to you, so only pass an ID returned by `list_exclusion_lists`, or create one with `create_exclusion_list`."),
238
240
  },
239
241
  async (params, extra) => {
240
242
  const {
@@ -245,6 +247,8 @@ export function registerTools(server) {
245
247
  target_job_titles = ["CEO"],
246
248
  find_email = true,
247
249
  find_phone = false,
250
+ exclusion_list_ids,
251
+ add_to_exclusion_list_id,
248
252
  } = params;
249
253
 
250
254
  log(`generate_lead_list: "${query}" (limit: ${limit}, mode: ${mode})`);
@@ -262,6 +266,18 @@ export function registerTools(server) {
262
266
  find_phone,
263
267
  };
264
268
 
269
+ // Only send the key when the caller asked for it: an absent key means
270
+ // "filter on the global exclusion list" server-side, while an empty
271
+ // array would disable exclusion filtering altogether.
272
+ if (exclusion_list_ids !== undefined) {
273
+ config.exclusion_filter_list_ids = exclusion_list_ids;
274
+ }
275
+
276
+ if (add_to_exclusion_list_id !== undefined) {
277
+ config.add_to_exclusion_list = true;
278
+ config.exclusion_list_id = add_to_exclusion_list_id;
279
+ }
280
+
265
281
  const startResult = await apiPost("/intellimatch/search", {
266
282
  query,
267
283
  limit: validatedLimit,
@@ -384,4 +400,135 @@ export function registerTools(server) {
384
400
  }
385
401
  }
386
402
  );
403
+
404
+ // ===========================================================================
405
+ // Tool: list_exclusion_lists
406
+ // ===========================================================================
407
+ server.tool(
408
+ "list_exclusion_lists",
409
+ "List the exclusion lists you can use (lists you own plus lists shared with your team). An exclusion list holds company domains that should never show up in search results. Returns each list's id, name, owner and sharing status — use those ids with `generate_lead_list` (exclusion_list_ids / add_to_exclusion_list_id), with `lookalike_search`, or with the other exclusion tools.",
410
+ {},
411
+ async (params, extra) => {
412
+ log("list_exclusion_lists");
413
+
414
+ try {
415
+ const apiKey = resolveApiKey(extra);
416
+ const data = await apiGet("/intellimatch/exclusion-lists", apiKey);
417
+ return formatResponse(data);
418
+ } catch (error) {
419
+ return formatError(error.message);
420
+ }
421
+ }
422
+ );
423
+
424
+ // ===========================================================================
425
+ // Tool: create_exclusion_list
426
+ // ===========================================================================
427
+ server.tool(
428
+ "create_exclusion_list",
429
+ "Create a new, empty exclusion list and return its id. Add domains to it with `add_exclusion_domains`, or let a search fill it automatically via `generate_lead_list`'s add_to_exclusion_list_id. List names must be unique per user. If is_shared is true and you do not belong to a team, the list is still created but the call returns an error — do not retry with the same name, it would then fail as a duplicate. Call `list_exclusion_lists` to check before retrying.",
430
+ {
431
+ name: z.string().describe("Name of the list (max 255 characters, must be unique among your lists, e.g. \"Competitors\")"),
432
+ is_shared: z.boolean().optional().default(false).describe("Share the list with your current team. Fails if you do not belong to a team."),
433
+ },
434
+ async ({ name, is_shared = false }, extra) => {
435
+ log(`create_exclusion_list: name="${name}" is_shared=${is_shared}`);
436
+
437
+ try {
438
+ const apiKey = resolveApiKey(extra);
439
+ const data = await apiPost("/intellimatch/exclusion-lists", { name, is_shared }, apiKey);
440
+ return formatResponse(data);
441
+ } catch (error) {
442
+ return formatError(error.message);
443
+ }
444
+ }
445
+ );
446
+
447
+ // ===========================================================================
448
+ // Tool: list_exclusion_domains
449
+ // ===========================================================================
450
+ server.tool(
451
+ "list_exclusion_domains",
452
+ "List the domains held by an exclusion list, paginated. Each domain is returned with its own id — those ids are what `remove_exclusion_domains` needs, so call this first when you want to remove domains. Omitting list_id does NOT return only your global exclusions: it returns EVERY domain you can reach — your global ones, every list you own, AND every list shared with your team. To act on the global exclusions only, keep the entries whose `excluded_domain_list_id` is null. Always pass an explicit list_id before deleting anything. Results are ordered by domain name alone, so an entry can move between pages — re-read the page before using an id.",
453
+ {
454
+ list_id: z.number().optional().describe("Exclusion list to read. Must be >= 1 — passing 0 returns a 422 error. Omit the parameter to list every domain you can reach (see the tool description). Get ids from `list_exclusion_lists`."),
455
+ query: z.string().optional().describe("Filter domains containing this text (max 100 characters, e.g. \"competitor\")"),
456
+ page: z.number().optional().default(1).describe("Page number (default: 1)"),
457
+ per_page: z.number().optional().default(15).describe("Domains per page (default: 15, max: 100)"),
458
+ },
459
+ async ({ list_id, query, page = 1, per_page = 15 }, extra) => {
460
+ log(`list_exclusion_domains: list_id=${list_id ?? "global"} query=${query ?? "-"} page=${page}`);
461
+
462
+ try {
463
+ const apiKey = resolveApiKey(extra);
464
+
465
+ const searchParams = new URLSearchParams({
466
+ page: String(Math.max(1, page)),
467
+ per_page: String(Math.min(Math.max(1, per_page), 100)),
468
+ });
469
+ if (list_id !== undefined) searchParams.set("list_id", String(list_id));
470
+ if (query) searchParams.set("query", query);
471
+
472
+ const data = await apiGet(`/intellimatch/domains?${searchParams.toString()}`, apiKey);
473
+ return formatResponse(data);
474
+ } catch (error) {
475
+ return formatError(error.message);
476
+ }
477
+ }
478
+ );
479
+
480
+ // ===========================================================================
481
+ // Tool: add_exclusion_domains
482
+ // ===========================================================================
483
+ server.tool(
484
+ "add_exclusion_domains",
485
+ "Add company domains to an exclusion list so they stop appearing in search results. Omit list_id to add them to your global exclusions instead. Domains are reduced to their registrable form before storage: protocol, path and ALL subdomains are stripped, so \"careers.acme.com\" and \"https://www.acme.com/jobs\" both become \"acme.com\" and exclude the whole company. Entries that cannot be parsed as a domain are dropped silently and are not reported back. The response counters do NOT reflect what was stored: `total` and `processed_immediately` count the entries you sent, dropped ones included, so `total: 4` can mean 3 domains excluded — read the list back with `list_exclusion_domains` to know what landed. Large batches are accepted (max 10,000): the first 50 domains are applied immediately and the rest are queued in the background, so a search started right away will only account for the first 50.",
486
+ {
487
+ domains: z.array(z.string()).describe("Company domains to exclude (max 10,000, each max 255 characters, e.g. [\"competitor.com\", \"blocked.io\"])"),
488
+ list_id: z.number().optional().describe("Exclusion list to add the domains to. Omit to add them as global exclusions — 0 does the same here, unlike `list_exclusion_domains` where 0 is rejected with a 422. Get ids from `list_exclusion_lists`."),
489
+ },
490
+ async ({ domains, list_id }, extra) => {
491
+ log(`add_exclusion_domains: ${domains.length} domain(s) to list_id=${list_id ?? "global"}`);
492
+
493
+ try {
494
+ const apiKey = resolveApiKey(extra);
495
+
496
+ const body = { domains };
497
+ if (list_id !== undefined) body.list_id = list_id;
498
+
499
+ const data = await apiPost("/intellimatch/domains", body, apiKey);
500
+ return formatResponse(data);
501
+ } catch (error) {
502
+ return formatError(error.message);
503
+ }
504
+ }
505
+ );
506
+
507
+ // ===========================================================================
508
+ // Tool: remove_exclusion_domains
509
+ // ===========================================================================
510
+ server.tool(
511
+ "remove_exclusion_domains",
512
+ "Remove domains from an exclusion list, making them eligible for search results again. Takes domain ids, NOT domain names — call `list_exclusion_domains` first to resolve names into ids. Deletion is permanent: there is no undo and no soft delete. If none of the ids are yours to delete the call fails with a 403 rather than reporting a count of zero; if only some are, the others are dropped silently and the response does not say which. On a team-shared list you are allowed to delete domains added by teammates, so check the list before deleting. Ids obtained right after a large `add_exclusion_domains` may be stale.",
513
+ {
514
+ ids: z.array(z.number()).describe("Ids of the domains to remove (max 1000), as returned by `list_exclusion_domains`"),
515
+ },
516
+ async ({ ids }, extra) => {
517
+ log(`remove_exclusion_domains: ${ids.length} id(s)`);
518
+
519
+ try {
520
+ const apiKey = resolveApiKey(extra);
521
+ const data = await apiDelete("/intellimatch/domains", { ids }, apiKey);
522
+ return formatResponse(data);
523
+ } catch (error) {
524
+ // abort(403) carries no reason of its own — say what it means here
525
+ if (error.status === 403) {
526
+ return formatError(
527
+ `${error.message}. None of the ids you passed belong to you or to a list you may edit, so nothing was deleted. Re-read the ids with \`list_exclusion_domains\` on an explicit list_id.`
528
+ );
529
+ }
530
+ return formatError(error.message);
531
+ }
532
+ }
533
+ );
387
534
  }