@jclvsh/iris 0.7.0 → 0.9.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/dist/cli-utils.d.ts +54 -0
- package/dist/cli-utils.js +94 -1
- package/dist/commands/keys.js +11 -0
- package/dist/tools/agent-credits.js +3 -18
- package/dist/tools/ai.js +5 -36
- package/dist/tools/analytics.js +6 -42
- package/dist/tools/billing.js +2 -9
- package/dist/tools/campaigns.js +12 -99
- package/dist/tools/channels.js +4 -27
- package/dist/tools/contacts.js +9 -72
- package/dist/tools/conversations.js +6 -45
- package/dist/tools/discovery.js +5 -36
- package/dist/tools/keys.js +16 -33
- package/dist/tools/messages.js +7 -54
- package/dist/tools/notifications.js +5 -36
- package/dist/tools/webhooks.js +9 -72
- package/dist/types.d.ts +2 -0
- package/package.json +1 -1
package/dist/cli-utils.d.ts
CHANGED
|
@@ -1,4 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared CLI + MCP output helpers.
|
|
3
|
+
*
|
|
4
|
+
* The CLI consumes these for terminal output (table / JSON / structured exit
|
|
5
|
+
* codes). MCP tools consume `formatMcpError` so error responses surface the
|
|
6
|
+
* structured `{success, error: {code, message}}` envelope to the LLM instead
|
|
7
|
+
* of a flattened message string — lets the model branch on `error.code`
|
|
8
|
+
* without regex-extracting the bracketed prefix.
|
|
9
|
+
*/
|
|
1
10
|
export declare function formatOutput(data: unknown, format?: string): void;
|
|
11
|
+
/**
|
|
12
|
+
* Map an iris error-code prefix to a CLI exit code.
|
|
13
|
+
*
|
|
14
|
+
* Convention so shell scripts can branch on failure type without parsing stderr:
|
|
15
|
+
* - 0: success (not handled here)
|
|
16
|
+
* - 1: generic / unknown
|
|
17
|
+
* - 2: input / validation (SERVER_VALIDATION_FAILED, SERVER_BAD_REQUEST)
|
|
18
|
+
* - 3: rate limit
|
|
19
|
+
* - 4: auth (AUTH_*, APIKEY_*)
|
|
20
|
+
* - 5: payment / billing (PAYMENT_*, BILLING_*)
|
|
21
|
+
* - 6: not found (any *_NOT_FOUND)
|
|
22
|
+
*
|
|
23
|
+
* Domain-specific codes (CAMP_001, CONTACT_001, etc.) are categorized by their
|
|
24
|
+
* suffix shape — *_NOT_FOUND maps to 6, others fall through to 1.
|
|
25
|
+
*/
|
|
26
|
+
export declare function exitCodeForMessage(message: string): number;
|
|
2
27
|
export declare function handleError(error: unknown): never;
|
|
28
|
+
/**
|
|
29
|
+
* Parse the `[CODE] message (field: x)` string format that IrisClient.handleError
|
|
30
|
+
* builds, recovering the structured fields.
|
|
31
|
+
*
|
|
32
|
+
* Returns `{code, message, field?}`. Falls back to `{code: "UNKNOWN_ERROR", message}`
|
|
33
|
+
* when no bracketed code is present (shouldn't happen for API errors, but safe
|
|
34
|
+
* for client-side throws like network timeouts).
|
|
35
|
+
*/
|
|
36
|
+
export declare function parseErrorMessage(raw: string): {
|
|
37
|
+
code: string;
|
|
38
|
+
message: string;
|
|
39
|
+
field?: string;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Format an error caught in an MCP tool handler as the structured response
|
|
43
|
+
* the MCP SDK returns to the model.
|
|
44
|
+
*
|
|
45
|
+
* Returns the canonical iris error envelope `{success: false, error: {code, message, field?}}`
|
|
46
|
+
* as JSON text inside the MCP `content` block, plus `isError: true` so the SDK
|
|
47
|
+
* surfaces it as an error to the model. Lets the LLM read `error.code`
|
|
48
|
+
* structurally instead of regexing it out of a flattened message.
|
|
49
|
+
*/
|
|
50
|
+
export declare function formatMcpError(error: unknown): {
|
|
51
|
+
content: Array<{
|
|
52
|
+
type: "text";
|
|
53
|
+
text: string;
|
|
54
|
+
}>;
|
|
55
|
+
isError: true;
|
|
56
|
+
};
|
|
3
57
|
export declare function getFormat(opts: Record<string, unknown>): string;
|
|
4
58
|
export declare function parseList(value: string): string[];
|
package/dist/cli-utils.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared CLI + MCP output helpers.
|
|
3
|
+
*
|
|
4
|
+
* The CLI consumes these for terminal output (table / JSON / structured exit
|
|
5
|
+
* codes). MCP tools consume `formatMcpError` so error responses surface the
|
|
6
|
+
* structured `{success, error: {code, message}}` envelope to the LLM instead
|
|
7
|
+
* of a flattened message string — lets the model branch on `error.code`
|
|
8
|
+
* without regex-extracting the bracketed prefix.
|
|
9
|
+
*/
|
|
1
10
|
export function formatOutput(data, format = "json") {
|
|
2
11
|
if (format === "table" && typeof data === "object" && data !== null) {
|
|
3
12
|
const obj = data;
|
|
@@ -16,10 +25,94 @@ export function formatOutput(data, format = "json") {
|
|
|
16
25
|
}
|
|
17
26
|
console.log(JSON.stringify(data, null, 2));
|
|
18
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Map an iris error-code prefix to a CLI exit code.
|
|
30
|
+
*
|
|
31
|
+
* Convention so shell scripts can branch on failure type without parsing stderr:
|
|
32
|
+
* - 0: success (not handled here)
|
|
33
|
+
* - 1: generic / unknown
|
|
34
|
+
* - 2: input / validation (SERVER_VALIDATION_FAILED, SERVER_BAD_REQUEST)
|
|
35
|
+
* - 3: rate limit
|
|
36
|
+
* - 4: auth (AUTH_*, APIKEY_*)
|
|
37
|
+
* - 5: payment / billing (PAYMENT_*, BILLING_*)
|
|
38
|
+
* - 6: not found (any *_NOT_FOUND)
|
|
39
|
+
*
|
|
40
|
+
* Domain-specific codes (CAMP_001, CONTACT_001, etc.) are categorized by their
|
|
41
|
+
* suffix shape — *_NOT_FOUND maps to 6, others fall through to 1.
|
|
42
|
+
*/
|
|
43
|
+
export function exitCodeForMessage(message) {
|
|
44
|
+
const codeMatch = message.match(/\[([A-Z]+)_(\d+|[A-Z_]+)\]/);
|
|
45
|
+
if (!codeMatch)
|
|
46
|
+
return 1;
|
|
47
|
+
const prefix = codeMatch[1];
|
|
48
|
+
const suffix = codeMatch[2];
|
|
49
|
+
// Suffix-based: *_NOT_FOUND → 6 regardless of prefix
|
|
50
|
+
if (suffix.includes("NOT_FOUND"))
|
|
51
|
+
return 6;
|
|
52
|
+
switch (prefix) {
|
|
53
|
+
case "AUTH":
|
|
54
|
+
case "APIKEY":
|
|
55
|
+
return 4;
|
|
56
|
+
case "RATE":
|
|
57
|
+
return 3;
|
|
58
|
+
case "PAYMENT":
|
|
59
|
+
case "BILLING":
|
|
60
|
+
return 5;
|
|
61
|
+
case "SERVER":
|
|
62
|
+
// SERVER_002/005 = validation; SERVER_003 = not found; rest = generic
|
|
63
|
+
if (suffix === "002" || suffix === "005")
|
|
64
|
+
return 2;
|
|
65
|
+
if (suffix === "003")
|
|
66
|
+
return 6;
|
|
67
|
+
return 1;
|
|
68
|
+
default:
|
|
69
|
+
return 1;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
19
72
|
export function handleError(error) {
|
|
20
73
|
const message = error instanceof Error ? error.message : String(error);
|
|
21
74
|
console.error(`error: ${message}`);
|
|
22
|
-
process.exit(
|
|
75
|
+
process.exit(exitCodeForMessage(message));
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Parse the `[CODE] message (field: x)` string format that IrisClient.handleError
|
|
79
|
+
* builds, recovering the structured fields.
|
|
80
|
+
*
|
|
81
|
+
* Returns `{code, message, field?}`. Falls back to `{code: "UNKNOWN_ERROR", message}`
|
|
82
|
+
* when no bracketed code is present (shouldn't happen for API errors, but safe
|
|
83
|
+
* for client-side throws like network timeouts).
|
|
84
|
+
*/
|
|
85
|
+
export function parseErrorMessage(raw) {
|
|
86
|
+
// Format: "[CODE] message (field: x)" — code optional, field optional
|
|
87
|
+
const match = raw.match(/^\[([A-Z_0-9]+)\]\s+(.*?)(?:\s+\(field:\s+([^)]+)\))?$/);
|
|
88
|
+
if (!match)
|
|
89
|
+
return { code: "UNKNOWN_ERROR", message: raw };
|
|
90
|
+
return {
|
|
91
|
+
code: match[1],
|
|
92
|
+
message: match[2],
|
|
93
|
+
...(match[3] && { field: match[3] }),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Format an error caught in an MCP tool handler as the structured response
|
|
98
|
+
* the MCP SDK returns to the model.
|
|
99
|
+
*
|
|
100
|
+
* Returns the canonical iris error envelope `{success: false, error: {code, message, field?}}`
|
|
101
|
+
* as JSON text inside the MCP `content` block, plus `isError: true` so the SDK
|
|
102
|
+
* surfaces it as an error to the model. Lets the LLM read `error.code`
|
|
103
|
+
* structurally instead of regexing it out of a flattened message.
|
|
104
|
+
*/
|
|
105
|
+
export function formatMcpError(error) {
|
|
106
|
+
const raw = error instanceof Error ? error.message : String(error);
|
|
107
|
+
const parsed = parseErrorMessage(raw);
|
|
108
|
+
const envelope = {
|
|
109
|
+
success: false,
|
|
110
|
+
error: parsed,
|
|
111
|
+
};
|
|
112
|
+
return {
|
|
113
|
+
content: [{ type: "text", text: JSON.stringify(envelope, null, 2) }],
|
|
114
|
+
isError: true,
|
|
115
|
+
};
|
|
23
116
|
}
|
|
24
117
|
export function getFormat(opts) {
|
|
25
118
|
if (opts.json)
|
package/dist/commands/keys.js
CHANGED
|
@@ -62,4 +62,15 @@ export function registerKeyCommands(program, client) {
|
|
|
62
62
|
handleError(error);
|
|
63
63
|
}
|
|
64
64
|
});
|
|
65
|
+
keys.command("rotate <id>")
|
|
66
|
+
.description("rotate an API key — revokes the old key and returns a new one with the same name and scopes (requires admin scope; cannot rotate the key being used for this call). The new raw key is shown once — store it immediately.")
|
|
67
|
+
.action(async (id) => {
|
|
68
|
+
try {
|
|
69
|
+
const result = await client.post(`/keys/${id}/rotate`);
|
|
70
|
+
formatOutput(result, getFormat(program.opts()));
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
handleError(error);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
65
76
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { formatMcpError } from "../cli-utils.js";
|
|
1
2
|
/**
|
|
2
3
|
* Agent credit tools.
|
|
3
4
|
*
|
|
@@ -12,15 +13,7 @@ export function registerAgentCreditTools(server, client) {
|
|
|
12
13
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
13
14
|
}
|
|
14
15
|
catch (error) {
|
|
15
|
-
return
|
|
16
|
-
content: [
|
|
17
|
-
{
|
|
18
|
-
type: "text",
|
|
19
|
-
text: `error: ${error instanceof Error ? error.message : String(error)}`,
|
|
20
|
-
},
|
|
21
|
-
],
|
|
22
|
-
isError: true,
|
|
23
|
-
};
|
|
16
|
+
return formatMcpError(error);
|
|
24
17
|
}
|
|
25
18
|
});
|
|
26
19
|
server.tool("purchase_credit_pack", "purchase a 5-credit pack via MPP ($12.00 USD). x402 agents use per-campaign pricing instead. API key users do not need credits.", {}, async () => {
|
|
@@ -29,15 +22,7 @@ export function registerAgentCreditTools(server, client) {
|
|
|
29
22
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
30
23
|
}
|
|
31
24
|
catch (error) {
|
|
32
|
-
return
|
|
33
|
-
content: [
|
|
34
|
-
{
|
|
35
|
-
type: "text",
|
|
36
|
-
text: `error: ${error instanceof Error ? error.message : String(error)}`,
|
|
37
|
-
},
|
|
38
|
-
],
|
|
39
|
-
isError: true,
|
|
40
|
-
};
|
|
25
|
+
return formatMcpError(error);
|
|
41
26
|
}
|
|
42
27
|
});
|
|
43
28
|
}
|
package/dist/tools/ai.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { formatMcpError } from "../cli-utils.js";
|
|
2
3
|
export function registerAiTools(server, client) {
|
|
3
4
|
server.tool("generate_content", "generate AI content for a specific contact conversation (email draft, follow-up, reply). requires generate scope.", {
|
|
4
5
|
contact_id: z.string().uuid().describe("contact ID"),
|
|
@@ -11,15 +12,7 @@ export function registerAiTools(server, client) {
|
|
|
11
12
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
12
13
|
}
|
|
13
14
|
catch (error) {
|
|
14
|
-
return
|
|
15
|
-
content: [
|
|
16
|
-
{
|
|
17
|
-
type: "text",
|
|
18
|
-
text: `error: ${error instanceof Error ? error.message : String(error)}`,
|
|
19
|
-
},
|
|
20
|
-
],
|
|
21
|
-
isError: true,
|
|
22
|
-
};
|
|
15
|
+
return formatMcpError(error);
|
|
23
16
|
}
|
|
24
17
|
});
|
|
25
18
|
server.tool("generate_campaign_content", "generate campaign-level outreach content (email sequence, templates) from a campaign brief. content-first: takes the strategy inline, not a campaign id. requires generate scope.", {
|
|
@@ -34,15 +27,7 @@ export function registerAiTools(server, client) {
|
|
|
34
27
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
35
28
|
}
|
|
36
29
|
catch (error) {
|
|
37
|
-
return
|
|
38
|
-
content: [
|
|
39
|
-
{
|
|
40
|
-
type: "text",
|
|
41
|
-
text: `error: ${error instanceof Error ? error.message : String(error)}`,
|
|
42
|
-
},
|
|
43
|
-
],
|
|
44
|
-
isError: true,
|
|
45
|
-
};
|
|
30
|
+
return formatMcpError(error);
|
|
46
31
|
}
|
|
47
32
|
});
|
|
48
33
|
server.tool("analyze_response", "analyze an inbound message using AI to determine sentiment, intent, and suggested actions. requires generate scope.", {
|
|
@@ -54,15 +39,7 @@ export function registerAiTools(server, client) {
|
|
|
54
39
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
55
40
|
}
|
|
56
41
|
catch (error) {
|
|
57
|
-
return
|
|
58
|
-
content: [
|
|
59
|
-
{
|
|
60
|
-
type: "text",
|
|
61
|
-
text: `error: ${error instanceof Error ? error.message : String(error)}`,
|
|
62
|
-
},
|
|
63
|
-
],
|
|
64
|
-
isError: true,
|
|
65
|
-
};
|
|
42
|
+
return formatMcpError(error);
|
|
66
43
|
}
|
|
67
44
|
});
|
|
68
45
|
server.tool("get_ai_usage", "get AI generation usage limits and current counts for the billing period. requires read scope.", {}, async () => {
|
|
@@ -71,15 +48,7 @@ export function registerAiTools(server, client) {
|
|
|
71
48
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
72
49
|
}
|
|
73
50
|
catch (error) {
|
|
74
|
-
return
|
|
75
|
-
content: [
|
|
76
|
-
{
|
|
77
|
-
type: "text",
|
|
78
|
-
text: `error: ${error instanceof Error ? error.message : String(error)}`,
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
isError: true,
|
|
82
|
-
};
|
|
51
|
+
return formatMcpError(error);
|
|
83
52
|
}
|
|
84
53
|
});
|
|
85
54
|
}
|
package/dist/tools/analytics.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { formatMcpError } from "../cli-utils.js";
|
|
2
3
|
export function registerAnalyticsTools(server, client) {
|
|
3
4
|
server.tool("get_analytics_overview", "get a high-level overview of all campaign analytics. requires read scope.", {}, async () => {
|
|
4
5
|
try {
|
|
@@ -6,15 +7,7 @@ export function registerAnalyticsTools(server, client) {
|
|
|
6
7
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
7
8
|
}
|
|
8
9
|
catch (error) {
|
|
9
|
-
return
|
|
10
|
-
content: [
|
|
11
|
-
{
|
|
12
|
-
type: "text",
|
|
13
|
-
text: `error: ${error instanceof Error ? error.message : String(error)}`,
|
|
14
|
-
},
|
|
15
|
-
],
|
|
16
|
-
isError: true,
|
|
17
|
-
};
|
|
10
|
+
return formatMcpError(error);
|
|
18
11
|
}
|
|
19
12
|
});
|
|
20
13
|
server.tool("get_campaign_analytics", "get detailed analytics for a specific campaign. requires read scope.", {
|
|
@@ -25,15 +18,7 @@ export function registerAnalyticsTools(server, client) {
|
|
|
25
18
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
26
19
|
}
|
|
27
20
|
catch (error) {
|
|
28
|
-
return
|
|
29
|
-
content: [
|
|
30
|
-
{
|
|
31
|
-
type: "text",
|
|
32
|
-
text: `error: ${error instanceof Error ? error.message : String(error)}`,
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
-
isError: true,
|
|
36
|
-
};
|
|
21
|
+
return formatMcpError(error);
|
|
37
22
|
}
|
|
38
23
|
});
|
|
39
24
|
server.tool("get_performance_metrics", "get email performance metrics over time. requires read scope.", {
|
|
@@ -50,15 +35,7 @@ export function registerAnalyticsTools(server, client) {
|
|
|
50
35
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
51
36
|
}
|
|
52
37
|
catch (error) {
|
|
53
|
-
return
|
|
54
|
-
content: [
|
|
55
|
-
{
|
|
56
|
-
type: "text",
|
|
57
|
-
text: `error: ${error instanceof Error ? error.message : String(error)}`,
|
|
58
|
-
},
|
|
59
|
-
],
|
|
60
|
-
isError: true,
|
|
61
|
-
};
|
|
38
|
+
return formatMcpError(error);
|
|
62
39
|
}
|
|
63
40
|
});
|
|
64
41
|
server.tool("get_response_time", "get average response time analytics. requires read scope.", {
|
|
@@ -72,15 +49,7 @@ export function registerAnalyticsTools(server, client) {
|
|
|
72
49
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
73
50
|
}
|
|
74
51
|
catch (error) {
|
|
75
|
-
return
|
|
76
|
-
content: [
|
|
77
|
-
{
|
|
78
|
-
type: "text",
|
|
79
|
-
text: `error: ${error instanceof Error ? error.message : String(error)}`,
|
|
80
|
-
},
|
|
81
|
-
],
|
|
82
|
-
isError: true,
|
|
83
|
-
};
|
|
52
|
+
return formatMcpError(error);
|
|
84
53
|
}
|
|
85
54
|
});
|
|
86
55
|
server.tool("get_contact_types", "get breakdown of contacts by type/source. requires read scope.", {}, async () => {
|
|
@@ -89,12 +58,7 @@ export function registerAnalyticsTools(server, client) {
|
|
|
89
58
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
90
59
|
}
|
|
91
60
|
catch (error) {
|
|
92
|
-
return
|
|
93
|
-
content: [
|
|
94
|
-
{ type: "text", text: `error: ${error instanceof Error ? error.message : String(error)}` },
|
|
95
|
-
],
|
|
96
|
-
isError: true,
|
|
97
|
-
};
|
|
61
|
+
return formatMcpError(error);
|
|
98
62
|
}
|
|
99
63
|
});
|
|
100
64
|
}
|
package/dist/tools/billing.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { formatMcpError } from "../cli-utils.js";
|
|
1
2
|
export function registerBillingTools(server, client) {
|
|
2
3
|
server.tool("get_billing_plans", "get all available billing plans with pricing and feature limits. requires read scope.", {}, async () => {
|
|
3
4
|
try {
|
|
@@ -5,15 +6,7 @@ export function registerBillingTools(server, client) {
|
|
|
5
6
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
6
7
|
}
|
|
7
8
|
catch (error) {
|
|
8
|
-
return
|
|
9
|
-
content: [
|
|
10
|
-
{
|
|
11
|
-
type: "text",
|
|
12
|
-
text: `error: ${error instanceof Error ? error.message : String(error)}`,
|
|
13
|
-
},
|
|
14
|
-
],
|
|
15
|
-
isError: true,
|
|
16
|
-
};
|
|
9
|
+
return formatMcpError(error);
|
|
17
10
|
}
|
|
18
11
|
});
|
|
19
12
|
}
|
package/dist/tools/campaigns.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { formatMcpError } from "../cli-utils.js";
|
|
2
3
|
const CAMPAIGN_STATUSES = ["draft", "active", "paused", "completed", "deleted"];
|
|
3
4
|
const OBJECTIVE_TYPES = ["venue_dj", "venue_host", "product_promotion", "custom"];
|
|
4
5
|
const TARGET_PROFILE_TYPES = [
|
|
@@ -30,15 +31,7 @@ export function registerCampaignTools(server, client) {
|
|
|
30
31
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
31
32
|
}
|
|
32
33
|
catch (error) {
|
|
33
|
-
return
|
|
34
|
-
content: [
|
|
35
|
-
{
|
|
36
|
-
type: "text",
|
|
37
|
-
text: `error: ${error instanceof Error ? error.message : String(error)}`,
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
isError: true,
|
|
41
|
-
};
|
|
34
|
+
return formatMcpError(error);
|
|
42
35
|
}
|
|
43
36
|
});
|
|
44
37
|
server.tool("create_campaign", "create a new outreach campaign. requires write scope.", {
|
|
@@ -57,15 +50,7 @@ export function registerCampaignTools(server, client) {
|
|
|
57
50
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
58
51
|
}
|
|
59
52
|
catch (error) {
|
|
60
|
-
return
|
|
61
|
-
content: [
|
|
62
|
-
{
|
|
63
|
-
type: "text",
|
|
64
|
-
text: `error: ${error instanceof Error ? error.message : String(error)}`,
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
isError: true,
|
|
68
|
-
};
|
|
53
|
+
return formatMcpError(error);
|
|
69
54
|
}
|
|
70
55
|
});
|
|
71
56
|
server.tool("get_campaign", "get a campaign by ID with stats. requires read scope.", {
|
|
@@ -76,15 +61,7 @@ export function registerCampaignTools(server, client) {
|
|
|
76
61
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
77
62
|
}
|
|
78
63
|
catch (error) {
|
|
79
|
-
return
|
|
80
|
-
content: [
|
|
81
|
-
{
|
|
82
|
-
type: "text",
|
|
83
|
-
text: `error: ${error instanceof Error ? error.message : String(error)}`,
|
|
84
|
-
},
|
|
85
|
-
],
|
|
86
|
-
isError: true,
|
|
87
|
-
};
|
|
64
|
+
return formatMcpError(error);
|
|
88
65
|
}
|
|
89
66
|
});
|
|
90
67
|
server.tool("update_campaign", "update a campaign's details. requires write scope.", {
|
|
@@ -100,15 +77,7 @@ export function registerCampaignTools(server, client) {
|
|
|
100
77
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
101
78
|
}
|
|
102
79
|
catch (error) {
|
|
103
|
-
return
|
|
104
|
-
content: [
|
|
105
|
-
{
|
|
106
|
-
type: "text",
|
|
107
|
-
text: `error: ${error instanceof Error ? error.message : String(error)}`,
|
|
108
|
-
},
|
|
109
|
-
],
|
|
110
|
-
isError: true,
|
|
111
|
-
};
|
|
80
|
+
return formatMcpError(error);
|
|
112
81
|
}
|
|
113
82
|
});
|
|
114
83
|
server.tool("delete_campaign", "soft-delete a campaign (sets status to deleted). requires write scope.", {
|
|
@@ -119,15 +88,7 @@ export function registerCampaignTools(server, client) {
|
|
|
119
88
|
return { content: [{ type: "text", text: `campaign ${id} deleted` }] };
|
|
120
89
|
}
|
|
121
90
|
catch (error) {
|
|
122
|
-
return
|
|
123
|
-
content: [
|
|
124
|
-
{
|
|
125
|
-
type: "text",
|
|
126
|
-
text: `error: ${error instanceof Error ? error.message : String(error)}`,
|
|
127
|
-
},
|
|
128
|
-
],
|
|
129
|
-
isError: true,
|
|
130
|
-
};
|
|
91
|
+
return formatMcpError(error);
|
|
131
92
|
}
|
|
132
93
|
});
|
|
133
94
|
server.tool("list_campaign_contacts", "list contacts in a campaign with optional status filter. requires read scope.", {
|
|
@@ -151,15 +112,7 @@ export function registerCampaignTools(server, client) {
|
|
|
151
112
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
152
113
|
}
|
|
153
114
|
catch (error) {
|
|
154
|
-
return
|
|
155
|
-
content: [
|
|
156
|
-
{
|
|
157
|
-
type: "text",
|
|
158
|
-
text: `error: ${error instanceof Error ? error.message : String(error)}`,
|
|
159
|
-
},
|
|
160
|
-
],
|
|
161
|
-
isError: true,
|
|
162
|
-
};
|
|
115
|
+
return formatMcpError(error);
|
|
163
116
|
}
|
|
164
117
|
});
|
|
165
118
|
server.tool("get_campaign_usage", "get usage limits and current counts for a campaign. requires read scope.", {
|
|
@@ -170,15 +123,7 @@ export function registerCampaignTools(server, client) {
|
|
|
170
123
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
171
124
|
}
|
|
172
125
|
catch (error) {
|
|
173
|
-
return
|
|
174
|
-
content: [
|
|
175
|
-
{
|
|
176
|
-
type: "text",
|
|
177
|
-
text: `error: ${error instanceof Error ? error.message : String(error)}`,
|
|
178
|
-
},
|
|
179
|
-
],
|
|
180
|
-
isError: true,
|
|
181
|
-
};
|
|
126
|
+
return formatMcpError(error);
|
|
182
127
|
}
|
|
183
128
|
});
|
|
184
129
|
server.tool("analyze_campaign", "trigger AI analysis of a campaign to generate target profiles and recommendations. requires write scope.", {
|
|
@@ -189,15 +134,7 @@ export function registerCampaignTools(server, client) {
|
|
|
189
134
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
190
135
|
}
|
|
191
136
|
catch (error) {
|
|
192
|
-
return
|
|
193
|
-
content: [
|
|
194
|
-
{
|
|
195
|
-
type: "text",
|
|
196
|
-
text: `error: ${error instanceof Error ? error.message : String(error)}`,
|
|
197
|
-
},
|
|
198
|
-
],
|
|
199
|
-
isError: true,
|
|
200
|
-
};
|
|
137
|
+
return formatMcpError(error);
|
|
201
138
|
}
|
|
202
139
|
});
|
|
203
140
|
server.tool("list_target_profiles", "list target profiles for a campaign. requires read scope.", {
|
|
@@ -208,15 +145,7 @@ export function registerCampaignTools(server, client) {
|
|
|
208
145
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
209
146
|
}
|
|
210
147
|
catch (error) {
|
|
211
|
-
return
|
|
212
|
-
content: [
|
|
213
|
-
{
|
|
214
|
-
type: "text",
|
|
215
|
-
text: `error: ${error instanceof Error ? error.message : String(error)}`,
|
|
216
|
-
},
|
|
217
|
-
],
|
|
218
|
-
isError: true,
|
|
219
|
-
};
|
|
148
|
+
return formatMcpError(error);
|
|
220
149
|
}
|
|
221
150
|
});
|
|
222
151
|
server.tool("create_target_profile", "create a target profile for a campaign. requires write scope.", {
|
|
@@ -236,15 +165,7 @@ export function registerCampaignTools(server, client) {
|
|
|
236
165
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
237
166
|
}
|
|
238
167
|
catch (error) {
|
|
239
|
-
return
|
|
240
|
-
content: [
|
|
241
|
-
{
|
|
242
|
-
type: "text",
|
|
243
|
-
text: `error: ${error instanceof Error ? error.message : String(error)}`,
|
|
244
|
-
},
|
|
245
|
-
],
|
|
246
|
-
isError: true,
|
|
247
|
-
};
|
|
168
|
+
return formatMcpError(error);
|
|
248
169
|
}
|
|
249
170
|
});
|
|
250
171
|
server.tool("delete_target_profile", "delete a target profile from a campaign. requires write scope.", {
|
|
@@ -256,15 +177,7 @@ export function registerCampaignTools(server, client) {
|
|
|
256
177
|
return { content: [{ type: "text", text: `target profile ${profile_id} deleted` }] };
|
|
257
178
|
}
|
|
258
179
|
catch (error) {
|
|
259
|
-
return
|
|
260
|
-
content: [
|
|
261
|
-
{
|
|
262
|
-
type: "text",
|
|
263
|
-
text: `error: ${error instanceof Error ? error.message : String(error)}`,
|
|
264
|
-
},
|
|
265
|
-
],
|
|
266
|
-
isError: true,
|
|
267
|
-
};
|
|
180
|
+
return formatMcpError(error);
|
|
268
181
|
}
|
|
269
182
|
});
|
|
270
183
|
}
|
package/dist/tools/channels.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { formatMcpError } from "../cli-utils.js";
|
|
2
3
|
const CHANNELS = ["email", "instagram", "twitter"];
|
|
3
4
|
export function registerChannelTools(server, client) {
|
|
4
5
|
server.tool("list_connected_accounts", "list all connected social media accounts. requires read scope.", {}, async () => {
|
|
@@ -7,15 +8,7 @@ export function registerChannelTools(server, client) {
|
|
|
7
8
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
8
9
|
}
|
|
9
10
|
catch (error) {
|
|
10
|
-
return
|
|
11
|
-
content: [
|
|
12
|
-
{
|
|
13
|
-
type: "text",
|
|
14
|
-
text: `error: ${error instanceof Error ? error.message : String(error)}`,
|
|
15
|
-
},
|
|
16
|
-
],
|
|
17
|
-
isError: true,
|
|
18
|
-
};
|
|
11
|
+
return formatMcpError(error);
|
|
19
12
|
}
|
|
20
13
|
});
|
|
21
14
|
server.tool("check_channel_availability", "check which outreach channels are available and configured. requires read scope.", {}, async () => {
|
|
@@ -24,15 +17,7 @@ export function registerChannelTools(server, client) {
|
|
|
24
17
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
25
18
|
}
|
|
26
19
|
catch (error) {
|
|
27
|
-
return
|
|
28
|
-
content: [
|
|
29
|
-
{
|
|
30
|
-
type: "text",
|
|
31
|
-
text: `error: ${error instanceof Error ? error.message : String(error)}`,
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
isError: true,
|
|
35
|
-
};
|
|
20
|
+
return formatMcpError(error);
|
|
36
21
|
}
|
|
37
22
|
});
|
|
38
23
|
server.tool("send_channel_message", "send a message through a specific channel in a conversation. requires send scope.", {
|
|
@@ -50,15 +35,7 @@ export function registerChannelTools(server, client) {
|
|
|
50
35
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
51
36
|
}
|
|
52
37
|
catch (error) {
|
|
53
|
-
return
|
|
54
|
-
content: [
|
|
55
|
-
{
|
|
56
|
-
type: "text",
|
|
57
|
-
text: `error: ${error instanceof Error ? error.message : String(error)}`,
|
|
58
|
-
},
|
|
59
|
-
],
|
|
60
|
-
isError: true,
|
|
61
|
-
};
|
|
38
|
+
return formatMcpError(error);
|
|
62
39
|
}
|
|
63
40
|
});
|
|
64
41
|
}
|