@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.
- package/README.md +76 -0
- package/dist/chunk-4GBVJ4OY.js +847 -0
- package/dist/chunk-4GBVJ4OY.js.map +1 -0
- package/dist/chunk-H2OYWLOA.js +919 -0
- package/dist/chunk-H2OYWLOA.js.map +1 -0
- package/dist/chunk-JFEQYSWM.js +174 -0
- package/dist/chunk-JFEQYSWM.js.map +1 -0
- package/dist/chunk-WWFVD7BO.js +273 -0
- package/dist/chunk-WWFVD7BO.js.map +1 -0
- package/dist/context-1jV4NsLv.d.cts +138 -0
- package/dist/context-1jV4NsLv.d.ts +138 -0
- package/dist/core/index.cjs +953 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +59 -0
- package/dist/core/index.d.ts +59 -0
- package/dist/core/index.js +3 -0
- package/dist/core/index.js.map +1 -0
- package/dist/http-BP4c721D.d.cts +22 -0
- package/dist/http-DXTeCD5r.d.ts +22 -0
- package/dist/index.cjs +1013 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/module-DBcfA-i3.d.ts +67 -0
- package/dist/module-DFQBZNK6.d.cts +67 -0
- package/dist/modules/auth/index.cjs +533 -0
- package/dist/modules/auth/index.cjs.map +1 -0
- package/dist/modules/auth/index.d.cts +51 -0
- package/dist/modules/auth/index.d.ts +51 -0
- package/dist/modules/auth/index.js +159 -0
- package/dist/modules/auth/index.js.map +1 -0
- package/dist/modules/billing/index.cjs +655 -0
- package/dist/modules/billing/index.cjs.map +1 -0
- package/dist/modules/billing/index.d.cts +8 -0
- package/dist/modules/billing/index.d.ts +8 -0
- package/dist/modules/billing/index.js +606 -0
- package/dist/modules/billing/index.js.map +1 -0
- package/dist/modules/channels/index.cjs +443 -0
- package/dist/modules/channels/index.cjs.map +1 -0
- package/dist/modules/channels/index.d.cts +8 -0
- package/dist/modules/channels/index.d.ts +8 -0
- package/dist/modules/channels/index.js +394 -0
- package/dist/modules/channels/index.js.map +1 -0
- package/dist/modules/conversations/index.cjs +288 -0
- package/dist/modules/conversations/index.cjs.map +1 -0
- package/dist/modules/conversations/index.d.cts +8 -0
- package/dist/modules/conversations/index.d.ts +8 -0
- package/dist/modules/conversations/index.js +239 -0
- package/dist/modules/conversations/index.js.map +1 -0
- package/dist/modules/devportal/index.cjs +796 -0
- package/dist/modules/devportal/index.cjs.map +1 -0
- package/dist/modules/devportal/index.d.cts +8 -0
- package/dist/modules/devportal/index.d.ts +8 -0
- package/dist/modules/devportal/index.js +747 -0
- package/dist/modules/devportal/index.js.map +1 -0
- package/dist/modules/export/index.cjs +333 -0
- package/dist/modules/export/index.cjs.map +1 -0
- package/dist/modules/export/index.d.cts +8 -0
- package/dist/modules/export/index.d.ts +8 -0
- package/dist/modules/export/index.js +284 -0
- package/dist/modules/export/index.js.map +1 -0
- package/dist/modules/files/index.cjs +278 -0
- package/dist/modules/files/index.cjs.map +1 -0
- package/dist/modules/files/index.d.cts +8 -0
- package/dist/modules/files/index.d.ts +8 -0
- package/dist/modules/files/index.js +229 -0
- package/dist/modules/files/index.js.map +1 -0
- package/dist/modules/groups/index.cjs +451 -0
- package/dist/modules/groups/index.cjs.map +1 -0
- package/dist/modules/groups/index.d.cts +8 -0
- package/dist/modules/groups/index.d.ts +8 -0
- package/dist/modules/groups/index.js +402 -0
- package/dist/modules/groups/index.js.map +1 -0
- package/dist/modules/health/index.cjs +159 -0
- package/dist/modules/health/index.cjs.map +1 -0
- package/dist/modules/health/index.d.cts +8 -0
- package/dist/modules/health/index.d.ts +8 -0
- package/dist/modules/health/index.js +36 -0
- package/dist/modules/health/index.js.map +1 -0
- package/dist/modules/integrations/index.cjs +316 -0
- package/dist/modules/integrations/index.cjs.map +1 -0
- package/dist/modules/integrations/index.d.cts +8 -0
- package/dist/modules/integrations/index.d.ts +8 -0
- package/dist/modules/integrations/index.js +267 -0
- package/dist/modules/integrations/index.js.map +1 -0
- package/dist/modules/notifications/index.cjs +222 -0
- package/dist/modules/notifications/index.cjs.map +1 -0
- package/dist/modules/notifications/index.d.cts +8 -0
- package/dist/modules/notifications/index.d.ts +8 -0
- package/dist/modules/notifications/index.js +173 -0
- package/dist/modules/notifications/index.js.map +1 -0
- package/dist/modules/organizations/index.cjs +267 -0
- package/dist/modules/organizations/index.cjs.map +1 -0
- package/dist/modules/organizations/index.d.cts +8 -0
- package/dist/modules/organizations/index.d.ts +8 -0
- package/dist/modules/organizations/index.js +218 -0
- package/dist/modules/organizations/index.js.map +1 -0
- package/dist/modules/products/index.cjs +736 -0
- package/dist/modules/products/index.cjs.map +1 -0
- package/dist/modules/products/index.d.cts +8 -0
- package/dist/modules/products/index.d.ts +8 -0
- package/dist/modules/products/index.js +687 -0
- package/dist/modules/products/index.js.map +1 -0
- package/dist/modules/rbac/index.cjs +378 -0
- package/dist/modules/rbac/index.cjs.map +1 -0
- package/dist/modules/rbac/index.d.cts +8 -0
- package/dist/modules/rbac/index.d.ts +8 -0
- package/dist/modules/rbac/index.js +329 -0
- package/dist/modules/rbac/index.js.map +1 -0
- package/dist/modules/sandbox/index.cjs +318 -0
- package/dist/modules/sandbox/index.cjs.map +1 -0
- package/dist/modules/sandbox/index.d.cts +8 -0
- package/dist/modules/sandbox/index.d.ts +8 -0
- package/dist/modules/sandbox/index.js +225 -0
- package/dist/modules/sandbox/index.js.map +1 -0
- package/dist/modules/scheduler/index.cjs +267 -0
- package/dist/modules/scheduler/index.cjs.map +1 -0
- package/dist/modules/scheduler/index.d.cts +8 -0
- package/dist/modules/scheduler/index.d.ts +8 -0
- package/dist/modules/scheduler/index.js +218 -0
- package/dist/modules/scheduler/index.js.map +1 -0
- package/dist/modules/security/index.cjs +529 -0
- package/dist/modules/security/index.cjs.map +1 -0
- package/dist/modules/security/index.d.cts +8 -0
- package/dist/modules/security/index.d.ts +8 -0
- package/dist/modules/security/index.js +480 -0
- package/dist/modules/security/index.js.map +1 -0
- package/dist/modules/store/index.cjs +450 -0
- package/dist/modules/store/index.cjs.map +1 -0
- package/dist/modules/store/index.d.cts +8 -0
- package/dist/modules/store/index.d.ts +8 -0
- package/dist/modules/store/index.js +401 -0
- package/dist/modules/store/index.js.map +1 -0
- package/dist/modules/support/index.cjs +285 -0
- package/dist/modules/support/index.cjs.map +1 -0
- package/dist/modules/support/index.d.cts +8 -0
- package/dist/modules/support/index.d.ts +8 -0
- package/dist/modules/support/index.js +236 -0
- package/dist/modules/support/index.js.map +1 -0
- package/dist/modules/tags/index.cjs +421 -0
- package/dist/modules/tags/index.cjs.map +1 -0
- package/dist/modules/tags/index.d.cts +8 -0
- package/dist/modules/tags/index.d.ts +8 -0
- package/dist/modules/tags/index.js +372 -0
- package/dist/modules/tags/index.js.map +1 -0
- package/dist/modules/tours/index.cjs +225 -0
- package/dist/modules/tours/index.cjs.map +1 -0
- package/dist/modules/tours/index.d.cts +8 -0
- package/dist/modules/tours/index.d.ts +8 -0
- package/dist/modules/tours/index.js +176 -0
- package/dist/modules/tours/index.js.map +1 -0
- package/dist/modules/vibecontrols/index.cjs +5551 -0
- package/dist/modules/vibecontrols/index.cjs.map +1 -0
- package/dist/modules/vibecontrols/index.d.cts +8 -0
- package/dist/modules/vibecontrols/index.d.ts +8 -0
- package/dist/modules/vibecontrols/index.js +4380 -0
- package/dist/modules/vibecontrols/index.js.map +1 -0
- package/dist/modules/workspaces/index.cjs +552 -0
- package/dist/modules/workspaces/index.cjs.map +1 -0
- package/dist/modules/workspaces/index.d.cts +8 -0
- package/dist/modules/workspaces/index.d.ts +8 -0
- package/dist/modules/workspaces/index.js +503 -0
- package/dist/modules/workspaces/index.js.map +1 -0
- package/dist/tool-name-CQf_IqAj.d.cts +47 -0
- package/dist/tool-name-DlnrBsZ6.d.ts +47 -0
- package/dist/transports/index.cjs +183 -0
- package/dist/transports/index.cjs.map +1 -0
- package/dist/transports/index.d.cts +13 -0
- package/dist/transports/index.d.ts +13 -0
- package/dist/transports/index.js +3 -0
- package/dist/transports/index.js.map +1 -0
- package/package.json +125 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { mcpToolName, jsonResult, errorResult } from '../../chunk-H2OYWLOA.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
// src/modules/notifications/operations.ts
|
|
5
|
+
var LIST_NOTIFICATIONS = `
|
|
6
|
+
query ListNotifications($filter: NotificationFilterInput, $limit: Int, $offset: Int) {
|
|
7
|
+
notifications(filter: $filter, limit: $limit, offset: $offset) {
|
|
8
|
+
items { id title message channel status isRead createdAt }
|
|
9
|
+
total
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
|
+
var MARK_NOTIFICATION_READ = `
|
|
14
|
+
mutation MarkNotificationRead($id: ID!) {
|
|
15
|
+
markNotificationAsRead(id: $id) {
|
|
16
|
+
id isRead readAt
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
var NOTIFICATION_PREFERENCES = `
|
|
21
|
+
query NotificationPreferences($filter: NotificationPreferenceFilterInput, $limit: Int) {
|
|
22
|
+
notificationPreferences(filter: $filter, limit: $limit) {
|
|
23
|
+
items { id channel enabled frequency scope topicId userId }
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
27
|
+
var CREATE_NOTIFICATION_PREFERENCE = `
|
|
28
|
+
mutation CreateNotificationPreference($input: CreateNotificationPreferenceInput!) {
|
|
29
|
+
createNotificationPreference(input: $input) {
|
|
30
|
+
id channel enabled frequency
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
// src/modules/notifications/tools.ts
|
|
36
|
+
function registerNotificationsTools(server, ctx, track) {
|
|
37
|
+
server.registerTool(
|
|
38
|
+
track(mcpToolName(ctx.productName, "notifications_list")),
|
|
39
|
+
{
|
|
40
|
+
title: "List Notifications",
|
|
41
|
+
description: "List the current user's notifications with optional filters.",
|
|
42
|
+
inputSchema: {
|
|
43
|
+
unread: z.boolean().optional().describe("Only unread notifications"),
|
|
44
|
+
channel: z.string().optional().describe("Filter by channel (will be uppercased)"),
|
|
45
|
+
limit: z.number().optional().describe("Page size (default 50)")
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
async ({ unread, channel, limit }) => {
|
|
49
|
+
try {
|
|
50
|
+
const filter = {};
|
|
51
|
+
if (unread === true) filter.isRead = false;
|
|
52
|
+
if (channel !== void 0) filter.channel = channel.toUpperCase();
|
|
53
|
+
const data = await ctx.gql.global.request(LIST_NOTIFICATIONS, {
|
|
54
|
+
filter: Object.keys(filter).length ? filter : void 0,
|
|
55
|
+
limit: limit ?? 50,
|
|
56
|
+
offset: 0
|
|
57
|
+
});
|
|
58
|
+
return jsonResult(data.notifications);
|
|
59
|
+
} catch (error) {
|
|
60
|
+
ctx.logger.error("notifications_list failed", { error: String(error) });
|
|
61
|
+
return errorResult(
|
|
62
|
+
`Failed to list notifications: ${error instanceof Error ? error.message : String(error)}`
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
server.registerTool(
|
|
68
|
+
track(mcpToolName(ctx.productName, "notifications_read")),
|
|
69
|
+
{
|
|
70
|
+
title: "Mark Notification Read",
|
|
71
|
+
description: "Mark a notification as read.",
|
|
72
|
+
inputSchema: { id: z.string().describe("Notification ID") }
|
|
73
|
+
},
|
|
74
|
+
async ({ id }) => {
|
|
75
|
+
try {
|
|
76
|
+
const data = await ctx.gql.global.request(MARK_NOTIFICATION_READ, { id });
|
|
77
|
+
return jsonResult(data.markNotificationAsRead);
|
|
78
|
+
} catch (error) {
|
|
79
|
+
ctx.logger.error("notifications_read failed", { error: String(error) });
|
|
80
|
+
return errorResult(
|
|
81
|
+
`Failed to mark notification read: ${error instanceof Error ? error.message : String(error)}`
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
server.registerTool(
|
|
87
|
+
track(mcpToolName(ctx.productName, "notifications_preferences_get")),
|
|
88
|
+
{
|
|
89
|
+
title: "Get Notification Preferences",
|
|
90
|
+
description: "Show the current user's notification preferences.",
|
|
91
|
+
inputSchema: {
|
|
92
|
+
user: z.string().optional().describe("Override user ID"),
|
|
93
|
+
limit: z.number().optional().describe("Page size (default 100)")
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
async ({ user, limit }) => {
|
|
97
|
+
try {
|
|
98
|
+
const auth = ctx.auth.read();
|
|
99
|
+
const userId = user ?? auth?.workspaceId ?? "";
|
|
100
|
+
const filter = userId ? { userId } : {};
|
|
101
|
+
const data = await ctx.gql.global.request(NOTIFICATION_PREFERENCES, {
|
|
102
|
+
filter: Object.keys(filter).length ? filter : void 0,
|
|
103
|
+
limit: limit ?? 100
|
|
104
|
+
});
|
|
105
|
+
return jsonResult(data.notificationPreferences);
|
|
106
|
+
} catch (error) {
|
|
107
|
+
ctx.logger.error("notifications_preferences_get failed", { error: String(error) });
|
|
108
|
+
return errorResult(
|
|
109
|
+
`Failed to get notification preferences: ${error instanceof Error ? error.message : String(error)}`
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
server.registerTool(
|
|
115
|
+
track(mcpToolName(ctx.productName, "notifications_preferences_set")),
|
|
116
|
+
{
|
|
117
|
+
title: "Set Notification Preference",
|
|
118
|
+
description: "Create/update a notification preference.",
|
|
119
|
+
inputSchema: {
|
|
120
|
+
channel: z.string().describe("EMAIL|SMS|IN_APP|PUSH|WEBHOOK (will be uppercased)"),
|
|
121
|
+
enabled: z.boolean().describe("Whether the channel is enabled"),
|
|
122
|
+
frequency: z.string().optional().describe("IMMEDIATE|HOURLY|DAILY|WEEKLY (default IMMEDIATE)"),
|
|
123
|
+
scope: z.string().optional().describe("GLOBAL|WORKSPACE|VIBE (default GLOBAL)"),
|
|
124
|
+
topic: z.string().optional().describe("Topic ID"),
|
|
125
|
+
user: z.string().optional().describe("Override user ID")
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
async ({ channel, enabled, frequency, scope, topic, user }) => {
|
|
129
|
+
try {
|
|
130
|
+
const auth = ctx.auth.read();
|
|
131
|
+
const input = {
|
|
132
|
+
channel: channel.toUpperCase(),
|
|
133
|
+
enabled,
|
|
134
|
+
frequency: (frequency ?? "IMMEDIATE").toUpperCase(),
|
|
135
|
+
scope: (scope ?? "GLOBAL").toUpperCase()
|
|
136
|
+
};
|
|
137
|
+
if (topic !== void 0) input.topicId = topic;
|
|
138
|
+
const userId = user ?? auth?.workspaceId;
|
|
139
|
+
if (userId !== void 0) input.userId = userId;
|
|
140
|
+
const data = await ctx.gql.global.request(CREATE_NOTIFICATION_PREFERENCE, { input });
|
|
141
|
+
return jsonResult(data.createNotificationPreference);
|
|
142
|
+
} catch (error) {
|
|
143
|
+
ctx.logger.error("notifications_preferences_set failed", { error: String(error) });
|
|
144
|
+
return errorResult(
|
|
145
|
+
`Failed to set notification preference: ${error instanceof Error ? error.message : String(error)}`
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// src/modules/notifications/index.ts
|
|
153
|
+
var notificationsModule = {
|
|
154
|
+
id: "notifications",
|
|
155
|
+
version: "0.0.1",
|
|
156
|
+
displayName: "Notifications",
|
|
157
|
+
dependsOn: ["auth"],
|
|
158
|
+
capabilities: { tools: {} },
|
|
159
|
+
register(server, ctx) {
|
|
160
|
+
const tools = [];
|
|
161
|
+
const track = (n) => {
|
|
162
|
+
tools.push(n);
|
|
163
|
+
return n;
|
|
164
|
+
};
|
|
165
|
+
registerNotificationsTools(server, ctx, track);
|
|
166
|
+
return { tools, resources: [], prompts: [] };
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
var notifications_default = notificationsModule;
|
|
170
|
+
|
|
171
|
+
export { notifications_default as default };
|
|
172
|
+
//# sourceMappingURL=index.js.map
|
|
173
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/modules/notifications/operations.ts","../../../src/modules/notifications/tools.ts","../../../src/modules/notifications/index.ts"],"names":[],"mappings":";;;;AAAO,IAAM,kBAAA,GAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAS3B,IAAM,sBAAA,GAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAQ/B,IAAM,wBAAA,GAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAQjC,IAAM,8BAAA,GAAiC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;;;ACKvC,SAAS,0BAAA,CACd,MAAA,EACA,GAAA,EACA,KAAA,EACM;AACN,EAAA,MAAA,CAAO,YAAA;AAAA,IACL,KAAA,CAAM,WAAA,CAAY,GAAA,CAAI,WAAA,EAAa,oBAAoB,CAAC,CAAA;AAAA,IACxD;AAAA,MACE,KAAA,EAAO,oBAAA;AAAA,MACP,WAAA,EAAa,8DAAA;AAAA,MACb,WAAA,EAAa;AAAA,QACX,QAAQ,CAAA,CAAE,OAAA,GAAU,QAAA,EAAS,CAAE,SAAS,2BAA2B,CAAA;AAAA,QACnE,SAAS,CAAA,CAAE,MAAA,GAAS,QAAA,EAAS,CAAE,SAAS,wCAAwC,CAAA;AAAA,QAChF,OAAO,CAAA,CAAE,MAAA,GAAS,QAAA,EAAS,CAAE,SAAS,wBAAwB;AAAA;AAChE,KACF;AAAA,IACA,OAAO,EAAE,MAAA,EAAQ,OAAA,EAAS,OAAM,KAAM;AACpC,MAAA,IAAI;AACF,QAAA,MAAM,SAAkC,EAAC;AACzC,QAAA,IAAI,MAAA,KAAW,IAAA,EAAM,MAAA,CAAO,MAAA,GAAS,KAAA;AACrC,QAAA,IAAI,OAAA,KAAY,KAAA,CAAA,EAA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IAAA,OAAO,EAAE,KAAA,EAAO,SAAA,EAAW,EAAC,EAAG,OAAA,EAAS,EAAC,EAAE;AAAA,EAC7C;AACF,CAAA;AAEA,IAAO,qBAAA,GAAQ","file":"index.js","sourcesContent":["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,267 @@
|
|
|
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/organizations/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/organizations/operations.ts
|
|
54
|
+
var MY_ORGANIZATIONS = `
|
|
55
|
+
query MyOrganizations($limit: Int, $offset: Int) {
|
|
56
|
+
myOrganizations(limit: $limit, offset: $offset) {
|
|
57
|
+
items {
|
|
58
|
+
id
|
|
59
|
+
name
|
|
60
|
+
slug
|
|
61
|
+
tenantId
|
|
62
|
+
description
|
|
63
|
+
status
|
|
64
|
+
createdAt
|
|
65
|
+
updatedAt
|
|
66
|
+
}
|
|
67
|
+
total
|
|
68
|
+
hasMore
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
`;
|
|
72
|
+
var MY_ORGANIZATION_INVITES = `
|
|
73
|
+
query MyOrganizationInvites($status: InviteStatus, $limit: Int, $offset: Int) {
|
|
74
|
+
myOrganizationInvites(status: $status, limit: $limit, offset: $offset) {
|
|
75
|
+
items {
|
|
76
|
+
id
|
|
77
|
+
organizationId
|
|
78
|
+
email
|
|
79
|
+
role
|
|
80
|
+
status
|
|
81
|
+
expiresAt
|
|
82
|
+
message
|
|
83
|
+
createdAt
|
|
84
|
+
}
|
|
85
|
+
total
|
|
86
|
+
hasMore
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
`;
|
|
90
|
+
var ACCEPT_ORG_INVITE = `
|
|
91
|
+
mutation AcceptOrganizationInvite($inviteId: ID!) {
|
|
92
|
+
acceptOrganizationInvite(inviteId: $inviteId) {
|
|
93
|
+
id
|
|
94
|
+
userId
|
|
95
|
+
organizationId
|
|
96
|
+
role
|
|
97
|
+
joinedAt
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
`;
|
|
101
|
+
var REJECT_ORG_INVITE = `
|
|
102
|
+
mutation RejectOrganizationInvite($inviteId: ID!) {
|
|
103
|
+
rejectOrganizationInvite(inviteId: $inviteId) {
|
|
104
|
+
id
|
|
105
|
+
status
|
|
106
|
+
respondedAt
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
`;
|
|
110
|
+
|
|
111
|
+
// src/modules/organizations/tools.ts
|
|
112
|
+
var InviteStatusEnum = zod.z.enum(["PENDING", "ACCEPTED", "REJECTED", "EXPIRED", "REVOKED"]);
|
|
113
|
+
function registerOrganizationsTools(server, ctx, track) {
|
|
114
|
+
server.registerTool(
|
|
115
|
+
track(mcpToolName(ctx.productName, "organizations_list")),
|
|
116
|
+
{
|
|
117
|
+
title: "List Organizations",
|
|
118
|
+
description: "List organizations the current user is a member of.",
|
|
119
|
+
inputSchema: {
|
|
120
|
+
limit: zod.z.number().optional().describe("Page size"),
|
|
121
|
+
offset: zod.z.number().optional().describe("Offset for pagination")
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
async ({ limit, offset }) => {
|
|
125
|
+
try {
|
|
126
|
+
const data = await ctx.gql.global.request(MY_ORGANIZATIONS, {
|
|
127
|
+
limit: limit ?? 50,
|
|
128
|
+
offset: offset ?? 0
|
|
129
|
+
});
|
|
130
|
+
return jsonResult(data.myOrganizations);
|
|
131
|
+
} catch (error) {
|
|
132
|
+
ctx.logger.error("organizations_list failed", { error: String(error) });
|
|
133
|
+
return errorResult(
|
|
134
|
+
`Failed to list organizations: ${error instanceof Error ? error.message : String(error)}`
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
server.registerTool(
|
|
140
|
+
track(mcpToolName(ctx.productName, "organizations_current")),
|
|
141
|
+
{
|
|
142
|
+
title: "Current Organization",
|
|
143
|
+
description: "Return the current organization context from the auth store.",
|
|
144
|
+
inputSchema: {}
|
|
145
|
+
},
|
|
146
|
+
async () => {
|
|
147
|
+
try {
|
|
148
|
+
const auth = ctx.auth.read();
|
|
149
|
+
if (!auth?.organizationId) {
|
|
150
|
+
return errorResult(
|
|
151
|
+
"No active organization context. Run the auth login flow to bind a tenant."
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
return jsonResult({
|
|
155
|
+
organizationId: auth.organizationId,
|
|
156
|
+
workspaceId: auth.workspaceId ?? null
|
|
157
|
+
});
|
|
158
|
+
} catch (error) {
|
|
159
|
+
ctx.logger.error("organizations_current failed", { error: String(error) });
|
|
160
|
+
return errorResult(
|
|
161
|
+
`Failed to read current organization: ${error instanceof Error ? error.message : String(error)}`
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
);
|
|
166
|
+
server.registerTool(
|
|
167
|
+
track(mcpToolName(ctx.productName, "organizations_invites_list")),
|
|
168
|
+
{
|
|
169
|
+
title: "List Organization Invites",
|
|
170
|
+
description: "List organization invites for the current user.",
|
|
171
|
+
inputSchema: {
|
|
172
|
+
status: InviteStatusEnum.optional().describe("Filter by invite status (default: PENDING)"),
|
|
173
|
+
limit: zod.z.number().optional().describe("Page size"),
|
|
174
|
+
offset: zod.z.number().optional().describe("Offset for pagination")
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
async ({ status, limit, offset }) => {
|
|
178
|
+
try {
|
|
179
|
+
const data = await ctx.gql.global.request(
|
|
180
|
+
MY_ORGANIZATION_INVITES,
|
|
181
|
+
{
|
|
182
|
+
status: status ?? "PENDING",
|
|
183
|
+
limit: limit ?? 50,
|
|
184
|
+
offset: offset ?? 0
|
|
185
|
+
}
|
|
186
|
+
);
|
|
187
|
+
return jsonResult(data.myOrganizationInvites);
|
|
188
|
+
} catch (error) {
|
|
189
|
+
ctx.logger.error("organizations_invites_list failed", { error: String(error) });
|
|
190
|
+
return errorResult(
|
|
191
|
+
`Failed to list organization invites: ${error instanceof Error ? error.message : String(error)}`
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
);
|
|
196
|
+
server.registerTool(
|
|
197
|
+
track(mcpToolName(ctx.productName, "organizations_invites_accept")),
|
|
198
|
+
{
|
|
199
|
+
title: "Accept Organization Invite",
|
|
200
|
+
description: "Accept a pending organization invite.",
|
|
201
|
+
inputSchema: {
|
|
202
|
+
invitationId: zod.z.string().describe("Invite ID")
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
async ({ invitationId }) => {
|
|
206
|
+
try {
|
|
207
|
+
const data = await ctx.gql.global.request(
|
|
208
|
+
ACCEPT_ORG_INVITE,
|
|
209
|
+
{ inviteId: invitationId }
|
|
210
|
+
);
|
|
211
|
+
return jsonResult(data.acceptOrganizationInvite);
|
|
212
|
+
} catch (error) {
|
|
213
|
+
ctx.logger.error("organizations_invites_accept failed", { error: String(error) });
|
|
214
|
+
return errorResult(
|
|
215
|
+
`Failed to accept invite: ${error instanceof Error ? error.message : String(error)}`
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
);
|
|
220
|
+
server.registerTool(
|
|
221
|
+
track(mcpToolName(ctx.productName, "organizations_invites_decline")),
|
|
222
|
+
{
|
|
223
|
+
title: "Decline Organization Invite",
|
|
224
|
+
description: "Decline a pending organization invite.",
|
|
225
|
+
inputSchema: {
|
|
226
|
+
invitationId: zod.z.string().describe("Invite ID")
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
async ({ invitationId }) => {
|
|
230
|
+
try {
|
|
231
|
+
const data = await ctx.gql.global.request(
|
|
232
|
+
REJECT_ORG_INVITE,
|
|
233
|
+
{ inviteId: invitationId }
|
|
234
|
+
);
|
|
235
|
+
return jsonResult(data.rejectOrganizationInvite);
|
|
236
|
+
} catch (error) {
|
|
237
|
+
ctx.logger.error("organizations_invites_decline failed", { error: String(error) });
|
|
238
|
+
return errorResult(
|
|
239
|
+
`Failed to decline invite: ${error instanceof Error ? error.message : String(error)}`
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// src/modules/organizations/index.ts
|
|
247
|
+
var organizationsModule = {
|
|
248
|
+
id: "organizations",
|
|
249
|
+
version: "0.0.1",
|
|
250
|
+
displayName: "Organizations",
|
|
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
|
+
registerOrganizationsTools(server, ctx, track);
|
|
260
|
+
return { tools, resources: [], prompts: [] };
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
var organizations_default = organizationsModule;
|
|
264
|
+
|
|
265
|
+
module.exports = organizations_default;
|
|
266
|
+
//# sourceMappingURL=index.cjs.map
|
|
267
|
+
//# 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/organizations/operations.ts","../../../src/modules/organizations/tools.ts","../../../src/modules/organizations/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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AA,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 MY_ORGANIZATIONS = `\n query MyOrganizations($limit: Int, $offset: Int) {\n myOrganizations(limit: $limit, offset: $offset) {\n items {\n id\n name\n slug\n tenantId\n description\n status\n createdAt\n updatedAt\n }\n total\n hasMore\n }\n }\n`;\n\nexport const MY_ORGANIZATION_INVITES = `\n query MyOrganizationInvites($status: InviteStatus, $limit: Int, $offset: Int) {\n myOrganizationInvites(status: $status, limit: $limit, offset: $offset) {\n items {\n id\n organizationId\n email\n role\n status\n expiresAt\n message\n createdAt\n }\n total\n hasMore\n }\n }\n`;\n\nexport const ACCEPT_ORG_INVITE = `\n mutation AcceptOrganizationInvite($inviteId: ID!) {\n acceptOrganizationInvite(inviteId: $inviteId) {\n id\n userId\n organizationId\n role\n joinedAt\n }\n }\n`;\n\nexport const REJECT_ORG_INVITE = `\n mutation RejectOrganizationInvite($inviteId: ID!) {\n rejectOrganizationInvite(inviteId: $inviteId) {\n id\n status\n respondedAt\n }\n }\n`;\n","import { z } from 'zod';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { jsonResult, errorResult, mcpToolName, type McpContext } from '../../core/index.js';\nimport {\n MY_ORGANIZATIONS,\n MY_ORGANIZATION_INVITES,\n ACCEPT_ORG_INVITE,\n REJECT_ORG_INVITE,\n} from './operations.js';\n\nconst InviteStatusEnum = z.enum(['PENDING', 'ACCEPTED', 'REJECTED', 'EXPIRED', 'REVOKED']);\n\nexport function registerOrganizationsTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n server.registerTool(\n track(mcpToolName(ctx.productName, 'organizations_list')),\n {\n title: 'List Organizations',\n description: 'List organizations the current user is a member of.',\n inputSchema: {\n limit: z.number().optional().describe('Page size'),\n offset: z.number().optional().describe('Offset for pagination'),\n },\n },\n async ({ limit, offset }) => {\n try {\n const data = await ctx.gql.global.request<{ myOrganizations: unknown }>(MY_ORGANIZATIONS, {\n limit: limit ?? 50,\n offset: offset ?? 0,\n });\n return jsonResult(data.myOrganizations);\n } catch (error) {\n ctx.logger.error('organizations_list failed', { error: String(error) });\n return errorResult(\n `Failed to list organizations: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'organizations_current')),\n {\n title: 'Current Organization',\n description: 'Return the current organization context from the auth store.',\n inputSchema: {},\n },\n async () => {\n try {\n const auth = ctx.auth.read();\n if (!auth?.organizationId) {\n return errorResult(\n 'No active organization context. Run the auth login flow to bind a tenant.',\n );\n }\n return jsonResult({\n organizationId: auth.organizationId,\n workspaceId: auth.workspaceId ?? null,\n });\n } catch (error) {\n ctx.logger.error('organizations_current failed', { error: String(error) });\n return errorResult(\n `Failed to read current organization: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'organizations_invites_list')),\n {\n title: 'List Organization Invites',\n description: 'List organization invites for the current user.',\n inputSchema: {\n status: InviteStatusEnum.optional().describe('Filter by invite status (default: PENDING)'),\n limit: z.number().optional().describe('Page size'),\n offset: z.number().optional().describe('Offset for pagination'),\n },\n },\n async ({ status, limit, offset }) => {\n try {\n const data = await ctx.gql.global.request<{ myOrganizationInvites: unknown }>(\n MY_ORGANIZATION_INVITES,\n {\n status: status ?? 'PENDING',\n limit: limit ?? 50,\n offset: offset ?? 0,\n },\n );\n return jsonResult(data.myOrganizationInvites);\n } catch (error) {\n ctx.logger.error('organizations_invites_list failed', { error: String(error) });\n return errorResult(\n `Failed to list organization invites: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'organizations_invites_accept')),\n {\n title: 'Accept Organization Invite',\n description: 'Accept a pending organization invite.',\n inputSchema: {\n invitationId: z.string().describe('Invite ID'),\n },\n },\n async ({ invitationId }) => {\n try {\n const data = await ctx.gql.global.request<{ acceptOrganizationInvite: unknown }>(\n ACCEPT_ORG_INVITE,\n { inviteId: invitationId },\n );\n return jsonResult(data.acceptOrganizationInvite);\n } catch (error) {\n ctx.logger.error('organizations_invites_accept failed', { error: String(error) });\n return errorResult(\n `Failed to accept invite: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'organizations_invites_decline')),\n {\n title: 'Decline Organization Invite',\n description: 'Decline a pending organization invite.',\n inputSchema: {\n invitationId: z.string().describe('Invite ID'),\n },\n },\n async ({ invitationId }) => {\n try {\n const data = await ctx.gql.global.request<{ rejectOrganizationInvite: unknown }>(\n REJECT_ORG_INVITE,\n { inviteId: invitationId },\n );\n return jsonResult(data.rejectOrganizationInvite);\n } catch (error) {\n ctx.logger.error('organizations_invites_decline failed', { error: String(error) });\n return errorResult(\n `Failed to decline invite: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n}\n","/**\n * Organizations module — multi-tenant org membership + invite acceptance.\n *\n * Tools:\n * <product>_organizations_{list,current}\n * <product>_organizations_invites_{list,accept,decline}\n *\n * Backend: ~/products/global/tenant/global-tenant-svc/.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { McpContext, McpModule, ModuleRegistration } from '../../core/index.js';\nimport { registerOrganizationsTools } from './tools.js';\n\nconst organizationsModule: McpModule = {\n id: 'organizations',\n version: '0.0.1',\n displayName: 'Organizations',\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 registerOrganizationsTools(server, ctx, track);\n\n return { tools, resources: [], prompts: [] };\n },\n};\n\nexport default organizationsModule;\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 organizationsModule: McpModule;
|
|
7
|
+
|
|
8
|
+
export { organizationsModule 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 organizationsModule: McpModule;
|
|
7
|
+
|
|
8
|
+
export { organizationsModule as default };
|