@burdenoff/mcp-libs 2026.522.1 → 2026.523.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/{chunk-4GBVJ4OY.js → chunk-N2CZNPYC.js} +31 -3
  2. package/dist/chunk-N2CZNPYC.js.map +1 -0
  3. package/dist/modules/auth/index.cjs +317 -0
  4. package/dist/modules/auth/index.cjs.map +1 -1
  5. package/dist/modules/auth/index.js +289 -1
  6. package/dist/modules/auth/index.js.map +1 -1
  7. package/dist/modules/channels/index.cjs +47 -0
  8. package/dist/modules/channels/index.cjs.map +1 -1
  9. package/dist/modules/channels/index.js +47 -0
  10. package/dist/modules/channels/index.js.map +1 -1
  11. package/dist/modules/conversations/index.cjs +181 -0
  12. package/dist/modules/conversations/index.cjs.map +1 -1
  13. package/dist/modules/conversations/index.js +181 -0
  14. package/dist/modules/conversations/index.js.map +1 -1
  15. package/dist/modules/devportal/index.cjs +281 -0
  16. package/dist/modules/devportal/index.cjs.map +1 -1
  17. package/dist/modules/devportal/index.js +281 -0
  18. package/dist/modules/devportal/index.js.map +1 -1
  19. package/dist/modules/files/index.cjs +244 -2
  20. package/dist/modules/files/index.cjs.map +1 -1
  21. package/dist/modules/files/index.js +244 -2
  22. package/dist/modules/files/index.js.map +1 -1
  23. package/dist/modules/organizations/index.cjs +211 -0
  24. package/dist/modules/organizations/index.cjs.map +1 -1
  25. package/dist/modules/organizations/index.js +211 -0
  26. package/dist/modules/organizations/index.js.map +1 -1
  27. package/dist/modules/products/index.cjs +131 -0
  28. package/dist/modules/products/index.cjs.map +1 -1
  29. package/dist/modules/products/index.js +131 -0
  30. package/dist/modules/products/index.js.map +1 -1
  31. package/dist/modules/rbac/index.cjs +114 -0
  32. package/dist/modules/rbac/index.cjs.map +1 -1
  33. package/dist/modules/rbac/index.js +114 -0
  34. package/dist/modules/rbac/index.js.map +1 -1
  35. package/dist/modules/sandbox/index.cjs.map +1 -1
  36. package/dist/modules/sandbox/index.js +1 -1
  37. package/dist/modules/scheduler/index.cjs +124 -0
  38. package/dist/modules/scheduler/index.cjs.map +1 -1
  39. package/dist/modules/scheduler/index.js +124 -0
  40. package/dist/modules/scheduler/index.js.map +1 -1
  41. package/dist/modules/security/index.cjs +51 -0
  42. package/dist/modules/security/index.cjs.map +1 -1
  43. package/dist/modules/security/index.js +51 -0
  44. package/dist/modules/security/index.js.map +1 -1
  45. package/dist/modules/store/index.cjs +102 -0
  46. package/dist/modules/store/index.cjs.map +1 -1
  47. package/dist/modules/store/index.js +102 -0
  48. package/dist/modules/store/index.js.map +1 -1
  49. package/dist/modules/tours/index.cjs +43 -0
  50. package/dist/modules/tours/index.cjs.map +1 -1
  51. package/dist/modules/tours/index.js +43 -0
  52. package/dist/modules/tours/index.js.map +1 -1
  53. package/dist/modules/vibecontrols/index.cjs +197 -0
  54. package/dist/modules/vibecontrols/index.cjs.map +1 -1
  55. package/dist/modules/vibecontrols/index.js +170 -1
  56. package/dist/modules/vibecontrols/index.js.map +1 -1
  57. package/dist/modules/workspaces/index.cjs +46 -3
  58. package/dist/modules/workspaces/index.cjs.map +1 -1
  59. package/dist/modules/workspaces/index.js +46 -3
  60. package/dist/modules/workspaces/index.js.map +1 -1
  61. package/package.json +4 -3
  62. package/dist/chunk-4GBVJ4OY.js.map +0 -1
@@ -93,9 +93,37 @@ var SEND_MESSAGE = `
93
93
  }
94
94
  }
95
95
  `;
96
+ var LIST_MESSAGES = `
97
+ query Messages($conversationId: ID!, $filter: MessageFilter, $first: Int, $after: String) {
98
+ messages(conversationId: $conversationId, filter: $filter, first: $first, after: $after) {
99
+ edges {
100
+ cursor
101
+ node { id conversationId senderId content type metadata createdAt updatedAt }
102
+ }
103
+ pageInfo { hasNextPage endCursor }
104
+ }
105
+ }
106
+ `;
107
+ var GET_CONVERSATION_SETTINGS = `
108
+ query ConversationSettings($id: ID!) {
109
+ conversation(id: $id) {
110
+ id
111
+ settings
112
+ }
113
+ }
114
+ `;
115
+ var UPDATE_CONVERSATION_SETTINGS = `
116
+ mutation UpdateConversationSettings($input: UpdateConversationInput!) {
117
+ updateConversation(input: $input) {
118
+ conversation { id settings }
119
+ success
120
+ }
121
+ }
122
+ `;
96
123
 
97
124
  // src/modules/conversations/tools.ts
98
125
  var ConversationTypeEnum = zod.z.enum(["DIRECT", "GROUP", "CHANNEL"]);
126
+ var NotificationLevelEnum = zod.z.enum(["ALL", "MENTIONS", "MUTED"]);
99
127
  function registerConversationsTools(server, ctx, track) {
100
128
  server.registerTool(
101
129
  track(mcpToolName(ctx.productName, "conversations_list")),
@@ -262,6 +290,159 @@ function registerConversationsTools(server, ctx, track) {
262
290
  }
263
291
  }
264
292
  );
293
+ server.registerTool(
294
+ track(mcpToolName(ctx.productName, "conversations_messages_list")),
295
+ {
296
+ title: "List Conversation Messages",
297
+ description: "List messages in a conversation with cursor pagination. Returns { items, pageInfo }.",
298
+ inputSchema: {
299
+ conversationId: zod.z.string().describe("Conversation ID"),
300
+ first: zod.z.number().optional().describe("Page size (default 50)"),
301
+ after: zod.z.string().optional().describe("Cursor returned by a previous page")
302
+ }
303
+ },
304
+ async ({ conversationId, first, after }) => {
305
+ try {
306
+ const data = await ctx.gql.workspace.request(LIST_MESSAGES, { conversationId, first, after });
307
+ return jsonResult({
308
+ items: data.messages.edges.map((e) => e.node),
309
+ pageInfo: data.messages.pageInfo
310
+ });
311
+ } catch (error) {
312
+ ctx.logger.error("conversations_messages_list failed", { error });
313
+ return errorResult(
314
+ `Failed to list messages: ${error instanceof Error ? error.message : String(error)}`
315
+ );
316
+ }
317
+ }
318
+ );
319
+ server.registerTool(
320
+ track(mcpToolName(ctx.productName, "conversations_messages_send")),
321
+ {
322
+ title: "Send Conversation Message",
323
+ description: "Send a message to a conversation under the nested messages.send surface. Returns the created Message.",
324
+ inputSchema: {
325
+ conversationId: zod.z.string().describe("Conversation ID"),
326
+ content: zod.z.string().describe("Message content"),
327
+ parentMessageId: zod.z.string().optional().describe("Parent message ID (for thread replies)"),
328
+ type: zod.z.string().optional().describe("Message type (default TEXT, will be uppercased)")
329
+ }
330
+ },
331
+ async ({ conversationId, content, parentMessageId, type }) => {
332
+ try {
333
+ const input = {
334
+ conversationId,
335
+ content,
336
+ type: (type ?? "TEXT").toUpperCase()
337
+ };
338
+ if (parentMessageId !== void 0) input.parentMessageId = parentMessageId;
339
+ const data = await ctx.gql.workspace.request(SEND_MESSAGE, { input });
340
+ return jsonResult(data.sendMessage.message);
341
+ } catch (error) {
342
+ ctx.logger.error("conversations_messages_send failed", { error });
343
+ return errorResult(
344
+ `Failed to send message: ${error instanceof Error ? error.message : String(error)}`
345
+ );
346
+ }
347
+ }
348
+ );
349
+ server.registerTool(
350
+ track(mcpToolName(ctx.productName, "conversations_settings_get")),
351
+ {
352
+ title: "Get Conversation Settings",
353
+ description: "Fetch the settings JSON for a conversation. Returns { id, settings }; settings is null if the conversation has no overrides.",
354
+ inputSchema: {
355
+ conversationId: zod.z.string().describe("Conversation ID")
356
+ }
357
+ },
358
+ async ({ conversationId }) => {
359
+ try {
360
+ const data = await ctx.gql.workspace.request(GET_CONVERSATION_SETTINGS, { id: conversationId });
361
+ if (!data.conversation) {
362
+ return errorResult(`Conversation ${conversationId} not found`);
363
+ }
364
+ return jsonResult({
365
+ id: data.conversation.id,
366
+ settings: data.conversation.settings ?? null
367
+ });
368
+ } catch (error) {
369
+ ctx.logger.error("conversations_settings_get failed", { error });
370
+ return errorResult(
371
+ `Failed to get conversation settings: ${error instanceof Error ? error.message : String(error)}`
372
+ );
373
+ }
374
+ }
375
+ );
376
+ server.registerTool(
377
+ track(mcpToolName(ctx.productName, "conversations_settings_set")),
378
+ {
379
+ title: "Update Conversation Settings",
380
+ description: "Update the settings (notification level, retention, moderation, etc.) for a conversation. At least one setting field must be provided. Returns the updated conversation { id, settings }.",
381
+ inputSchema: {
382
+ conversationId: zod.z.string().describe("Conversation ID"),
383
+ allowAnonymous: zod.z.boolean().optional().describe("Whether anonymous users can post"),
384
+ allowGuests: zod.z.boolean().optional().describe("Whether guests can join"),
385
+ allowMessageDeletion: zod.z.boolean().optional().describe("Whether members can delete messages"),
386
+ allowMessageEditing: zod.z.boolean().optional().describe("Whether members can edit messages"),
387
+ defaultNotificationLevel: NotificationLevelEnum.optional().describe(
388
+ "Default notification level for new members (ALL/MENTIONS/MUTED)"
389
+ ),
390
+ messageRetentionDays: zod.z.number().int().optional().describe("Auto-delete messages older than N days (null = keep forever)"),
391
+ moderationEnabled: zod.z.boolean().optional().describe("Enable auto-moderation"),
392
+ reactionsEnabled: zod.z.boolean().optional().describe("Enable emoji reactions"),
393
+ threadsEnabled: zod.z.boolean().optional().describe("Enable threaded replies"),
394
+ slowModeSeconds: zod.z.number().int().optional().describe("Seconds between consecutive messages per user (0 = off)")
395
+ }
396
+ },
397
+ async ({
398
+ conversationId,
399
+ allowAnonymous,
400
+ allowGuests,
401
+ allowMessageDeletion,
402
+ allowMessageEditing,
403
+ defaultNotificationLevel,
404
+ messageRetentionDays,
405
+ moderationEnabled,
406
+ reactionsEnabled,
407
+ threadsEnabled,
408
+ slowModeSeconds
409
+ }) => {
410
+ try {
411
+ const settings = {};
412
+ if (allowAnonymous !== void 0) settings.allowAnonymous = allowAnonymous;
413
+ if (allowGuests !== void 0) settings.allowGuests = allowGuests;
414
+ if (allowMessageDeletion !== void 0)
415
+ settings.allowMessageDeletion = allowMessageDeletion;
416
+ if (allowMessageEditing !== void 0) settings.allowMessageEditing = allowMessageEditing;
417
+ if (defaultNotificationLevel !== void 0)
418
+ settings.defaultNotificationLevel = defaultNotificationLevel;
419
+ if (messageRetentionDays !== void 0)
420
+ settings.messageRetentionDays = messageRetentionDays;
421
+ if (moderationEnabled !== void 0) settings.moderationEnabled = moderationEnabled;
422
+ if (reactionsEnabled !== void 0) settings.reactionsEnabled = reactionsEnabled;
423
+ if (threadsEnabled !== void 0) settings.threadsEnabled = threadsEnabled;
424
+ if (slowModeSeconds !== void 0) settings.slowModeSeconds = slowModeSeconds;
425
+ if (Object.keys(settings).length === 0) {
426
+ return errorResult(
427
+ "No settings specified \u2014 provide at least one settings field to update"
428
+ );
429
+ }
430
+ const data = await ctx.gql.workspace.request(UPDATE_CONVERSATION_SETTINGS, {
431
+ input: { id: conversationId, settings }
432
+ });
433
+ return jsonResult({
434
+ success: data.updateConversation.success,
435
+ id: data.updateConversation.conversation?.id ?? conversationId,
436
+ settings: data.updateConversation.conversation?.settings ?? null
437
+ });
438
+ } catch (error) {
439
+ ctx.logger.error("conversations_settings_set failed", { error });
440
+ return errorResult(
441
+ `Failed to update conversation settings: ${error instanceof Error ? error.message : String(error)}`
442
+ );
443
+ }
444
+ }
445
+ );
265
446
  }
266
447
 
267
448
  // src/modules/conversations/index.ts
@@ -1 +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,EAA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,QAAkB,EAAC;AACzB,IAAA,MAAM,KAAA,GAAQ,CAAC,CAAA,KAAsB;AACnC,MAAA,KAAA,CAAM,KAAK,CAAC,CAAA;AACZ,MAAA,OAAO,CAAA;AAAA,IACT,CAAA;AAEA,IAAA,0BAAA,CAA2B,MAAA,EAAQ,KAAK,KAAK,CAAA;AAE7C,IAAA,OAAO,EAAE,KAAA,EAAO,SAAA,EAAW,EAAC,EAAG,OAAA,EAAS,EAAC,EAAE;AAAA,EAC7C;AACF,CAAA;AAEA,IAAO,qBAAA,GAAQ","file":"index.cjs","sourcesContent":["/**\n * Error classes for MCP SDK.\n *\n * Modules MUST throw these instead of throwing raw Errors. The registerTool\n * wrapper in result.ts catches and maps them to MCP-protocol-compliant\n * `{ isError: true, content: [...] }` responses.\n *\n * Throwing past the wrapper to the protocol surfaces as JSON-RPC -32603 to\n * the client and is a protocol bug.\n */\n\nexport class McpUserError extends Error {\n public readonly hint: string | undefined;\n\n constructor(message: string, opts?: { hint?: string }) {\n super(message);\n this.name = 'McpUserError';\n this.hint = opts?.hint;\n }\n}\n\nexport class McpAuthError extends McpUserError {\n constructor(message: string, opts?: { hint?: string }) {\n super(message, {\n hint: opts?.hint ?? 'Run the auth_login tool to authenticate.',\n });\n this.name = 'McpAuthError';\n }\n}\n\nexport class McpInternalError extends Error {\n public override readonly cause: unknown;\n\n constructor(message: string, cause?: unknown) {\n super(message);\n this.name = 'McpInternalError';\n this.cause = cause;\n }\n}\n","/**\n * MCP tool result helpers + central handler.\n *\n * Modules NEVER call server.registerTool directly — they use registerTool()\n * from this module so the central try/catch wraps the handler and:\n * - maps thrown McpUserError / McpAuthError / McpInternalError to\n * MCP-protocol-compliant `{ isError: true, content: [...] }` shapes\n * - threads `_meta.progressToken` into ctx.progress for long ops\n * - emits a structured log line on every error\n * - never leaks `cause` from McpInternalError to the client\n *\n * This is the analog of cli-sdk's createProgram() central error handler.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { ZodRawShape } from 'zod';\nimport type { McpContext } from './context.js';\nimport { McpAuthError, McpInternalError, McpUserError } from './errors.js';\n\nexport interface ToolTextContent {\n type: 'text';\n text: string;\n [k: string]: unknown;\n}\n\nexport interface ToolResult {\n content: ToolTextContent[];\n isError?: boolean;\n structuredContent?: Record<string, unknown>;\n [k: string]: unknown;\n}\n\nexport interface ToolMeta {\n progressToken?: string | number;\n}\n\n/**\n * Build a successful tool result with JSON content (pretty-printed).\n */\nexport function jsonResult(data: unknown, structured?: Record<string, unknown>): ToolResult {\n const result: ToolResult = {\n content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],\n };\n if (structured !== undefined) {\n result.structuredContent = structured;\n }\n return result;\n}\n\n/**\n * Build a successful tool result with plain text content.\n */\nexport function textResult(text: string): ToolResult {\n return { content: [{ type: 'text', text }] };\n}\n\n/**\n * Build an error tool result. Honors MCP's `{ isError: true, content }` shape.\n * Optional hint is appended on a new line so the LLM can react.\n */\nexport function errorResult(message: string, hint?: string): ToolResult {\n const text = hint ? `${message}\\n\\nHint: ${hint}` : message;\n return { content: [{ type: 'text', text }], isError: true };\n}\n\nexport interface ToolMetadata {\n title: string;\n description: string;\n inputSchema?: ZodRawShape;\n}\n\nexport type ToolHandler<TArgs = Record<string, unknown>> = (\n args: TArgs,\n ctx: McpContext,\n meta: ToolMeta,\n) => Promise<unknown>;\n\n/**\n * Register a tool with the central error wrapper.\n *\n * The handler returns a plain value or void. The wrapper:\n * - wraps non-undefined returns in jsonResult()\n * - if the value already looks like a ToolResult (has `content`), passes through\n * - catches McpAuthError / McpUserError / McpInternalError / generic Error\n * - logs every error via ctx.logger.error\n */\nexport function registerTool<TArgs extends Record<string, unknown>>(\n server: McpServer,\n ctx: McpContext,\n name: string,\n metadata: ToolMetadata,\n handler: ToolHandler<TArgs>,\n): void {\n const sdkConfig = {\n title: metadata.title,\n description: metadata.description,\n ...(metadata.inputSchema ? { inputSchema: metadata.inputSchema } : {}),\n };\n\n // The MCP SDK's registerTool signature is `(name, config, handler)`. The\n // handler arity depends on whether inputSchema is present (1-arg without,\n // 2-arg with). We accept a unified handler shape and dispatch at runtime.\n // The SDK's typing is strict and conditional on the inputSchema generic;\n // bypass with a cast since runtime acceptance is unconditional.\n const wrapped = async (...callbackArgs: unknown[]): Promise<ToolResult> => {\n const hasArgs = callbackArgs.length === 2;\n const args = (hasArgs ? callbackArgs[0] : {}) as TArgs;\n const extra = (hasArgs ? callbackArgs[1] : callbackArgs[0]) as\n | { _meta?: { progressToken?: string | number } }\n | undefined;\n\n const progressToken = extra?._meta?.progressToken;\n const meta: ToolMeta = progressToken !== undefined ? { progressToken } : {};\n\n try {\n const result = await handler(args, ctx, meta);\n if (isToolResult(result)) return result;\n if (result === undefined) return textResult('OK');\n return jsonResult(result);\n } catch (error) {\n return mapErrorToResult(error, ctx, name);\n }\n };\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (server as any).registerTool(name, sdkConfig, wrapped);\n}\n\nfunction isToolResult(value: unknown): value is ToolResult {\n return (\n !!value &&\n typeof value === 'object' &&\n 'content' in value &&\n Array.isArray((value as ToolResult).content)\n );\n}\n\nfunction mapErrorToResult(error: unknown, ctx: McpContext, toolName: string): ToolResult {\n if (error instanceof McpAuthError) {\n ctx.logger.warn(`${toolName}: auth required`, { message: error.message });\n return errorResult(error.message, error.hint);\n }\n if (error instanceof McpUserError) {\n ctx.logger.info(`${toolName}: user error`, { message: error.message });\n return errorResult(error.message, error.hint);\n }\n if (error instanceof McpInternalError) {\n ctx.logger.error(`${toolName}: internal error`, {\n message: error.message,\n cause: stringifyCause(error.cause),\n });\n return errorResult(`Internal error in ${toolName}.`);\n }\n const message = error instanceof Error ? error.message : String(error);\n ctx.logger.error(`${toolName}: unhandled error`, { message });\n return errorResult(`${toolName}: ${message}`);\n}\n\nfunction stringifyCause(cause: unknown): string | undefined {\n if (cause === undefined || cause === null) return undefined;\n if (cause instanceof Error) return cause.message;\n try {\n return JSON.stringify(cause);\n } catch {\n return String(cause);\n }\n}\n","/**\n * Tool / resource / prompt naming helpers.\n *\n * Mandatory product prefix avoids collisions when Claude Desktop runs\n * multiple MCP servers concurrently (typical setup is ~6).\n *\n * Tool names are capped at 63 characters — Claude Desktop pre-1.x\n * truncated at 64 in some versions.\n */\n\nimport { McpInternalError } from './errors.js';\n\nconst MAX_TOOL_NAME_LENGTH = 63;\n\nfunction assertSafeName(name: string, kind: 'tool' | 'resource' | 'prompt'): string {\n if (kind === 'tool' && name.length > MAX_TOOL_NAME_LENGTH) {\n throw new McpInternalError(\n `Tool name '${name}' exceeds ${MAX_TOOL_NAME_LENGTH} characters (some MCP clients truncate at 64).`,\n );\n }\n return name;\n}\n\n/**\n * Build a tool name. Format: `<productName>_<...parts>` (snake_case).\n * Example: mcpToolName('vibecontrols', 'vibes', 'list') -> 'vibecontrols_vibes_list'\n */\nexport function mcpToolName(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpToolName: productName is required');\n }\n const name = [productName, ...parts].filter(Boolean).join('_');\n return assertSafeName(name, 'tool');\n}\n\n/**\n * Build a resource URI. Format: `<productName>://<...parts>`.\n * Example: mcpResourceUri('vibecontrols', 'schema') -> 'vibecontrols://schema'\n */\nexport function mcpResourceUri(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpResourceUri: productName is required');\n }\n return `${productName}://${parts.filter(Boolean).join('/')}`;\n}\n\n/**\n * Build a prompt name. Format: `<productName>-<...parts>` (kebab-case).\n * Example: mcpPromptName('vibecontrols', 'setup') -> 'vibecontrols-setup'\n */\nexport function mcpPromptName(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpPromptName: productName is required');\n }\n return [productName, ...parts].filter(Boolean).join('-');\n}\n\nexport const TOOL_NAME_LIMIT = MAX_TOOL_NAME_LENGTH;\n","export const LIST_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"]}
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;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,MAAA,EAAQ,KAAK,KAAK,CAAA;AAE7C,IAAA,OAAO,EAAE,KAAA,EAAO,SAAA,EAAW,EAAC,EAAG,OAAA,EAAS,EAAC,EAAE;AAAA,EAC7C;AACF,CAAA;AAEA,IAAO,qBAAA,GAAQ","file":"index.cjs","sourcesContent":["/**\n * Error classes for MCP SDK.\n *\n * Modules MUST throw these instead of throwing raw Errors. The registerTool\n * wrapper in result.ts catches and maps them to MCP-protocol-compliant\n * `{ isError: true, content: [...] }` responses.\n *\n * Throwing past the wrapper to the protocol surfaces as JSON-RPC -32603 to\n * the client and is a protocol bug.\n */\n\nexport class McpUserError extends Error {\n public readonly hint: string | undefined;\n\n constructor(message: string, opts?: { hint?: string }) {\n super(message);\n this.name = 'McpUserError';\n this.hint = opts?.hint;\n }\n}\n\nexport class McpAuthError extends McpUserError {\n constructor(message: string, opts?: { hint?: string }) {\n super(message, {\n hint: opts?.hint ?? 'Run the auth_login tool to authenticate.',\n });\n this.name = 'McpAuthError';\n }\n}\n\nexport class McpInternalError extends Error {\n public override readonly cause: unknown;\n\n constructor(message: string, cause?: unknown) {\n super(message);\n this.name = 'McpInternalError';\n this.cause = cause;\n }\n}\n","/**\n * MCP tool result helpers + central handler.\n *\n * Modules NEVER call server.registerTool directly — they use registerTool()\n * from this module so the central try/catch wraps the handler and:\n * - maps thrown McpUserError / McpAuthError / McpInternalError to\n * MCP-protocol-compliant `{ isError: true, content: [...] }` shapes\n * - threads `_meta.progressToken` into ctx.progress for long ops\n * - emits a structured log line on every error\n * - never leaks `cause` from McpInternalError to the client\n *\n * This is the analog of cli-sdk's createProgram() central error handler.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { ZodRawShape } from 'zod';\nimport type { McpContext } from './context.js';\nimport { McpAuthError, McpInternalError, McpUserError } from './errors.js';\n\nexport interface ToolTextContent {\n type: 'text';\n text: string;\n [k: string]: unknown;\n}\n\nexport interface ToolResult {\n content: ToolTextContent[];\n isError?: boolean;\n structuredContent?: Record<string, unknown>;\n [k: string]: unknown;\n}\n\nexport interface ToolMeta {\n progressToken?: string | number;\n}\n\n/**\n * Build a successful tool result with JSON content (pretty-printed).\n */\nexport function jsonResult(data: unknown, structured?: Record<string, unknown>): ToolResult {\n const result: ToolResult = {\n content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],\n };\n if (structured !== undefined) {\n result.structuredContent = structured;\n }\n return result;\n}\n\n/**\n * Build a successful tool result with plain text content.\n */\nexport function textResult(text: string): ToolResult {\n return { content: [{ type: 'text', text }] };\n}\n\n/**\n * Build an error tool result. Honors MCP's `{ isError: true, content }` shape.\n * Optional hint is appended on a new line so the LLM can react.\n */\nexport function errorResult(message: string, hint?: string): ToolResult {\n const text = hint ? `${message}\\n\\nHint: ${hint}` : message;\n return { content: [{ type: 'text', text }], isError: true };\n}\n\nexport interface ToolMetadata {\n title: string;\n description: string;\n inputSchema?: ZodRawShape;\n}\n\nexport type ToolHandler<TArgs = Record<string, unknown>> = (\n args: TArgs,\n ctx: McpContext,\n meta: ToolMeta,\n) => Promise<unknown>;\n\n/**\n * Register a tool with the central error wrapper.\n *\n * The handler returns a plain value or void. The wrapper:\n * - wraps non-undefined returns in jsonResult()\n * - if the value already looks like a ToolResult (has `content`), passes through\n * - catches McpAuthError / McpUserError / McpInternalError / generic Error\n * - logs every error via ctx.logger.error\n */\nexport function registerTool<TArgs extends Record<string, unknown>>(\n server: McpServer,\n ctx: McpContext,\n name: string,\n metadata: ToolMetadata,\n handler: ToolHandler<TArgs>,\n): void {\n const sdkConfig = {\n title: metadata.title,\n description: metadata.description,\n ...(metadata.inputSchema ? { inputSchema: metadata.inputSchema } : {}),\n };\n\n // The MCP SDK's registerTool signature is `(name, config, handler)`. The\n // handler arity depends on whether inputSchema is present (1-arg without,\n // 2-arg with). We accept a unified handler shape and dispatch at runtime.\n // The SDK's typing is strict and conditional on the inputSchema generic;\n // bypass with a cast since runtime acceptance is unconditional.\n const wrapped = async (...callbackArgs: unknown[]): Promise<ToolResult> => {\n const hasArgs = callbackArgs.length === 2;\n const args = (hasArgs ? callbackArgs[0] : {}) as TArgs;\n const extra = (hasArgs ? callbackArgs[1] : callbackArgs[0]) as\n | { _meta?: { progressToken?: string | number } }\n | undefined;\n\n const progressToken = extra?._meta?.progressToken;\n const meta: ToolMeta = progressToken !== undefined ? { progressToken } : {};\n\n try {\n const result = await handler(args, ctx, meta);\n if (isToolResult(result)) return result;\n if (result === undefined) return textResult('OK');\n return jsonResult(result);\n } catch (error) {\n return mapErrorToResult(error, ctx, name);\n }\n };\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (server as any).registerTool(name, sdkConfig, wrapped);\n}\n\nfunction isToolResult(value: unknown): value is ToolResult {\n return (\n !!value &&\n typeof value === 'object' &&\n 'content' in value &&\n Array.isArray((value as ToolResult).content)\n );\n}\n\nfunction mapErrorToResult(error: unknown, ctx: McpContext, toolName: string): ToolResult {\n if (error instanceof McpAuthError) {\n ctx.logger.warn(`${toolName}: auth required`, { message: error.message });\n return errorResult(error.message, error.hint);\n }\n if (error instanceof McpUserError) {\n ctx.logger.info(`${toolName}: user error`, { message: error.message });\n return errorResult(error.message, error.hint);\n }\n if (error instanceof McpInternalError) {\n ctx.logger.error(`${toolName}: internal error`, {\n message: error.message,\n cause: stringifyCause(error.cause),\n });\n return errorResult(`Internal error in ${toolName}.`);\n }\n const message = error instanceof Error ? error.message : String(error);\n ctx.logger.error(`${toolName}: unhandled error`, { message });\n return errorResult(`${toolName}: ${message}`);\n}\n\nfunction stringifyCause(cause: unknown): string | undefined {\n if (cause === undefined || cause === null) return undefined;\n if (cause instanceof Error) return cause.message;\n try {\n return JSON.stringify(cause);\n } catch {\n return String(cause);\n }\n}\n","/**\n * Tool / resource / prompt naming helpers.\n *\n * Mandatory product prefix avoids collisions when Claude Desktop runs\n * multiple MCP servers concurrently (typical setup is ~6).\n *\n * Tool names are capped at 63 characters — Claude Desktop pre-1.x\n * truncated at 64 in some versions.\n */\n\nimport { McpInternalError } from './errors.js';\n\nconst MAX_TOOL_NAME_LENGTH = 63;\n\nfunction assertSafeName(name: string, kind: 'tool' | 'resource' | 'prompt'): string {\n if (kind === 'tool' && name.length > MAX_TOOL_NAME_LENGTH) {\n throw new McpInternalError(\n `Tool name '${name}' exceeds ${MAX_TOOL_NAME_LENGTH} characters (some MCP clients truncate at 64).`,\n );\n }\n return name;\n}\n\n/**\n * Build a tool name. Format: `<productName>_<...parts>` (snake_case).\n * Example: mcpToolName('vibecontrols', 'vibes', 'list') -> 'vibecontrols_vibes_list'\n */\nexport function mcpToolName(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpToolName: productName is required');\n }\n const name = [productName, ...parts].filter(Boolean).join('_');\n return assertSafeName(name, 'tool');\n}\n\n/**\n * Build a resource URI. Format: `<productName>://<...parts>`.\n * Example: mcpResourceUri('vibecontrols', 'schema') -> 'vibecontrols://schema'\n */\nexport function mcpResourceUri(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpResourceUri: productName is required');\n }\n return `${productName}://${parts.filter(Boolean).join('/')}`;\n}\n\n/**\n * Build a prompt name. Format: `<productName>-<...parts>` (kebab-case).\n * Example: mcpPromptName('vibecontrols', 'setup') -> 'vibecontrols-setup'\n */\nexport function mcpPromptName(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpPromptName: productName is required');\n }\n return [productName, ...parts].filter(Boolean).join('-');\n}\n\nexport const TOOL_NAME_LIMIT = MAX_TOOL_NAME_LENGTH;\n","export const LIST_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\nexport const LIST_MESSAGES = `\n query Messages($conversationId: ID!, $filter: MessageFilter, $first: Int, $after: String) {\n messages(conversationId: $conversationId, filter: $filter, first: $first, after: $after) {\n edges {\n cursor\n node { id conversationId senderId content type metadata createdAt updatedAt }\n }\n pageInfo { hasNextPage endCursor }\n }\n }\n`;\n\nexport const GET_CONVERSATION_SETTINGS = `\n query ConversationSettings($id: ID!) {\n conversation(id: $id) {\n id\n settings\n }\n }\n`;\n\nexport const UPDATE_CONVERSATION_SETTINGS = `\n mutation UpdateConversationSettings($input: UpdateConversationInput!) {\n updateConversation(input: $input) {\n conversation { id settings }\n success\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 LIST_MESSAGES,\n GET_CONVERSATION_SETTINGS,\n UPDATE_CONVERSATION_SETTINGS,\n} from './operations.js';\n\nconst ConversationTypeEnum = z.enum(['DIRECT', 'GROUP', 'CHANNEL']);\nconst NotificationLevelEnum = z.enum(['ALL', 'MENTIONS', 'MUTED']);\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\ninterface MessageNode {\n id: string;\n conversationId?: string;\n senderId?: string;\n content?: string;\n type?: string;\n createdAt?: string;\n updatedAt?: string;\n metadata?: Record<string, unknown> | null;\n}\n\ninterface ConversationSettingsShape {\n id?: string;\n settings?: Record<string, unknown> | null;\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 // ── Messages ────────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'conversations_messages_list')),\n {\n title: 'List Conversation Messages',\n description:\n 'List messages in a conversation with cursor pagination. Returns { items, pageInfo }.',\n inputSchema: {\n conversationId: z.string().describe('Conversation ID'),\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 ({ conversationId, first, after }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n messages: {\n edges: Array<{ cursor: string; node: MessageNode }>;\n pageInfo: { hasNextPage: boolean; endCursor?: string };\n };\n }>(LIST_MESSAGES, { conversationId, first, after });\n return jsonResult({\n items: data.messages.edges.map((e) => e.node),\n pageInfo: data.messages.pageInfo,\n });\n } catch (error) {\n ctx.logger.error('conversations_messages_list failed', { error });\n return errorResult(\n `Failed to list messages: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'conversations_messages_send')),\n {\n title: 'Send Conversation Message',\n description:\n 'Send a message to a conversation under the nested messages.send surface. Returns the created 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 thread replies)'),\n type: z.string().optional().describe('Message type (default TEXT, will be uppercased)'),\n },\n },\n async ({ conversationId, content, parentMessageId, type }) => {\n try {\n const input: Record<string, unknown> = {\n conversationId,\n content,\n type: (type ?? 'TEXT').toUpperCase(),\n };\n if (parentMessageId !== undefined) input.parentMessageId = parentMessageId;\n const data = await ctx.gql.workspace.request<{\n sendMessage: { message: MessageNode };\n }>(SEND_MESSAGE, { input });\n return jsonResult(data.sendMessage.message);\n } catch (error) {\n ctx.logger.error('conversations_messages_send failed', { error });\n return errorResult(\n `Failed to send message: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Settings ────────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'conversations_settings_get')),\n {\n title: 'Get Conversation Settings',\n description:\n 'Fetch the settings JSON for a conversation. Returns { id, settings }; settings is null if the conversation has no overrides.',\n inputSchema: {\n conversationId: z.string().describe('Conversation ID'),\n },\n },\n async ({ conversationId }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n conversation: ConversationSettingsShape | null;\n }>(GET_CONVERSATION_SETTINGS, { id: conversationId });\n if (!data.conversation) {\n return errorResult(`Conversation ${conversationId} not found`);\n }\n return jsonResult({\n id: data.conversation.id,\n settings: data.conversation.settings ?? null,\n });\n } catch (error) {\n ctx.logger.error('conversations_settings_get failed', { error });\n return errorResult(\n `Failed to get conversation settings: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'conversations_settings_set')),\n {\n title: 'Update Conversation Settings',\n description:\n 'Update the settings (notification level, retention, moderation, etc.) for a conversation. At least one setting field must be provided. Returns the updated conversation { id, settings }.',\n inputSchema: {\n conversationId: z.string().describe('Conversation ID'),\n allowAnonymous: z.boolean().optional().describe('Whether anonymous users can post'),\n allowGuests: z.boolean().optional().describe('Whether guests can join'),\n allowMessageDeletion: z\n .boolean()\n .optional()\n .describe('Whether members can delete messages'),\n allowMessageEditing: z.boolean().optional().describe('Whether members can edit messages'),\n defaultNotificationLevel: NotificationLevelEnum.optional().describe(\n 'Default notification level for new members (ALL/MENTIONS/MUTED)',\n ),\n messageRetentionDays: z\n .number()\n .int()\n .optional()\n .describe('Auto-delete messages older than N days (null = keep forever)'),\n moderationEnabled: z.boolean().optional().describe('Enable auto-moderation'),\n reactionsEnabled: z.boolean().optional().describe('Enable emoji reactions'),\n threadsEnabled: z.boolean().optional().describe('Enable threaded replies'),\n slowModeSeconds: z\n .number()\n .int()\n .optional()\n .describe('Seconds between consecutive messages per user (0 = off)'),\n },\n },\n async ({\n conversationId,\n allowAnonymous,\n allowGuests,\n allowMessageDeletion,\n allowMessageEditing,\n defaultNotificationLevel,\n messageRetentionDays,\n moderationEnabled,\n reactionsEnabled,\n threadsEnabled,\n slowModeSeconds,\n }) => {\n try {\n const settings: Record<string, unknown> = {};\n if (allowAnonymous !== undefined) settings.allowAnonymous = allowAnonymous;\n if (allowGuests !== undefined) settings.allowGuests = allowGuests;\n if (allowMessageDeletion !== undefined)\n settings.allowMessageDeletion = allowMessageDeletion;\n if (allowMessageEditing !== undefined) settings.allowMessageEditing = allowMessageEditing;\n if (defaultNotificationLevel !== undefined)\n settings.defaultNotificationLevel = defaultNotificationLevel;\n if (messageRetentionDays !== undefined)\n settings.messageRetentionDays = messageRetentionDays;\n if (moderationEnabled !== undefined) settings.moderationEnabled = moderationEnabled;\n if (reactionsEnabled !== undefined) settings.reactionsEnabled = reactionsEnabled;\n if (threadsEnabled !== undefined) settings.threadsEnabled = threadsEnabled;\n if (slowModeSeconds !== undefined) settings.slowModeSeconds = slowModeSeconds;\n\n if (Object.keys(settings).length === 0) {\n return errorResult(\n 'No settings specified — provide at least one settings field to update',\n );\n }\n\n const data = await ctx.gql.workspace.request<{\n updateConversation: { conversation: ConversationSettingsShape | null; success: boolean };\n }>(UPDATE_CONVERSATION_SETTINGS, {\n input: { id: conversationId, settings },\n });\n return jsonResult({\n success: data.updateConversation.success,\n id: data.updateConversation.conversation?.id ?? conversationId,\n settings: data.updateConversation.conversation?.settings ?? null,\n });\n } catch (error) {\n ctx.logger.error('conversations_settings_set failed', { error });\n return errorResult(\n `Failed to update conversation settings: ${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"]}
@@ -44,9 +44,37 @@ var SEND_MESSAGE = `
44
44
  }
45
45
  }
46
46
  `;
47
+ var LIST_MESSAGES = `
48
+ query Messages($conversationId: ID!, $filter: MessageFilter, $first: Int, $after: String) {
49
+ messages(conversationId: $conversationId, filter: $filter, first: $first, after: $after) {
50
+ edges {
51
+ cursor
52
+ node { id conversationId senderId content type metadata createdAt updatedAt }
53
+ }
54
+ pageInfo { hasNextPage endCursor }
55
+ }
56
+ }
57
+ `;
58
+ var GET_CONVERSATION_SETTINGS = `
59
+ query ConversationSettings($id: ID!) {
60
+ conversation(id: $id) {
61
+ id
62
+ settings
63
+ }
64
+ }
65
+ `;
66
+ var UPDATE_CONVERSATION_SETTINGS = `
67
+ mutation UpdateConversationSettings($input: UpdateConversationInput!) {
68
+ updateConversation(input: $input) {
69
+ conversation { id settings }
70
+ success
71
+ }
72
+ }
73
+ `;
47
74
 
48
75
  // src/modules/conversations/tools.ts
49
76
  var ConversationTypeEnum = z.enum(["DIRECT", "GROUP", "CHANNEL"]);
77
+ var NotificationLevelEnum = z.enum(["ALL", "MENTIONS", "MUTED"]);
50
78
  function registerConversationsTools(server, ctx, track) {
51
79
  server.registerTool(
52
80
  track(mcpToolName(ctx.productName, "conversations_list")),
@@ -213,6 +241,159 @@ function registerConversationsTools(server, ctx, track) {
213
241
  }
214
242
  }
215
243
  );
244
+ server.registerTool(
245
+ track(mcpToolName(ctx.productName, "conversations_messages_list")),
246
+ {
247
+ title: "List Conversation Messages",
248
+ description: "List messages in a conversation with cursor pagination. Returns { items, pageInfo }.",
249
+ inputSchema: {
250
+ conversationId: z.string().describe("Conversation ID"),
251
+ first: z.number().optional().describe("Page size (default 50)"),
252
+ after: z.string().optional().describe("Cursor returned by a previous page")
253
+ }
254
+ },
255
+ async ({ conversationId, first, after }) => {
256
+ try {
257
+ const data = await ctx.gql.workspace.request(LIST_MESSAGES, { conversationId, first, after });
258
+ return jsonResult({
259
+ items: data.messages.edges.map((e) => e.node),
260
+ pageInfo: data.messages.pageInfo
261
+ });
262
+ } catch (error) {
263
+ ctx.logger.error("conversations_messages_list failed", { error });
264
+ return errorResult(
265
+ `Failed to list messages: ${error instanceof Error ? error.message : String(error)}`
266
+ );
267
+ }
268
+ }
269
+ );
270
+ server.registerTool(
271
+ track(mcpToolName(ctx.productName, "conversations_messages_send")),
272
+ {
273
+ title: "Send Conversation Message",
274
+ description: "Send a message to a conversation under the nested messages.send surface. Returns the created Message.",
275
+ inputSchema: {
276
+ conversationId: z.string().describe("Conversation ID"),
277
+ content: z.string().describe("Message content"),
278
+ parentMessageId: z.string().optional().describe("Parent message ID (for thread replies)"),
279
+ type: z.string().optional().describe("Message type (default TEXT, will be uppercased)")
280
+ }
281
+ },
282
+ async ({ conversationId, content, parentMessageId, type }) => {
283
+ try {
284
+ const input = {
285
+ conversationId,
286
+ content,
287
+ type: (type ?? "TEXT").toUpperCase()
288
+ };
289
+ if (parentMessageId !== void 0) input.parentMessageId = parentMessageId;
290
+ const data = await ctx.gql.workspace.request(SEND_MESSAGE, { input });
291
+ return jsonResult(data.sendMessage.message);
292
+ } catch (error) {
293
+ ctx.logger.error("conversations_messages_send failed", { error });
294
+ return errorResult(
295
+ `Failed to send message: ${error instanceof Error ? error.message : String(error)}`
296
+ );
297
+ }
298
+ }
299
+ );
300
+ server.registerTool(
301
+ track(mcpToolName(ctx.productName, "conversations_settings_get")),
302
+ {
303
+ title: "Get Conversation Settings",
304
+ description: "Fetch the settings JSON for a conversation. Returns { id, settings }; settings is null if the conversation has no overrides.",
305
+ inputSchema: {
306
+ conversationId: z.string().describe("Conversation ID")
307
+ }
308
+ },
309
+ async ({ conversationId }) => {
310
+ try {
311
+ const data = await ctx.gql.workspace.request(GET_CONVERSATION_SETTINGS, { id: conversationId });
312
+ if (!data.conversation) {
313
+ return errorResult(`Conversation ${conversationId} not found`);
314
+ }
315
+ return jsonResult({
316
+ id: data.conversation.id,
317
+ settings: data.conversation.settings ?? null
318
+ });
319
+ } catch (error) {
320
+ ctx.logger.error("conversations_settings_get failed", { error });
321
+ return errorResult(
322
+ `Failed to get conversation settings: ${error instanceof Error ? error.message : String(error)}`
323
+ );
324
+ }
325
+ }
326
+ );
327
+ server.registerTool(
328
+ track(mcpToolName(ctx.productName, "conversations_settings_set")),
329
+ {
330
+ title: "Update Conversation Settings",
331
+ description: "Update the settings (notification level, retention, moderation, etc.) for a conversation. At least one setting field must be provided. Returns the updated conversation { id, settings }.",
332
+ inputSchema: {
333
+ conversationId: z.string().describe("Conversation ID"),
334
+ allowAnonymous: z.boolean().optional().describe("Whether anonymous users can post"),
335
+ allowGuests: z.boolean().optional().describe("Whether guests can join"),
336
+ allowMessageDeletion: z.boolean().optional().describe("Whether members can delete messages"),
337
+ allowMessageEditing: z.boolean().optional().describe("Whether members can edit messages"),
338
+ defaultNotificationLevel: NotificationLevelEnum.optional().describe(
339
+ "Default notification level for new members (ALL/MENTIONS/MUTED)"
340
+ ),
341
+ messageRetentionDays: z.number().int().optional().describe("Auto-delete messages older than N days (null = keep forever)"),
342
+ moderationEnabled: z.boolean().optional().describe("Enable auto-moderation"),
343
+ reactionsEnabled: z.boolean().optional().describe("Enable emoji reactions"),
344
+ threadsEnabled: z.boolean().optional().describe("Enable threaded replies"),
345
+ slowModeSeconds: z.number().int().optional().describe("Seconds between consecutive messages per user (0 = off)")
346
+ }
347
+ },
348
+ async ({
349
+ conversationId,
350
+ allowAnonymous,
351
+ allowGuests,
352
+ allowMessageDeletion,
353
+ allowMessageEditing,
354
+ defaultNotificationLevel,
355
+ messageRetentionDays,
356
+ moderationEnabled,
357
+ reactionsEnabled,
358
+ threadsEnabled,
359
+ slowModeSeconds
360
+ }) => {
361
+ try {
362
+ const settings = {};
363
+ if (allowAnonymous !== void 0) settings.allowAnonymous = allowAnonymous;
364
+ if (allowGuests !== void 0) settings.allowGuests = allowGuests;
365
+ if (allowMessageDeletion !== void 0)
366
+ settings.allowMessageDeletion = allowMessageDeletion;
367
+ if (allowMessageEditing !== void 0) settings.allowMessageEditing = allowMessageEditing;
368
+ if (defaultNotificationLevel !== void 0)
369
+ settings.defaultNotificationLevel = defaultNotificationLevel;
370
+ if (messageRetentionDays !== void 0)
371
+ settings.messageRetentionDays = messageRetentionDays;
372
+ if (moderationEnabled !== void 0) settings.moderationEnabled = moderationEnabled;
373
+ if (reactionsEnabled !== void 0) settings.reactionsEnabled = reactionsEnabled;
374
+ if (threadsEnabled !== void 0) settings.threadsEnabled = threadsEnabled;
375
+ if (slowModeSeconds !== void 0) settings.slowModeSeconds = slowModeSeconds;
376
+ if (Object.keys(settings).length === 0) {
377
+ return errorResult(
378
+ "No settings specified \u2014 provide at least one settings field to update"
379
+ );
380
+ }
381
+ const data = await ctx.gql.workspace.request(UPDATE_CONVERSATION_SETTINGS, {
382
+ input: { id: conversationId, settings }
383
+ });
384
+ return jsonResult({
385
+ success: data.updateConversation.success,
386
+ id: data.updateConversation.conversation?.id ?? conversationId,
387
+ settings: data.updateConversation.conversation?.settings ?? null
388
+ });
389
+ } catch (error) {
390
+ ctx.logger.error("conversations_settings_set failed", { error });
391
+ return errorResult(
392
+ `Failed to update conversation settings: ${error instanceof Error ? error.message : String(error)}`
393
+ );
394
+ }
395
+ }
396
+ );
216
397
  }
217
398
 
218
399
  // src/modules/conversations/index.ts