@kantadev/cli 0.1.7 → 0.1.8
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 +2 -2
- package/package.json +1 -1
- package/server.json +2 -2
- package/src/cli/commands/db/export.js +1 -0
- package/src/cli/commands/db/index.js +2 -2
- package/src/cli/commands/login.js +31 -28
- package/src/cli/context.js +4 -0
- package/src/core/stdin.js +24 -0
- package/src/mcp/server.js +21 -1
- package/src/mcp/tools/database.js +9 -7
package/README.md
CHANGED
|
@@ -136,9 +136,9 @@ kanta --profile admin db ca-count # CCPA California-record monitor (admin)
|
|
|
136
136
|
| `--company <text>` | company name prefix |
|
|
137
137
|
| `--company-domain <domain…>` | company domain(s) |
|
|
138
138
|
| `--industry <name…>` | company industry/industries |
|
|
139
|
-
| `--employee-range <range…>` |
|
|
139
|
+
| `--employee-range <range…>` | 1-10, 11-50, 51-199, 200-499, 500-999, 1000-4999, 5000-9999, 10000-49999, 50000+, Unknown |
|
|
140
140
|
| `--has-email` / `--has-linkedin` / `--has-phone` | presence filters |
|
|
141
|
-
| `--verification-status <s…>` |
|
|
141
|
+
| `--verification-status <s…>` | valid, catch_all, risky, unknown, invalid |
|
|
142
142
|
| `--filter-file <path>` | raw JSON filter object, merged under the flags |
|
|
143
143
|
|
|
144
144
|
Company flags: `--query`, `--domain`, `--industry`, `--employee-range`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kantadev/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "Kanta CLI + MCP server — email verification, email finding, and the Kanta B2B contact database from your terminal or an MCP client.",
|
|
5
5
|
"mcpName": "dev.kanta/cli",
|
|
6
6
|
"type": "module",
|
package/server.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
3
|
"name": "dev.kanta/cli",
|
|
4
4
|
"description": "Kanta Verify, Find, and Database: email verification, email finding, and B2B contact search.",
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.8",
|
|
6
6
|
"repository": {
|
|
7
7
|
"url": "https://github.com/griffinkanta/kanta-dev",
|
|
8
8
|
"source": "github",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
{
|
|
13
13
|
"registryType": "npm",
|
|
14
14
|
"identifier": "@kantadev/cli",
|
|
15
|
-
"version": "0.1.
|
|
15
|
+
"version": "0.1.8",
|
|
16
16
|
"runtimeHint": "npx",
|
|
17
17
|
"packageArguments": [
|
|
18
18
|
{
|
|
@@ -63,6 +63,7 @@ export async function runExportFlow(config, client, deps = {}) {
|
|
|
63
63
|
|
|
64
64
|
const parts = [`Delivered ${Number(status.delivered || 0).toLocaleString()} rows`];
|
|
65
65
|
if (status.suppressed) parts.push(`${Number(status.suppressed).toLocaleString()} suppressed`);
|
|
66
|
+
if (status.duplicates) parts.push(`${Number(status.duplicates).toLocaleString()} duplicate emails skipped`);
|
|
66
67
|
if (status.truncated) parts.push('truncated (credit balance ran out)');
|
|
67
68
|
const msg = `${parts.join(', ')} -> ${config.output}`;
|
|
68
69
|
process.stdout.write(msg + '\n');
|
|
@@ -17,11 +17,11 @@ export function personFilterOptions(cmd) {
|
|
|
17
17
|
.option('--company <text>', 'company name (prefix match)')
|
|
18
18
|
.option('--company-domain <domain...>', 'company domain(s)')
|
|
19
19
|
.option('--industry <name...>', 'company industry/industries')
|
|
20
|
-
.option('--employee-range <range...>', 'company
|
|
20
|
+
.option('--employee-range <range...>', 'company size band(s): 1-10, 11-50, 51-199, 200-499, 500-999, 1000-4999, 5000-9999, 10000-49999, 50000+, Unknown')
|
|
21
21
|
.option('--has-email', 'only records with an email')
|
|
22
22
|
.option('--has-linkedin', 'only records with a LinkedIn URL')
|
|
23
23
|
.option('--has-phone', 'only records with a phone')
|
|
24
|
-
.option('--verification-status <s...>', 'email
|
|
24
|
+
.option('--verification-status <s...>', 'email status: valid, catch_all, risky, unknown, invalid')
|
|
25
25
|
.option('--filter-file <path>', 'raw JSON filter object, merged under the flags');
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -41,6 +41,14 @@ async function readKey() {
|
|
|
41
41
|
return Buffer.concat(chunks).toString('utf8').trim();
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
async function saveKey(key, { profile, baseUrl, json }) {
|
|
45
|
+
const client = new KantaClient({ key, baseUrl });
|
|
46
|
+
const me = await client.getMe();
|
|
47
|
+
setProfile(profile, { key, base_url: baseUrl });
|
|
48
|
+
if (json) return printJson({ saved: profile, email: me.email, scope: me.scope });
|
|
49
|
+
process.stdout.write(`Saved profile "${profile}" (${me.email}, scope: ${me.scope}) to ${configPath()}\n`);
|
|
50
|
+
}
|
|
51
|
+
|
|
44
52
|
export function registerLogin(program) {
|
|
45
53
|
program
|
|
46
54
|
.command('login')
|
|
@@ -56,35 +64,30 @@ export function registerLogin(program) {
|
|
|
56
64
|
const profile = globalOpts(cmd).profile || opts.profile;
|
|
57
65
|
const baseUrl = opts.baseUrl || DEFAULT_BASE_URL;
|
|
58
66
|
const json = globalOpts(cmd).json;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
clientName: `${hostname()} (kanta CLI)`.slice(0, 64),
|
|
64
|
-
openUrl: opts.browser ? undefined : () => { throw new Error('no browser'); },
|
|
65
|
-
onCode: (s) => {
|
|
66
|
-
if (json) return;
|
|
67
|
-
process.stdout.write(
|
|
68
|
-
`Your code: ${s.user_code}\n` +
|
|
69
|
-
`${opts.browser ? 'Opening' : 'Open'} ${s.verification_uri_complete}\n` +
|
|
70
|
-
'Approve it in the browser; waiting...\n',
|
|
71
|
-
);
|
|
72
|
-
},
|
|
73
|
-
}).catch((err) => { throw new CliExit(err.message); });
|
|
74
|
-
setProfile(profile, { key: apiKey, base_url: baseUrl });
|
|
75
|
-
if (json) return printJson({ saved: profile, email });
|
|
76
|
-
process.stdout.write(`Signed in as ${email || 'your account'}. Saved profile "${profile}" to ${configPath()}\n`);
|
|
77
|
-
return;
|
|
67
|
+
if (opts.key) {
|
|
68
|
+
const key = await readKey();
|
|
69
|
+
if (!key) throw new CliExit('No key entered.');
|
|
70
|
+
return saveKey(key, { profile, baseUrl, json });
|
|
78
71
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
72
|
+
// Piped input (echo $KEY | kanta login) keeps working as a key login.
|
|
73
|
+
const piped = deps.stdinIsTTY ? '' : await deps.readPipedInput();
|
|
74
|
+
if (piped) return saveKey(piped, { profile, baseUrl, json });
|
|
75
|
+
const { apiKey, email } = await deps.browserLogin({
|
|
76
|
+
baseUrl,
|
|
77
|
+
clientName: `${hostname()} (kanta CLI)`.slice(0, 64),
|
|
78
|
+
openUrl: opts.browser ? undefined : () => { throw new Error('no browser'); },
|
|
79
|
+
onCode: (s) => {
|
|
80
|
+
if (json) return;
|
|
81
|
+
process.stdout.write(
|
|
82
|
+
`Your code: ${s.user_code}\n` +
|
|
83
|
+
`${opts.browser ? 'Opening' : 'Open'} ${s.verification_uri_complete}\n` +
|
|
84
|
+
'Approve it in the browser; waiting...\n',
|
|
85
|
+
);
|
|
86
|
+
},
|
|
87
|
+
}).catch((err) => { throw new CliExit(err.message); });
|
|
88
|
+
setProfile(profile, { key: apiKey, base_url: baseUrl });
|
|
89
|
+
if (json) return printJson({ saved: profile, email });
|
|
90
|
+
process.stdout.write(`Signed in as ${email || 'your account'}. Saved profile "${profile}" to ${configPath()}\n`);
|
|
88
91
|
}),
|
|
89
92
|
);
|
|
90
93
|
|
package/src/cli/context.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Shared helpers for CLI commands.
|
|
2
2
|
import { browserLogin as realBrowserLogin } from '../core/browserLogin.js';
|
|
3
|
+
import { readPipedInput } from '../core/stdin.js';
|
|
3
4
|
import { resolveColumns } from '../core/bulkInput.js';
|
|
4
5
|
import { readFileSync, existsSync, writeFileSync } from 'node:fs';
|
|
5
6
|
import { createInterface } from 'node:readline';
|
|
@@ -46,6 +47,9 @@ export function defaultDeps() {
|
|
|
46
47
|
return realBrowserLogin(opts);
|
|
47
48
|
},
|
|
48
49
|
stdinIsTTY: Boolean(process.stdin.isTTY),
|
|
50
|
+
readPipedInput() {
|
|
51
|
+
return readPipedInput();
|
|
52
|
+
},
|
|
49
53
|
confirm(question) {
|
|
50
54
|
return defaultConfirm(question);
|
|
51
55
|
},
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Non-interactive stdin: a piped key (echo $KEY | kanta login) arrives at once.
|
|
2
|
+
// An empty or idle stdin (scripts, IDEs, agents) means there's no key to read,
|
|
3
|
+
// so the caller falls back to browser sign-in instead of failing.
|
|
4
|
+
export function readPipedInput({ stdin = process.stdin, waitMs = 1000 } = {}) {
|
|
5
|
+
return new Promise((resolve) => {
|
|
6
|
+
const chunks = [];
|
|
7
|
+
let done = false;
|
|
8
|
+
const finish = () => {
|
|
9
|
+
if (done) return;
|
|
10
|
+
done = true;
|
|
11
|
+
clearTimeout(timer);
|
|
12
|
+
stdin.removeListener('data', onData);
|
|
13
|
+
stdin.removeListener('end', finish);
|
|
14
|
+
stdin.removeListener('error', finish);
|
|
15
|
+
stdin.destroy?.();
|
|
16
|
+
resolve(Buffer.concat(chunks).toString('utf8').trim());
|
|
17
|
+
};
|
|
18
|
+
const onData = (c) => chunks.push(Buffer.from(c));
|
|
19
|
+
const timer = setTimeout(() => { if (!chunks.length) finish(); }, waitMs);
|
|
20
|
+
stdin.on('data', onData);
|
|
21
|
+
stdin.on('end', finish);
|
|
22
|
+
stdin.on('error', finish);
|
|
23
|
+
});
|
|
24
|
+
}
|
package/src/mcp/server.js
CHANGED
|
@@ -31,6 +31,26 @@ export async function resolveIdentity() {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
// Told to the MCP client on connect, so the agent knows whose account (and
|
|
35
|
+
// credits) every tool call uses before it plans a search or an export.
|
|
36
|
+
export function identityInstructions(identity) {
|
|
37
|
+
if (!identity || identity.offline) {
|
|
38
|
+
return 'Kanta could not confirm which account this API key belongs to at startup. ' +
|
|
39
|
+
'Call kanta_account before spending credits to see the account and its balances.';
|
|
40
|
+
}
|
|
41
|
+
const fmt = n => Number(n ?? 0).toLocaleString('en-US');
|
|
42
|
+
const c = identity.credits || {};
|
|
43
|
+
const lines = [
|
|
44
|
+
`Kanta tools act as ${identity.email} (${identity.plan || 'free'} plan, ${identity.scope} key).`,
|
|
45
|
+
`Balances at startup: Verify ${fmt(c.verify)}, Find ${fmt(c.find)}, Database ${fmt(c.db)}. Call kanta_account for current balances.`,
|
|
46
|
+
];
|
|
47
|
+
if (identity.scope !== 'admin') {
|
|
48
|
+
lines.push('kanta_db_search masks email and phone on this key; kanta_db_export returns them at 1 Database credit per row.');
|
|
49
|
+
if (!c.db) lines.push('This account has no Database credits, so kanta_db_export will fail until credits are added.');
|
|
50
|
+
}
|
|
51
|
+
return lines.join(' ');
|
|
52
|
+
}
|
|
53
|
+
|
|
34
54
|
export async function startServer() {
|
|
35
55
|
const { key, baseUrl, dbBaseUrl } = resolveKey({
|
|
36
56
|
profile: process.env.KANTA_PROFILE,
|
|
@@ -42,7 +62,7 @@ export async function startServer() {
|
|
|
42
62
|
|
|
43
63
|
const server = new Server(
|
|
44
64
|
{ name: 'kanta', version: VERSION },
|
|
45
|
-
{ capabilities: { tools: {} } },
|
|
65
|
+
{ capabilities: { tools: {} }, instructions: identityInstructions(identity) },
|
|
46
66
|
);
|
|
47
67
|
|
|
48
68
|
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
@@ -12,12 +12,13 @@ const FILTER_SCHEMA = {
|
|
|
12
12
|
description:
|
|
13
13
|
'Kanta DB person filter. Keys: query (free text), seniority[] (C-Suite, VP, Director, Manager, …), ' +
|
|
14
14
|
'function[], title, title_exact[], person_country[], person_state[], company, company_domain[], ' +
|
|
15
|
-
'industry[], employee_range[] (e.g. "51-
|
|
16
|
-
'verification_status[]
|
|
15
|
+
'industry[], employee_range[] (e.g. "51-199"), has_email, has_linkedin, has_phone. ' +
|
|
16
|
+
'verification_status[] (valid, catch_all, risky, unknown, invalid). All list keys accept a bare string too. ' +
|
|
17
17
|
'industry takes industry names case-insensitively (e.g. "Software Development", "software") and ' +
|
|
18
18
|
'includes sub-industries; kanta_db_industries lists them. person_country (aliases like "USA", "UK"), ' +
|
|
19
|
-
'person_state (abbreviations like "CA", "ON") and function match case-insensitively
|
|
20
|
-
'takes size bands: 1-10, 11-50, 51-
|
|
19
|
+
'person_state (abbreviations like "CA", "ON") and function match case-insensitively; a function also ' +
|
|
20
|
+
'matches people listed under several functions. employee_range takes size bands: 1-10, 11-50, 51-199, ' +
|
|
21
|
+
'200-499, 500-999, 1000-4999, 5000-9999, 10000-49999, 50000+, Unknown (by headcount where known). ' +
|
|
21
22
|
'Unknown values return suggestions. title_exact matches exactly.',
|
|
22
23
|
};
|
|
23
24
|
|
|
@@ -29,7 +30,8 @@ const COMPANY_FILTER_SCHEMA = {
|
|
|
29
30
|
'hq_state[], employees_min, employees_max, revenue_min_k, revenue_max_k, ' +
|
|
30
31
|
'founded_after (year), min_contacts. industry takes industry names case-insensitively and includes ' +
|
|
31
32
|
'sub-industries; hq_country / hq_state accept aliases and abbreviations; employee_range takes the ' +
|
|
32
|
-
'size bands 1-10
|
|
33
|
+
'size bands 1-10, 11-50, 51-199, 200-499, 500-999, 1000-4999, 5000-9999, 10000-49999, 50000+, Unknown. ' +
|
|
34
|
+
'domain matches stored values exactly.',
|
|
33
35
|
};
|
|
34
36
|
|
|
35
37
|
const realSleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
@@ -42,7 +44,7 @@ async function saveExport(client, id, output) {
|
|
|
42
44
|
const path = resolve(output);
|
|
43
45
|
writeFileSync(path, csv);
|
|
44
46
|
const rows = Math.max(0, String(csv).trim().split('\n').length - 1);
|
|
45
|
-
return { id, rows, output: path, delivered: status.delivered, suppressed: status.suppressed, truncated: status.truncated };
|
|
47
|
+
return { id, rows, output: path, delivered: status.delivered, suppressed: status.suppressed, duplicates: status.duplicates ?? 0, truncated: status.truncated };
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
function errResult(text) {
|
|
@@ -180,7 +182,7 @@ export const databaseTools = [
|
|
|
180
182
|
},
|
|
181
183
|
{
|
|
182
184
|
name: 'kanta_db_export_status',
|
|
183
|
-
description: 'Check a Kanta Database export job: status, rows delivered, rows suppressed.',
|
|
185
|
+
description: 'Check a Kanta Database export job: status, rows delivered, rows suppressed, duplicate emails skipped.',
|
|
184
186
|
inputSchema: {
|
|
185
187
|
type: 'object',
|
|
186
188
|
properties: { id: { type: 'string' } },
|