@agifyai/leadify-mcp 7.1.1 → 7.1.2
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/dist/tools/organizations.js +66 -0
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
1
2
|
import { getClient } from "../client.js";
|
|
2
3
|
import { toolResult, handleToolError } from "../types.js";
|
|
3
4
|
export function registerOrganizationTools(server) {
|
|
@@ -14,4 +15,69 @@ export function registerOrganizationTools(server) {
|
|
|
14
15
|
return handleToolError(error);
|
|
15
16
|
}
|
|
16
17
|
});
|
|
18
|
+
server.tool("list_lead_groups", "List lead groups visible in one explicitly selected organization. Returns a compact " +
|
|
19
|
+
"navigation view only: id, name, organizationId, lead count, published and refresh state. " +
|
|
20
|
+
"Start with discover_leadify_context when no organization_id is known.", {
|
|
21
|
+
organization_id: z.string().describe("Organization ID explicitly selected from list_organizations or discover_leadify_context."),
|
|
22
|
+
limit: z.number().int().min(1).max(100).optional().default(50).describe("Maximum groups returned, bounded to 100."),
|
|
23
|
+
}, async ({ organization_id, limit }) => {
|
|
24
|
+
try {
|
|
25
|
+
const params = new URLSearchParams({ organizationId: organization_id });
|
|
26
|
+
const data = await getClient().get("/api/lead-groups", params);
|
|
27
|
+
const groups = Array.isArray(data.leadGroups)
|
|
28
|
+
? data.leadGroups
|
|
29
|
+
: [];
|
|
30
|
+
return toolResult({
|
|
31
|
+
organizationId: organization_id,
|
|
32
|
+
leadGroups: groups.slice(0, limit).map((group) => ({
|
|
33
|
+
id: group.id,
|
|
34
|
+
name: group.name,
|
|
35
|
+
organizationId: group.organizationId,
|
|
36
|
+
leadCount: group._count?.leads ?? 0,
|
|
37
|
+
published: group.published ?? false,
|
|
38
|
+
refreshEnabled: group.refreshEnabled ?? false,
|
|
39
|
+
})),
|
|
40
|
+
total: groups.length,
|
|
41
|
+
truncated: groups.length > limit,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
return handleToolError(error);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
server.tool("discover_leadify_context", "Safe zero-ID entry point for Leadify. With no organization_id, lists accessible organizations " +
|
|
49
|
+
"and never chooses one when several are available. With an explicit organization_id, returns " +
|
|
50
|
+
"a compact list of its lead groups. Use the returned lead_group_id with lead, campaign, persona " +
|
|
51
|
+
"and data-room tools.", {
|
|
52
|
+
organization_id: z.string().optional().describe("Organization selected explicitly after discovery. Omit only for the first step."),
|
|
53
|
+
limit: z.number().int().min(1).max(100).optional().default(50).describe("Maximum lead groups returned after selection."),
|
|
54
|
+
}, async ({ organization_id, limit }) => {
|
|
55
|
+
try {
|
|
56
|
+
const orgData = await getClient().get("/api/organizations");
|
|
57
|
+
const organizations = Array.isArray(orgData.organizations)
|
|
58
|
+
? orgData.organizations.map((org) => ({ id: org.id, name: org.name ?? null, slug: org.slug ?? null }))
|
|
59
|
+
: [];
|
|
60
|
+
if (!organization_id) {
|
|
61
|
+
if (organizations.length !== 1) {
|
|
62
|
+
return toolResult({ organizations, selectionRequired: organizations.length > 1, message: organizations.length === 0 ? "No accessible organization." : "Select organization_id explicitly before reading lead groups." });
|
|
63
|
+
}
|
|
64
|
+
organization_id = String(organizations[0].id);
|
|
65
|
+
}
|
|
66
|
+
if (!organizations.some((org) => org.id === organization_id)) {
|
|
67
|
+
return toolResult({ organizations, selectionRequired: true, message: "organization_id is not accessible to this key." });
|
|
68
|
+
}
|
|
69
|
+
const groupsData = await getClient().get("/api/lead-groups", new URLSearchParams({ organizationId: organization_id }));
|
|
70
|
+
const groups = Array.isArray(groupsData.leadGroups) ? groupsData.leadGroups : [];
|
|
71
|
+
return toolResult({
|
|
72
|
+
organization: organizations.find((org) => org.id === organization_id),
|
|
73
|
+
leadGroups: groups.slice(0, limit).map((group) => ({ id: group.id, name: group.name, leadCount: group._count?.leads ?? 0, published: group.published ?? false })),
|
|
74
|
+
total: groups.length,
|
|
75
|
+
truncated: groups.length > limit,
|
|
76
|
+
next: "Choose a lead_group_id, then use get_leads, get_data_room_context, or get_lead_group_persona.",
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
return handleToolError(error);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
17
83
|
}
|