@kantadev/cli 0.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.
- package/README.md +223 -0
- package/bin/kanta-mcp.js +8 -0
- package/bin/kanta.js +7 -0
- package/package.json +58 -0
- package/server.json +43 -0
- package/src/cli/commands/account.js +22 -0
- package/src/cli/commands/admin/index.js +136 -0
- package/src/cli/commands/credits.js +25 -0
- package/src/cli/commands/db/companies.js +133 -0
- package/src/cli/commands/db/export.js +137 -0
- package/src/cli/commands/db/index.js +190 -0
- package/src/cli/commands/find.js +57 -0
- package/src/cli/commands/jobs.js +106 -0
- package/src/cli/commands/login.js +120 -0
- package/src/cli/commands/verify.js +44 -0
- package/src/cli/context.js +134 -0
- package/src/cli/format.js +39 -0
- package/src/cli/index.js +42 -0
- package/src/core/auth.js +79 -0
- package/src/core/client.js +293 -0
- package/src/core/config.js +93 -0
- package/src/core/dbFilter.js +72 -0
- package/src/core/errors.js +65 -0
- package/src/core/identity.js +30 -0
- package/src/mcp/register.js +31 -0
- package/src/mcp/server.js +72 -0
- package/src/mcp/tools/admin.js +77 -0
- package/src/mcp/tools/customer.js +165 -0
- package/src/mcp/tools/database.js +209 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Compile parsed commander options into the canonical Kanta Database filter
|
|
2
|
+
// object (spec §5 / §6). These builders only *shape* flags — they do not
|
|
3
|
+
// validate against the API's rules (the API does that) — and merge a raw
|
|
4
|
+
// --filter-file object underneath the flag-built one (flags win on conflict).
|
|
5
|
+
import fs from 'node:fs';
|
|
6
|
+
|
|
7
|
+
function applyMaps(opts, out, arrayMap, stringMap = {}, boolMap = {}) {
|
|
8
|
+
for (const [flag, key] of Object.entries(arrayMap)) {
|
|
9
|
+
if (opts[flag] != null) out[key] = Array.isArray(opts[flag]) ? opts[flag] : [opts[flag]];
|
|
10
|
+
}
|
|
11
|
+
for (const [flag, key] of Object.entries(stringMap)) {
|
|
12
|
+
if (opts[flag] != null) out[key] = String(opts[flag]);
|
|
13
|
+
}
|
|
14
|
+
for (const [flag, key] of Object.entries(boolMap)) {
|
|
15
|
+
if (opts[flag]) out[key] = true;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function loadFilterFile(opts, io) {
|
|
20
|
+
if (!opts.filterFile) return {};
|
|
21
|
+
const parsed = JSON.parse(io.readFileSync(opts.filterFile, 'utf8'));
|
|
22
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
23
|
+
throw new Error(`--filter-file ${opts.filterFile} must contain a JSON object`);
|
|
24
|
+
}
|
|
25
|
+
return parsed;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const PERSON_ARRAY = {
|
|
29
|
+
seniority: 'seniority',
|
|
30
|
+
function: 'function',
|
|
31
|
+
titleExact: 'title_exact',
|
|
32
|
+
country: 'person_country',
|
|
33
|
+
state: 'person_state',
|
|
34
|
+
companyDomain: 'company_domain',
|
|
35
|
+
industry: 'industry',
|
|
36
|
+
employeeRange: 'employee_range',
|
|
37
|
+
verificationStatus: 'verification_status',
|
|
38
|
+
};
|
|
39
|
+
const PERSON_STRING = { query: 'query', title: 'title', company: 'company' };
|
|
40
|
+
const PERSON_BOOL = { hasEmail: 'has_email', hasLinkedin: 'has_linkedin', hasPhone: 'has_phone' };
|
|
41
|
+
|
|
42
|
+
export function buildPersonFilter(opts = {}, io = fs) {
|
|
43
|
+
const out = { ...loadFilterFile(opts, io) };
|
|
44
|
+
applyMaps(opts, out, PERSON_ARRAY, PERSON_STRING, PERSON_BOOL);
|
|
45
|
+
return out;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const CO_ARRAY = {
|
|
49
|
+
domain: 'domain',
|
|
50
|
+
industry: 'industry',
|
|
51
|
+
employeeRange: 'employee_range',
|
|
52
|
+
hqCountry: 'hq_country',
|
|
53
|
+
hqState: 'hq_state',
|
|
54
|
+
fundingStage: 'funding_stage',
|
|
55
|
+
};
|
|
56
|
+
const CO_NUM = {
|
|
57
|
+
employeesMin: 'employees_min',
|
|
58
|
+
employeesMax: 'employees_max',
|
|
59
|
+
revenueMinK: 'revenue_min_k',
|
|
60
|
+
revenueMaxK: 'revenue_max_k',
|
|
61
|
+
foundedAfter: 'founded_after',
|
|
62
|
+
minContacts: 'min_contacts',
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export function buildCompanyFilter(opts = {}, io = fs) {
|
|
66
|
+
const out = { ...loadFilterFile(opts, io) };
|
|
67
|
+
applyMaps(opts, out, CO_ARRAY, { query: 'query' });
|
|
68
|
+
for (const [flag, key] of Object.entries(CO_NUM)) {
|
|
69
|
+
if (opts[flag] != null) out[key] = Math.trunc(Number(opts[flag]));
|
|
70
|
+
}
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Typed errors for the Kanta CLI/MCP core.
|
|
2
|
+
|
|
3
|
+
export class KantaApiError extends Error {
|
|
4
|
+
constructor(message, { status, code, extra } = {}) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.name = 'KantaApiError';
|
|
7
|
+
this.status = status ?? null;
|
|
8
|
+
this.code = code ?? null;
|
|
9
|
+
this.extra = extra ?? {};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class KantaConfigError extends Error {
|
|
14
|
+
constructor(message) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.name = 'KantaConfigError';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class KantaAuthError extends Error {
|
|
21
|
+
constructor(message) {
|
|
22
|
+
super(message);
|
|
23
|
+
this.name = 'KantaAuthError';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Map a KantaApiError (or network error) to a human sentence for the CLI.
|
|
28
|
+
export function humanizeError(err, { baseUrl } = {}) {
|
|
29
|
+
if (err instanceof KantaApiError) {
|
|
30
|
+
switch (err.code) {
|
|
31
|
+
case 'insufficient_credits':
|
|
32
|
+
return 'Not enough credits. Top up at app.kanta.dev/pricing.';
|
|
33
|
+
case 'invalid_api_key':
|
|
34
|
+
case 'missing_api_key':
|
|
35
|
+
case 'api_key_expired':
|
|
36
|
+
return 'Key rejected. Run: kanta login';
|
|
37
|
+
case 'admin_required':
|
|
38
|
+
return 'This command requires an admin profile. The active profile is a standard key.';
|
|
39
|
+
case 'admin_filter':
|
|
40
|
+
return 'The --verification-status filter requires an admin profile.';
|
|
41
|
+
case 'es_unavailable':
|
|
42
|
+
return 'Kanta Database is temporarily unavailable. Try again shortly.';
|
|
43
|
+
case 'confirm_credits_required': {
|
|
44
|
+
const est = err.extra?.estimated_max;
|
|
45
|
+
return est != null
|
|
46
|
+
? `Export needs confirmation. Re-run with --max ${est} (or pass --yes to auto-confirm).`
|
|
47
|
+
: 'Export needs a confirm-credits value. Run the count first.';
|
|
48
|
+
}
|
|
49
|
+
default:
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
if (err.status === 402) return 'Not enough credits. Top up at app.kanta.dev/pricing.';
|
|
53
|
+
if (err.status === 401) return 'Key rejected. Run: kanta login';
|
|
54
|
+
if (err.status === 403) return 'This command requires an admin profile. The active profile is a standard key.';
|
|
55
|
+
if (err.status === 429) return 'Rate limited — retry in a few seconds.';
|
|
56
|
+
return err.message || `Request failed (${err.status}).`;
|
|
57
|
+
}
|
|
58
|
+
if (err instanceof KantaConfigError || err instanceof KantaAuthError) {
|
|
59
|
+
return err.message;
|
|
60
|
+
}
|
|
61
|
+
if (err && (err.code === 'ENOTFOUND' || err.code === 'ECONNREFUSED' || err.code === 'ETIMEDOUT' || err.name === 'AbortError')) {
|
|
62
|
+
return `Cannot reach ${baseUrl || 'the API'}. Check your connection or KANTA_BASE_URL.`;
|
|
63
|
+
}
|
|
64
|
+
return err?.message || 'Unknown error.';
|
|
65
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// whoami() — resolve the caller's identity via GET /me, cached per process.
|
|
2
|
+
import { KantaClient } from './client.js';
|
|
3
|
+
import { resolveKey } from './auth.js';
|
|
4
|
+
|
|
5
|
+
let _cache = null;
|
|
6
|
+
|
|
7
|
+
export async function whoami({ profile, apiKey, baseUrl, fetchImpl, force } = {}) {
|
|
8
|
+
if (_cache && !force) return _cache;
|
|
9
|
+
const { key, baseUrl: resolvedBase, source, profile: resolvedProfile } = resolveKey({ profile, apiKey, baseUrl });
|
|
10
|
+
const client = new KantaClient({ key, baseUrl: resolvedBase, fetchImpl });
|
|
11
|
+
const me = await client.getMe();
|
|
12
|
+
_cache = {
|
|
13
|
+
email: me.email,
|
|
14
|
+
plan: me.plan,
|
|
15
|
+
scope: me.scope || 'user',
|
|
16
|
+
credits: {
|
|
17
|
+
verify: me.verify_credits ?? 0,
|
|
18
|
+
find: me.find_credits ?? 0,
|
|
19
|
+
db: me.db_credits ?? 0,
|
|
20
|
+
},
|
|
21
|
+
profile: resolvedProfile ?? null,
|
|
22
|
+
source,
|
|
23
|
+
baseUrl: resolvedBase,
|
|
24
|
+
};
|
|
25
|
+
return _cache;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function resetIdentityCache() {
|
|
29
|
+
_cache = null;
|
|
30
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Build the MCP tool list. Admin tools are appended only when scope === 'admin'.
|
|
2
|
+
// customerTools / adminTools already include the Kanta Database tools
|
|
3
|
+
// (tools/database.js is spread into them).
|
|
4
|
+
import { customerTools } from './tools/customer.js';
|
|
5
|
+
import { adminTools } from './tools/admin.js';
|
|
6
|
+
|
|
7
|
+
export function buildToolList(scope) {
|
|
8
|
+
return scope === 'admin' ? [...customerTools, ...adminTools] : [...customerTools];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// Wrap a tool handler so it never throws raw — errors come back as MCP isError content.
|
|
12
|
+
export function wrapHandler(tool, { client }) {
|
|
13
|
+
return async (args) => {
|
|
14
|
+
try {
|
|
15
|
+
const result = await tool.handler(args || {}, { client });
|
|
16
|
+
// A handler may return a ready MCP result (e.g. an actionable error).
|
|
17
|
+
if (result && typeof result === 'object' && (Array.isArray(result.content) || result.isError === true)) {
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
22
|
+
};
|
|
23
|
+
} catch (err) {
|
|
24
|
+
const detail = err?.status ? ` (HTTP ${err.status}${err.code ? `, ${err.code}` : ''})` : '';
|
|
25
|
+
return {
|
|
26
|
+
isError: true,
|
|
27
|
+
content: [{ type: 'text', text: `${err?.message || 'Tool failed'}${detail}` }],
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Kanta MCP stdio server. Resolves the API key (env or config), calls GET /me
|
|
3
|
+
// once to learn the scope, then registers customer tools (plus admin tools when
|
|
4
|
+
// the key is admin-scoped).
|
|
5
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
6
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
7
|
+
import {
|
|
8
|
+
ListToolsRequestSchema,
|
|
9
|
+
CallToolRequestSchema,
|
|
10
|
+
} from '@modelcontextprotocol/sdk/types.js';
|
|
11
|
+
import { KantaClient } from '../core/client.js';
|
|
12
|
+
import { resolveKey } from '../core/auth.js';
|
|
13
|
+
import { whoami } from '../core/identity.js';
|
|
14
|
+
import { buildToolList, wrapHandler } from './register.js';
|
|
15
|
+
|
|
16
|
+
// Resolve the caller's scope via GET /me, but never block startup on it:
|
|
17
|
+
// the server must boot offline (first-run UX, sandboxed clients). On any
|
|
18
|
+
// failure fall back to the customer tool set and warn on stderr.
|
|
19
|
+
export async function resolveIdentity() {
|
|
20
|
+
try {
|
|
21
|
+
return await whoami({});
|
|
22
|
+
} catch (err) {
|
|
23
|
+
process.stderr.write(
|
|
24
|
+
`kanta-mcp: could not verify identity (${err?.message || err}); ` +
|
|
25
|
+
'starting with customer tools only. Admin tools appear once the API is reachable.\n',
|
|
26
|
+
);
|
|
27
|
+
return { scope: 'user', offline: true };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export async function startServer() {
|
|
32
|
+
const { key, baseUrl, dbBaseUrl } = resolveKey({
|
|
33
|
+
profile: process.env.KANTA_PROFILE,
|
|
34
|
+
});
|
|
35
|
+
const client = new KantaClient({ key, baseUrl, dbBaseUrl });
|
|
36
|
+
const identity = await resolveIdentity();
|
|
37
|
+
const tools = buildToolList(identity.scope);
|
|
38
|
+
const handlers = new Map(tools.map(t => [t.name, wrapHandler(t, { client })]));
|
|
39
|
+
|
|
40
|
+
const server = new Server(
|
|
41
|
+
{ name: 'kanta', version: '0.1.0' },
|
|
42
|
+
{ capabilities: { tools: {} } },
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
46
|
+
tools: tools.map(t => ({
|
|
47
|
+
name: t.name,
|
|
48
|
+
description: t.description,
|
|
49
|
+
inputSchema: t.inputSchema,
|
|
50
|
+
})),
|
|
51
|
+
}));
|
|
52
|
+
|
|
53
|
+
server.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
54
|
+
const handler = handlers.get(req.params.name);
|
|
55
|
+
if (!handler) {
|
|
56
|
+
return { isError: true, content: [{ type: 'text', text: `Unknown tool: ${req.params.name}` }] };
|
|
57
|
+
}
|
|
58
|
+
return handler(req.params.arguments);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const transport = new StdioServerTransport();
|
|
62
|
+
await server.connect(transport);
|
|
63
|
+
return { server, tools, identity };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const isMain = process.argv[1] && import.meta.url === `file://${process.argv[1]}`;
|
|
67
|
+
if (isMain) {
|
|
68
|
+
startServer().catch((err) => {
|
|
69
|
+
process.stderr.write(`kanta-mcp failed to start: ${err?.message || err}\n`);
|
|
70
|
+
process.exit(1);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Admin MCP tools — only registered when the resolving key has scope === 'admin'.
|
|
2
|
+
import { databaseAdminTools } from './database.js';
|
|
3
|
+
|
|
4
|
+
export const adminTools = [
|
|
5
|
+
{
|
|
6
|
+
name: 'kanta_admin_credits_add',
|
|
7
|
+
description: 'Grant credits to a user. Identify the user by email or user_id. The grant is always recorded as an "admin_topup" on the ledger; "note" is free text kept alongside it.',
|
|
8
|
+
inputSchema: {
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
email: { type: 'string' },
|
|
12
|
+
user_id: { type: 'string' },
|
|
13
|
+
product: { type: 'string', enum: ['verify', 'find', 'db'] },
|
|
14
|
+
amount: { type: 'number' },
|
|
15
|
+
note: { type: 'string', description: 'free-text note for the ledger entry' },
|
|
16
|
+
},
|
|
17
|
+
required: ['product', 'amount'],
|
|
18
|
+
},
|
|
19
|
+
handler: (a, { client }) =>
|
|
20
|
+
client.adminAddCredits({
|
|
21
|
+
email: a.email,
|
|
22
|
+
userId: a.user_id,
|
|
23
|
+
product: a.product,
|
|
24
|
+
amount: a.amount,
|
|
25
|
+
label: a.note ?? a.reason,
|
|
26
|
+
}),
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'kanta_admin_jobs_list',
|
|
30
|
+
description: 'List jobs across all users. Optional status and user (email) filters.',
|
|
31
|
+
inputSchema: {
|
|
32
|
+
type: 'object',
|
|
33
|
+
properties: { status: { type: 'string' }, user: { type: 'string' } },
|
|
34
|
+
},
|
|
35
|
+
handler: (a, { client }) => client.adminListJobs({ status: a.status, user: a.user }),
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'kanta_admin_user',
|
|
39
|
+
description: 'Show a user account, credit balances, and last 10 jobs.',
|
|
40
|
+
inputSchema: {
|
|
41
|
+
type: 'object',
|
|
42
|
+
properties: { email: { type: 'string' }, user_id: { type: 'string' } },
|
|
43
|
+
},
|
|
44
|
+
handler: (a, { client }) => client.adminGetUser({ email: a.email, userId: a.user_id }),
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: 'kanta_admin_verify',
|
|
48
|
+
description: 'Verify an email with no credit charge.',
|
|
49
|
+
inputSchema: {
|
|
50
|
+
type: 'object',
|
|
51
|
+
properties: { email: { type: 'string' } },
|
|
52
|
+
required: ['email'],
|
|
53
|
+
},
|
|
54
|
+
handler: (a, { client }) => client.adminVerify(a.email),
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'kanta_admin_suppress_add',
|
|
58
|
+
description: 'Add an email or domain to the suppression list (auto-detected by "@").',
|
|
59
|
+
inputSchema: {
|
|
60
|
+
type: 'object',
|
|
61
|
+
properties: { value: { type: 'string' } },
|
|
62
|
+
required: ['value'],
|
|
63
|
+
},
|
|
64
|
+
handler: (a, { client }) => client.adminSuppressAdd(a.value),
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'kanta_admin_suppress_check',
|
|
68
|
+
description: 'Check whether an email is suppressed (by exact email or by domain).',
|
|
69
|
+
inputSchema: {
|
|
70
|
+
type: 'object',
|
|
71
|
+
properties: { email: { type: 'string' } },
|
|
72
|
+
required: ['email'],
|
|
73
|
+
},
|
|
74
|
+
handler: (a, { client }) => client.adminSuppressCheck(a.email),
|
|
75
|
+
},
|
|
76
|
+
...databaseAdminTools,
|
|
77
|
+
];
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
// Customer MCP tools. Each entry: { name, description, inputSchema, handler }.
|
|
2
|
+
// handler(args, { client }) -> any JSON-serialisable value.
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
4
|
+
import { parse as csvParse } from 'csv-parse/sync';
|
|
5
|
+
import { databaseTools } from './database.js';
|
|
6
|
+
|
|
7
|
+
const INLINE_ROW_CAP = 100;
|
|
8
|
+
|
|
9
|
+
function loadEmails(args) {
|
|
10
|
+
if (Array.isArray(args.emails)) return args.emails.filter(Boolean);
|
|
11
|
+
if (args.path) {
|
|
12
|
+
const rows = csvParse(readFileSync(args.path, 'utf8'), { columns: true, skip_empty_lines: true, trim: true });
|
|
13
|
+
return rows.map(r => r.email).filter(Boolean);
|
|
14
|
+
}
|
|
15
|
+
throw new Error('Provide either "emails" (array) or "path" (CSV with an email column).');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function loadContacts(args) {
|
|
19
|
+
if (Array.isArray(args.contacts)) return args.contacts;
|
|
20
|
+
if (args.path) {
|
|
21
|
+
const rows = csvParse(readFileSync(args.path, 'utf8'), { columns: true, skip_empty_lines: true, trim: true });
|
|
22
|
+
return rows.map(r => ({ firstName: r.first_name, lastName: r.last_name, company: r.company }));
|
|
23
|
+
}
|
|
24
|
+
throw new Error('Provide either "contacts" (array) or "path" (CSV with first_name,last_name,company).');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function capResults(out) {
|
|
28
|
+
const rows = out.results || [];
|
|
29
|
+
if (rows.length > INLINE_ROW_CAP) {
|
|
30
|
+
return {
|
|
31
|
+
job_id: out.job_id,
|
|
32
|
+
total: out.total,
|
|
33
|
+
note: `${rows.length} rows — too many to return inline. Re-run with an "output" path or use the CLI: kanta jobs results ${out.job_id} -o results.csv`,
|
|
34
|
+
sample: rows.slice(0, INLINE_ROW_CAP),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const customerTools = [
|
|
41
|
+
{
|
|
42
|
+
name: 'kanta_verify_email',
|
|
43
|
+
description: 'Verify a single email address. Returns status (valid/invalid/risky/unknown) and signal flags.',
|
|
44
|
+
inputSchema: {
|
|
45
|
+
type: 'object',
|
|
46
|
+
properties: { email: { type: 'string', description: 'Email address to verify' } },
|
|
47
|
+
required: ['email'],
|
|
48
|
+
},
|
|
49
|
+
handler: (a, { client }) => client.verifySingle(a.email),
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'kanta_verify_bulk',
|
|
53
|
+
description: 'Submit a bulk email verification job. Provide "emails" (array) or "path" (CSV with an email column). Returns a job_id.',
|
|
54
|
+
inputSchema: {
|
|
55
|
+
type: 'object',
|
|
56
|
+
properties: {
|
|
57
|
+
emails: { type: 'array', items: { type: 'string' } },
|
|
58
|
+
path: { type: 'string', description: 'Path to a CSV file with an "email" column' },
|
|
59
|
+
filename: { type: 'string' },
|
|
60
|
+
webhook: { type: 'string' },
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
handler: (a, { client }) =>
|
|
64
|
+
client.verifyBulk(loadEmails(a), { filename: a.filename, webhook: a.webhook }),
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'kanta_find_email',
|
|
68
|
+
description:
|
|
69
|
+
'Find one email from first name, last name, and company. Synchronous — returns ' +
|
|
70
|
+
'{ email, confidence, method, pattern } inline, or { email: null } on a miss. ' +
|
|
71
|
+
'A find credit is charged only on a hit. Use kanta_find_bulk for many contacts.',
|
|
72
|
+
inputSchema: {
|
|
73
|
+
type: 'object',
|
|
74
|
+
properties: {
|
|
75
|
+
first_name: { type: 'string' },
|
|
76
|
+
last_name: { type: 'string' },
|
|
77
|
+
company: { type: 'string', description: 'Company name or domain' },
|
|
78
|
+
},
|
|
79
|
+
required: ['first_name', 'last_name', 'company'],
|
|
80
|
+
},
|
|
81
|
+
handler: (a, { client }) =>
|
|
82
|
+
client.findSingle({ firstName: a.first_name, lastName: a.last_name, company: a.company }),
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: 'kanta_find_bulk',
|
|
86
|
+
description: 'Submit a bulk find job. Provide "contacts" (array of {firstName,lastName,company}) or "path" (CSV). Returns a job_id.',
|
|
87
|
+
inputSchema: {
|
|
88
|
+
type: 'object',
|
|
89
|
+
properties: {
|
|
90
|
+
contacts: {
|
|
91
|
+
type: 'array',
|
|
92
|
+
items: {
|
|
93
|
+
type: 'object',
|
|
94
|
+
properties: {
|
|
95
|
+
firstName: { type: 'string' },
|
|
96
|
+
lastName: { type: 'string' },
|
|
97
|
+
company: { type: 'string' },
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
path: { type: 'string' },
|
|
102
|
+
filename: { type: 'string' },
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
handler: (a, { client }) => client.findBulk(loadContacts(a), { filename: a.filename }),
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: 'kanta_jobs_list',
|
|
109
|
+
description: 'List your recent verify/find jobs.',
|
|
110
|
+
inputSchema: {
|
|
111
|
+
type: 'object',
|
|
112
|
+
properties: { status: { type: 'string' } },
|
|
113
|
+
},
|
|
114
|
+
handler: (a, { client }) => client.listJobs({ status: a.status }),
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: 'kanta_job_get',
|
|
118
|
+
description: 'Get one job status and progress. Set breakdown=true for verify status counts.',
|
|
119
|
+
inputSchema: {
|
|
120
|
+
type: 'object',
|
|
121
|
+
properties: { id: { type: 'string' }, breakdown: { type: 'boolean' } },
|
|
122
|
+
required: ['id'],
|
|
123
|
+
},
|
|
124
|
+
handler: async (a, { client }) => {
|
|
125
|
+
const job = await client.getJob(a.id);
|
|
126
|
+
if (a.breakdown) job.breakdown = await client.getJobBreakdown(a.id);
|
|
127
|
+
return job;
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
name: 'kanta_job_results',
|
|
132
|
+
description: 'Fetch job results. Inline output is capped at 100 rows; larger jobs return a sample and a CLI hint.',
|
|
133
|
+
inputSchema: {
|
|
134
|
+
type: 'object',
|
|
135
|
+
properties: { id: { type: 'string' } },
|
|
136
|
+
required: ['id'],
|
|
137
|
+
},
|
|
138
|
+
handler: async (a, { client }) => capResults(await client.getJobResults(a.id)),
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
name: 'kanta_job_cancel',
|
|
142
|
+
description: 'Cancel a running verify job.',
|
|
143
|
+
inputSchema: { type: 'object', properties: { id: { type: 'string' } }, required: ['id'] },
|
|
144
|
+
handler: (a, { client }) => client.cancelJob(a.id),
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: 'kanta_job_delete',
|
|
148
|
+
description: 'Delete a finished job.',
|
|
149
|
+
inputSchema: { type: 'object', properties: { id: { type: 'string' } }, required: ['id'] },
|
|
150
|
+
handler: (a, { client }) => client.deleteJob(a.id),
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
name: 'kanta_account',
|
|
154
|
+
description: 'Show your account email, plan, and verify/find/db credit balances.',
|
|
155
|
+
inputSchema: { type: 'object', properties: {} },
|
|
156
|
+
handler: (_a, { client }) => client.getAccount(),
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
name: 'kanta_credits',
|
|
160
|
+
description: 'Show your credit ledger (last 20 entries) and balances.',
|
|
161
|
+
inputSchema: { type: 'object', properties: {} },
|
|
162
|
+
handler: (_a, { client }) => client.getCredits(),
|
|
163
|
+
},
|
|
164
|
+
...databaseTools,
|
|
165
|
+
];
|