@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.
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { formatMcpError } from "../cli-utils.js";
2
3
  export function registerContactTools(server, client) {
3
4
  server.tool("list_contacts", "list all contacts with optional search. requires read scope.", {
4
5
  page: z.number().int().positive().optional().describe("page number (default 1)"),
@@ -17,15 +18,7 @@ export function registerContactTools(server, client) {
17
18
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
18
19
  }
19
20
  catch (error) {
20
- return {
21
- content: [
22
- {
23
- type: "text",
24
- text: `error: ${error instanceof Error ? error.message : String(error)}`,
25
- },
26
- ],
27
- isError: true,
28
- };
21
+ return formatMcpError(error);
29
22
  }
30
23
  });
31
24
  server.tool("create_contact", "create a new contact. requires write scope.", {
@@ -43,15 +36,7 @@ export function registerContactTools(server, client) {
43
36
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
44
37
  }
45
38
  catch (error) {
46
- return {
47
- content: [
48
- {
49
- type: "text",
50
- text: `error: ${error instanceof Error ? error.message : String(error)}`,
51
- },
52
- ],
53
- isError: true,
54
- };
39
+ return formatMcpError(error);
55
40
  }
56
41
  });
57
42
  server.tool("get_contact", "get a contact by ID. requires read scope.", {
@@ -62,15 +47,7 @@ export function registerContactTools(server, client) {
62
47
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
63
48
  }
64
49
  catch (error) {
65
- return {
66
- content: [
67
- {
68
- type: "text",
69
- text: `error: ${error instanceof Error ? error.message : String(error)}`,
70
- },
71
- ],
72
- isError: true,
73
- };
50
+ return formatMcpError(error);
74
51
  }
75
52
  });
76
53
  server.tool("update_contact", "update a contact's details. requires write scope.", {
@@ -89,15 +66,7 @@ export function registerContactTools(server, client) {
89
66
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
90
67
  }
91
68
  catch (error) {
92
- return {
93
- content: [
94
- {
95
- type: "text",
96
- text: `error: ${error instanceof Error ? error.message : String(error)}`,
97
- },
98
- ],
99
- isError: true,
100
- };
69
+ return formatMcpError(error);
101
70
  }
102
71
  });
103
72
  server.tool("delete_contact", "soft-delete a contact. requires write scope.", {
@@ -108,15 +77,7 @@ export function registerContactTools(server, client) {
108
77
  return { content: [{ type: "text", text: `contact ${id} deleted` }] };
109
78
  }
110
79
  catch (error) {
111
- return {
112
- content: [
113
- {
114
- type: "text",
115
- text: `error: ${error instanceof Error ? error.message : String(error)}`,
116
- },
117
- ],
118
- isError: true,
119
- };
80
+ return formatMcpError(error);
120
81
  }
121
82
  });
122
83
  server.tool("bulk_import_contacts", "import multiple contacts at once, optionally adding them to a campaign. requires write scope.", {
@@ -139,15 +100,7 @@ export function registerContactTools(server, client) {
139
100
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
140
101
  }
141
102
  catch (error) {
142
- return {
143
- content: [
144
- {
145
- type: "text",
146
- text: `error: ${error instanceof Error ? error.message : String(error)}`,
147
- },
148
- ],
149
- isError: true,
150
- };
103
+ return formatMcpError(error);
151
104
  }
152
105
  });
153
106
  server.tool("get_contact_usage", "get contact usage limits and current counts for the billing period. requires read scope.", {}, async () => {
@@ -156,15 +109,7 @@ export function registerContactTools(server, client) {
156
109
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
157
110
  }
158
111
  catch (error) {
159
- return {
160
- content: [
161
- {
162
- type: "text",
163
- text: `error: ${error instanceof Error ? error.message : String(error)}`,
164
- },
165
- ],
166
- isError: true,
167
- };
112
+ return formatMcpError(error);
168
113
  }
169
114
  });
170
115
  server.tool("list_contact_conversations", "list all conversations for a specific contact. requires read scope.", {
@@ -175,15 +120,7 @@ export function registerContactTools(server, client) {
175
120
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
176
121
  }
177
122
  catch (error) {
178
- return {
179
- content: [
180
- {
181
- type: "text",
182
- text: `error: ${error instanceof Error ? error.message : String(error)}`,
183
- },
184
- ],
185
- isError: true,
186
- };
123
+ return formatMcpError(error);
187
124
  }
188
125
  });
189
126
  }
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { formatMcpError } from "../cli-utils.js";
2
3
  const CONVERSATION_STATUSES = ["active", "completed", "failed", "human_review"];
3
4
  export function registerConversationTools(server, client) {
4
5
  server.tool("list_conversations", "list conversations with optional filtering. requires read scope.", {
@@ -21,15 +22,7 @@ export function registerConversationTools(server, client) {
21
22
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
22
23
  }
23
24
  catch (error) {
24
- return {
25
- content: [
26
- {
27
- type: "text",
28
- text: `error: ${error instanceof Error ? error.message : String(error)}`,
29
- },
30
- ],
31
- isError: true,
32
- };
25
+ return formatMcpError(error);
33
26
  }
34
27
  });
35
28
  server.tool("get_conversation", "get a conversation by ID with contact and campaign details. requires read scope.", {
@@ -40,15 +33,7 @@ export function registerConversationTools(server, client) {
40
33
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
41
34
  }
42
35
  catch (error) {
43
- return {
44
- content: [
45
- {
46
- type: "text",
47
- text: `error: ${error instanceof Error ? error.message : String(error)}`,
48
- },
49
- ],
50
- isError: true,
51
- };
36
+ return formatMcpError(error);
52
37
  }
53
38
  });
54
39
  server.tool("get_conversation_messages", "get all messages in a conversation. requires read scope.", {
@@ -59,15 +44,7 @@ export function registerConversationTools(server, client) {
59
44
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
60
45
  }
61
46
  catch (error) {
62
- return {
63
- content: [
64
- {
65
- type: "text",
66
- text: `error: ${error instanceof Error ? error.message : String(error)}`,
67
- },
68
- ],
69
- isError: true,
70
- };
47
+ return formatMcpError(error);
71
48
  }
72
49
  });
73
50
  server.tool("mark_conversation_read", "mark a conversation as read. requires write scope.", {
@@ -78,15 +55,7 @@ export function registerConversationTools(server, client) {
78
55
  return { content: [{ type: "text", text: `conversation ${id} marked as read` }] };
79
56
  }
80
57
  catch (error) {
81
- return {
82
- content: [
83
- {
84
- type: "text",
85
- text: `error: ${error instanceof Error ? error.message : String(error)}`,
86
- },
87
- ],
88
- isError: true,
89
- };
58
+ return formatMcpError(error);
90
59
  }
91
60
  });
92
61
  server.tool("get_engagement_metrics", "get overall engagement metrics across all conversations. requires read scope.", {}, async () => {
@@ -95,15 +64,7 @@ export function registerConversationTools(server, client) {
95
64
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
96
65
  }
97
66
  catch (error) {
98
- return {
99
- content: [
100
- {
101
- type: "text",
102
- text: `error: ${error instanceof Error ? error.message : String(error)}`,
103
- },
104
- ],
105
- isError: true,
106
- };
67
+ return formatMcpError(error);
107
68
  }
108
69
  });
109
70
  }
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { formatMcpError } from "../cli-utils.js";
2
3
  const DISCOVERY_SOURCES = ["google_maps", "instagram", "twitter", "tiktok", "reddit"];
3
4
  const PROFILE_TYPES = [
4
5
  "local_business",
@@ -49,15 +50,7 @@ export function registerDiscoveryTools(server, client) {
49
50
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
50
51
  }
51
52
  catch (error) {
52
- return {
53
- content: [
54
- {
55
- type: "text",
56
- text: `error: ${error instanceof Error ? error.message : String(error)}`,
57
- },
58
- ],
59
- isError: true,
60
- };
53
+ return formatMcpError(error);
61
54
  }
62
55
  });
63
56
  server.tool("search_campaign_contacts", "search for contacts matching a campaign's target profiles. requires generate scope.", {
@@ -69,15 +62,7 @@ export function registerDiscoveryTools(server, client) {
69
62
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
70
63
  }
71
64
  catch (error) {
72
- return {
73
- content: [
74
- {
75
- type: "text",
76
- text: `error: ${error instanceof Error ? error.message : String(error)}`,
77
- },
78
- ],
79
- isError: true,
80
- };
65
+ return formatMcpError(error);
81
66
  }
82
67
  });
83
68
  server.tool("get_discovery_job", "get the status, progress, and contacts of a discovery job. status values: pending, running, completed, failed. contacts populated only when status=completed. requires read scope.", {
@@ -88,15 +73,7 @@ export function registerDiscoveryTools(server, client) {
88
73
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
89
74
  }
90
75
  catch (error) {
91
- return {
92
- content: [
93
- {
94
- type: "text",
95
- text: `error: ${error instanceof Error ? error.message : String(error)}`,
96
- },
97
- ],
98
- isError: true,
99
- };
76
+ return formatMcpError(error);
100
77
  }
101
78
  });
102
79
  server.tool("list_discovery_sources", "list available discovery data sources and their status. requires read scope.", {}, async () => {
@@ -105,15 +82,7 @@ export function registerDiscoveryTools(server, client) {
105
82
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
106
83
  }
107
84
  catch (error) {
108
- return {
109
- content: [
110
- {
111
- type: "text",
112
- text: `error: ${error instanceof Error ? error.message : String(error)}`,
113
- },
114
- ],
115
- isError: true,
116
- };
85
+ return formatMcpError(error);
117
86
  }
118
87
  });
119
88
  }
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { formatMcpError } from "../cli-utils.js";
2
3
  // Five-verb scope vocabulary. iris uses soft-deletes everywhere, so DELETE
3
4
  // routes gate on `write` — there is no separate `delete` scope.
4
5
  //
@@ -15,12 +16,7 @@ export function registerKeyTools(server, client) {
15
16
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
16
17
  }
17
18
  catch (error) {
18
- return {
19
- content: [
20
- { type: "text", text: `error: ${error instanceof Error ? error.message : String(error)}` },
21
- ],
22
- isError: true,
23
- };
19
+ return formatMcpError(error);
24
20
  }
25
21
  });
26
22
  server.tool("list_api_keys", "list all API keys for the account. requires admin scope.", {
@@ -37,15 +33,7 @@ export function registerKeyTools(server, client) {
37
33
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
38
34
  }
39
35
  catch (error) {
40
- return {
41
- content: [
42
- {
43
- type: "text",
44
- text: `error: ${error instanceof Error ? error.message : String(error)}`,
45
- },
46
- ],
47
- isError: true,
48
- };
36
+ return formatMcpError(error);
49
37
  }
50
38
  });
51
39
  server.tool("create_api_key", "create a new API key. requires admin scope.", {
@@ -63,15 +51,7 @@ export function registerKeyTools(server, client) {
63
51
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
64
52
  }
65
53
  catch (error) {
66
- return {
67
- content: [
68
- {
69
- type: "text",
70
- text: `error: ${error instanceof Error ? error.message : String(error)}`,
71
- },
72
- ],
73
- isError: true,
74
- };
54
+ return formatMcpError(error);
75
55
  }
76
56
  });
77
57
  server.tool("revoke_api_key", "revoke (delete) an API key. requires admin scope.", {
@@ -82,15 +62,18 @@ export function registerKeyTools(server, client) {
82
62
  return { content: [{ type: "text", text: `API key ${id} revoked` }] };
83
63
  }
84
64
  catch (error) {
85
- return {
86
- content: [
87
- {
88
- type: "text",
89
- text: `error: ${error instanceof Error ? error.message : String(error)}`,
90
- },
91
- ],
92
- isError: true,
93
- };
65
+ return formatMcpError(error);
66
+ }
67
+ });
68
+ server.tool("rotate_api_key", "rotate an API key — revokes the old key and returns a new one with the same name and scopes. The new raw key is shown once; store it immediately. The old key stops authenticating as soon as this returns. (requires admin scope; cannot rotate the key being used for this call)", {
69
+ id: z.string().uuid().describe("API key ID to rotate"),
70
+ }, async ({ id }) => {
71
+ try {
72
+ const result = await client.post(`/keys/${id}/rotate`);
73
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
74
+ }
75
+ catch (error) {
76
+ return formatMcpError(error);
94
77
  }
95
78
  });
96
79
  }
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { formatMcpError } from "../cli-utils.js";
2
3
  export function registerMessageTools(server, client) {
3
4
  server.tool("list_pending_messages", "list messages awaiting approval before sending. requires read scope.", {
4
5
  page: z.number().int().positive().optional().describe("page number (default 1)"),
@@ -17,15 +18,7 @@ export function registerMessageTools(server, client) {
17
18
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
18
19
  }
19
20
  catch (error) {
20
- return {
21
- content: [
22
- {
23
- type: "text",
24
- text: `error: ${error instanceof Error ? error.message : String(error)}`,
25
- },
26
- ],
27
- isError: true,
28
- };
21
+ return formatMcpError(error);
29
22
  }
30
23
  });
31
24
  server.tool("approve_message", "approve a pending message for sending. requires send scope.", {
@@ -36,15 +29,7 @@ export function registerMessageTools(server, client) {
36
29
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
37
30
  }
38
31
  catch (error) {
39
- return {
40
- content: [
41
- {
42
- type: "text",
43
- text: `error: ${error instanceof Error ? error.message : String(error)}`,
44
- },
45
- ],
46
- isError: true,
47
- };
32
+ return formatMcpError(error);
48
33
  }
49
34
  });
50
35
  server.tool("reject_message", "reject a pending message with an optional reason. requires send scope.", {
@@ -56,15 +41,7 @@ export function registerMessageTools(server, client) {
56
41
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
57
42
  }
58
43
  catch (error) {
59
- return {
60
- content: [
61
- {
62
- type: "text",
63
- text: `error: ${error instanceof Error ? error.message : String(error)}`,
64
- },
65
- ],
66
- isError: true,
67
- };
44
+ return formatMcpError(error);
68
45
  }
69
46
  });
70
47
  server.tool("retry_message", "retry sending a failed message. requires send scope.", {
@@ -75,15 +52,7 @@ export function registerMessageTools(server, client) {
75
52
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
76
53
  }
77
54
  catch (error) {
78
- return {
79
- content: [
80
- {
81
- type: "text",
82
- text: `error: ${error instanceof Error ? error.message : String(error)}`,
83
- },
84
- ],
85
- isError: true,
86
- };
55
+ return formatMcpError(error);
87
56
  }
88
57
  });
89
58
  server.tool("submit_message_feedback", "submit feedback on an AI-generated message to improve future generations. requires send scope.", {
@@ -95,15 +64,7 @@ export function registerMessageTools(server, client) {
95
64
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
96
65
  }
97
66
  catch (error) {
98
- return {
99
- content: [
100
- {
101
- type: "text",
102
- text: `error: ${error instanceof Error ? error.message : String(error)}`,
103
- },
104
- ],
105
- isError: true,
106
- };
67
+ return formatMcpError(error);
107
68
  }
108
69
  });
109
70
  server.tool("bulk_message_action", "approve or reject multiple messages at once. requires send scope.", {
@@ -115,15 +76,7 @@ export function registerMessageTools(server, client) {
115
76
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
116
77
  }
117
78
  catch (error) {
118
- return {
119
- content: [
120
- {
121
- type: "text",
122
- text: `error: ${error instanceof Error ? error.message : String(error)}`,
123
- },
124
- ],
125
- isError: true,
126
- };
79
+ return formatMcpError(error);
127
80
  }
128
81
  });
129
82
  }
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { formatMcpError } from "../cli-utils.js";
2
3
  export function registerNotificationTools(server, client) {
3
4
  server.tool("list_notifications", "list user notifications. requires read scope.", {
4
5
  page: z.number().int().positive().optional().describe("page number (default 1)"),
@@ -14,15 +15,7 @@ export function registerNotificationTools(server, client) {
14
15
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
15
16
  }
16
17
  catch (error) {
17
- return {
18
- content: [
19
- {
20
- type: "text",
21
- text: `error: ${error instanceof Error ? error.message : String(error)}`,
22
- },
23
- ],
24
- isError: true,
25
- };
18
+ return formatMcpError(error);
26
19
  }
27
20
  });
28
21
  server.tool("update_notification", "update a notification (e.g., mark as read). requires write scope.", {
@@ -34,15 +27,7 @@ export function registerNotificationTools(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("delete_notification", "delete a notification. requires write scope.", {
@@ -53,15 +38,7 @@ export function registerNotificationTools(server, client) {
53
38
  return { content: [{ type: "text", text: `notification ${id} deleted` }] };
54
39
  }
55
40
  catch (error) {
56
- return {
57
- content: [
58
- {
59
- type: "text",
60
- text: `error: ${error instanceof Error ? error.message : String(error)}`,
61
- },
62
- ],
63
- isError: true,
64
- };
41
+ return formatMcpError(error);
65
42
  }
66
43
  });
67
44
  server.tool("mark_all_notifications_read", "mark all notifications as read. requires write scope.", {}, async () => {
@@ -70,15 +47,7 @@ export function registerNotificationTools(server, client) {
70
47
  return { content: [{ type: "text", text: "all notifications marked as read" }] };
71
48
  }
72
49
  catch (error) {
73
- return {
74
- content: [
75
- {
76
- type: "text",
77
- text: `error: ${error instanceof Error ? error.message : String(error)}`,
78
- },
79
- ],
80
- isError: true,
81
- };
50
+ return formatMcpError(error);
82
51
  }
83
52
  });
84
53
  }