@burdenoff/mcp-libs 2026.511.1

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.
Files changed (174) hide show
  1. package/README.md +76 -0
  2. package/dist/chunk-4GBVJ4OY.js +847 -0
  3. package/dist/chunk-4GBVJ4OY.js.map +1 -0
  4. package/dist/chunk-H2OYWLOA.js +919 -0
  5. package/dist/chunk-H2OYWLOA.js.map +1 -0
  6. package/dist/chunk-JFEQYSWM.js +174 -0
  7. package/dist/chunk-JFEQYSWM.js.map +1 -0
  8. package/dist/chunk-WWFVD7BO.js +273 -0
  9. package/dist/chunk-WWFVD7BO.js.map +1 -0
  10. package/dist/context-1jV4NsLv.d.cts +138 -0
  11. package/dist/context-1jV4NsLv.d.ts +138 -0
  12. package/dist/core/index.cjs +953 -0
  13. package/dist/core/index.cjs.map +1 -0
  14. package/dist/core/index.d.cts +59 -0
  15. package/dist/core/index.d.ts +59 -0
  16. package/dist/core/index.js +3 -0
  17. package/dist/core/index.js.map +1 -0
  18. package/dist/http-BP4c721D.d.cts +22 -0
  19. package/dist/http-DXTeCD5r.d.ts +22 -0
  20. package/dist/index.cjs +1013 -0
  21. package/dist/index.cjs.map +1 -0
  22. package/dist/index.d.cts +7 -0
  23. package/dist/index.d.ts +7 -0
  24. package/dist/index.js +4 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/module-DBcfA-i3.d.ts +67 -0
  27. package/dist/module-DFQBZNK6.d.cts +67 -0
  28. package/dist/modules/auth/index.cjs +533 -0
  29. package/dist/modules/auth/index.cjs.map +1 -0
  30. package/dist/modules/auth/index.d.cts +51 -0
  31. package/dist/modules/auth/index.d.ts +51 -0
  32. package/dist/modules/auth/index.js +159 -0
  33. package/dist/modules/auth/index.js.map +1 -0
  34. package/dist/modules/billing/index.cjs +655 -0
  35. package/dist/modules/billing/index.cjs.map +1 -0
  36. package/dist/modules/billing/index.d.cts +8 -0
  37. package/dist/modules/billing/index.d.ts +8 -0
  38. package/dist/modules/billing/index.js +606 -0
  39. package/dist/modules/billing/index.js.map +1 -0
  40. package/dist/modules/channels/index.cjs +443 -0
  41. package/dist/modules/channels/index.cjs.map +1 -0
  42. package/dist/modules/channels/index.d.cts +8 -0
  43. package/dist/modules/channels/index.d.ts +8 -0
  44. package/dist/modules/channels/index.js +394 -0
  45. package/dist/modules/channels/index.js.map +1 -0
  46. package/dist/modules/conversations/index.cjs +288 -0
  47. package/dist/modules/conversations/index.cjs.map +1 -0
  48. package/dist/modules/conversations/index.d.cts +8 -0
  49. package/dist/modules/conversations/index.d.ts +8 -0
  50. package/dist/modules/conversations/index.js +239 -0
  51. package/dist/modules/conversations/index.js.map +1 -0
  52. package/dist/modules/devportal/index.cjs +796 -0
  53. package/dist/modules/devportal/index.cjs.map +1 -0
  54. package/dist/modules/devportal/index.d.cts +8 -0
  55. package/dist/modules/devportal/index.d.ts +8 -0
  56. package/dist/modules/devportal/index.js +747 -0
  57. package/dist/modules/devportal/index.js.map +1 -0
  58. package/dist/modules/export/index.cjs +333 -0
  59. package/dist/modules/export/index.cjs.map +1 -0
  60. package/dist/modules/export/index.d.cts +8 -0
  61. package/dist/modules/export/index.d.ts +8 -0
  62. package/dist/modules/export/index.js +284 -0
  63. package/dist/modules/export/index.js.map +1 -0
  64. package/dist/modules/files/index.cjs +278 -0
  65. package/dist/modules/files/index.cjs.map +1 -0
  66. package/dist/modules/files/index.d.cts +8 -0
  67. package/dist/modules/files/index.d.ts +8 -0
  68. package/dist/modules/files/index.js +229 -0
  69. package/dist/modules/files/index.js.map +1 -0
  70. package/dist/modules/groups/index.cjs +451 -0
  71. package/dist/modules/groups/index.cjs.map +1 -0
  72. package/dist/modules/groups/index.d.cts +8 -0
  73. package/dist/modules/groups/index.d.ts +8 -0
  74. package/dist/modules/groups/index.js +402 -0
  75. package/dist/modules/groups/index.js.map +1 -0
  76. package/dist/modules/health/index.cjs +159 -0
  77. package/dist/modules/health/index.cjs.map +1 -0
  78. package/dist/modules/health/index.d.cts +8 -0
  79. package/dist/modules/health/index.d.ts +8 -0
  80. package/dist/modules/health/index.js +36 -0
  81. package/dist/modules/health/index.js.map +1 -0
  82. package/dist/modules/integrations/index.cjs +316 -0
  83. package/dist/modules/integrations/index.cjs.map +1 -0
  84. package/dist/modules/integrations/index.d.cts +8 -0
  85. package/dist/modules/integrations/index.d.ts +8 -0
  86. package/dist/modules/integrations/index.js +267 -0
  87. package/dist/modules/integrations/index.js.map +1 -0
  88. package/dist/modules/notifications/index.cjs +222 -0
  89. package/dist/modules/notifications/index.cjs.map +1 -0
  90. package/dist/modules/notifications/index.d.cts +8 -0
  91. package/dist/modules/notifications/index.d.ts +8 -0
  92. package/dist/modules/notifications/index.js +173 -0
  93. package/dist/modules/notifications/index.js.map +1 -0
  94. package/dist/modules/organizations/index.cjs +267 -0
  95. package/dist/modules/organizations/index.cjs.map +1 -0
  96. package/dist/modules/organizations/index.d.cts +8 -0
  97. package/dist/modules/organizations/index.d.ts +8 -0
  98. package/dist/modules/organizations/index.js +218 -0
  99. package/dist/modules/organizations/index.js.map +1 -0
  100. package/dist/modules/products/index.cjs +736 -0
  101. package/dist/modules/products/index.cjs.map +1 -0
  102. package/dist/modules/products/index.d.cts +8 -0
  103. package/dist/modules/products/index.d.ts +8 -0
  104. package/dist/modules/products/index.js +687 -0
  105. package/dist/modules/products/index.js.map +1 -0
  106. package/dist/modules/rbac/index.cjs +378 -0
  107. package/dist/modules/rbac/index.cjs.map +1 -0
  108. package/dist/modules/rbac/index.d.cts +8 -0
  109. package/dist/modules/rbac/index.d.ts +8 -0
  110. package/dist/modules/rbac/index.js +329 -0
  111. package/dist/modules/rbac/index.js.map +1 -0
  112. package/dist/modules/sandbox/index.cjs +318 -0
  113. package/dist/modules/sandbox/index.cjs.map +1 -0
  114. package/dist/modules/sandbox/index.d.cts +8 -0
  115. package/dist/modules/sandbox/index.d.ts +8 -0
  116. package/dist/modules/sandbox/index.js +225 -0
  117. package/dist/modules/sandbox/index.js.map +1 -0
  118. package/dist/modules/scheduler/index.cjs +267 -0
  119. package/dist/modules/scheduler/index.cjs.map +1 -0
  120. package/dist/modules/scheduler/index.d.cts +8 -0
  121. package/dist/modules/scheduler/index.d.ts +8 -0
  122. package/dist/modules/scheduler/index.js +218 -0
  123. package/dist/modules/scheduler/index.js.map +1 -0
  124. package/dist/modules/security/index.cjs +529 -0
  125. package/dist/modules/security/index.cjs.map +1 -0
  126. package/dist/modules/security/index.d.cts +8 -0
  127. package/dist/modules/security/index.d.ts +8 -0
  128. package/dist/modules/security/index.js +480 -0
  129. package/dist/modules/security/index.js.map +1 -0
  130. package/dist/modules/store/index.cjs +450 -0
  131. package/dist/modules/store/index.cjs.map +1 -0
  132. package/dist/modules/store/index.d.cts +8 -0
  133. package/dist/modules/store/index.d.ts +8 -0
  134. package/dist/modules/store/index.js +401 -0
  135. package/dist/modules/store/index.js.map +1 -0
  136. package/dist/modules/support/index.cjs +285 -0
  137. package/dist/modules/support/index.cjs.map +1 -0
  138. package/dist/modules/support/index.d.cts +8 -0
  139. package/dist/modules/support/index.d.ts +8 -0
  140. package/dist/modules/support/index.js +236 -0
  141. package/dist/modules/support/index.js.map +1 -0
  142. package/dist/modules/tags/index.cjs +421 -0
  143. package/dist/modules/tags/index.cjs.map +1 -0
  144. package/dist/modules/tags/index.d.cts +8 -0
  145. package/dist/modules/tags/index.d.ts +8 -0
  146. package/dist/modules/tags/index.js +372 -0
  147. package/dist/modules/tags/index.js.map +1 -0
  148. package/dist/modules/tours/index.cjs +225 -0
  149. package/dist/modules/tours/index.cjs.map +1 -0
  150. package/dist/modules/tours/index.d.cts +8 -0
  151. package/dist/modules/tours/index.d.ts +8 -0
  152. package/dist/modules/tours/index.js +176 -0
  153. package/dist/modules/tours/index.js.map +1 -0
  154. package/dist/modules/vibecontrols/index.cjs +5551 -0
  155. package/dist/modules/vibecontrols/index.cjs.map +1 -0
  156. package/dist/modules/vibecontrols/index.d.cts +8 -0
  157. package/dist/modules/vibecontrols/index.d.ts +8 -0
  158. package/dist/modules/vibecontrols/index.js +4380 -0
  159. package/dist/modules/vibecontrols/index.js.map +1 -0
  160. package/dist/modules/workspaces/index.cjs +552 -0
  161. package/dist/modules/workspaces/index.cjs.map +1 -0
  162. package/dist/modules/workspaces/index.d.cts +8 -0
  163. package/dist/modules/workspaces/index.d.ts +8 -0
  164. package/dist/modules/workspaces/index.js +503 -0
  165. package/dist/modules/workspaces/index.js.map +1 -0
  166. package/dist/tool-name-CQf_IqAj.d.cts +47 -0
  167. package/dist/tool-name-DlnrBsZ6.d.ts +47 -0
  168. package/dist/transports/index.cjs +183 -0
  169. package/dist/transports/index.cjs.map +1 -0
  170. package/dist/transports/index.d.cts +13 -0
  171. package/dist/transports/index.d.ts +13 -0
  172. package/dist/transports/index.js +3 -0
  173. package/dist/transports/index.js.map +1 -0
  174. package/package.json +125 -0
@@ -0,0 +1,267 @@
1
+ import { mcpToolName, jsonResult, errorResult } from '../../chunk-H2OYWLOA.js';
2
+ import { z } from 'zod';
3
+
4
+ // src/modules/integrations/operations.ts
5
+ var GET_PROVIDERS = `
6
+ query GetProviders($filter: ProviderFilterInput, $pagination: IntegrationsPaginationInput) {
7
+ getProviders(filter: $filter, pagination: $pagination) {
8
+ items { id key name category authType isEnabled }
9
+ total hasMore
10
+ }
11
+ }
12
+ `;
13
+ var GET_PROVIDER = `
14
+ query GetProvider($id: ID!) {
15
+ getProvider(id: $id) {
16
+ id key name authType category connectionCount
17
+ }
18
+ }
19
+ `;
20
+ var GET_CONNECTIONS = `
21
+ query GetConnections($filter: ConnectionFilterInput, $pagination: IntegrationsPaginationInput) {
22
+ getConnections(filter: $filter, pagination: $pagination) {
23
+ items { id name providerId status grantedScopes }
24
+ total hasMore
25
+ }
26
+ }
27
+ `;
28
+ var GET_CONNECTION = `
29
+ query GetConnection($id: ID!) {
30
+ getConnection(id: $id) {
31
+ id name providerId status externalAccountEmail credentialSource
32
+ }
33
+ }
34
+ `;
35
+ var CREATE_CONNECTION = `
36
+ mutation CreateConnection($input: CreateConnectionInput!) {
37
+ createConnection(input: $input) {
38
+ id name status providerId
39
+ }
40
+ }
41
+ `;
42
+ var DELETE_CONNECTION = `
43
+ mutation DeleteConnection($id: ID!, $deleteVaultSecret: Boolean) {
44
+ deleteConnection(id: $id, deleteVaultSecret: $deleteVaultSecret)
45
+ }
46
+ `;
47
+ var GET_INTEGRATION_LOGS = `
48
+ query GetIntegrationLogs($filter: LogFilterInput, $pagination: IntegrationsPaginationInput) {
49
+ getIntegrationLogs(filter: $filter, pagination: $pagination) {
50
+ items { id action level message createdAt }
51
+ total hasMore
52
+ }
53
+ }
54
+ `;
55
+
56
+ // src/modules/integrations/tools.ts
57
+ function registerIntegrationsTools(server, ctx, track) {
58
+ server.registerTool(
59
+ track(mcpToolName(ctx.productName, "integrations_providers_list")),
60
+ {
61
+ title: "List Integration Providers",
62
+ description: "List integration providers with optional category/enabled filters.",
63
+ inputSchema: {
64
+ category: z.string().optional().describe("Filter by category (will be uppercased)"),
65
+ enabled: z.boolean().optional().describe("Filter by enabled flag"),
66
+ limit: z.number().optional().describe("Page size (default 100)")
67
+ }
68
+ },
69
+ async ({ category, enabled, limit }) => {
70
+ try {
71
+ const filter = {};
72
+ if (category !== void 0) filter.category = category.toUpperCase();
73
+ if (enabled !== void 0) filter.isEnabled = enabled;
74
+ const data = await ctx.gql.workspace.request(GET_PROVIDERS, {
75
+ filter: Object.keys(filter).length > 0 ? filter : void 0,
76
+ pagination: { limit: limit ?? 100, offset: 0 }
77
+ });
78
+ return jsonResult(data.getProviders);
79
+ } catch (error) {
80
+ ctx.logger.error("integrations_providers_list failed", { error: String(error) });
81
+ return errorResult(
82
+ `Failed to list providers: ${error instanceof Error ? error.message : String(error)}`
83
+ );
84
+ }
85
+ }
86
+ );
87
+ server.registerTool(
88
+ track(mcpToolName(ctx.productName, "integrations_providers_get")),
89
+ {
90
+ title: "Get Integration Provider",
91
+ description: "Get an integration provider by ID.",
92
+ inputSchema: { id: z.string().describe("Provider ID") }
93
+ },
94
+ async ({ id }) => {
95
+ try {
96
+ const data = await ctx.gql.workspace.request(
97
+ GET_PROVIDER,
98
+ { id }
99
+ );
100
+ if (!data.getProvider) return errorResult(`Provider ${id} not found`);
101
+ return jsonResult(data.getProvider);
102
+ } catch (error) {
103
+ ctx.logger.error("integrations_providers_get failed", { error: String(error) });
104
+ return errorResult(
105
+ `Failed to get provider: ${error instanceof Error ? error.message : String(error)}`
106
+ );
107
+ }
108
+ }
109
+ );
110
+ server.registerTool(
111
+ track(mcpToolName(ctx.productName, "integrations_connections_list")),
112
+ {
113
+ title: "List Connections",
114
+ description: "List provider connections (OAuth + credential).",
115
+ inputSchema: {
116
+ provider: z.string().optional().describe("Filter by provider ID"),
117
+ status: z.string().optional().describe("Filter by status (will be uppercased)"),
118
+ limit: z.number().optional().describe("Page size (default 100)")
119
+ }
120
+ },
121
+ async ({ provider, status, limit }) => {
122
+ try {
123
+ const filter = {};
124
+ if (provider !== void 0) filter.providerId = provider;
125
+ if (status !== void 0) filter.status = status.toUpperCase();
126
+ const data = await ctx.gql.workspace.request(GET_CONNECTIONS, {
127
+ filter: Object.keys(filter).length > 0 ? filter : void 0,
128
+ pagination: { limit: limit ?? 100, offset: 0 }
129
+ });
130
+ return jsonResult(data.getConnections);
131
+ } catch (error) {
132
+ ctx.logger.error("integrations_connections_list failed", { error: String(error) });
133
+ return errorResult(
134
+ `Failed to list connections: ${error instanceof Error ? error.message : String(error)}`
135
+ );
136
+ }
137
+ }
138
+ );
139
+ server.registerTool(
140
+ track(mcpToolName(ctx.productName, "integrations_connections_get")),
141
+ {
142
+ title: "Get Connection",
143
+ description: "Get a connection by ID.",
144
+ inputSchema: { id: z.string().describe("Connection ID") }
145
+ },
146
+ async ({ id }) => {
147
+ try {
148
+ const data = await ctx.gql.workspace.request(
149
+ GET_CONNECTION,
150
+ { id }
151
+ );
152
+ if (!data.getConnection) return errorResult(`Connection ${id} not found`);
153
+ return jsonResult(data.getConnection);
154
+ } catch (error) {
155
+ ctx.logger.error("integrations_connections_get failed", { error: String(error) });
156
+ return errorResult(
157
+ `Failed to get connection: ${error instanceof Error ? error.message : String(error)}`
158
+ );
159
+ }
160
+ }
161
+ );
162
+ server.registerTool(
163
+ track(mcpToolName(ctx.productName, "integrations_connections_add")),
164
+ {
165
+ title: "Create Connection",
166
+ description: "Create a connection (provider id required; credentials stored in vault).",
167
+ inputSchema: {
168
+ name: z.string().describe("Connection name"),
169
+ provider: z.string().describe("Provider ID"),
170
+ scopes: z.array(z.string()).optional().describe("Granted scopes")
171
+ }
172
+ },
173
+ async ({ name, provider, scopes }) => {
174
+ try {
175
+ const input = { name, providerId: provider };
176
+ if (scopes !== void 0) input.grantedScopes = scopes;
177
+ const data = await ctx.gql.workspace.request(
178
+ CREATE_CONNECTION,
179
+ { input }
180
+ );
181
+ return jsonResult(data.createConnection);
182
+ } catch (error) {
183
+ ctx.logger.error("integrations_connections_add failed", { error: String(error) });
184
+ return errorResult(
185
+ `Failed to create connection: ${error instanceof Error ? error.message : String(error)}`
186
+ );
187
+ }
188
+ }
189
+ );
190
+ server.registerTool(
191
+ track(mcpToolName(ctx.productName, "integrations_connections_delete")),
192
+ {
193
+ title: "Delete Connection",
194
+ description: "Delete a connection. Use keepSecret=true to retain the vault secret.",
195
+ inputSchema: {
196
+ id: z.string().describe("Connection ID"),
197
+ keepSecret: z.boolean().optional().describe("Keep vault secret (default false)")
198
+ }
199
+ },
200
+ async ({ id, keepSecret }) => {
201
+ try {
202
+ const data = await ctx.gql.workspace.request(
203
+ DELETE_CONNECTION,
204
+ { id, deleteVaultSecret: !keepSecret }
205
+ );
206
+ return jsonResult({ deleted: data.deleteConnection, connectionId: id });
207
+ } catch (error) {
208
+ ctx.logger.error("integrations_connections_delete failed", { error: String(error) });
209
+ return errorResult(
210
+ `Failed to delete connection: ${error instanceof Error ? error.message : String(error)}`
211
+ );
212
+ }
213
+ }
214
+ );
215
+ server.registerTool(
216
+ track(mcpToolName(ctx.productName, "integrations_logs")),
217
+ {
218
+ title: "Integration Audit Logs",
219
+ description: "List integration audit logs with optional filters.",
220
+ inputSchema: {
221
+ connection: z.string().optional().describe("Filter by connection ID"),
222
+ level: z.string().optional().describe("INFO|WARN|ERROR (will be uppercased)"),
223
+ limit: z.number().optional().describe("Page size (default 100)")
224
+ }
225
+ },
226
+ async ({ connection, level, limit }) => {
227
+ try {
228
+ const filter = {};
229
+ if (connection !== void 0) filter.connectionId = connection;
230
+ if (level !== void 0) filter.level = level.toUpperCase();
231
+ const data = await ctx.gql.workspace.request(GET_INTEGRATION_LOGS, {
232
+ filter: Object.keys(filter).length > 0 ? filter : void 0,
233
+ pagination: { limit: limit ?? 100, offset: 0 }
234
+ });
235
+ return jsonResult(data.getIntegrationLogs);
236
+ } catch (error) {
237
+ ctx.logger.error("integrations_logs failed", { error: String(error) });
238
+ return errorResult(
239
+ `Failed to get integration logs: ${error instanceof Error ? error.message : String(error)}`
240
+ );
241
+ }
242
+ }
243
+ );
244
+ }
245
+
246
+ // src/modules/integrations/index.ts
247
+ var integrationsModule = {
248
+ id: "integrations",
249
+ version: "0.0.1",
250
+ displayName: "Integrations",
251
+ dependsOn: ["auth"],
252
+ capabilities: { tools: {} },
253
+ register(server, ctx) {
254
+ const tools = [];
255
+ const track = (n) => {
256
+ tools.push(n);
257
+ return n;
258
+ };
259
+ registerIntegrationsTools(server, ctx, track);
260
+ return { tools, resources: [], prompts: [] };
261
+ }
262
+ };
263
+ var integrations_default = integrationsModule;
264
+
265
+ export { integrations_default as default };
266
+ //# sourceMappingURL=index.js.map
267
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/modules/integrations/operations.ts","../../../src/modules/integrations/tools.ts","../../../src/modules/integrations/index.ts"],"names":[],"mappings":";;;;AAAO,IAAM,aAAA,GAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAStB,IAAM,YAAA,GAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AA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b,SAAA,EAAW,CAAC,MAAM,CAAA;AAAA,EAClB,YAAA,EAAc,EAAE,KAAA,EAAO,EAAC,EAAE;AAAA,EAE1B,QAAA,CAAS,QAAmB,GAAA,EAAqC;AAC/D,IAAA,MAAM,QAAkB,EAAC;AACzB,IAAA,MAAM,KAAA,GAAQ,CAAC,CAAA,KAAsB;AACnC,MAAA,KAAA,CAAM,KAAK,CAAC,CAAA;AACZ,MAAA,OAAO,CAAA;AAAA,IACT,CAAA;AAEA,IAAA,yBAAA,CAA0B,MAAA,EAAQ,KAAK,KAAK,CAAA;AAE5C,IAAA,OAAO,EAAE,KAAA,EAAO,SAAA,EAAW,EAAC,EAAG,OAAA,EAAS,EAAC,EAAE;AAAA,EAC7C;AACF,CAAA;AAEA,IAAO,oBAAA,GAAQ","file":"index.js","sourcesContent":["export const GET_PROVIDERS = `\n query GetProviders($filter: ProviderFilterInput, $pagination: IntegrationsPaginationInput) {\n getProviders(filter: $filter, pagination: $pagination) {\n items { id key name category authType isEnabled }\n total hasMore\n }\n }\n`;\n\nexport const GET_PROVIDER = `\n query GetProvider($id: ID!) {\n getProvider(id: $id) {\n id key name authType category connectionCount\n }\n }\n`;\n\nexport const GET_CONNECTIONS = `\n query GetConnections($filter: ConnectionFilterInput, $pagination: IntegrationsPaginationInput) {\n getConnections(filter: $filter, pagination: $pagination) {\n items { id name providerId status grantedScopes }\n total hasMore\n }\n }\n`;\n\nexport const GET_CONNECTION = `\n query GetConnection($id: ID!) {\n getConnection(id: $id) {\n id name providerId status externalAccountEmail credentialSource\n }\n }\n`;\n\nexport const CREATE_CONNECTION = `\n mutation CreateConnection($input: CreateConnectionInput!) {\n createConnection(input: $input) {\n id name status providerId\n }\n }\n`;\n\nexport const DELETE_CONNECTION = `\n mutation DeleteConnection($id: ID!, $deleteVaultSecret: Boolean) {\n deleteConnection(id: $id, deleteVaultSecret: $deleteVaultSecret)\n }\n`;\n\nexport const GET_INTEGRATION_LOGS = `\n query GetIntegrationLogs($filter: LogFilterInput, $pagination: IntegrationsPaginationInput) {\n getIntegrationLogs(filter: $filter, pagination: $pagination) {\n items { id action level message createdAt }\n total hasMore\n }\n }\n`;\n","/**\n * Integrations MCP tools — providers, connections, logs.\n * Surface mirrors cli-sdk/src/modules/integrations/commands.ts.\n */\n\nimport { z } from 'zod';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { jsonResult, errorResult, mcpToolName, type McpContext } from '../../core/index.js';\nimport * as ops from './operations.js';\n\ninterface ProviderRow {\n id: string;\n key: string;\n name: string;\n category?: string;\n authType?: string;\n isEnabled?: boolean;\n}\n\ninterface ConnectionRow {\n id: string;\n name: string;\n providerId: string;\n status?: string;\n grantedScopes?: string[];\n}\n\ninterface IntegrationLog {\n id: string;\n action: string;\n level: string;\n message: string;\n createdAt: string;\n}\n\nexport function registerIntegrationsTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n // ── Providers ───────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_providers_list')),\n {\n title: 'List Integration Providers',\n description: 'List integration providers with optional category/enabled filters.',\n inputSchema: {\n category: z.string().optional().describe('Filter by category (will be uppercased)'),\n enabled: z.boolean().optional().describe('Filter by enabled flag'),\n limit: z.number().optional().describe('Page size (default 100)'),\n },\n },\n async ({ category, enabled, limit }) => {\n try {\n const filter: Record<string, unknown> = {};\n if (category !== undefined) filter.category = category.toUpperCase();\n if (enabled !== undefined) filter.isEnabled = enabled;\n const data = await ctx.gql.workspace.request<{\n getProviders: { items: ProviderRow[]; total: number; hasMore: boolean };\n }>(ops.GET_PROVIDERS, {\n filter: Object.keys(filter).length > 0 ? filter : undefined,\n pagination: { limit: limit ?? 100, offset: 0 },\n });\n return jsonResult(data.getProviders);\n } catch (error) {\n ctx.logger.error('integrations_providers_list failed', { error: String(error) });\n return errorResult(\n `Failed to list providers: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_providers_get')),\n {\n title: 'Get Integration Provider',\n description: 'Get an integration provider by ID.',\n inputSchema: { id: z.string().describe('Provider ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.workspace.request<{ getProvider: ProviderRow | null }>(\n ops.GET_PROVIDER,\n { id },\n );\n if (!data.getProvider) return errorResult(`Provider ${id} not found`);\n return jsonResult(data.getProvider);\n } catch (error) {\n ctx.logger.error('integrations_providers_get failed', { error: String(error) });\n return errorResult(\n `Failed to get provider: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Connections ─────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_connections_list')),\n {\n title: 'List Connections',\n description: 'List provider connections (OAuth + credential).',\n inputSchema: {\n provider: z.string().optional().describe('Filter by provider ID'),\n status: z.string().optional().describe('Filter by status (will be uppercased)'),\n limit: z.number().optional().describe('Page size (default 100)'),\n },\n },\n async ({ provider, status, limit }) => {\n try {\n const filter: Record<string, unknown> = {};\n if (provider !== undefined) filter.providerId = provider;\n if (status !== undefined) filter.status = status.toUpperCase();\n const data = await ctx.gql.workspace.request<{\n getConnections: { items: ConnectionRow[]; total: number; hasMore: boolean };\n }>(ops.GET_CONNECTIONS, {\n filter: Object.keys(filter).length > 0 ? filter : undefined,\n pagination: { limit: limit ?? 100, offset: 0 },\n });\n return jsonResult(data.getConnections);\n } catch (error) {\n ctx.logger.error('integrations_connections_list failed', { error: String(error) });\n return errorResult(\n `Failed to list connections: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_connections_get')),\n {\n title: 'Get Connection',\n description: 'Get a connection by ID.',\n inputSchema: { id: z.string().describe('Connection ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.workspace.request<{ getConnection: ConnectionRow | null }>(\n ops.GET_CONNECTION,\n { id },\n );\n if (!data.getConnection) return errorResult(`Connection ${id} not found`);\n return jsonResult(data.getConnection);\n } catch (error) {\n ctx.logger.error('integrations_connections_get failed', { error: String(error) });\n return errorResult(\n `Failed to get connection: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_connections_add')),\n {\n title: 'Create Connection',\n description: 'Create a connection (provider id required; credentials stored in vault).',\n inputSchema: {\n name: z.string().describe('Connection name'),\n provider: z.string().describe('Provider ID'),\n scopes: z.array(z.string()).optional().describe('Granted scopes'),\n },\n },\n async ({ name, provider, scopes }) => {\n try {\n const input: Record<string, unknown> = { name, providerId: provider };\n if (scopes !== undefined) input.grantedScopes = scopes;\n const data = await ctx.gql.workspace.request<{ createConnection: ConnectionRow }>(\n ops.CREATE_CONNECTION,\n { input },\n );\n return jsonResult(data.createConnection);\n } catch (error) {\n ctx.logger.error('integrations_connections_add failed', { error: String(error) });\n return errorResult(\n `Failed to create connection: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_connections_delete')),\n {\n title: 'Delete Connection',\n description: 'Delete a connection. Use keepSecret=true to retain the vault secret.',\n inputSchema: {\n id: z.string().describe('Connection ID'),\n keepSecret: z.boolean().optional().describe('Keep vault secret (default false)'),\n },\n },\n async ({ id, keepSecret }) => {\n try {\n const data = await ctx.gql.workspace.request<{ deleteConnection: boolean }>(\n ops.DELETE_CONNECTION,\n { id, deleteVaultSecret: !keepSecret },\n );\n return jsonResult({ deleted: data.deleteConnection, connectionId: id });\n } catch (error) {\n ctx.logger.error('integrations_connections_delete failed', { error: String(error) });\n return errorResult(\n `Failed to delete connection: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Logs ────────────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'integrations_logs')),\n {\n title: 'Integration Audit Logs',\n description: 'List integration audit logs with optional filters.',\n inputSchema: {\n connection: z.string().optional().describe('Filter by connection ID'),\n level: z.string().optional().describe('INFO|WARN|ERROR (will be uppercased)'),\n limit: z.number().optional().describe('Page size (default 100)'),\n },\n },\n async ({ connection, level, limit }) => {\n try {\n const filter: Record<string, unknown> = {};\n if (connection !== undefined) filter.connectionId = connection;\n if (level !== undefined) filter.level = level.toUpperCase();\n const data = await ctx.gql.workspace.request<{\n getIntegrationLogs: { items: IntegrationLog[]; total: number; hasMore: boolean };\n }>(ops.GET_INTEGRATION_LOGS, {\n filter: Object.keys(filter).length > 0 ? filter : undefined,\n pagination: { limit: limit ?? 100, offset: 0 },\n });\n return jsonResult(data.getIntegrationLogs);\n } catch (error) {\n ctx.logger.error('integrations_logs failed', { error: String(error) });\n return errorResult(\n `Failed to get integration logs: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n}\n","/**\n * Integrations module — providers, connections, audit logs.\n * Surface mirrors cli-sdk/src/modules/integrations/.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { McpContext, McpModule, ModuleRegistration } from '../../core/index.js';\nimport { registerIntegrationsTools } from './tools.js';\n\nconst integrationsModule: McpModule = {\n id: 'integrations',\n version: '0.0.1',\n displayName: 'Integrations',\n dependsOn: ['auth'],\n capabilities: { tools: {} },\n\n register(server: McpServer, ctx: McpContext): ModuleRegistration {\n const tools: string[] = [];\n const track = (n: string): string => {\n tools.push(n);\n return n;\n };\n\n registerIntegrationsTools(server, ctx, track);\n\n return { tools, resources: [], prompts: [] };\n },\n};\n\nexport default integrationsModule;\n"]}
@@ -0,0 +1,222 @@
1
+ 'use strict';
2
+
3
+ var zod = require('zod');
4
+ require('graphql-request');
5
+ require('cross-fetch');
6
+ require('@modelcontextprotocol/sdk/server/mcp.js');
7
+ require('@modelcontextprotocol/sdk/types.js');
8
+
9
+ // src/modules/notifications/tools.ts
10
+
11
+ // src/core/errors.ts
12
+ var McpInternalError = class extends Error {
13
+ cause;
14
+ constructor(message, cause) {
15
+ super(message);
16
+ this.name = "McpInternalError";
17
+ this.cause = cause;
18
+ }
19
+ };
20
+
21
+ // src/core/result.ts
22
+ function jsonResult(data, structured) {
23
+ const result = {
24
+ content: [{ type: "text", text: JSON.stringify(data, null, 2) }]
25
+ };
26
+ return result;
27
+ }
28
+ function errorResult(message, hint) {
29
+ const text = hint ? `${message}
30
+
31
+ Hint: ${hint}` : message;
32
+ return { content: [{ type: "text", text }], isError: true };
33
+ }
34
+
35
+ // src/core/tool-name.ts
36
+ var MAX_TOOL_NAME_LENGTH = 63;
37
+ function assertSafeName(name, kind) {
38
+ if (name.length > MAX_TOOL_NAME_LENGTH) {
39
+ throw new McpInternalError(
40
+ `Tool name '${name}' exceeds ${MAX_TOOL_NAME_LENGTH} characters (some MCP clients truncate at 64).`
41
+ );
42
+ }
43
+ return name;
44
+ }
45
+ function mcpToolName(productName, ...parts) {
46
+ if (!productName) {
47
+ throw new McpInternalError("mcpToolName: productName is required");
48
+ }
49
+ const name = [productName, ...parts].filter(Boolean).join("_");
50
+ return assertSafeName(name);
51
+ }
52
+
53
+ // src/modules/notifications/operations.ts
54
+ var LIST_NOTIFICATIONS = `
55
+ query ListNotifications($filter: NotificationFilterInput, $limit: Int, $offset: Int) {
56
+ notifications(filter: $filter, limit: $limit, offset: $offset) {
57
+ items { id title message channel status isRead createdAt }
58
+ total
59
+ }
60
+ }
61
+ `;
62
+ var MARK_NOTIFICATION_READ = `
63
+ mutation MarkNotificationRead($id: ID!) {
64
+ markNotificationAsRead(id: $id) {
65
+ id isRead readAt
66
+ }
67
+ }
68
+ `;
69
+ var NOTIFICATION_PREFERENCES = `
70
+ query NotificationPreferences($filter: NotificationPreferenceFilterInput, $limit: Int) {
71
+ notificationPreferences(filter: $filter, limit: $limit) {
72
+ items { id channel enabled frequency scope topicId userId }
73
+ }
74
+ }
75
+ `;
76
+ var CREATE_NOTIFICATION_PREFERENCE = `
77
+ mutation CreateNotificationPreference($input: CreateNotificationPreferenceInput!) {
78
+ createNotificationPreference(input: $input) {
79
+ id channel enabled frequency
80
+ }
81
+ }
82
+ `;
83
+
84
+ // src/modules/notifications/tools.ts
85
+ function registerNotificationsTools(server, ctx, track) {
86
+ server.registerTool(
87
+ track(mcpToolName(ctx.productName, "notifications_list")),
88
+ {
89
+ title: "List Notifications",
90
+ description: "List the current user's notifications with optional filters.",
91
+ inputSchema: {
92
+ unread: zod.z.boolean().optional().describe("Only unread notifications"),
93
+ channel: zod.z.string().optional().describe("Filter by channel (will be uppercased)"),
94
+ limit: zod.z.number().optional().describe("Page size (default 50)")
95
+ }
96
+ },
97
+ async ({ unread, channel, limit }) => {
98
+ try {
99
+ const filter = {};
100
+ if (unread === true) filter.isRead = false;
101
+ if (channel !== void 0) filter.channel = channel.toUpperCase();
102
+ const data = await ctx.gql.global.request(LIST_NOTIFICATIONS, {
103
+ filter: Object.keys(filter).length ? filter : void 0,
104
+ limit: limit ?? 50,
105
+ offset: 0
106
+ });
107
+ return jsonResult(data.notifications);
108
+ } catch (error) {
109
+ ctx.logger.error("notifications_list failed", { error: String(error) });
110
+ return errorResult(
111
+ `Failed to list notifications: ${error instanceof Error ? error.message : String(error)}`
112
+ );
113
+ }
114
+ }
115
+ );
116
+ server.registerTool(
117
+ track(mcpToolName(ctx.productName, "notifications_read")),
118
+ {
119
+ title: "Mark Notification Read",
120
+ description: "Mark a notification as read.",
121
+ inputSchema: { id: zod.z.string().describe("Notification ID") }
122
+ },
123
+ async ({ id }) => {
124
+ try {
125
+ const data = await ctx.gql.global.request(MARK_NOTIFICATION_READ, { id });
126
+ return jsonResult(data.markNotificationAsRead);
127
+ } catch (error) {
128
+ ctx.logger.error("notifications_read failed", { error: String(error) });
129
+ return errorResult(
130
+ `Failed to mark notification read: ${error instanceof Error ? error.message : String(error)}`
131
+ );
132
+ }
133
+ }
134
+ );
135
+ server.registerTool(
136
+ track(mcpToolName(ctx.productName, "notifications_preferences_get")),
137
+ {
138
+ title: "Get Notification Preferences",
139
+ description: "Show the current user's notification preferences.",
140
+ inputSchema: {
141
+ user: zod.z.string().optional().describe("Override user ID"),
142
+ limit: zod.z.number().optional().describe("Page size (default 100)")
143
+ }
144
+ },
145
+ async ({ user, limit }) => {
146
+ try {
147
+ const auth = ctx.auth.read();
148
+ const userId = user ?? auth?.workspaceId ?? "";
149
+ const filter = userId ? { userId } : {};
150
+ const data = await ctx.gql.global.request(NOTIFICATION_PREFERENCES, {
151
+ filter: Object.keys(filter).length ? filter : void 0,
152
+ limit: limit ?? 100
153
+ });
154
+ return jsonResult(data.notificationPreferences);
155
+ } catch (error) {
156
+ ctx.logger.error("notifications_preferences_get failed", { error: String(error) });
157
+ return errorResult(
158
+ `Failed to get notification preferences: ${error instanceof Error ? error.message : String(error)}`
159
+ );
160
+ }
161
+ }
162
+ );
163
+ server.registerTool(
164
+ track(mcpToolName(ctx.productName, "notifications_preferences_set")),
165
+ {
166
+ title: "Set Notification Preference",
167
+ description: "Create/update a notification preference.",
168
+ inputSchema: {
169
+ channel: zod.z.string().describe("EMAIL|SMS|IN_APP|PUSH|WEBHOOK (will be uppercased)"),
170
+ enabled: zod.z.boolean().describe("Whether the channel is enabled"),
171
+ frequency: zod.z.string().optional().describe("IMMEDIATE|HOURLY|DAILY|WEEKLY (default IMMEDIATE)"),
172
+ scope: zod.z.string().optional().describe("GLOBAL|WORKSPACE|VIBE (default GLOBAL)"),
173
+ topic: zod.z.string().optional().describe("Topic ID"),
174
+ user: zod.z.string().optional().describe("Override user ID")
175
+ }
176
+ },
177
+ async ({ channel, enabled, frequency, scope, topic, user }) => {
178
+ try {
179
+ const auth = ctx.auth.read();
180
+ const input = {
181
+ channel: channel.toUpperCase(),
182
+ enabled,
183
+ frequency: (frequency ?? "IMMEDIATE").toUpperCase(),
184
+ scope: (scope ?? "GLOBAL").toUpperCase()
185
+ };
186
+ if (topic !== void 0) input.topicId = topic;
187
+ const userId = user ?? auth?.workspaceId;
188
+ if (userId !== void 0) input.userId = userId;
189
+ const data = await ctx.gql.global.request(CREATE_NOTIFICATION_PREFERENCE, { input });
190
+ return jsonResult(data.createNotificationPreference);
191
+ } catch (error) {
192
+ ctx.logger.error("notifications_preferences_set failed", { error: String(error) });
193
+ return errorResult(
194
+ `Failed to set notification preference: ${error instanceof Error ? error.message : String(error)}`
195
+ );
196
+ }
197
+ }
198
+ );
199
+ }
200
+
201
+ // src/modules/notifications/index.ts
202
+ var notificationsModule = {
203
+ id: "notifications",
204
+ version: "0.0.1",
205
+ displayName: "Notifications",
206
+ dependsOn: ["auth"],
207
+ capabilities: { tools: {} },
208
+ register(server, ctx) {
209
+ const tools = [];
210
+ const track = (n) => {
211
+ tools.push(n);
212
+ return n;
213
+ };
214
+ registerNotificationsTools(server, ctx, track);
215
+ return { tools, resources: [], prompts: [] };
216
+ }
217
+ };
218
+ var notifications_default = notificationsModule;
219
+
220
+ module.exports = notifications_default;
221
+ //# sourceMappingURL=index.cjs.map
222
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/core/errors.ts","../../../src/core/result.ts","../../../src/core/tool-name.ts","../../../src/modules/notifications/operations.ts","../../../src/modules/notifications/tools.ts","../../../src/modules/notifications/index.ts"],"names":["z"],"mappings":";;;;;;;;;;;AA8BO,IAAM,gBAAA,GAAN,cAA+B,KAAA,CAAM;AAAA,EACjB,KAAA;AAAA,EAEzB,WAAA,CAAY,SAAiB,KAAA,EAAiB;AAC5C,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,kBAAA;AACZ,IAAA,IAAA,CAAK,KAAA,GAAQ,KAAA;AAAA,EACf;AACF,CAAA;;;ACCO,SAAS,UAAA,CAAW,MAAe,UAAA,EAAkD;AAC1F,EAAA,MAAM,MAAA,GAAqB;AAAA,IACzB,OAAA,EAAS,CAAC,EAAE,IAAA,EAAM,MAAA,EAAQ,IAAA,EAAM,IAAA,CAAK,SAAA,CAAU,IAAA,EAAM,IAAA,EAAM,CAAC,CAAA,EAAG;AAAA,GACjE;AAIA,EAAA,OAAO,MAAA;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,OAAO,MAAA,CAAO,KAAK,GAAG,CAAA;AACjF,QAAA,OAAO,WAAA;AAAA,UACL,0CAA0C,KAAA,YAAiB,KAAA,GAAQ,MAAM,OAAA,GAAU,MAAA,CAAO,KAAK,CAAC,CAAA;AAAA,SAClG;AAAA,MACF;AAAA,IACF;AAAA,GACF;AACF;;;ACzJA,IAAM,mBAAA,GAAiC;AAAA,EACrC,EAAA,EAAI,eAAA;AAAA,EACJ,OAAA,EAAS,OAAA;AAAA,EACT,WAAA,EAAa,eAAA;AAAA,EACb,SAAA,EAAW,CAAC,MAAM,CAAA;AAAA,EAClB,YAAA,EAAc,EAAE,KAAA,EAAO,EAAC,EAAE;AAAA,EAE1B,QAAA,CAAS,QAAmB,GAAA,EAAqC;AAC/D,IAAA,MAAM,QAAkB,EAAC;AACzB,IAAA,MAAM,KAAA,GAAQ,CAAC,CAAA,KAAsB;AACnC,MAAA,KAAA,CAAM,KAAK,CAAC,CAAA;AACZ,MAAA,OAAO,CAAA;AAAA,IACT,CAAA;AAEA,IAAA,0BAAA,CAA2B,MAAA,EAAQ,KAAK,KAAK,CAAA;AAE7C,IAAA,OAAO,EAAE,KAAA,EAAO,SAAA,EAAW,EAAC,EAAG,OAAA,EAAS,EAAC,EAAE;AAAA,EAC7C;AACF,CAAA;AAEA,IAAO,qBAAA,GAAQ","file":"index.cjs","sourcesContent":["/**\n * Error classes for MCP SDK.\n *\n * Modules MUST throw these instead of throwing raw Errors. The registerTool\n * wrapper in result.ts catches and maps them to MCP-protocol-compliant\n * `{ isError: true, content: [...] }` responses.\n *\n * Throwing past the wrapper to the protocol surfaces as JSON-RPC -32603 to\n * the client and is a protocol bug.\n */\n\nexport class McpUserError extends Error {\n public readonly hint: string | undefined;\n\n constructor(message: string, opts?: { hint?: string }) {\n super(message);\n this.name = 'McpUserError';\n this.hint = opts?.hint;\n }\n}\n\nexport class McpAuthError extends McpUserError {\n constructor(message: string, opts?: { hint?: string }) {\n super(message, {\n hint: opts?.hint ?? 'Run the auth_login tool to authenticate.',\n });\n this.name = 'McpAuthError';\n }\n}\n\nexport class McpInternalError extends Error {\n public override readonly cause: unknown;\n\n constructor(message: string, cause?: unknown) {\n super(message);\n this.name = 'McpInternalError';\n this.cause = cause;\n }\n}\n","/**\n * MCP tool result helpers + central handler.\n *\n * Modules NEVER call server.registerTool directly — they use registerTool()\n * from this module so the central try/catch wraps the handler and:\n * - maps thrown McpUserError / McpAuthError / McpInternalError to\n * MCP-protocol-compliant `{ isError: true, content: [...] }` shapes\n * - threads `_meta.progressToken` into ctx.progress for long ops\n * - emits a structured log line on every error\n * - never leaks `cause` from McpInternalError to the client\n *\n * This is the analog of cli-sdk's createProgram() central error handler.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { ZodRawShape } from 'zod';\nimport type { McpContext } from './context.js';\nimport { McpAuthError, McpInternalError, McpUserError } from './errors.js';\n\nexport interface ToolTextContent {\n type: 'text';\n text: string;\n [k: string]: unknown;\n}\n\nexport interface ToolResult {\n content: ToolTextContent[];\n isError?: boolean;\n structuredContent?: Record<string, unknown>;\n [k: string]: unknown;\n}\n\nexport interface ToolMeta {\n progressToken?: string | number;\n}\n\n/**\n * Build a successful tool result with JSON content (pretty-printed).\n */\nexport function jsonResult(data: unknown, structured?: Record<string, unknown>): ToolResult {\n const result: ToolResult = {\n content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],\n };\n if (structured !== undefined) {\n result.structuredContent = structured;\n }\n return result;\n}\n\n/**\n * Build a successful tool result with plain text content.\n */\nexport function textResult(text: string): ToolResult {\n return { content: [{ type: 'text', text }] };\n}\n\n/**\n * Build an error tool result. Honors MCP's `{ isError: true, content }` shape.\n * Optional hint is appended on a new line so the LLM can react.\n */\nexport function errorResult(message: string, hint?: string): ToolResult {\n const text = hint ? `${message}\\n\\nHint: ${hint}` : message;\n return { content: [{ type: 'text', text }], isError: true };\n}\n\nexport interface ToolMetadata {\n title: string;\n description: string;\n inputSchema?: ZodRawShape;\n}\n\nexport type ToolHandler<TArgs = Record<string, unknown>> = (\n args: TArgs,\n ctx: McpContext,\n meta: ToolMeta,\n) => Promise<unknown>;\n\n/**\n * Register a tool with the central error wrapper.\n *\n * The handler returns a plain value or void. The wrapper:\n * - wraps non-undefined returns in jsonResult()\n * - if the value already looks like a ToolResult (has `content`), passes through\n * - catches McpAuthError / McpUserError / McpInternalError / generic Error\n * - logs every error via ctx.logger.error\n */\nexport function registerTool<TArgs extends Record<string, unknown>>(\n server: McpServer,\n ctx: McpContext,\n name: string,\n metadata: ToolMetadata,\n handler: ToolHandler<TArgs>,\n): void {\n const sdkConfig = {\n title: metadata.title,\n description: metadata.description,\n ...(metadata.inputSchema ? { inputSchema: metadata.inputSchema } : {}),\n };\n\n // The MCP SDK's registerTool signature is `(name, config, handler)`. The\n // handler arity depends on whether inputSchema is present (1-arg without,\n // 2-arg with). We accept a unified handler shape and dispatch at runtime.\n // The SDK's typing is strict and conditional on the inputSchema generic;\n // bypass with a cast since runtime acceptance is unconditional.\n const wrapped = async (...callbackArgs: unknown[]): Promise<ToolResult> => {\n const hasArgs = callbackArgs.length === 2;\n const args = (hasArgs ? callbackArgs[0] : {}) as TArgs;\n const extra = (hasArgs ? callbackArgs[1] : callbackArgs[0]) as\n | { _meta?: { progressToken?: string | number } }\n | undefined;\n\n const progressToken = extra?._meta?.progressToken;\n const meta: ToolMeta = progressToken !== undefined ? { progressToken } : {};\n\n try {\n const result = await handler(args, ctx, meta);\n if (isToolResult(result)) return result;\n if (result === undefined) return textResult('OK');\n return jsonResult(result);\n } catch (error) {\n return mapErrorToResult(error, ctx, name);\n }\n };\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (server as any).registerTool(name, sdkConfig, wrapped);\n}\n\nfunction isToolResult(value: unknown): value is ToolResult {\n return (\n !!value &&\n typeof value === 'object' &&\n 'content' in value &&\n Array.isArray((value as ToolResult).content)\n );\n}\n\nfunction mapErrorToResult(error: unknown, ctx: McpContext, toolName: string): ToolResult {\n if (error instanceof McpAuthError) {\n ctx.logger.warn(`${toolName}: auth required`, { message: error.message });\n return errorResult(error.message, error.hint);\n }\n if (error instanceof McpUserError) {\n ctx.logger.info(`${toolName}: user error`, { message: error.message });\n return errorResult(error.message, error.hint);\n }\n if (error instanceof McpInternalError) {\n ctx.logger.error(`${toolName}: internal error`, {\n message: error.message,\n cause: stringifyCause(error.cause),\n });\n return errorResult(`Internal error in ${toolName}.`);\n }\n const message = error instanceof Error ? error.message : String(error);\n ctx.logger.error(`${toolName}: unhandled error`, { message });\n return errorResult(`${toolName}: ${message}`);\n}\n\nfunction stringifyCause(cause: unknown): string | undefined {\n if (cause === undefined || cause === null) return undefined;\n if (cause instanceof Error) return cause.message;\n try {\n return JSON.stringify(cause);\n } catch {\n return String(cause);\n }\n}\n","/**\n * Tool / resource / prompt naming helpers.\n *\n * Mandatory product prefix avoids collisions when Claude Desktop runs\n * multiple MCP servers concurrently (typical setup is ~6).\n *\n * Tool names are capped at 63 characters — Claude Desktop pre-1.x\n * truncated at 64 in some versions.\n */\n\nimport { McpInternalError } from './errors.js';\n\nconst MAX_TOOL_NAME_LENGTH = 63;\n\nfunction assertSafeName(name: string, kind: 'tool' | 'resource' | 'prompt'): string {\n if (kind === 'tool' && name.length > MAX_TOOL_NAME_LENGTH) {\n throw new McpInternalError(\n `Tool name '${name}' exceeds ${MAX_TOOL_NAME_LENGTH} characters (some MCP clients truncate at 64).`,\n );\n }\n return name;\n}\n\n/**\n * Build a tool name. Format: `<productName>_<...parts>` (snake_case).\n * Example: mcpToolName('vibecontrols', 'vibes', 'list') -> 'vibecontrols_vibes_list'\n */\nexport function mcpToolName(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpToolName: productName is required');\n }\n const name = [productName, ...parts].filter(Boolean).join('_');\n return assertSafeName(name, 'tool');\n}\n\n/**\n * Build a resource URI. Format: `<productName>://<...parts>`.\n * Example: mcpResourceUri('vibecontrols', 'schema') -> 'vibecontrols://schema'\n */\nexport function mcpResourceUri(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpResourceUri: productName is required');\n }\n return `${productName}://${parts.filter(Boolean).join('/')}`;\n}\n\n/**\n * Build a prompt name. Format: `<productName>-<...parts>` (kebab-case).\n * Example: mcpPromptName('vibecontrols', 'setup') -> 'vibecontrols-setup'\n */\nexport function mcpPromptName(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpPromptName: productName is required');\n }\n return [productName, ...parts].filter(Boolean).join('-');\n}\n\nexport const TOOL_NAME_LIMIT = MAX_TOOL_NAME_LENGTH;\n","export const LIST_NOTIFICATIONS = `\n query ListNotifications($filter: NotificationFilterInput, $limit: Int, $offset: Int) {\n notifications(filter: $filter, limit: $limit, offset: $offset) {\n items { id title message channel status isRead createdAt }\n total\n }\n }\n`;\n\nexport const MARK_NOTIFICATION_READ = `\n mutation MarkNotificationRead($id: ID!) {\n markNotificationAsRead(id: $id) {\n id isRead readAt\n }\n }\n`;\n\nexport const NOTIFICATION_PREFERENCES = `\n query NotificationPreferences($filter: NotificationPreferenceFilterInput, $limit: Int) {\n notificationPreferences(filter: $filter, limit: $limit) {\n items { id channel enabled frequency scope topicId userId }\n }\n }\n`;\n\nexport const CREATE_NOTIFICATION_PREFERENCE = `\n mutation CreateNotificationPreference($input: CreateNotificationPreferenceInput!) {\n createNotificationPreference(input: $input) {\n id channel enabled frequency\n }\n }\n`;\n","/**\n * Notifications MCP tools — notification inbox & preferences.\n * Surface mirrors cli-sdk/src/modules/notifications/commands.ts.\n */\n\nimport { z } from 'zod';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { jsonResult, errorResult, mcpToolName, type McpContext } from '../../core/index.js';\nimport * as ops from './operations.js';\n\ninterface NotificationRow {\n id: string;\n title?: string;\n message?: string;\n channel?: string;\n status?: string;\n isRead?: boolean;\n createdAt?: string;\n}\n\ninterface PreferenceRow {\n id: string;\n channel: string;\n enabled: boolean;\n frequency?: string;\n scope?: string;\n topicId?: string;\n userId?: string;\n}\n\nexport function registerNotificationsTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n server.registerTool(\n track(mcpToolName(ctx.productName, 'notifications_list')),\n {\n title: 'List Notifications',\n description: \"List the current user's notifications with optional filters.\",\n inputSchema: {\n unread: z.boolean().optional().describe('Only unread notifications'),\n channel: z.string().optional().describe('Filter by channel (will be uppercased)'),\n limit: z.number().optional().describe('Page size (default 50)'),\n },\n },\n async ({ unread, channel, limit }) => {\n try {\n const filter: Record<string, unknown> = {};\n if (unread === true) filter.isRead = false;\n if (channel !== undefined) filter.channel = channel.toUpperCase();\n const data = await ctx.gql.global.request<{\n notifications: { items: NotificationRow[]; total: number };\n }>(ops.LIST_NOTIFICATIONS, {\n filter: Object.keys(filter).length ? filter : undefined,\n limit: limit ?? 50,\n offset: 0,\n });\n return jsonResult(data.notifications);\n } catch (error) {\n ctx.logger.error('notifications_list failed', { error: String(error) });\n return errorResult(\n `Failed to list notifications: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'notifications_read')),\n {\n title: 'Mark Notification Read',\n description: 'Mark a notification as read.',\n inputSchema: { id: z.string().describe('Notification ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.global.request<{\n markNotificationAsRead: { id: string; isRead: boolean; readAt?: string };\n }>(ops.MARK_NOTIFICATION_READ, { id });\n return jsonResult(data.markNotificationAsRead);\n } catch (error) {\n ctx.logger.error('notifications_read failed', { error: String(error) });\n return errorResult(\n `Failed to mark notification read: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'notifications_preferences_get')),\n {\n title: 'Get Notification Preferences',\n description: \"Show the current user's notification preferences.\",\n inputSchema: {\n user: z.string().optional().describe('Override user ID'),\n limit: z.number().optional().describe('Page size (default 100)'),\n },\n },\n async ({ user, limit }) => {\n try {\n const auth = ctx.auth.read();\n const userId = user ?? auth?.workspaceId ?? '';\n const filter: Record<string, unknown> = userId ? { userId } : {};\n const data = await ctx.gql.global.request<{\n notificationPreferences: { items: PreferenceRow[] };\n }>(ops.NOTIFICATION_PREFERENCES, {\n filter: Object.keys(filter).length ? filter : undefined,\n limit: limit ?? 100,\n });\n return jsonResult(data.notificationPreferences);\n } catch (error) {\n ctx.logger.error('notifications_preferences_get failed', { error: String(error) });\n return errorResult(\n `Failed to get notification preferences: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'notifications_preferences_set')),\n {\n title: 'Set Notification Preference',\n description: 'Create/update a notification preference.',\n inputSchema: {\n channel: z.string().describe('EMAIL|SMS|IN_APP|PUSH|WEBHOOK (will be uppercased)'),\n enabled: z.boolean().describe('Whether the channel is enabled'),\n frequency: z\n .string()\n .optional()\n .describe('IMMEDIATE|HOURLY|DAILY|WEEKLY (default IMMEDIATE)'),\n scope: z.string().optional().describe('GLOBAL|WORKSPACE|VIBE (default GLOBAL)'),\n topic: z.string().optional().describe('Topic ID'),\n user: z.string().optional().describe('Override user ID'),\n },\n },\n async ({ channel, enabled, frequency, scope, topic, user }) => {\n try {\n const auth = ctx.auth.read();\n const input: Record<string, unknown> = {\n channel: channel.toUpperCase(),\n enabled,\n frequency: (frequency ?? 'IMMEDIATE').toUpperCase(),\n scope: (scope ?? 'GLOBAL').toUpperCase(),\n };\n if (topic !== undefined) input.topicId = topic;\n const userId = user ?? auth?.workspaceId;\n if (userId !== undefined) input.userId = userId;\n const data = await ctx.gql.global.request<{\n createNotificationPreference: PreferenceRow;\n }>(ops.CREATE_NOTIFICATION_PREFERENCE, { input });\n return jsonResult(data.createNotificationPreference);\n } catch (error) {\n ctx.logger.error('notifications_preferences_set failed', { error: String(error) });\n return errorResult(\n `Failed to set notification preference: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n}\n","/**\n * Notifications module — notification inbox + preferences (global gateway).\n * Surface mirrors cli-sdk/src/modules/notifications/.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { McpContext, McpModule, ModuleRegistration } from '../../core/index.js';\nimport { registerNotificationsTools } from './tools.js';\n\nconst notificationsModule: McpModule = {\n id: 'notifications',\n version: '0.0.1',\n displayName: 'Notifications',\n dependsOn: ['auth'],\n capabilities: { tools: {} },\n\n register(server: McpServer, ctx: McpContext): ModuleRegistration {\n const tools: string[] = [];\n const track = (n: string): string => {\n tools.push(n);\n return n;\n };\n\n registerNotificationsTools(server, ctx, track);\n\n return { tools, resources: [], prompts: [] };\n },\n};\n\nexport default notificationsModule;\n"]}
@@ -0,0 +1,8 @@
1
+ import { c as McpModule } from '../../module-DFQBZNK6.cjs';
2
+ import '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import '../../context-1jV4NsLv.cjs';
4
+ import 'graphql-request';
5
+
6
+ declare const notificationsModule: McpModule;
7
+
8
+ export { notificationsModule as default };
@@ -0,0 +1,8 @@
1
+ import { c as McpModule } from '../../module-DBcfA-i3.js';
2
+ import '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import '../../context-1jV4NsLv.js';
4
+ import 'graphql-request';
5
+
6
+ declare const notificationsModule: McpModule;
7
+
8
+ export { notificationsModule as default };