@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,209 @@
|
|
|
1
|
+
// Kanta Database MCP tools. Same shape as tools/customer.js:
|
|
2
|
+
// { name, description, inputSchema, handler(args, { client }) -> JSON value }
|
|
3
|
+
// A handler MAY instead return a ready MCP result ({ content } / { isError })
|
|
4
|
+
// and register.js#wrapHandler will pass it through untouched.
|
|
5
|
+
|
|
6
|
+
const FILTER_SCHEMA = {
|
|
7
|
+
type: 'object',
|
|
8
|
+
additionalProperties: true,
|
|
9
|
+
description:
|
|
10
|
+
'Kanta DB person filter. Keys: query (free text), seniority[] (C-Suite, VP, Director, Manager, …), ' +
|
|
11
|
+
'function[], title, title_exact[], person_country[], person_state[], company, company_domain[], ' +
|
|
12
|
+
'industry[], employee_range[] (e.g. "51-200"), has_email, has_linkedin, has_phone. ' +
|
|
13
|
+
'verification_status[] is admin-only. All list keys accept a bare string too.',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const COMPANY_FILTER_SCHEMA = {
|
|
17
|
+
type: 'object',
|
|
18
|
+
additionalProperties: true,
|
|
19
|
+
description:
|
|
20
|
+
'Kanta DB company filter. Keys: query, domain[], industry[], employee_range[], hq_country[], ' +
|
|
21
|
+
'hq_state[], funding_stage[], employees_min, employees_max, revenue_min_k, revenue_max_k, ' +
|
|
22
|
+
'founded_after (year), min_contacts.',
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
function errResult(text) {
|
|
26
|
+
return { isError: true, content: [{ type: 'text', text }] };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const databaseTools = [
|
|
30
|
+
{
|
|
31
|
+
name: 'kanta_db_count',
|
|
32
|
+
description: 'Count people in the Kanta Database matching a filter. Free.',
|
|
33
|
+
inputSchema: { type: 'object', properties: { filter: FILTER_SCHEMA }, required: ['filter'] },
|
|
34
|
+
handler: (a, { client }) => client.dbCount(a.filter || {}),
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'kanta_db_search',
|
|
38
|
+
description:
|
|
39
|
+
'List up to 50 matching people (email/phone masked on non-admin keys). Free. ' +
|
|
40
|
+
'Use kanta_db_export for bulk extraction.',
|
|
41
|
+
inputSchema: {
|
|
42
|
+
type: 'object',
|
|
43
|
+
properties: {
|
|
44
|
+
filter: FILTER_SCHEMA,
|
|
45
|
+
limit: { type: 'integer', minimum: 1, maximum: 50 },
|
|
46
|
+
cursor: { type: 'string' },
|
|
47
|
+
},
|
|
48
|
+
required: ['filter'],
|
|
49
|
+
},
|
|
50
|
+
handler: async (a, { client }) => {
|
|
51
|
+
const limit = Math.min(a.limit || 25, 50);
|
|
52
|
+
const res = await client.dbSearch(a.filter || {}, { limit, cursor: a.cursor });
|
|
53
|
+
const records = res.records || [];
|
|
54
|
+
const total = res.total ?? records.length;
|
|
55
|
+
if (total > records.length) {
|
|
56
|
+
return {
|
|
57
|
+
...res,
|
|
58
|
+
note:
|
|
59
|
+
`${Number(total).toLocaleString()}${res.exact === false ? '+' : ''} people match — ` +
|
|
60
|
+
'only the first page is shown. Narrow the filter or use kanta_db_export.',
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return res;
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'kanta_db_facets',
|
|
68
|
+
description: 'Term breakdowns (counts by value) for a person segment. Free. Max 5 fields.',
|
|
69
|
+
inputSchema: {
|
|
70
|
+
type: 'object',
|
|
71
|
+
properties: {
|
|
72
|
+
filter: FILTER_SCHEMA,
|
|
73
|
+
fields: { type: 'array', items: { type: 'string' }, minItems: 1, maxItems: 5 },
|
|
74
|
+
},
|
|
75
|
+
required: ['filter', 'fields'],
|
|
76
|
+
},
|
|
77
|
+
handler: (a, { client }) => client.dbFacets(a.filter || {}, a.fields || []),
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: 'kanta_db_lookup',
|
|
81
|
+
description: 'Find one person by email, LinkedIn URL, or name + company domain. Free.',
|
|
82
|
+
inputSchema: {
|
|
83
|
+
type: 'object',
|
|
84
|
+
properties: {
|
|
85
|
+
email: { type: 'string' },
|
|
86
|
+
linkedin_url: { type: 'string' },
|
|
87
|
+
name: { type: 'string' },
|
|
88
|
+
domain: { type: 'string' },
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
handler: (a, { client }) => {
|
|
92
|
+
let params;
|
|
93
|
+
if (a.email) params = { email: a.email };
|
|
94
|
+
else if (a.linkedin_url) params = { linkedin_url: a.linkedin_url };
|
|
95
|
+
else if (a.name && a.domain) params = { name: a.name, domain: a.domain };
|
|
96
|
+
else return errResult('Provide email, linkedin_url, or both name and domain.');
|
|
97
|
+
return client.dbLookup(params);
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: 'kanta_db_export',
|
|
102
|
+
description:
|
|
103
|
+
'Export matching people to a CSV job. Costs 1 db_credit per row delivered (admin keys are not charged). ' +
|
|
104
|
+
'Call kanta_db_count first, then set confirm_credits to the number of credits you intend to spend ' +
|
|
105
|
+
'(normally equal to max). Poll the job with kanta_db_export_status.',
|
|
106
|
+
inputSchema: {
|
|
107
|
+
type: 'object',
|
|
108
|
+
properties: {
|
|
109
|
+
filter: FILTER_SCHEMA,
|
|
110
|
+
max: { type: 'integer', minimum: 1, description: 'maximum rows to export' },
|
|
111
|
+
confirm_credits: {
|
|
112
|
+
type: 'integer',
|
|
113
|
+
minimum: 1,
|
|
114
|
+
description: 'credits you authorize spending; must equal the API-computed estimated_max',
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
required: ['filter', 'max', 'confirm_credits'],
|
|
118
|
+
},
|
|
119
|
+
handler: async (a, { client }) => {
|
|
120
|
+
try {
|
|
121
|
+
const job = await client.dbExport(a.filter || {}, a.max, a.confirm_credits);
|
|
122
|
+
return {
|
|
123
|
+
job_id: job.job_id || job.id,
|
|
124
|
+
estimated_max: job.estimated_max,
|
|
125
|
+
note: 'Export started. Poll kanta_db_export_status with this job_id.',
|
|
126
|
+
};
|
|
127
|
+
} catch (err) {
|
|
128
|
+
if (err && err.code === 'confirm_credits_required') {
|
|
129
|
+
const est = err.extra && err.extra.estimated_max;
|
|
130
|
+
return errResult(
|
|
131
|
+
`confirm_credits must equal ${est} (the API-capped affordable maximum). ` +
|
|
132
|
+
`Retry kanta_db_export with confirm_credits: ${est}. ` +
|
|
133
|
+
'Run kanta_db_count first if you need to review the match size.',
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
throw err;
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
name: 'kanta_db_export_status',
|
|
142
|
+
description: 'Check a Kanta Database export job: status, rows delivered, rows suppressed.',
|
|
143
|
+
inputSchema: {
|
|
144
|
+
type: 'object',
|
|
145
|
+
properties: { id: { type: 'string' } },
|
|
146
|
+
required: ['id'],
|
|
147
|
+
},
|
|
148
|
+
handler: (a, { client }) => client.getExport(a.id),
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
name: 'kanta_db_companies_count',
|
|
152
|
+
description: 'Count companies (organizations) in the Kanta Database matching a filter. Free.',
|
|
153
|
+
inputSchema: { type: 'object', properties: { filter: COMPANY_FILTER_SCHEMA }, required: ['filter'] },
|
|
154
|
+
handler: (a, { client }) => client.companiesCount(a.filter || {}),
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
name: 'kanta_db_companies_search',
|
|
158
|
+
description: 'List companies matching a filter, sorted by contact count. Free.',
|
|
159
|
+
inputSchema: {
|
|
160
|
+
type: 'object',
|
|
161
|
+
properties: {
|
|
162
|
+
filter: COMPANY_FILTER_SCHEMA,
|
|
163
|
+
limit: { type: 'integer', minimum: 1, maximum: 50 },
|
|
164
|
+
cursor: { type: 'string' },
|
|
165
|
+
},
|
|
166
|
+
required: ['filter'],
|
|
167
|
+
},
|
|
168
|
+
handler: (a, { client }) =>
|
|
169
|
+
client.companiesSearch(a.filter || {}, { limit: Math.min(a.limit || 25, 50), cursor: a.cursor }),
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
name: 'kanta_db_companies_facets',
|
|
173
|
+
description: 'Term breakdowns for a company segment. Free. Max 5 fields.',
|
|
174
|
+
inputSchema: {
|
|
175
|
+
type: 'object',
|
|
176
|
+
properties: {
|
|
177
|
+
filter: COMPANY_FILTER_SCHEMA,
|
|
178
|
+
fields: { type: 'array', items: { type: 'string' }, minItems: 1, maxItems: 5 },
|
|
179
|
+
},
|
|
180
|
+
required: ['filter', 'fields'],
|
|
181
|
+
},
|
|
182
|
+
handler: (a, { client }) => client.companiesFacets(a.filter || {}, a.fields || []),
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
name: 'kanta_db_company_contacts',
|
|
186
|
+
description: 'List people at one company by its Kanta org id. Free (masked per key scope).',
|
|
187
|
+
inputSchema: {
|
|
188
|
+
type: 'object',
|
|
189
|
+
properties: {
|
|
190
|
+
kanta_org_id: { type: 'string' },
|
|
191
|
+
limit: { type: 'integer', minimum: 1, maximum: 50 },
|
|
192
|
+
cursor: { type: 'string' },
|
|
193
|
+
},
|
|
194
|
+
required: ['kanta_org_id'],
|
|
195
|
+
},
|
|
196
|
+
handler: (a, { client }) =>
|
|
197
|
+
client.companyContacts(a.kanta_org_id, { limit: Math.min(a.limit || 25, 50), cursor: a.cursor }),
|
|
198
|
+
},
|
|
199
|
+
];
|
|
200
|
+
|
|
201
|
+
export const databaseAdminTools = [
|
|
202
|
+
{
|
|
203
|
+
name: 'kanta_db_ca_count',
|
|
204
|
+
description:
|
|
205
|
+
'California-resident record count for the CCPA data-broker threshold monitor. Admin only.',
|
|
206
|
+
inputSchema: { type: 'object', properties: {} },
|
|
207
|
+
handler: (_a, { client }) => client.dbCaCount(),
|
|
208
|
+
},
|
|
209
|
+
];
|