@agifyai/leadify-mcp 8.4.1 → 8.5.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 +4 -1
- package/dist/server.js +3 -2
- package/dist/tools/auth.d.ts +5 -1
- package/dist/tools/auth.js +31 -2
- package/dist/tools/leads.js +49 -14
- package/dist/version.d.ts +3 -0
- package/dist/version.js +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@ Serveur MCP (Model Context Protocol) pour l'API Leadify. Expose les endpoints RE
|
|
|
4
4
|
|
|
5
5
|
Package npm : [`@agifyai/leadify-mcp`](https://www.npmjs.com/package/@agifyai/leadify-mcp)
|
|
6
6
|
|
|
7
|
+
`get_mcp_runtime_info` est le diagnostic de livraison en lecture seule. Il expose la version exacte du package et du serveur, puis vérifie qu'un `organization_id` explicitement choisi est accessible à la clé configurée. Il ne lit aucun prospect et n'effectue aucune écriture, aucun envoi, aucune publication ni activation.
|
|
8
|
+
|
|
7
9
|
---
|
|
8
10
|
|
|
9
11
|
## 📦 Pour les utilisateurs
|
|
@@ -198,7 +200,8 @@ Pour `add_leads` et `update_lead`, `location` utilise l’objet canonique
|
|
|
198
200
|
`{ city, region?, postalCode?, countryCode, street? }`. `city` et le code pays
|
|
199
201
|
ISO-2 `countryCode` sont obligatoires. La projection `geo` est calculée par
|
|
200
202
|
Leadify et ne doit jamais être envoyée par un agent MCP.
|
|
201
|
-
| `
|
|
203
|
+
| `preview_reset_sequence_messages` / `execute_reset_sequence_messages` | Prévisualiser puis effacer irréversiblement les messages générés d'un prospect, d'une liste explicite ou d'un groupe explicite. L'exécution exige le digest de preview et une clé d'idempotence. |
|
|
204
|
+
| `preview_reset_ai_fields` / `execute_reset_ai_fields` | Prévisualiser puis effacer irréversiblement les champs IA d'un prospect, d'une liste explicite ou d'un groupe explicite, sans toucher aux contacts, flags manuels, activités ou campagnes. |
|
|
202
205
|
| `delete_leads` | Supprimer définitivement des leads par leurs IDs. |
|
|
203
206
|
| `update_schema` | Ajouter ou modifier les définitions de champs d'un groupe. |
|
|
204
207
|
| `delete_columns` | Supprimer des colonnes du schéma et des données d'un groupe. |
|
package/dist/server.js
CHANGED
|
@@ -15,10 +15,11 @@ import { registerFineTuningTools } from "./tools/fine_tuning.js";
|
|
|
15
15
|
import { registerContextWorkspaceTools } from "./tools/context_workspace.js";
|
|
16
16
|
import { registerLeadViewTools } from "./tools/views.js";
|
|
17
17
|
import { registerRelationshipTools } from "./tools/relationships.js";
|
|
18
|
+
import { MCP_SERVER_NAME, MCP_VERSION } from "./version.js";
|
|
18
19
|
export function createServer() {
|
|
19
20
|
const server = new McpServer({
|
|
20
|
-
name:
|
|
21
|
-
version:
|
|
21
|
+
name: MCP_SERVER_NAME,
|
|
22
|
+
version: MCP_VERSION,
|
|
22
23
|
});
|
|
23
24
|
registerAuthTools(server);
|
|
24
25
|
registerOrganizationTools(server);
|
package/dist/tools/auth.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
|
|
2
|
+
import { getClient } from "../client.js";
|
|
3
|
+
type ReadClient = Pick<ReturnType<typeof getClient>, "get">;
|
|
4
|
+
export declare function projectMcpRuntimeInfo(data: unknown, organizationId: string): Record<string, unknown>;
|
|
5
|
+
export declare function registerAuthTools(server: McpServer, injectedClient?: ReadClient): void;
|
|
6
|
+
export {};
|
package/dist/tools/auth.js
CHANGED
|
@@ -1,16 +1,45 @@
|
|
|
1
1
|
import { getClient } from "../client.js";
|
|
2
2
|
import { toolResult, handleToolError } from "../types.js";
|
|
3
|
-
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { MCP_PACKAGE_NAME, MCP_SERVER_NAME, MCP_VERSION } from "../version.js";
|
|
5
|
+
export function projectMcpRuntimeInfo(data, organizationId) {
|
|
6
|
+
const source = data && typeof data === "object" ? data : {};
|
|
7
|
+
const organizations = Array.isArray(source.organizations) ? source.organizations : [];
|
|
8
|
+
const organization = organizations.find((candidate) => candidate.id === organizationId);
|
|
9
|
+
return {
|
|
10
|
+
package: MCP_PACKAGE_NAME,
|
|
11
|
+
server: MCP_SERVER_NAME,
|
|
12
|
+
version: MCP_VERSION,
|
|
13
|
+
organization: organization ? { id: organization.id, name: organization.name ?? null, slug: organization.slug ?? null } : null,
|
|
14
|
+
organizationAccessible: Boolean(organization),
|
|
15
|
+
readOnly: true,
|
|
16
|
+
writes: 0,
|
|
17
|
+
sends: 0,
|
|
18
|
+
externalActivation: 0,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export function registerAuthTools(server, injectedClient) {
|
|
4
22
|
server.tool("test_api_key", "Verify that the configured Leadify API key is valid and has not been revoked. " +
|
|
5
23
|
"Returns a success message if the key is active. Use this as a health check " +
|
|
6
24
|
"before performing other operations, or to diagnose authentication errors " +
|
|
7
25
|
"(401/403) from other tools.", {}, async () => {
|
|
8
26
|
try {
|
|
9
|
-
const data = await getClient().get("/test-api-key");
|
|
27
|
+
const data = await (injectedClient ?? getClient()).get("/test-api-key");
|
|
10
28
|
return toolResult(data);
|
|
11
29
|
}
|
|
12
30
|
catch (error) {
|
|
13
31
|
return handleToolError(error);
|
|
14
32
|
}
|
|
15
33
|
});
|
|
34
|
+
server.tool("get_mcp_runtime_info", "Read the exact Leadify MCP package/server version and verify that one explicitly selected organization is accessible to the configured API key. This diagnostic is read-only: it never reads prospects and never writes, sends, schedules, publishes, or activates anything.", {
|
|
35
|
+
organization_id: z.string().min(1).describe("Exact organization ID selected by the caller. The server never chooses an organization implicitly."),
|
|
36
|
+
}, async ({ organization_id }) => {
|
|
37
|
+
try {
|
|
38
|
+
const data = await (injectedClient ?? getClient()).get("/api/organizations");
|
|
39
|
+
return toolResult(projectMcpRuntimeInfo(data, organization_id));
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
return handleToolError(error);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
16
45
|
}
|
package/dist/tools/leads.js
CHANGED
|
@@ -33,6 +33,31 @@ const leadUpdateSchema = z.object({
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
+
const destructiveResetScopeShape = {
|
|
37
|
+
organization_id: z.string().trim().min(1).describe("Explicit organization ID. The server verifies tenant access and admin permission."),
|
|
38
|
+
scope: z.enum(["lead", "lead_ids", "lead_group"]).describe("Exactly one explicit target scope; no implicit group or organization selection is allowed."),
|
|
39
|
+
lead_id: z.string().trim().min(1).optional().describe("Required only when scope is lead."),
|
|
40
|
+
lead_ids: z.array(z.string().trim().min(1)).min(1).max(100).optional().describe("Required only when scope is lead_ids; unique JSON list of lead IDs."),
|
|
41
|
+
lead_group_id: z.string().trim().min(1).optional().describe("Required only when scope is lead_group."),
|
|
42
|
+
};
|
|
43
|
+
const destructiveResetScopeSchema = z.object(destructiveResetScopeShape).superRefine((value, context) => {
|
|
44
|
+
const exactly = value.scope === "lead" ? Boolean(value.lead_id) && !value.lead_ids && !value.lead_group_id
|
|
45
|
+
: value.scope === "lead_ids" ? !value.lead_id && Boolean(value.lead_ids) && !value.lead_group_id
|
|
46
|
+
: !value.lead_id && !value.lead_ids && Boolean(value.lead_group_id);
|
|
47
|
+
if (!exactly)
|
|
48
|
+
context.addIssue({ code: z.ZodIssueCode.custom, message: "Provide exactly the identifier required by scope and no other target identifier." });
|
|
49
|
+
if (value.lead_ids && new Set(value.lead_ids).size !== value.lead_ids.length)
|
|
50
|
+
context.addIssue({ code: z.ZodIssueCode.custom, path: ["lead_ids"], message: "lead_ids must not contain duplicates." });
|
|
51
|
+
});
|
|
52
|
+
function resetScopePayload(value) {
|
|
53
|
+
return {
|
|
54
|
+
organizationId: value.organization_id,
|
|
55
|
+
scope: value.scope,
|
|
56
|
+
...(value.scope === "lead" ? { leadId: value.lead_id } : {}),
|
|
57
|
+
...(value.scope === "lead_ids" ? { leadIds: value.lead_ids } : {}),
|
|
58
|
+
...(value.scope === "lead_group" ? { leadGroupId: value.lead_group_id } : {}),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
36
61
|
function projectLead(lead, fields) {
|
|
37
62
|
const source = lead && typeof lead === "object" ? lead : {};
|
|
38
63
|
const data = source.data && typeof source.data === "object" ? source.data : {};
|
|
@@ -51,6 +76,30 @@ function compactLeadsResponse(data, fields, includeSchema) {
|
|
|
51
76
|
return result;
|
|
52
77
|
}
|
|
53
78
|
export function registerLeadTools(server, client = getClient()) {
|
|
79
|
+
for (const reset of [
|
|
80
|
+
{ key: "sequence_messages", label: "generated sequence messages" },
|
|
81
|
+
{ key: "ai_fields", label: "AI-generated fields" },
|
|
82
|
+
]) {
|
|
83
|
+
const route = reset.key === "sequence_messages" ? "sequence-messages" : "ai-fields";
|
|
84
|
+
server.tool(`preview_reset_${reset.key}`, `Preview the irreversible reset of ${reset.label}. This is non-mutating and returns the mandatory previewDigest, exact lead IDs and fields that would be cleared. Select one explicit scope only.`, destructiveResetScopeShape, async (params) => {
|
|
85
|
+
try {
|
|
86
|
+
const checked = destructiveResetScopeSchema.parse(params);
|
|
87
|
+
return toolResult(await client.post(`/api/resets/${route}/preview`, resetScopePayload(checked)));
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
return handleToolError(error);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
server.tool(`execute_reset_${reset.key}`, `IRREVERSIBLE: execute the ${reset.label} reset only after its preview. Requires that preview's exact digest and a unique idempotency key; the result includes persisted readback. This never sends outreach or changes campaigns, activities or contacts.`, { ...destructiveResetScopeShape, preview_digest: z.string().regex(/^[a-f0-9]{64}$/), idempotency_key: z.string().trim().min(8).max(200) }, async (params) => {
|
|
94
|
+
try {
|
|
95
|
+
const checked = destructiveResetScopeSchema.parse(params);
|
|
96
|
+
return toolResult(await client.post(`/api/resets/${route}/execute`, { ...resetScopePayload(checked), previewDigest: params.preview_digest, idempotencyKey: params.idempotency_key }));
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
return handleToolError(error);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
54
103
|
// ── add_leads ──────────────────────────────────────────────────────────
|
|
55
104
|
server.tool("add_leads", "Add one or more leads to a specific lead group in Leadify. Provide the group ID " +
|
|
56
105
|
"and an array of lead objects with any combination of fields (email, firstName, " +
|
|
@@ -231,20 +280,6 @@ export function registerLeadTools(server, client = getClient()) {
|
|
|
231
280
|
return handleToolError(error);
|
|
232
281
|
}
|
|
233
282
|
});
|
|
234
|
-
// ── delete_sequence_messages ──────────────────────────────────────────
|
|
235
|
-
server.tool("delete_sequence_messages", "Permanently remove only the generated LinkedIn and email sequence messages for one lead. " +
|
|
236
|
-
"It does not modify the lead's contact data, qualification, activities, campaign state, or any other fields. " +
|
|
237
|
-
"This action is irreversible: obtain explicit user confirmation before calling it.", {
|
|
238
|
-
lead_id: z.string().describe("ID of the lead whose generated sequence messages must be removed."),
|
|
239
|
-
}, async ({ lead_id }) => {
|
|
240
|
-
try {
|
|
241
|
-
const data = await client.post("/api/delete-sequence-messages", { leadId: lead_id });
|
|
242
|
-
return toolResult(data);
|
|
243
|
-
}
|
|
244
|
-
catch (error) {
|
|
245
|
-
return handleToolError(error);
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
283
|
// ── delete_leads ───────────────────────────────────────────────────────
|
|
249
284
|
server.tool("delete_leads", "Permanently delete one or more leads by their IDs. This action is irreversible. " +
|
|
250
285
|
"Returns the count and IDs of deleted leads. If some leads are not found or " +
|
package/dist/version.js
ADDED