@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,288 @@
|
|
|
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/conversations/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/conversations/operations.ts
|
|
54
|
+
var LIST_CONVERSATIONS = `
|
|
55
|
+
query ListConversations($filter: ConversationFilterInput, $first: Int, $after: String) {
|
|
56
|
+
conversations(filter: $filter, first: $first, after: $after) {
|
|
57
|
+
edges { node { id title type description createdAt updatedAt unreadCount } }
|
|
58
|
+
pageInfo { hasNextPage endCursor }
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
62
|
+
var GET_CONVERSATION = `
|
|
63
|
+
query GetConversation($id: ID!) {
|
|
64
|
+
conversation(id: $id) {
|
|
65
|
+
id title type description avatarUrl settings
|
|
66
|
+
createdAt updatedAt
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
`;
|
|
70
|
+
var CREATE_CONVERSATION = `
|
|
71
|
+
mutation CreateConversation($input: CreateConversationInput!) {
|
|
72
|
+
createConversation(input: $input) {
|
|
73
|
+
conversation { id title type }
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
`;
|
|
77
|
+
var DELETE_CONVERSATION = `
|
|
78
|
+
mutation DeleteConversation($id: ID!) {
|
|
79
|
+
deleteConversation(id: $id) { success }
|
|
80
|
+
}
|
|
81
|
+
`;
|
|
82
|
+
var UPDATE_CONVERSATION = `
|
|
83
|
+
mutation UpdateConversation($input: UpdateConversationInput!) {
|
|
84
|
+
updateConversation(input: $input) {
|
|
85
|
+
conversation { id title description }
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
`;
|
|
89
|
+
var SEND_MESSAGE = `
|
|
90
|
+
mutation SendMessage($input: SendMessageInput!) {
|
|
91
|
+
sendMessage(input: $input) {
|
|
92
|
+
message { id content type createdAt }
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
`;
|
|
96
|
+
|
|
97
|
+
// src/modules/conversations/tools.ts
|
|
98
|
+
var ConversationTypeEnum = zod.z.enum(["DIRECT", "GROUP", "CHANNEL"]);
|
|
99
|
+
function registerConversationsTools(server, ctx, track) {
|
|
100
|
+
server.registerTool(
|
|
101
|
+
track(mcpToolName(ctx.productName, "conversations_list")),
|
|
102
|
+
{
|
|
103
|
+
title: "List Conversations",
|
|
104
|
+
description: "List threaded conversations with optional type filter and cursor pagination.",
|
|
105
|
+
inputSchema: {
|
|
106
|
+
type: ConversationTypeEnum.optional().describe("Filter by conversation type"),
|
|
107
|
+
first: zod.z.number().optional().describe("Page size (default 50)"),
|
|
108
|
+
after: zod.z.string().optional().describe("Cursor returned by a previous page")
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
async ({ type, first, after }) => {
|
|
112
|
+
try {
|
|
113
|
+
const filter = {};
|
|
114
|
+
if (type !== void 0) filter.type = type;
|
|
115
|
+
const data = await ctx.gql.workspace.request(LIST_CONVERSATIONS, {
|
|
116
|
+
filter: Object.keys(filter).length > 0 ? filter : void 0,
|
|
117
|
+
first,
|
|
118
|
+
after
|
|
119
|
+
});
|
|
120
|
+
return jsonResult({
|
|
121
|
+
items: data.conversations.edges.map((e) => e.node),
|
|
122
|
+
pageInfo: data.conversations.pageInfo
|
|
123
|
+
});
|
|
124
|
+
} catch (error) {
|
|
125
|
+
ctx.logger.error("conversations_list failed", { error });
|
|
126
|
+
return errorResult(
|
|
127
|
+
`Failed to list conversations: ${error instanceof Error ? error.message : String(error)}`
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
);
|
|
132
|
+
server.registerTool(
|
|
133
|
+
track(mcpToolName(ctx.productName, "conversations_get")),
|
|
134
|
+
{
|
|
135
|
+
title: "Get Conversation",
|
|
136
|
+
description: "Get a single conversation by ID.",
|
|
137
|
+
inputSchema: {
|
|
138
|
+
id: zod.z.string().describe("Conversation ID")
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
async ({ id }) => {
|
|
142
|
+
try {
|
|
143
|
+
const data = await ctx.gql.workspace.request(GET_CONVERSATION, { id });
|
|
144
|
+
if (!data.conversation) {
|
|
145
|
+
return errorResult(`Conversation ${id} not found`);
|
|
146
|
+
}
|
|
147
|
+
return jsonResult(data.conversation);
|
|
148
|
+
} catch (error) {
|
|
149
|
+
ctx.logger.error("conversations_get failed", { error });
|
|
150
|
+
return errorResult(
|
|
151
|
+
`Failed to get conversation: ${error instanceof Error ? error.message : String(error)}`
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
server.registerTool(
|
|
157
|
+
track(mcpToolName(ctx.productName, "conversations_create")),
|
|
158
|
+
{
|
|
159
|
+
title: "Create Conversation",
|
|
160
|
+
description: "Create a new threaded conversation.",
|
|
161
|
+
inputSchema: {
|
|
162
|
+
title: zod.z.string().describe("Conversation title"),
|
|
163
|
+
description: zod.z.string().optional().describe("Conversation description"),
|
|
164
|
+
type: ConversationTypeEnum.optional().describe("Conversation type (default: GROUP)"),
|
|
165
|
+
participantIds: zod.z.array(zod.z.string()).optional().describe("Participant user IDs")
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
async ({ title, description, type, participantIds }) => {
|
|
169
|
+
try {
|
|
170
|
+
const input = {
|
|
171
|
+
title,
|
|
172
|
+
type: type ?? "GROUP"
|
|
173
|
+
};
|
|
174
|
+
if (description !== void 0) input.description = description;
|
|
175
|
+
if (participantIds !== void 0) input.participantIds = participantIds;
|
|
176
|
+
const data = await ctx.gql.workspace.request(CREATE_CONVERSATION, { input });
|
|
177
|
+
return jsonResult(data.createConversation.conversation);
|
|
178
|
+
} catch (error) {
|
|
179
|
+
ctx.logger.error("conversations_create failed", { error });
|
|
180
|
+
return errorResult(
|
|
181
|
+
`Failed to create conversation: ${error instanceof Error ? error.message : String(error)}`
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
);
|
|
186
|
+
server.registerTool(
|
|
187
|
+
track(mcpToolName(ctx.productName, "conversations_update")),
|
|
188
|
+
{
|
|
189
|
+
title: "Update Conversation",
|
|
190
|
+
description: "Update title and/or description of a conversation.",
|
|
191
|
+
inputSchema: {
|
|
192
|
+
id: zod.z.string().describe("Conversation ID"),
|
|
193
|
+
title: zod.z.string().optional().describe("New title"),
|
|
194
|
+
description: zod.z.string().optional().describe("New description")
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
async ({ id, title, description }) => {
|
|
198
|
+
try {
|
|
199
|
+
const input = { id };
|
|
200
|
+
if (title !== void 0) input.title = title;
|
|
201
|
+
if (description !== void 0) input.description = description;
|
|
202
|
+
if (Object.keys(input).length === 1) {
|
|
203
|
+
return errorResult("No updates specified");
|
|
204
|
+
}
|
|
205
|
+
const data = await ctx.gql.workspace.request(UPDATE_CONVERSATION, { input });
|
|
206
|
+
return jsonResult(data.updateConversation.conversation);
|
|
207
|
+
} catch (error) {
|
|
208
|
+
ctx.logger.error("conversations_update failed", { error });
|
|
209
|
+
return errorResult(
|
|
210
|
+
`Failed to update conversation: ${error instanceof Error ? error.message : String(error)}`
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
);
|
|
215
|
+
server.registerTool(
|
|
216
|
+
track(mcpToolName(ctx.productName, "conversations_delete")),
|
|
217
|
+
{
|
|
218
|
+
title: "Delete Conversation",
|
|
219
|
+
description: "Delete a conversation by ID.",
|
|
220
|
+
inputSchema: {
|
|
221
|
+
id: zod.z.string().describe("Conversation ID to delete")
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
async ({ id }) => {
|
|
225
|
+
try {
|
|
226
|
+
const data = await ctx.gql.workspace.request(DELETE_CONVERSATION, { id });
|
|
227
|
+
return jsonResult({ deleted: data.deleteConversation.success, conversationId: id });
|
|
228
|
+
} catch (error) {
|
|
229
|
+
ctx.logger.error("conversations_delete failed", { error });
|
|
230
|
+
return errorResult(
|
|
231
|
+
`Failed to delete conversation: ${error instanceof Error ? error.message : String(error)}`
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
);
|
|
236
|
+
server.registerTool(
|
|
237
|
+
track(mcpToolName(ctx.productName, "conversations_send_message")),
|
|
238
|
+
{
|
|
239
|
+
title: "Send Message",
|
|
240
|
+
description: "Send a text message to a conversation. Optionally reply to a parent message.",
|
|
241
|
+
inputSchema: {
|
|
242
|
+
conversationId: zod.z.string().describe("Conversation ID"),
|
|
243
|
+
content: zod.z.string().describe("Message content"),
|
|
244
|
+
parentMessageId: zod.z.string().optional().describe("Parent message ID (for replies)")
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
async ({ conversationId, content, parentMessageId }) => {
|
|
248
|
+
try {
|
|
249
|
+
const input = {
|
|
250
|
+
conversationId,
|
|
251
|
+
content,
|
|
252
|
+
type: "TEXT"
|
|
253
|
+
};
|
|
254
|
+
if (parentMessageId !== void 0) input.parentMessageId = parentMessageId;
|
|
255
|
+
const data = await ctx.gql.workspace.request(SEND_MESSAGE, { input });
|
|
256
|
+
return jsonResult(data.sendMessage.message);
|
|
257
|
+
} catch (error) {
|
|
258
|
+
ctx.logger.error("conversations_send_message failed", { error });
|
|
259
|
+
return errorResult(
|
|
260
|
+
`Failed to send message: ${error instanceof Error ? error.message : String(error)}`
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// src/modules/conversations/index.ts
|
|
268
|
+
var conversationsModule = {
|
|
269
|
+
id: "conversations",
|
|
270
|
+
version: "0.0.1",
|
|
271
|
+
displayName: "Conversations",
|
|
272
|
+
dependsOn: ["auth"],
|
|
273
|
+
capabilities: { tools: {} },
|
|
274
|
+
register(server, ctx) {
|
|
275
|
+
const tools = [];
|
|
276
|
+
const track = (n) => {
|
|
277
|
+
tools.push(n);
|
|
278
|
+
return n;
|
|
279
|
+
};
|
|
280
|
+
registerConversationsTools(server, ctx, track);
|
|
281
|
+
return { tools, resources: [], prompts: [] };
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
var conversations_default = conversationsModule;
|
|
285
|
+
|
|
286
|
+
module.exports = conversations_default;
|
|
287
|
+
//# sourceMappingURL=index.cjs.map
|
|
288
|
+
//# 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/conversations/operations.ts","../../../src/modules/conversations/tools.ts","../../../src/modules/conversations/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;AACT;AAaO,SAAS,WAAA,CAAY,SAAiB,IAAA,EAA2B;AACtE,EAAA,MAAM,IAAA,GAAO,IAAA,GAAO,CAAA,EAAG,OAAO;;AAAA,MAAA,EAAa,IAAI,CAAA,CAAA,GAAK,OAAA;AACpD,EAAA,OAAO,EAAE,OAAA,EAAS,CAAC,EAAE,IAAA,EAAM,QAAQ,IAAA,EAAM,CAAA,EAAG,OAAA,EAAS,IAAA,EAAK;AAC5D;;;ACnDA,IAAM,o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K,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_CONVERSATIONS = `\n query ListConversations($filter: ConversationFilterInput, $first: Int, $after: String) {\n conversations(filter: $filter, first: $first, after: $after) {\n edges { node { id title type description createdAt updatedAt unreadCount } }\n pageInfo { hasNextPage endCursor }\n }\n }\n`;\n\nexport const GET_CONVERSATION = `\n query GetConversation($id: ID!) {\n conversation(id: $id) {\n id title type description avatarUrl settings\n createdAt updatedAt\n }\n }\n`;\n\nexport const CREATE_CONVERSATION = `\n mutation CreateConversation($input: CreateConversationInput!) {\n createConversation(input: $input) {\n conversation { id title type }\n }\n }\n`;\n\nexport const DELETE_CONVERSATION = `\n mutation DeleteConversation($id: ID!) {\n deleteConversation(id: $id) { success }\n }\n`;\n\nexport const UPDATE_CONVERSATION = `\n mutation UpdateConversation($input: UpdateConversationInput!) {\n updateConversation(input: $input) {\n conversation { id title description }\n }\n }\n`;\n\nexport const SEND_MESSAGE = `\n mutation SendMessage($input: SendMessageInput!) {\n sendMessage(input: $input) {\n message { id content type createdAt }\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 LIST_CONVERSATIONS,\n GET_CONVERSATION,\n CREATE_CONVERSATION,\n UPDATE_CONVERSATION,\n DELETE_CONVERSATION,\n SEND_MESSAGE,\n} from './operations.js';\n\nconst ConversationTypeEnum = z.enum(['DIRECT', 'GROUP', 'CHANNEL']);\n\ninterface ConversationNode {\n id: string;\n title?: string;\n type?: string;\n description?: string | null;\n createdAt?: string;\n updatedAt?: string;\n unreadCount?: number;\n}\n\nexport function registerConversationsTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n server.registerTool(\n track(mcpToolName(ctx.productName, 'conversations_list')),\n {\n title: 'List Conversations',\n description: 'List threaded conversations with optional type filter and cursor pagination.',\n inputSchema: {\n type: ConversationTypeEnum.optional().describe('Filter by conversation type'),\n first: z.number().optional().describe('Page size (default 50)'),\n after: z.string().optional().describe('Cursor returned by a previous page'),\n },\n },\n async ({ type, first, after }) => {\n try {\n const filter: Record<string, unknown> = {};\n if (type !== undefined) filter.type = type;\n\n const data = await ctx.gql.workspace.request<{\n conversations: {\n edges: Array<{ node: ConversationNode }>;\n pageInfo: { hasNextPage: boolean; endCursor?: string };\n };\n }>(LIST_CONVERSATIONS, {\n filter: Object.keys(filter).length > 0 ? filter : undefined,\n first,\n after,\n });\n return jsonResult({\n items: data.conversations.edges.map((e) => e.node),\n pageInfo: data.conversations.pageInfo,\n });\n } catch (error) {\n ctx.logger.error('conversations_list failed', { error });\n return errorResult(\n `Failed to list conversations: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'conversations_get')),\n {\n title: 'Get Conversation',\n description: 'Get a single conversation by ID.',\n inputSchema: {\n id: z.string().describe('Conversation ID'),\n },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n conversation: ConversationNode | null;\n }>(GET_CONVERSATION, { id });\n if (!data.conversation) {\n return errorResult(`Conversation ${id} not found`);\n }\n return jsonResult(data.conversation);\n } catch (error) {\n ctx.logger.error('conversations_get failed', { error });\n return errorResult(\n `Failed to get conversation: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'conversations_create')),\n {\n title: 'Create Conversation',\n description: 'Create a new threaded conversation.',\n inputSchema: {\n title: z.string().describe('Conversation title'),\n description: z.string().optional().describe('Conversation description'),\n type: ConversationTypeEnum.optional().describe('Conversation type (default: GROUP)'),\n participantIds: z.array(z.string()).optional().describe('Participant user IDs'),\n },\n },\n async ({ title, description, type, participantIds }) => {\n try {\n const input: Record<string, unknown> = {\n title,\n type: type ?? 'GROUP',\n };\n if (description !== undefined) input.description = description;\n if (participantIds !== undefined) input.participantIds = participantIds;\n\n const data = await ctx.gql.workspace.request<{\n createConversation: { conversation: ConversationNode };\n }>(CREATE_CONVERSATION, { input });\n return jsonResult(data.createConversation.conversation);\n } catch (error) {\n ctx.logger.error('conversations_create failed', { error });\n return errorResult(\n `Failed to create conversation: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'conversations_update')),\n {\n title: 'Update Conversation',\n description: 'Update title and/or description of a conversation.',\n inputSchema: {\n id: z.string().describe('Conversation ID'),\n title: z.string().optional().describe('New title'),\n description: z.string().optional().describe('New description'),\n },\n },\n async ({ id, title, description }) => {\n try {\n const input: Record<string, unknown> = { id };\n if (title !== undefined) input.title = title;\n if (description !== undefined) input.description = description;\n if (Object.keys(input).length === 1) {\n return errorResult('No updates specified');\n }\n const data = await ctx.gql.workspace.request<{\n updateConversation: { conversation: ConversationNode };\n }>(UPDATE_CONVERSATION, { input });\n return jsonResult(data.updateConversation.conversation);\n } catch (error) {\n ctx.logger.error('conversations_update failed', { error });\n return errorResult(\n `Failed to update conversation: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'conversations_delete')),\n {\n title: 'Delete Conversation',\n description: 'Delete a conversation by ID.',\n inputSchema: {\n id: z.string().describe('Conversation ID to delete'),\n },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n deleteConversation: { success: boolean };\n }>(DELETE_CONVERSATION, { id });\n return jsonResult({ deleted: data.deleteConversation.success, conversationId: id });\n } catch (error) {\n ctx.logger.error('conversations_delete failed', { error });\n return errorResult(\n `Failed to delete conversation: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'conversations_send_message')),\n {\n title: 'Send Message',\n description: 'Send a text message to a conversation. Optionally reply to a parent message.',\n inputSchema: {\n conversationId: z.string().describe('Conversation ID'),\n content: z.string().describe('Message content'),\n parentMessageId: z.string().optional().describe('Parent message ID (for replies)'),\n },\n },\n async ({ conversationId, content, parentMessageId }) => {\n try {\n const input: Record<string, unknown> = {\n conversationId,\n content,\n type: 'TEXT',\n };\n if (parentMessageId !== undefined) input.parentMessageId = parentMessageId;\n\n const data = await ctx.gql.workspace.request<{\n sendMessage: {\n message: { id: string; content: string; type?: string; createdAt?: string };\n };\n }>(SEND_MESSAGE, { input });\n return jsonResult(data.sendMessage.message);\n } catch (error) {\n ctx.logger.error('conversations_send_message failed', { error });\n return errorResult(\n `Failed to send message: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n}\n","/**\n * Conversations module — threaded conversations + messages\n * (<product>_conversations_{list,get,create,update,delete,send_message}).\n *\n * Backend: ~/products/wspace/conversations/wspace-conversations-svc/.\n * Ported from cli-sdk/src/modules/conversations/.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { McpContext, McpModule, ModuleRegistration } from '../../core/index.js';\nimport { registerConversationsTools } from './tools.js';\n\nconst conversationsModule: McpModule = {\n id: 'conversations',\n version: '0.0.1',\n displayName: 'Conversations',\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 registerConversationsTools(server, ctx, track);\n\n return { tools, resources: [], prompts: [] };\n },\n};\n\nexport default conversationsModule;\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 conversationsModule: McpModule;
|
|
7
|
+
|
|
8
|
+
export { conversationsModule 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 conversationsModule: McpModule;
|
|
7
|
+
|
|
8
|
+
export { conversationsModule as default };
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { mcpToolName, jsonResult, errorResult } from '../../chunk-H2OYWLOA.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
// src/modules/conversations/operations.ts
|
|
5
|
+
var LIST_CONVERSATIONS = `
|
|
6
|
+
query ListConversations($filter: ConversationFilterInput, $first: Int, $after: String) {
|
|
7
|
+
conversations(filter: $filter, first: $first, after: $after) {
|
|
8
|
+
edges { node { id title type description createdAt updatedAt unreadCount } }
|
|
9
|
+
pageInfo { hasNextPage endCursor }
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
|
+
var GET_CONVERSATION = `
|
|
14
|
+
query GetConversation($id: ID!) {
|
|
15
|
+
conversation(id: $id) {
|
|
16
|
+
id title type description avatarUrl settings
|
|
17
|
+
createdAt updatedAt
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
var CREATE_CONVERSATION = `
|
|
22
|
+
mutation CreateConversation($input: CreateConversationInput!) {
|
|
23
|
+
createConversation(input: $input) {
|
|
24
|
+
conversation { id title type }
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
var DELETE_CONVERSATION = `
|
|
29
|
+
mutation DeleteConversation($id: ID!) {
|
|
30
|
+
deleteConversation(id: $id) { success }
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
33
|
+
var UPDATE_CONVERSATION = `
|
|
34
|
+
mutation UpdateConversation($input: UpdateConversationInput!) {
|
|
35
|
+
updateConversation(input: $input) {
|
|
36
|
+
conversation { id title description }
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
`;
|
|
40
|
+
var SEND_MESSAGE = `
|
|
41
|
+
mutation SendMessage($input: SendMessageInput!) {
|
|
42
|
+
sendMessage(input: $input) {
|
|
43
|
+
message { id content type createdAt }
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
// src/modules/conversations/tools.ts
|
|
49
|
+
var ConversationTypeEnum = z.enum(["DIRECT", "GROUP", "CHANNEL"]);
|
|
50
|
+
function registerConversationsTools(server, ctx, track) {
|
|
51
|
+
server.registerTool(
|
|
52
|
+
track(mcpToolName(ctx.productName, "conversations_list")),
|
|
53
|
+
{
|
|
54
|
+
title: "List Conversations",
|
|
55
|
+
description: "List threaded conversations with optional type filter and cursor pagination.",
|
|
56
|
+
inputSchema: {
|
|
57
|
+
type: ConversationTypeEnum.optional().describe("Filter by conversation type"),
|
|
58
|
+
first: z.number().optional().describe("Page size (default 50)"),
|
|
59
|
+
after: z.string().optional().describe("Cursor returned by a previous page")
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
async ({ type, first, after }) => {
|
|
63
|
+
try {
|
|
64
|
+
const filter = {};
|
|
65
|
+
if (type !== void 0) filter.type = type;
|
|
66
|
+
const data = await ctx.gql.workspace.request(LIST_CONVERSATIONS, {
|
|
67
|
+
filter: Object.keys(filter).length > 0 ? filter : void 0,
|
|
68
|
+
first,
|
|
69
|
+
after
|
|
70
|
+
});
|
|
71
|
+
return jsonResult({
|
|
72
|
+
items: data.conversations.edges.map((e) => e.node),
|
|
73
|
+
pageInfo: data.conversations.pageInfo
|
|
74
|
+
});
|
|
75
|
+
} catch (error) {
|
|
76
|
+
ctx.logger.error("conversations_list failed", { error });
|
|
77
|
+
return errorResult(
|
|
78
|
+
`Failed to list conversations: ${error instanceof Error ? error.message : String(error)}`
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
server.registerTool(
|
|
84
|
+
track(mcpToolName(ctx.productName, "conversations_get")),
|
|
85
|
+
{
|
|
86
|
+
title: "Get Conversation",
|
|
87
|
+
description: "Get a single conversation by ID.",
|
|
88
|
+
inputSchema: {
|
|
89
|
+
id: z.string().describe("Conversation ID")
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
async ({ id }) => {
|
|
93
|
+
try {
|
|
94
|
+
const data = await ctx.gql.workspace.request(GET_CONVERSATION, { id });
|
|
95
|
+
if (!data.conversation) {
|
|
96
|
+
return errorResult(`Conversation ${id} not found`);
|
|
97
|
+
}
|
|
98
|
+
return jsonResult(data.conversation);
|
|
99
|
+
} catch (error) {
|
|
100
|
+
ctx.logger.error("conversations_get failed", { error });
|
|
101
|
+
return errorResult(
|
|
102
|
+
`Failed to get conversation: ${error instanceof Error ? error.message : String(error)}`
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
server.registerTool(
|
|
108
|
+
track(mcpToolName(ctx.productName, "conversations_create")),
|
|
109
|
+
{
|
|
110
|
+
title: "Create Conversation",
|
|
111
|
+
description: "Create a new threaded conversation.",
|
|
112
|
+
inputSchema: {
|
|
113
|
+
title: z.string().describe("Conversation title"),
|
|
114
|
+
description: z.string().optional().describe("Conversation description"),
|
|
115
|
+
type: ConversationTypeEnum.optional().describe("Conversation type (default: GROUP)"),
|
|
116
|
+
participantIds: z.array(z.string()).optional().describe("Participant user IDs")
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
async ({ title, description, type, participantIds }) => {
|
|
120
|
+
try {
|
|
121
|
+
const input = {
|
|
122
|
+
title,
|
|
123
|
+
type: type ?? "GROUP"
|
|
124
|
+
};
|
|
125
|
+
if (description !== void 0) input.description = description;
|
|
126
|
+
if (participantIds !== void 0) input.participantIds = participantIds;
|
|
127
|
+
const data = await ctx.gql.workspace.request(CREATE_CONVERSATION, { input });
|
|
128
|
+
return jsonResult(data.createConversation.conversation);
|
|
129
|
+
} catch (error) {
|
|
130
|
+
ctx.logger.error("conversations_create failed", { error });
|
|
131
|
+
return errorResult(
|
|
132
|
+
`Failed to create conversation: ${error instanceof Error ? error.message : String(error)}`
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
server.registerTool(
|
|
138
|
+
track(mcpToolName(ctx.productName, "conversations_update")),
|
|
139
|
+
{
|
|
140
|
+
title: "Update Conversation",
|
|
141
|
+
description: "Update title and/or description of a conversation.",
|
|
142
|
+
inputSchema: {
|
|
143
|
+
id: z.string().describe("Conversation ID"),
|
|
144
|
+
title: z.string().optional().describe("New title"),
|
|
145
|
+
description: z.string().optional().describe("New description")
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
async ({ id, title, description }) => {
|
|
149
|
+
try {
|
|
150
|
+
const input = { id };
|
|
151
|
+
if (title !== void 0) input.title = title;
|
|
152
|
+
if (description !== void 0) input.description = description;
|
|
153
|
+
if (Object.keys(input).length === 1) {
|
|
154
|
+
return errorResult("No updates specified");
|
|
155
|
+
}
|
|
156
|
+
const data = await ctx.gql.workspace.request(UPDATE_CONVERSATION, { input });
|
|
157
|
+
return jsonResult(data.updateConversation.conversation);
|
|
158
|
+
} catch (error) {
|
|
159
|
+
ctx.logger.error("conversations_update failed", { error });
|
|
160
|
+
return errorResult(
|
|
161
|
+
`Failed to update conversation: ${error instanceof Error ? error.message : String(error)}`
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
);
|
|
166
|
+
server.registerTool(
|
|
167
|
+
track(mcpToolName(ctx.productName, "conversations_delete")),
|
|
168
|
+
{
|
|
169
|
+
title: "Delete Conversation",
|
|
170
|
+
description: "Delete a conversation by ID.",
|
|
171
|
+
inputSchema: {
|
|
172
|
+
id: z.string().describe("Conversation ID to delete")
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
async ({ id }) => {
|
|
176
|
+
try {
|
|
177
|
+
const data = await ctx.gql.workspace.request(DELETE_CONVERSATION, { id });
|
|
178
|
+
return jsonResult({ deleted: data.deleteConversation.success, conversationId: id });
|
|
179
|
+
} catch (error) {
|
|
180
|
+
ctx.logger.error("conversations_delete failed", { error });
|
|
181
|
+
return errorResult(
|
|
182
|
+
`Failed to delete conversation: ${error instanceof Error ? error.message : String(error)}`
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
);
|
|
187
|
+
server.registerTool(
|
|
188
|
+
track(mcpToolName(ctx.productName, "conversations_send_message")),
|
|
189
|
+
{
|
|
190
|
+
title: "Send Message",
|
|
191
|
+
description: "Send a text message to a conversation. Optionally reply to a parent message.",
|
|
192
|
+
inputSchema: {
|
|
193
|
+
conversationId: z.string().describe("Conversation ID"),
|
|
194
|
+
content: z.string().describe("Message content"),
|
|
195
|
+
parentMessageId: z.string().optional().describe("Parent message ID (for replies)")
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
async ({ conversationId, content, parentMessageId }) => {
|
|
199
|
+
try {
|
|
200
|
+
const input = {
|
|
201
|
+
conversationId,
|
|
202
|
+
content,
|
|
203
|
+
type: "TEXT"
|
|
204
|
+
};
|
|
205
|
+
if (parentMessageId !== void 0) input.parentMessageId = parentMessageId;
|
|
206
|
+
const data = await ctx.gql.workspace.request(SEND_MESSAGE, { input });
|
|
207
|
+
return jsonResult(data.sendMessage.message);
|
|
208
|
+
} catch (error) {
|
|
209
|
+
ctx.logger.error("conversations_send_message failed", { error });
|
|
210
|
+
return errorResult(
|
|
211
|
+
`Failed to send message: ${error instanceof Error ? error.message : String(error)}`
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// src/modules/conversations/index.ts
|
|
219
|
+
var conversationsModule = {
|
|
220
|
+
id: "conversations",
|
|
221
|
+
version: "0.0.1",
|
|
222
|
+
displayName: "Conversations",
|
|
223
|
+
dependsOn: ["auth"],
|
|
224
|
+
capabilities: { tools: {} },
|
|
225
|
+
register(server, ctx) {
|
|
226
|
+
const tools = [];
|
|
227
|
+
const track = (n) => {
|
|
228
|
+
tools.push(n);
|
|
229
|
+
return n;
|
|
230
|
+
};
|
|
231
|
+
registerConversationsTools(server, ctx, track);
|
|
232
|
+
return { tools, resources: [], prompts: [] };
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
var conversations_default = conversationsModule;
|
|
236
|
+
|
|
237
|
+
export { conversations_default as default };
|
|
238
|
+
//# sourceMappingURL=index.js.map
|
|
239
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/modules/conversations/operations.ts","../../../src/modules/conversations/tools.ts","../../../src/modules/conversations/index.ts"],"names":[],"mappings":";;;;AAAO,IAAM,kBAAA,GAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAS3B,IAAM,gBAAA,GAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AASzB,IAAM,mBAAA,GAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAQ5B,IAAM,mBAAA,GAAsB;AAAA;AAAA;AAAA;AAAA,CAAA;AAM5B,IAAM,mBAAA,GAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAQ5B,IAAM,YAAA,GAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;;;AC5B5B,IAAM,uBAAuB,CAAA,CAAE,IAAA,CAAK,CAAC,QAAA,EAAU,OAAA,EAAS,SAAS,CAAC,CAAA;AAY3D,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,8EAAA;AAAA,MACb,WAAA,EAAa;AAAA,QACX,IAAA,EAAM,oBAAA,CAAqB,QAAA,EAAS,CAAE,SAAS,6BAA6B,CAAA;AAAA,QAC5E,OAAO,CAAA,CAAE,MAAA,GAAS,QAAA,EAAS,CAAE,SAAS,wBAAwB,CAAA;AAAA,QAC9D,OAAO,CAAA,CAAE,MAAA,GAAS,QAAA,EAAS,CAAE,SAAS,oCAAoC;AAAA;AAC5E,KACF;AAAA,IACA,OAAO,EAAE,IAAA,EAAM,KAAA,EAAO,OAAM,KAAM;AAChC,MAAA,IAAI;AACF,QAAA,MAAM,SAAkC,EAAC;AACzC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AAA,GAAA,CAAI,MAAA,CAAO,KAAA,CAAM,mCAAA,EAAqC,EAAE,OAAO,CAAA;AAC/D,QAAA,OAAO,WAAA;AAAA,UACL,2BAA2B,KAAA,YAAiB,KAAA,GAAQ,MAAM,OAAA,GAAU,MAAA,CAAO,KAAK,CAAC,CAAA;AAAA,SACnF;AAAA,MACF;AAAA,IACF;AAAA,GACF;AACF;;;AC/MA,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.js","sourcesContent":["export const LIST_CONVERSATIONS = `\n query ListConversations($filter: ConversationFilterInput, $first: Int, $after: String) {\n conversations(filter: $filter, first: $first, after: $after) {\n edges { node { id title type description createdAt updatedAt unreadCount } }\n pageInfo { hasNextPage endCursor }\n }\n }\n`;\n\nexport const GET_CONVERSATION = `\n query GetConversation($id: ID!) {\n conversation(id: $id) {\n id title type description avatarUrl settings\n createdAt updatedAt\n }\n }\n`;\n\nexport const CREATE_CONVERSATION = `\n mutation CreateConversation($input: CreateConversationInput!) {\n createConversation(input: $input) {\n conversation { id title type }\n }\n }\n`;\n\nexport const DELETE_CONVERSATION = `\n mutation DeleteConversation($id: ID!) {\n deleteConversation(id: $id) { success }\n }\n`;\n\nexport const UPDATE_CONVERSATION = `\n mutation UpdateConversation($input: UpdateConversationInput!) {\n updateConversation(input: $input) {\n conversation { id title description }\n }\n }\n`;\n\nexport const SEND_MESSAGE = `\n mutation SendMessage($input: SendMessageInput!) {\n sendMessage(input: $input) {\n message { id content type createdAt }\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 LIST_CONVERSATIONS,\n GET_CONVERSATION,\n CREATE_CONVERSATION,\n UPDATE_CONVERSATION,\n DELETE_CONVERSATION,\n SEND_MESSAGE,\n} from './operations.js';\n\nconst ConversationTypeEnum = z.enum(['DIRECT', 'GROUP', 'CHANNEL']);\n\ninterface ConversationNode {\n id: string;\n title?: string;\n type?: string;\n description?: string | null;\n createdAt?: string;\n updatedAt?: string;\n unreadCount?: number;\n}\n\nexport function registerConversationsTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n server.registerTool(\n track(mcpToolName(ctx.productName, 'conversations_list')),\n {\n title: 'List Conversations',\n description: 'List threaded conversations with optional type filter and cursor pagination.',\n inputSchema: {\n type: ConversationTypeEnum.optional().describe('Filter by conversation type'),\n first: z.number().optional().describe('Page size (default 50)'),\n after: z.string().optional().describe('Cursor returned by a previous page'),\n },\n },\n async ({ type, first, after }) => {\n try {\n const filter: Record<string, unknown> = {};\n if (type !== undefined) filter.type = type;\n\n const data = await ctx.gql.workspace.request<{\n conversations: {\n edges: Array<{ node: ConversationNode }>;\n pageInfo: { hasNextPage: boolean; endCursor?: string };\n };\n }>(LIST_CONVERSATIONS, {\n filter: Object.keys(filter).length > 0 ? filter : undefined,\n first,\n after,\n });\n return jsonResult({\n items: data.conversations.edges.map((e) => e.node),\n pageInfo: data.conversations.pageInfo,\n });\n } catch (error) {\n ctx.logger.error('conversations_list failed', { error });\n return errorResult(\n `Failed to list conversations: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'conversations_get')),\n {\n title: 'Get Conversation',\n description: 'Get a single conversation by ID.',\n inputSchema: {\n id: z.string().describe('Conversation ID'),\n },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n conversation: ConversationNode | null;\n }>(GET_CONVERSATION, { id });\n if (!data.conversation) {\n return errorResult(`Conversation ${id} not found`);\n }\n return jsonResult(data.conversation);\n } catch (error) {\n ctx.logger.error('conversations_get failed', { error });\n return errorResult(\n `Failed to get conversation: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'conversations_create')),\n {\n title: 'Create Conversation',\n description: 'Create a new threaded conversation.',\n inputSchema: {\n title: z.string().describe('Conversation title'),\n description: z.string().optional().describe('Conversation description'),\n type: ConversationTypeEnum.optional().describe('Conversation type (default: GROUP)'),\n participantIds: z.array(z.string()).optional().describe('Participant user IDs'),\n },\n },\n async ({ title, description, type, participantIds }) => {\n try {\n const input: Record<string, unknown> = {\n title,\n type: type ?? 'GROUP',\n };\n if (description !== undefined) input.description = description;\n if (participantIds !== undefined) input.participantIds = participantIds;\n\n const data = await ctx.gql.workspace.request<{\n createConversation: { conversation: ConversationNode };\n }>(CREATE_CONVERSATION, { input });\n return jsonResult(data.createConversation.conversation);\n } catch (error) {\n ctx.logger.error('conversations_create failed', { error });\n return errorResult(\n `Failed to create conversation: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'conversations_update')),\n {\n title: 'Update Conversation',\n description: 'Update title and/or description of a conversation.',\n inputSchema: {\n id: z.string().describe('Conversation ID'),\n title: z.string().optional().describe('New title'),\n description: z.string().optional().describe('New description'),\n },\n },\n async ({ id, title, description }) => {\n try {\n const input: Record<string, unknown> = { id };\n if (title !== undefined) input.title = title;\n if (description !== undefined) input.description = description;\n if (Object.keys(input).length === 1) {\n return errorResult('No updates specified');\n }\n const data = await ctx.gql.workspace.request<{\n updateConversation: { conversation: ConversationNode };\n }>(UPDATE_CONVERSATION, { input });\n return jsonResult(data.updateConversation.conversation);\n } catch (error) {\n ctx.logger.error('conversations_update failed', { error });\n return errorResult(\n `Failed to update conversation: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'conversations_delete')),\n {\n title: 'Delete Conversation',\n description: 'Delete a conversation by ID.',\n inputSchema: {\n id: z.string().describe('Conversation ID to delete'),\n },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n deleteConversation: { success: boolean };\n }>(DELETE_CONVERSATION, { id });\n return jsonResult({ deleted: data.deleteConversation.success, conversationId: id });\n } catch (error) {\n ctx.logger.error('conversations_delete failed', { error });\n return errorResult(\n `Failed to delete conversation: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'conversations_send_message')),\n {\n title: 'Send Message',\n description: 'Send a text message to a conversation. Optionally reply to a parent message.',\n inputSchema: {\n conversationId: z.string().describe('Conversation ID'),\n content: z.string().describe('Message content'),\n parentMessageId: z.string().optional().describe('Parent message ID (for replies)'),\n },\n },\n async ({ conversationId, content, parentMessageId }) => {\n try {\n const input: Record<string, unknown> = {\n conversationId,\n content,\n type: 'TEXT',\n };\n if (parentMessageId !== undefined) input.parentMessageId = parentMessageId;\n\n const data = await ctx.gql.workspace.request<{\n sendMessage: {\n message: { id: string; content: string; type?: string; createdAt?: string };\n };\n }>(SEND_MESSAGE, { input });\n return jsonResult(data.sendMessage.message);\n } catch (error) {\n ctx.logger.error('conversations_send_message failed', { error });\n return errorResult(\n `Failed to send message: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n}\n","/**\n * Conversations module — threaded conversations + messages\n * (<product>_conversations_{list,get,create,update,delete,send_message}).\n *\n * Backend: ~/products/wspace/conversations/wspace-conversations-svc/.\n * Ported from cli-sdk/src/modules/conversations/.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { McpContext, McpModule, ModuleRegistration } from '../../core/index.js';\nimport { registerConversationsTools } from './tools.js';\n\nconst conversationsModule: McpModule = {\n id: 'conversations',\n version: '0.0.1',\n displayName: 'Conversations',\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 registerConversationsTools(server, ctx, track);\n\n return { tools, resources: [], prompts: [] };\n },\n};\n\nexport default conversationsModule;\n"]}
|