@burdenoff/mcp-libs 2026.703.3 → 2026.719.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 (185) hide show
  1. package/dist/{chunk-WWFVD7BO.js → chunk-RHWHUY5Y.js} +3 -3
  2. package/dist/{chunk-WWFVD7BO.js.map → chunk-RHWHUY5Y.js.map} +1 -1
  3. package/dist/{chunk-H2OYWLOA.js → chunk-YOSQUY3M.js} +101 -35
  4. package/dist/chunk-YOSQUY3M.js.map +1 -0
  5. package/dist/core/index.cjs +101 -32
  6. package/dist/core/index.cjs.map +1 -1
  7. package/dist/core/index.d.cts +1 -1
  8. package/dist/core/index.d.ts +1 -1
  9. package/dist/core/index.js +1 -1
  10. package/dist/index.cjs +97 -31
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +1 -1
  13. package/dist/index.d.ts +1 -1
  14. package/dist/index.js +1 -1
  15. package/dist/modules/adaptercloud/index.cjs +14 -14
  16. package/dist/modules/adaptercloud/index.cjs.map +1 -1
  17. package/dist/modules/adaptercloud/index.js +1 -1
  18. package/dist/modules/artistrybase/index.cjs +14 -14
  19. package/dist/modules/artistrybase/index.cjs.map +1 -1
  20. package/dist/modules/artistrybase/index.js +1 -1
  21. package/dist/modules/assethandler/index.cjs +14 -14
  22. package/dist/modules/assethandler/index.cjs.map +1 -1
  23. package/dist/modules/assethandler/index.js +1 -1
  24. package/dist/modules/atheletebridge/index.cjs +14 -14
  25. package/dist/modules/atheletebridge/index.cjs.map +1 -1
  26. package/dist/modules/atheletebridge/index.js +1 -1
  27. package/dist/modules/auth/index.cjs +14 -14
  28. package/dist/modules/auth/index.cjs.map +1 -1
  29. package/dist/modules/auth/index.js +3 -3
  30. package/dist/modules/billing/index.cjs +14 -14
  31. package/dist/modules/billing/index.cjs.map +1 -1
  32. package/dist/modules/billing/index.js +1 -1
  33. package/dist/modules/brainyrich/index.cjs +14 -14
  34. package/dist/modules/brainyrich/index.cjs.map +1 -1
  35. package/dist/modules/brainyrich/index.js +1 -1
  36. package/dist/modules/buildmyiq/index.cjs +14 -14
  37. package/dist/modules/buildmyiq/index.cjs.map +1 -1
  38. package/dist/modules/buildmyiq/index.js +1 -1
  39. package/dist/modules/channels/index.cjs +14 -14
  40. package/dist/modules/channels/index.cjs.map +1 -1
  41. package/dist/modules/channels/index.js +1 -1
  42. package/dist/modules/collabkin/index.cjs +14 -14
  43. package/dist/modules/collabkin/index.cjs.map +1 -1
  44. package/dist/modules/collabkin/index.js +1 -1
  45. package/dist/modules/comradecircle/index.cjs +14 -14
  46. package/dist/modules/comradecircle/index.cjs.map +1 -1
  47. package/dist/modules/comradecircle/index.js +1 -1
  48. package/dist/modules/conversations/index.cjs +14 -14
  49. package/dist/modules/conversations/index.cjs.map +1 -1
  50. package/dist/modules/conversations/index.js +1 -1
  51. package/dist/modules/coolandlovely/index.cjs +14 -14
  52. package/dist/modules/coolandlovely/index.cjs.map +1 -1
  53. package/dist/modules/coolandlovely/index.js +1 -1
  54. package/dist/modules/cosmicintersection/index.cjs +14 -14
  55. package/dist/modules/cosmicintersection/index.cjs.map +1 -1
  56. package/dist/modules/cosmicintersection/index.js +1 -1
  57. package/dist/modules/crewfoundry/index.cjs +14 -14
  58. package/dist/modules/crewfoundry/index.cjs.map +1 -1
  59. package/dist/modules/crewfoundry/index.js +1 -1
  60. package/dist/modules/devportal/index.cjs +14 -14
  61. package/dist/modules/devportal/index.cjs.map +1 -1
  62. package/dist/modules/devportal/index.js +1 -1
  63. package/dist/modules/ecoimpacthub/index.cjs +14 -14
  64. package/dist/modules/ecoimpacthub/index.cjs.map +1 -1
  65. package/dist/modules/ecoimpacthub/index.js +1 -1
  66. package/dist/modules/eventfullymanaged/index.cjs +14 -14
  67. package/dist/modules/eventfullymanaged/index.cjs.map +1 -1
  68. package/dist/modules/eventfullymanaged/index.js +1 -1
  69. package/dist/modules/export/index.cjs +14 -14
  70. package/dist/modules/export/index.cjs.map +1 -1
  71. package/dist/modules/export/index.js +1 -1
  72. package/dist/modules/files/index.cjs +14 -14
  73. package/dist/modules/files/index.cjs.map +1 -1
  74. package/dist/modules/files/index.js +1 -1
  75. package/dist/modules/ggnomad/index.cjs +14 -14
  76. package/dist/modules/ggnomad/index.cjs.map +1 -1
  77. package/dist/modules/ggnomad/index.js +1 -1
  78. package/dist/modules/govcitizenhub/index.cjs +14 -14
  79. package/dist/modules/govcitizenhub/index.cjs.map +1 -1
  80. package/dist/modules/govcitizenhub/index.js +1 -1
  81. package/dist/modules/groups/index.cjs +14 -14
  82. package/dist/modules/groups/index.cjs.map +1 -1
  83. package/dist/modules/groups/index.js +1 -1
  84. package/dist/modules/headshotmarketing/index.cjs +14 -14
  85. package/dist/modules/headshotmarketing/index.cjs.map +1 -1
  86. package/dist/modules/headshotmarketing/index.js +1 -1
  87. package/dist/modules/health/index.cjs +21 -19
  88. package/dist/modules/health/index.cjs.map +1 -1
  89. package/dist/modules/health/index.js +1 -1
  90. package/dist/modules/hookmovies/index.cjs +14 -14
  91. package/dist/modules/hookmovies/index.cjs.map +1 -1
  92. package/dist/modules/hookmovies/index.js +1 -1
  93. package/dist/modules/housingvista/index.cjs +14 -14
  94. package/dist/modules/housingvista/index.cjs.map +1 -1
  95. package/dist/modules/housingvista/index.js +1 -1
  96. package/dist/modules/integrations/index.cjs +14 -14
  97. package/dist/modules/integrations/index.cjs.map +1 -1
  98. package/dist/modules/integrations/index.js +1 -1
  99. package/dist/modules/intelwatchtower/index.cjs +14 -14
  100. package/dist/modules/intelwatchtower/index.cjs.map +1 -1
  101. package/dist/modules/intelwatchtower/index.js +1 -1
  102. package/dist/modules/kadaikodi/index.cjs +14 -14
  103. package/dist/modules/kadaikodi/index.cjs.map +1 -1
  104. package/dist/modules/kadaikodi/index.js +1 -1
  105. package/dist/modules/labsofscience/index.cjs +14 -14
  106. package/dist/modules/labsofscience/index.cjs.map +1 -1
  107. package/dist/modules/labsofscience/index.js +1 -1
  108. package/dist/modules/manufacturedops/index.cjs +14 -14
  109. package/dist/modules/manufacturedops/index.cjs.map +1 -1
  110. package/dist/modules/manufacturedops/index.js +1 -1
  111. package/dist/modules/movethewheels/index.cjs +14 -14
  112. package/dist/modules/movethewheels/index.cjs.map +1 -1
  113. package/dist/modules/movethewheels/index.js +1 -1
  114. package/dist/modules/mybodyshield/index.cjs +14 -14
  115. package/dist/modules/mybodyshield/index.cjs.map +1 -1
  116. package/dist/modules/mybodyshield/index.js +1 -1
  117. package/dist/modules/notifications/index.cjs +14 -14
  118. package/dist/modules/notifications/index.cjs.map +1 -1
  119. package/dist/modules/notifications/index.js +1 -1
  120. package/dist/modules/organizations/index.cjs +14 -14
  121. package/dist/modules/organizations/index.cjs.map +1 -1
  122. package/dist/modules/organizations/index.js +1 -1
  123. package/dist/modules/planmagnet/index.cjs +14 -14
  124. package/dist/modules/planmagnet/index.cjs.map +1 -1
  125. package/dist/modules/planmagnet/index.js +1 -1
  126. package/dist/modules/products/index.cjs +14 -14
  127. package/dist/modules/products/index.cjs.map +1 -1
  128. package/dist/modules/products/index.js +1 -1
  129. package/dist/modules/proserviceworld/index.cjs +14 -14
  130. package/dist/modules/proserviceworld/index.cjs.map +1 -1
  131. package/dist/modules/proserviceworld/index.js +1 -1
  132. package/dist/modules/rbac/index.cjs +14 -14
  133. package/dist/modules/rbac/index.cjs.map +1 -1
  134. package/dist/modules/rbac/index.js +1 -1
  135. package/dist/modules/sandbox/index.cjs +14 -14
  136. package/dist/modules/sandbox/index.cjs.map +1 -1
  137. package/dist/modules/sandbox/index.js +1 -1
  138. package/dist/modules/scheduler/index.cjs +14 -14
  139. package/dist/modules/scheduler/index.cjs.map +1 -1
  140. package/dist/modules/scheduler/index.js +1 -1
  141. package/dist/modules/security/index.cjs +14 -14
  142. package/dist/modules/security/index.cjs.map +1 -1
  143. package/dist/modules/security/index.js +1 -1
  144. package/dist/modules/semanticfed/index.cjs +14 -14
  145. package/dist/modules/semanticfed/index.cjs.map +1 -1
  146. package/dist/modules/semanticfed/index.js +1 -1
  147. package/dist/modules/store/index.cjs +14 -14
  148. package/dist/modules/store/index.cjs.map +1 -1
  149. package/dist/modules/store/index.js +1 -1
  150. package/dist/modules/subscriberbot/index.cjs +14 -14
  151. package/dist/modules/subscriberbot/index.cjs.map +1 -1
  152. package/dist/modules/subscriberbot/index.js +1 -1
  153. package/dist/modules/support/index.cjs +14 -14
  154. package/dist/modules/support/index.cjs.map +1 -1
  155. package/dist/modules/support/index.js +1 -1
  156. package/dist/modules/tags/index.cjs +14 -14
  157. package/dist/modules/tags/index.cjs.map +1 -1
  158. package/dist/modules/tags/index.js +1 -1
  159. package/dist/modules/technospam/index.cjs +14 -14
  160. package/dist/modules/technospam/index.cjs.map +1 -1
  161. package/dist/modules/technospam/index.js +1 -1
  162. package/dist/modules/theculturepost/index.cjs +14 -14
  163. package/dist/modules/theculturepost/index.cjs.map +1 -1
  164. package/dist/modules/theculturepost/index.js +1 -1
  165. package/dist/modules/theglobalfuel/index.cjs +14 -14
  166. package/dist/modules/theglobalfuel/index.cjs.map +1 -1
  167. package/dist/modules/theglobalfuel/index.js +1 -1
  168. package/dist/modules/timecampus/index.cjs +21 -16
  169. package/dist/modules/timecampus/index.cjs.map +1 -1
  170. package/dist/modules/timecampus/index.js +8 -3
  171. package/dist/modules/timecampus/index.js.map +1 -1
  172. package/dist/modules/tours/index.cjs +14 -14
  173. package/dist/modules/tours/index.cjs.map +1 -1
  174. package/dist/modules/tours/index.js +1 -1
  175. package/dist/modules/vibecontrols/index.cjs +35 -17
  176. package/dist/modules/vibecontrols/index.cjs.map +1 -1
  177. package/dist/modules/vibecontrols/index.js +23 -5
  178. package/dist/modules/vibecontrols/index.js.map +1 -1
  179. package/dist/modules/workspaces/index.cjs +14 -14
  180. package/dist/modules/workspaces/index.cjs.map +1 -1
  181. package/dist/modules/workspaces/index.js +1 -1
  182. package/dist/{tool-name-DlnrBsZ6.d.ts → tool-name-BaPNMZdj.d.ts} +17 -1
  183. package/dist/{tool-name-CQf_IqAj.d.cts → tool-name-Bvb36qmq.d.cts} +17 -1
  184. package/package.json +1 -1
  185. package/dist/chunk-H2OYWLOA.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { mcpToolName, errorResult, jsonResult, mcpResourceUri, mcpPromptName } from '../../chunk-H2OYWLOA.js';
1
+ import { mcpToolName, errorResult, jsonResult, mcpResourceUri, mcpPromptName } from '../../chunk-YOSQUY3M.js';
2
2
  import { z } from 'zod';
3
3
 
4
4
  // src/modules/mybodyshield/operations.ts
@@ -18,20 +18,6 @@ var McpInternalError = class extends Error {
18
18
  }
19
19
  };
20
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
21
  // src/core/tool-name.ts
36
22
  var MAX_TOOL_NAME_LENGTH = 63;
37
23
  function assertSafeName(name, kind) {
@@ -50,6 +36,20 @@ function mcpToolName(productName, ...parts) {
50
36
  return assertSafeName(name);
51
37
  }
52
38
 
39
+ // src/core/result.ts
40
+ function jsonResult(data, structured) {
41
+ const result = {
42
+ content: [{ type: "text", text: JSON.stringify(data, null, 2) }]
43
+ };
44
+ return result;
45
+ }
46
+ function errorResult(message, hint) {
47
+ const text = hint ? `${message}
48
+
49
+ Hint: ${hint}` : message;
50
+ return { content: [{ type: "text", text }], isError: true };
51
+ }
52
+
53
53
  // src/modules/notifications/operations.ts
54
54
  var LIST_NOTIFICATIONS = `
55
55
  query ListNotifications($filter: NotificationFilterInput, $limit: Int, $offset: Int) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/errors.ts","../../../src/core/result.ts","../../../src/core/tool-name.ts","../../../src/modules/notifications/operations.ts","../../../src/modules/notifications/tools.ts","../../../src/modules/notifications/index.ts"],"names":["z"],"mappings":";;;;;;;;;;;A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SAAA,EAAW,EAAC,EAAG,OAAA,EAAS,EAAC,EAAE;AAAA,EAC7C;AACF,CAAA;AAEA,IAAO,qBAAA,GAAQ","file":"index.cjs","sourcesContent":["/**\n * Error classes for MCP SDK.\n *\n * Modules MUST throw these instead of throwing raw Errors. The registerTool\n * wrapper in result.ts catches and maps them to MCP-protocol-compliant\n * `{ isError: true, content: [...] }` responses.\n *\n * Throwing past the wrapper to the protocol surfaces as JSON-RPC -32603 to\n * the client and is a protocol bug.\n */\n\nexport class McpUserError extends Error {\n public readonly hint: string | undefined;\n\n constructor(message: string, opts?: { hint?: string }) {\n super(message);\n this.name = 'McpUserError';\n this.hint = opts?.hint;\n }\n}\n\nexport class McpAuthError extends McpUserError {\n constructor(message: string, opts?: { hint?: string }) {\n super(message, {\n hint: opts?.hint ?? 'Run the auth_login tool to authenticate.',\n });\n this.name = 'McpAuthError';\n }\n}\n\nexport class McpInternalError extends Error {\n public override readonly cause: unknown;\n\n constructor(message: string, cause?: unknown) {\n super(message);\n this.name = 'McpInternalError';\n this.cause = cause;\n }\n}\n","/**\n * MCP tool result helpers + central handler.\n *\n * Modules NEVER call server.registerTool directly — they use registerTool()\n * from this module so the central try/catch wraps the handler and:\n * - maps thrown McpUserError / McpAuthError / McpInternalError to\n * MCP-protocol-compliant `{ isError: true, content: [...] }` shapes\n * - threads `_meta.progressToken` into ctx.progress for long ops\n * - emits a structured log line on every error\n * - never leaks `cause` from McpInternalError to the client\n *\n * This is the analog of cli-sdk's createProgram() central error handler.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { ZodRawShape } from 'zod';\nimport type { McpContext } from './context.js';\nimport { McpAuthError, McpInternalError, McpUserError } from './errors.js';\n\nexport interface ToolTextContent {\n type: 'text';\n text: string;\n [k: string]: unknown;\n}\n\nexport interface ToolResult {\n content: ToolTextContent[];\n isError?: boolean;\n structuredContent?: Record<string, unknown>;\n [k: string]: unknown;\n}\n\nexport interface ToolMeta {\n progressToken?: string | number;\n}\n\n/**\n * Build a successful tool result with JSON content (pretty-printed).\n */\nexport function jsonResult(data: unknown, structured?: Record<string, unknown>): ToolResult {\n const result: ToolResult = {\n content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],\n };\n if (structured !== undefined) {\n result.structuredContent = structured;\n }\n return result;\n}\n\n/**\n * Build a successful tool result with plain text content.\n */\nexport function textResult(text: string): ToolResult {\n return { content: [{ type: 'text', text }] };\n}\n\n/**\n * Build an error tool result. Honors MCP's `{ isError: true, content }` shape.\n * Optional hint is appended on a new line so the LLM can react.\n */\nexport function errorResult(message: string, hint?: string): ToolResult {\n const text = hint ? `${message}\\n\\nHint: ${hint}` : message;\n return { content: [{ type: 'text', text }], isError: true };\n}\n\nexport interface ToolMetadata {\n title: string;\n description: string;\n inputSchema?: ZodRawShape;\n}\n\nexport type ToolHandler<TArgs = Record<string, unknown>> = (\n args: TArgs,\n ctx: McpContext,\n meta: ToolMeta,\n) => Promise<unknown>;\n\n/**\n * Register a tool with the central error wrapper.\n *\n * The handler returns a plain value or void. The wrapper:\n * - wraps non-undefined returns in jsonResult()\n * - if the value already looks like a ToolResult (has `content`), passes through\n * - catches McpAuthError / McpUserError / McpInternalError / generic Error\n * - logs every error via ctx.logger.error\n */\nexport function registerTool<TArgs extends Record<string, unknown>>(\n server: McpServer,\n ctx: McpContext,\n name: string,\n metadata: ToolMetadata,\n handler: ToolHandler<TArgs>,\n): void {\n const sdkConfig = {\n title: metadata.title,\n description: metadata.description,\n ...(metadata.inputSchema ? { inputSchema: metadata.inputSchema } : {}),\n };\n\n // The MCP SDK's registerTool signature is `(name, config, handler)`. The\n // handler arity depends on whether inputSchema is present (1-arg without,\n // 2-arg with). We accept a unified handler shape and dispatch at runtime.\n // The SDK's typing is strict and conditional on the inputSchema generic;\n // bypass with a cast since runtime acceptance is unconditional.\n const wrapped = async (...callbackArgs: unknown[]): Promise<ToolResult> => {\n const hasArgs = callbackArgs.length === 2;\n const args = (hasArgs ? callbackArgs[0] : {}) as TArgs;\n const extra = (hasArgs ? callbackArgs[1] : callbackArgs[0]) as\n | { _meta?: { progressToken?: string | number } }\n | undefined;\n\n const progressToken = extra?._meta?.progressToken;\n const meta: ToolMeta = progressToken !== undefined ? { progressToken } : {};\n\n try {\n const result = await handler(args, ctx, meta);\n if (isToolResult(result)) return result;\n if (result === undefined) return textResult('OK');\n return jsonResult(result);\n } catch (error) {\n return mapErrorToResult(error, ctx, name);\n }\n };\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (server as any).registerTool(name, sdkConfig, wrapped);\n}\n\nfunction isToolResult(value: unknown): value is ToolResult {\n return (\n !!value &&\n typeof value === 'object' &&\n 'content' in value &&\n Array.isArray((value as ToolResult).content)\n );\n}\n\nfunction mapErrorToResult(error: unknown, ctx: McpContext, toolName: string): ToolResult {\n if (error instanceof McpAuthError) {\n ctx.logger.warn(`${toolName}: auth required`, { message: error.message });\n return errorResult(error.message, error.hint);\n }\n if (error instanceof McpUserError) {\n ctx.logger.info(`${toolName}: user error`, { message: error.message });\n return errorResult(error.message, error.hint);\n }\n if (error instanceof McpInternalError) {\n ctx.logger.error(`${toolName}: internal error`, {\n message: error.message,\n cause: stringifyCause(error.cause),\n });\n return errorResult(`Internal error in ${toolName}.`);\n }\n const message = error instanceof Error ? error.message : String(error);\n ctx.logger.error(`${toolName}: unhandled error`, { message });\n return errorResult(`${toolName}: ${message}`);\n}\n\nfunction stringifyCause(cause: unknown): string | undefined {\n if (cause === undefined || cause === null) return undefined;\n if (cause instanceof Error) return cause.message;\n try {\n return JSON.stringify(cause);\n } catch {\n return String(cause);\n }\n}\n","/**\n * Tool / resource / prompt naming helpers.\n *\n * Mandatory product prefix avoids collisions when Claude Desktop runs\n * multiple MCP servers concurrently (typical setup is ~6).\n *\n * Tool names are capped at 63 characters — Claude Desktop pre-1.x\n * truncated at 64 in some versions.\n */\n\nimport { McpInternalError } from './errors.js';\n\nconst MAX_TOOL_NAME_LENGTH = 63;\n\nfunction assertSafeName(name: string, kind: 'tool' | 'resource' | 'prompt'): string {\n if (kind === 'tool' && name.length > MAX_TOOL_NAME_LENGTH) {\n throw new McpInternalError(\n `Tool name '${name}' exceeds ${MAX_TOOL_NAME_LENGTH} characters (some MCP clients truncate at 64).`,\n );\n }\n return name;\n}\n\n/**\n * Build a tool name. Format: `<productName>_<...parts>` (snake_case).\n * Example: mcpToolName('vibecontrols', 'vibes', 'list') -> 'vibecontrols_vibes_list'\n */\nexport function mcpToolName(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpToolName: productName is required');\n }\n const name = [productName, ...parts].filter(Boolean).join('_');\n return assertSafeName(name, 'tool');\n}\n\n/**\n * Build a resource URI. Format: `<productName>://<...parts>`.\n * Example: mcpResourceUri('vibecontrols', 'schema') -> 'vibecontrols://schema'\n */\nexport function mcpResourceUri(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpResourceUri: productName is required');\n }\n return `${productName}://${parts.filter(Boolean).join('/')}`;\n}\n\n/**\n * Build a prompt name. Format: `<productName>-<...parts>` (kebab-case).\n * Example: mcpPromptName('vibecontrols', 'setup') -> 'vibecontrols-setup'\n */\nexport function mcpPromptName(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpPromptName: productName is required');\n }\n return [productName, ...parts].filter(Boolean).join('-');\n}\n\nexport const TOOL_NAME_LIMIT = MAX_TOOL_NAME_LENGTH;\n","export const LIST_NOTIFICATIONS = `\n query ListNotifications($filter: NotificationFilterInput, $limit: Int, $offset: Int) {\n notifications(filter: $filter, limit: $limit, offset: $offset) {\n items { id title message channel status isRead createdAt }\n total\n }\n }\n`;\n\nexport const MARK_NOTIFICATION_READ = `\n mutation MarkNotificationRead($id: ID!) {\n markNotificationAsRead(id: $id) {\n id isRead readAt\n }\n }\n`;\n\nexport const NOTIFICATION_PREFERENCES = `\n query NotificationPreferences($filter: NotificationPreferenceFilterInput, $limit: Int) {\n notificationPreferences(filter: $filter, limit: $limit) {\n items { id channel enabled frequency scope topicId userId }\n }\n }\n`;\n\nexport const CREATE_NOTIFICATION_PREFERENCE = `\n mutation CreateNotificationPreference($input: CreateNotificationPreferenceInput!) {\n createNotificationPreference(input: $input) {\n id channel enabled frequency\n }\n }\n`;\n","/**\n * Notifications MCP tools — notification inbox & preferences.\n * Surface mirrors cli-sdk/src/modules/notifications/commands.ts.\n */\n\nimport { z } from 'zod';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { jsonResult, errorResult, mcpToolName, type McpContext } from '../../core/index.js';\nimport * as ops from './operations.js';\n\ninterface NotificationRow {\n id: string;\n title?: string;\n message?: string;\n channel?: string;\n status?: string;\n isRead?: boolean;\n createdAt?: string;\n}\n\ninterface PreferenceRow {\n id: string;\n channel: string;\n enabled: boolean;\n frequency?: string;\n scope?: string;\n topicId?: string;\n userId?: string;\n}\n\nexport function registerNotificationsTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n server.registerTool(\n track(mcpToolName(ctx.productName, 'notifications_list')),\n {\n title: 'List Notifications',\n description: \"List the current user's notifications with optional filters.\",\n inputSchema: {\n unread: z.boolean().optional().describe('Only unread notifications'),\n channel: z.string().optional().describe('Filter by channel (will be uppercased)'),\n limit: z.number().optional().describe('Page size (default 50)'),\n },\n },\n async ({ unread, channel, limit }) => {\n try {\n const filter: Record<string, unknown> = {};\n if (unread === true) filter.isRead = false;\n if (channel !== undefined) filter.channel = channel.toUpperCase();\n const data = await ctx.gql.global.request<{\n notifications: { items: NotificationRow[]; total: number };\n }>(ops.LIST_NOTIFICATIONS, {\n filter: Object.keys(filter).length ? filter : undefined,\n limit: limit ?? 50,\n offset: 0,\n });\n return jsonResult(data.notifications);\n } catch (error) {\n ctx.logger.error('notifications_list failed', { error: String(error) });\n return errorResult(\n `Failed to list notifications: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'notifications_read')),\n {\n title: 'Mark Notification Read',\n description: 'Mark a notification as read.',\n inputSchema: { id: z.string().describe('Notification ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.global.request<{\n markNotificationAsRead: { id: string; isRead: boolean; readAt?: string };\n }>(ops.MARK_NOTIFICATION_READ, { id });\n return jsonResult(data.markNotificationAsRead);\n } catch (error) {\n ctx.logger.error('notifications_read failed', { error: String(error) });\n return errorResult(\n `Failed to mark notification read: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'notifications_preferences_get')),\n {\n title: 'Get Notification Preferences',\n description: \"Show the current user's notification preferences.\",\n inputSchema: {\n user: z.string().optional().describe('Override user ID'),\n limit: z.number().optional().describe('Page size (default 100)'),\n },\n },\n async ({ user, limit }) => {\n try {\n const auth = ctx.auth.read();\n const userId = user ?? auth?.workspaceId ?? '';\n const filter: Record<string, unknown> = userId ? { userId } : {};\n const data = await ctx.gql.global.request<{\n notificationPreferences: { items: PreferenceRow[] };\n }>(ops.NOTIFICATION_PREFERENCES, {\n filter: Object.keys(filter).length ? filter : undefined,\n limit: limit ?? 100,\n });\n return jsonResult(data.notificationPreferences);\n } catch (error) {\n ctx.logger.error('notifications_preferences_get failed', { error: String(error) });\n return errorResult(\n `Failed to get notification preferences: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'notifications_preferences_set')),\n {\n title: 'Set Notification Preference',\n description: 'Create/update a notification preference.',\n inputSchema: {\n channel: z.string().describe('EMAIL|SMS|IN_APP|PUSH|WEBHOOK (will be uppercased)'),\n enabled: z.boolean().describe('Whether the channel is enabled'),\n frequency: z\n .string()\n .optional()\n .describe('IMMEDIATE|HOURLY|DAILY|WEEKLY (default IMMEDIATE)'),\n scope: z.string().optional().describe('GLOBAL|WORKSPACE|VIBE (default GLOBAL)'),\n topic: z.string().optional().describe('Topic ID'),\n user: z.string().optional().describe('Override user ID'),\n },\n },\n async ({ channel, enabled, frequency, scope, topic, user }) => {\n try {\n const auth = ctx.auth.read();\n const input: Record<string, unknown> = {\n channel: channel.toUpperCase(),\n enabled,\n frequency: (frequency ?? 'IMMEDIATE').toUpperCase(),\n scope: (scope ?? 'GLOBAL').toUpperCase(),\n };\n if (topic !== undefined) input.topicId = topic;\n const userId = user ?? auth?.workspaceId;\n if (userId !== undefined) input.userId = userId;\n const data = await ctx.gql.global.request<{\n createNotificationPreference: PreferenceRow;\n }>(ops.CREATE_NOTIFICATION_PREFERENCE, { input });\n return jsonResult(data.createNotificationPreference);\n } catch (error) {\n ctx.logger.error('notifications_preferences_set failed', { error: String(error) });\n return errorResult(\n `Failed to set notification preference: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n}\n","/**\n * Notifications module — notification inbox + preferences (global gateway).\n * Surface mirrors cli-sdk/src/modules/notifications/.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { McpContext, McpModule, ModuleRegistration } from '../../core/index.js';\nimport { registerNotificationsTools } from './tools.js';\n\nconst notificationsModule: McpModule = {\n id: 'notifications',\n version: '0.0.1',\n displayName: 'Notifications',\n dependsOn: ['auth'],\n capabilities: { tools: {} },\n\n register(server: McpServer, ctx: McpContext): ModuleRegistration {\n const tools: string[] = [];\n const track = (n: string): string => {\n tools.push(n);\n return n;\n };\n\n registerNotificationsTools(server, ctx, track);\n\n return { tools, resources: [], prompts: [] };\n },\n};\n\nexport default notificationsModule;\n"]}
1
+ {"version":3,"sources":["../../../src/core/errors.ts","../../../src/core/tool-name.ts","../../../src/core/result.ts","../../../src/modules/notifications/operations.ts","../../../src/modules/notifications/tools.ts","../../../src/modules/notifications/index.ts"],"names":["z"],"mappings":";;;;;;;;;;;AA8BO,IAAM,gBAAA,GAAN,cAA+B,KAAA,CAAM;AAAA,EACjB,KAAA;AAAA,EAEzB,WAAA,CAAY,SAAiB,KAAA,EAAiB;AAC5C,IAAA,KAAA,CAAM,OAAO,CAAA;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CP 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 * 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\n/**\n * Name-based hint heuristics for MCP `annotations` (readOnlyHint /\n * destructiveHint). Used by tool-governance.ts to auto-fill annotations for\n * the fleet of product modules that call `server.registerTool` directly\n * (bypassing the `registerTool()` core helper) and so never set them\n * explicitly today (BOFF-3903). Deliberately conservative — matched against\n * whole `_`-delimited segments so e.g. `timeentries_delete` and\n * `pomodoro_delete_goal` match, but a hypothetical `undeletable_check`\n * would not.\n *\n * A module can always override the inference by passing an explicit\n * `annotations` object to `registerTool()` / `server.registerTool()`.\n */\nconst DESTRUCTIVE_NAME_SEGMENT = /(?:^|_)delete(?:_|$)/i;\nconst READ_ONLY_NAME_SEGMENT = /(?:^|_)(?:list|get|search|check|read|count|stats|by_date)(?:_|$)/i;\n\n/** True when a tool name looks destructive (irreversibly deletes data) by naming convention. */\nexport function inferDestructiveHint(toolName: string): boolean {\n return DESTRUCTIVE_NAME_SEGMENT.test(toolName);\n}\n\n/**\n * True when a tool name looks read-only by naming convention. Never true for\n * a name that also looks destructive (a tool can't be both).\n */\nexport function inferReadOnlyHint(toolName: string): boolean {\n return !inferDestructiveHint(toolName) && READ_ONLY_NAME_SEGMENT.test(toolName);\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';\nimport type { ToolAnnotations } from './tool-governance.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 * Explicit MCP annotations (readOnlyHint / destructiveHint / ...). Optional\n * — when omitted, `wrapServerWithToolGovernance` (applied centrally in\n * `createMcpServer`) infers them from the tool name. Set this to override\n * the inference for a tool whose name doesn't match the naming convention.\n */\n annotations?: ToolAnnotations;\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 ...(metadata.annotations ? { annotations: metadata.annotations } : {}),\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","export const LIST_NOTIFICATIONS = `\n query ListNotifications($filter: NotificationFilterInput, $limit: Int, $offset: Int) {\n notifications(filter: $filter, limit: $limit, offset: $offset) {\n items { id title message channel status isRead createdAt }\n total\n }\n }\n`;\n\nexport const MARK_NOTIFICATION_READ = `\n mutation MarkNotificationRead($id: ID!) {\n markNotificationAsRead(id: $id) {\n id isRead readAt\n }\n }\n`;\n\nexport const NOTIFICATION_PREFERENCES = `\n query NotificationPreferences($filter: NotificationPreferenceFilterInput, $limit: Int) {\n notificationPreferences(filter: $filter, limit: $limit) {\n items { id channel enabled frequency scope topicId userId }\n }\n }\n`;\n\nexport const CREATE_NOTIFICATION_PREFERENCE = `\n mutation CreateNotificationPreference($input: CreateNotificationPreferenceInput!) {\n createNotificationPreference(input: $input) {\n id channel enabled frequency\n }\n }\n`;\n","/**\n * Notifications MCP tools — notification inbox & preferences.\n * Surface mirrors cli-sdk/src/modules/notifications/commands.ts.\n */\n\nimport { z } from 'zod';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { jsonResult, errorResult, mcpToolName, type McpContext } from '../../core/index.js';\nimport * as ops from './operations.js';\n\ninterface NotificationRow {\n id: string;\n title?: string;\n message?: string;\n channel?: string;\n status?: string;\n isRead?: boolean;\n createdAt?: string;\n}\n\ninterface PreferenceRow {\n id: string;\n channel: string;\n enabled: boolean;\n frequency?: string;\n scope?: string;\n topicId?: string;\n userId?: string;\n}\n\nexport function registerNotificationsTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n server.registerTool(\n track(mcpToolName(ctx.productName, 'notifications_list')),\n {\n title: 'List Notifications',\n description: \"List the current user's notifications with optional filters.\",\n inputSchema: {\n unread: z.boolean().optional().describe('Only unread notifications'),\n channel: z.string().optional().describe('Filter by channel (will be uppercased)'),\n limit: z.number().optional().describe('Page size (default 50)'),\n },\n },\n async ({ unread, channel, limit }) => {\n try {\n const filter: Record<string, unknown> = {};\n if (unread === true) filter.isRead = false;\n if (channel !== undefined) filter.channel = channel.toUpperCase();\n const data = await ctx.gql.global.request<{\n notifications: { items: NotificationRow[]; total: number };\n }>(ops.LIST_NOTIFICATIONS, {\n filter: Object.keys(filter).length ? filter : undefined,\n limit: limit ?? 50,\n offset: 0,\n });\n return jsonResult(data.notifications);\n } catch (error) {\n ctx.logger.error('notifications_list failed', { error: String(error) });\n return errorResult(\n `Failed to list notifications: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'notifications_read')),\n {\n title: 'Mark Notification Read',\n description: 'Mark a notification as read.',\n inputSchema: { id: z.string().describe('Notification ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.global.request<{\n markNotificationAsRead: { id: string; isRead: boolean; readAt?: string };\n }>(ops.MARK_NOTIFICATION_READ, { id });\n return jsonResult(data.markNotificationAsRead);\n } catch (error) {\n ctx.logger.error('notifications_read failed', { error: String(error) });\n return errorResult(\n `Failed to mark notification read: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'notifications_preferences_get')),\n {\n title: 'Get Notification Preferences',\n description: \"Show the current user's notification preferences.\",\n inputSchema: {\n user: z.string().optional().describe('Override user ID'),\n limit: z.number().optional().describe('Page size (default 100)'),\n },\n },\n async ({ user, limit }) => {\n try {\n const auth = ctx.auth.read();\n const userId = user ?? auth?.workspaceId ?? '';\n const filter: Record<string, unknown> = userId ? { userId } : {};\n const data = await ctx.gql.global.request<{\n notificationPreferences: { items: PreferenceRow[] };\n }>(ops.NOTIFICATION_PREFERENCES, {\n filter: Object.keys(filter).length ? filter : undefined,\n limit: limit ?? 100,\n });\n return jsonResult(data.notificationPreferences);\n } catch (error) {\n ctx.logger.error('notifications_preferences_get failed', { error: String(error) });\n return errorResult(\n `Failed to get notification preferences: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'notifications_preferences_set')),\n {\n title: 'Set Notification Preference',\n description: 'Create/update a notification preference.',\n inputSchema: {\n channel: z.string().describe('EMAIL|SMS|IN_APP|PUSH|WEBHOOK (will be uppercased)'),\n enabled: z.boolean().describe('Whether the channel is enabled'),\n frequency: z\n .string()\n .optional()\n .describe('IMMEDIATE|HOURLY|DAILY|WEEKLY (default IMMEDIATE)'),\n scope: z.string().optional().describe('GLOBAL|WORKSPACE|VIBE (default GLOBAL)'),\n topic: z.string().optional().describe('Topic ID'),\n user: z.string().optional().describe('Override user ID'),\n },\n },\n async ({ channel, enabled, frequency, scope, topic, user }) => {\n try {\n const auth = ctx.auth.read();\n const input: Record<string, unknown> = {\n channel: channel.toUpperCase(),\n enabled,\n frequency: (frequency ?? 'IMMEDIATE').toUpperCase(),\n scope: (scope ?? 'GLOBAL').toUpperCase(),\n };\n if (topic !== undefined) input.topicId = topic;\n const userId = user ?? auth?.workspaceId;\n if (userId !== undefined) input.userId = userId;\n const data = await ctx.gql.global.request<{\n createNotificationPreference: PreferenceRow;\n }>(ops.CREATE_NOTIFICATION_PREFERENCE, { input });\n return jsonResult(data.createNotificationPreference);\n } catch (error) {\n ctx.logger.error('notifications_preferences_set failed', { error: String(error) });\n return errorResult(\n `Failed to set notification preference: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n}\n","/**\n * Notifications module — notification inbox + preferences (global gateway).\n * Surface mirrors cli-sdk/src/modules/notifications/.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { McpContext, McpModule, ModuleRegistration } from '../../core/index.js';\nimport { registerNotificationsTools } from './tools.js';\n\nconst notificationsModule: McpModule = {\n id: 'notifications',\n version: '0.0.1',\n displayName: 'Notifications',\n dependsOn: ['auth'],\n capabilities: { tools: {} },\n\n register(server: McpServer, ctx: McpContext): ModuleRegistration {\n const tools: string[] = [];\n const track = (n: string): string => {\n tools.push(n);\n return n;\n };\n\n registerNotificationsTools(server, ctx, track);\n\n return { tools, resources: [], prompts: [] };\n },\n};\n\nexport default notificationsModule;\n"]}
@@ -1,4 +1,4 @@
1
- import { mcpToolName, jsonResult, errorResult } from '../../chunk-H2OYWLOA.js';
1
+ import { mcpToolName, jsonResult, errorResult } from '../../chunk-YOSQUY3M.js';
2
2
  import { z } from 'zod';
3
3
 
4
4
  // src/modules/notifications/operations.ts
@@ -18,20 +18,6 @@ var McpInternalError = class extends Error {
18
18
  }
19
19
  };
20
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
21
  // src/core/tool-name.ts
36
22
  var MAX_TOOL_NAME_LENGTH = 63;
37
23
  function assertSafeName(name, kind) {
@@ -50,6 +36,20 @@ function mcpToolName(productName, ...parts) {
50
36
  return assertSafeName(name);
51
37
  }
52
38
 
39
+ // src/core/result.ts
40
+ function jsonResult(data, structured) {
41
+ const result = {
42
+ content: [{ type: "text", text: JSON.stringify(data, null, 2) }]
43
+ };
44
+ return result;
45
+ }
46
+ function errorResult(message, hint) {
47
+ const text = hint ? `${message}
48
+
49
+ Hint: ${hint}` : message;
50
+ return { content: [{ type: "text", text }], isError: true };
51
+ }
52
+
53
53
  // src/modules/organizations/operations.ts
54
54
  var MY_ORGANIZATIONS = `
55
55
  query MyOrganizations($limit: Int, $offset: Int) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/errors.ts","../../../src/core/result.ts","../../../src/core/tool-name.ts","../../../src/modules/organizations/operations.ts","../../../src/modules/organizations/tools.ts","../../../src/modules/organizations/index.ts"],"names":["z"],"mappings":";;;;;;;;;;;AA8BO,IAAM,gBAAA,GAAN,cAA+B,KAAA,CAAM;AAAA,EACjB,KAAA;AAAA,EAEzB,WAAA,CAAY,SAAiB,KAAA,EAAiB;AAC5C,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,kBAAA;AACZ,IAAA,IAAA,CAAK,KAAA,GAAQ,KAAA;AAAA,EACf;AACF,CAAA;;;ACCO,SAAS,UAAA,CAAW,MAAe,UAAA,EAAkD;AAC1F,EAAA,MAAM,MAAA,GAAqB;AAAA,IACzB,OAAA,EAAS,CAAC,EAAE,IAAA,EAAM,MAAA,EAAQ,IAAA,EAAM,IAAA,CAAK,SAAA,CAAU,IAAA,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,oBAAA,GAAuB,EAAA;AAE7B,SAAS,cAAA,CAAe,MAAc,IAAA,EAA8C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A,GAAQ","file":"index.cjs","sourcesContent":["/**\n * Error classes for MCP SDK.\n *\n * Modules MUST throw these instead of throwing raw Errors. The registerTool\n * wrapper in result.ts catches and maps them to MCP-protocol-compliant\n * `{ isError: true, content: [...] }` responses.\n *\n * Throwing past the wrapper to the protocol surfaces as JSON-RPC -32603 to\n * the client and is a protocol bug.\n */\n\nexport class McpUserError extends Error {\n public readonly hint: string | undefined;\n\n constructor(message: string, opts?: { hint?: string }) {\n super(message);\n this.name = 'McpUserError';\n this.hint = opts?.hint;\n }\n}\n\nexport class McpAuthError extends McpUserError {\n constructor(message: string, opts?: { hint?: string }) {\n super(message, {\n hint: opts?.hint ?? 'Run the auth_login tool to authenticate.',\n });\n this.name = 'McpAuthError';\n }\n}\n\nexport class McpInternalError extends Error {\n public override readonly cause: unknown;\n\n constructor(message: string, cause?: unknown) {\n super(message);\n this.name = 'McpInternalError';\n this.cause = cause;\n }\n}\n","/**\n * MCP tool result helpers + central handler.\n *\n * Modules NEVER call server.registerTool directly — they use registerTool()\n * from this module so the central try/catch wraps the handler and:\n * - maps thrown McpUserError / McpAuthError / McpInternalError to\n * MCP-protocol-compliant `{ isError: true, content: [...] }` shapes\n * - threads `_meta.progressToken` into ctx.progress for long ops\n * - emits a structured log line on every error\n * - never leaks `cause` from McpInternalError to the client\n *\n * This is the analog of cli-sdk's createProgram() central error handler.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { ZodRawShape } from 'zod';\nimport type { McpContext } from './context.js';\nimport { McpAuthError, McpInternalError, McpUserError } from './errors.js';\n\nexport interface ToolTextContent {\n type: 'text';\n text: string;\n [k: string]: unknown;\n}\n\nexport interface ToolResult {\n content: ToolTextContent[];\n isError?: boolean;\n structuredContent?: Record<string, unknown>;\n [k: string]: unknown;\n}\n\nexport interface ToolMeta {\n progressToken?: string | number;\n}\n\n/**\n * Build a successful tool result with JSON content (pretty-printed).\n */\nexport function jsonResult(data: unknown, structured?: Record<string, unknown>): ToolResult {\n const result: ToolResult = {\n content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],\n };\n if (structured !== undefined) {\n result.structuredContent = structured;\n }\n return result;\n}\n\n/**\n * Build a successful tool result with plain text content.\n */\nexport function textResult(text: string): ToolResult {\n return { content: [{ type: 'text', text }] };\n}\n\n/**\n * Build an error tool result. Honors MCP's `{ isError: true, content }` shape.\n * Optional hint is appended on a new line so the LLM can react.\n */\nexport function errorResult(message: string, hint?: string): ToolResult {\n const text = hint ? `${message}\\n\\nHint: ${hint}` : message;\n return { content: [{ type: 'text', text }], isError: true };\n}\n\nexport interface ToolMetadata {\n title: string;\n description: string;\n inputSchema?: ZodRawShape;\n}\n\nexport type ToolHandler<TArgs = Record<string, unknown>> = (\n args: TArgs,\n ctx: McpContext,\n meta: ToolMeta,\n) => Promise<unknown>;\n\n/**\n * Register a tool with the central error wrapper.\n *\n * The handler returns a plain value or void. The wrapper:\n * - wraps non-undefined returns in jsonResult()\n * - if the value already looks like a ToolResult (has `content`), passes through\n * - catches McpAuthError / McpUserError / McpInternalError / generic Error\n * - logs every error via ctx.logger.error\n */\nexport function registerTool<TArgs extends Record<string, unknown>>(\n server: McpServer,\n ctx: McpContext,\n name: string,\n metadata: ToolMetadata,\n handler: ToolHandler<TArgs>,\n): void {\n const sdkConfig = {\n title: metadata.title,\n description: metadata.description,\n ...(metadata.inputSchema ? { inputSchema: metadata.inputSchema } : {}),\n };\n\n // The MCP SDK's registerTool signature is `(name, config, handler)`. The\n // handler arity depends on whether inputSchema is present (1-arg without,\n // 2-arg with). We accept a unified handler shape and dispatch at runtime.\n // The SDK's typing is strict and conditional on the inputSchema generic;\n // bypass with a cast since runtime acceptance is unconditional.\n const wrapped = async (...callbackArgs: unknown[]): Promise<ToolResult> => {\n const hasArgs = callbackArgs.length === 2;\n const args = (hasArgs ? callbackArgs[0] : {}) as TArgs;\n const extra = (hasArgs ? callbackArgs[1] : callbackArgs[0]) as\n | { _meta?: { progressToken?: string | number } }\n | undefined;\n\n const progressToken = extra?._meta?.progressToken;\n const meta: ToolMeta = progressToken !== undefined ? { progressToken } : {};\n\n try {\n const result = await handler(args, ctx, meta);\n if (isToolResult(result)) return result;\n if (result === undefined) return textResult('OK');\n return jsonResult(result);\n } catch (error) {\n return mapErrorToResult(error, ctx, name);\n }\n };\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (server as any).registerTool(name, sdkConfig, wrapped);\n}\n\nfunction isToolResult(value: unknown): value is ToolResult {\n return (\n !!value &&\n typeof value === 'object' &&\n 'content' in value &&\n Array.isArray((value as ToolResult).content)\n );\n}\n\nfunction mapErrorToResult(error: unknown, ctx: McpContext, toolName: string): ToolResult {\n if (error instanceof McpAuthError) {\n ctx.logger.warn(`${toolName}: auth required`, { message: error.message });\n return errorResult(error.message, error.hint);\n }\n if (error instanceof McpUserError) {\n ctx.logger.info(`${toolName}: user error`, { message: error.message });\n return errorResult(error.message, error.hint);\n }\n if (error instanceof McpInternalError) {\n ctx.logger.error(`${toolName}: internal error`, {\n message: error.message,\n cause: stringifyCause(error.cause),\n });\n return errorResult(`Internal error in ${toolName}.`);\n }\n const message = error instanceof Error ? error.message : String(error);\n ctx.logger.error(`${toolName}: unhandled error`, { message });\n return errorResult(`${toolName}: ${message}`);\n}\n\nfunction stringifyCause(cause: unknown): string | undefined {\n if (cause === undefined || cause === null) return undefined;\n if (cause instanceof Error) return cause.message;\n try {\n return JSON.stringify(cause);\n } catch {\n return String(cause);\n }\n}\n","/**\n * Tool / resource / prompt naming helpers.\n *\n * Mandatory product prefix avoids collisions when Claude Desktop runs\n * multiple MCP servers concurrently (typical setup is ~6).\n *\n * Tool names are capped at 63 characters — Claude Desktop pre-1.x\n * truncated at 64 in some versions.\n */\n\nimport { McpInternalError } from './errors.js';\n\nconst MAX_TOOL_NAME_LENGTH = 63;\n\nfunction assertSafeName(name: string, kind: 'tool' | 'resource' | 'prompt'): string {\n if (kind === 'tool' && name.length > MAX_TOOL_NAME_LENGTH) {\n throw new McpInternalError(\n `Tool name '${name}' exceeds ${MAX_TOOL_NAME_LENGTH} characters (some MCP clients truncate at 64).`,\n );\n }\n return name;\n}\n\n/**\n * Build a tool name. Format: `<productName>_<...parts>` (snake_case).\n * Example: mcpToolName('vibecontrols', 'vibes', 'list') -> 'vibecontrols_vibes_list'\n */\nexport function mcpToolName(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpToolName: productName is required');\n }\n const name = [productName, ...parts].filter(Boolean).join('_');\n return assertSafeName(name, 'tool');\n}\n\n/**\n * Build a resource URI. Format: `<productName>://<...parts>`.\n * Example: mcpResourceUri('vibecontrols', 'schema') -> 'vibecontrols://schema'\n */\nexport function mcpResourceUri(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpResourceUri: productName is required');\n }\n return `${productName}://${parts.filter(Boolean).join('/')}`;\n}\n\n/**\n * Build a prompt name. Format: `<productName>-<...parts>` (kebab-case).\n * Example: mcpPromptName('vibecontrols', 'setup') -> 'vibecontrols-setup'\n */\nexport function mcpPromptName(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpPromptName: productName is required');\n }\n return [productName, ...parts].filter(Boolean).join('-');\n}\n\nexport const TOOL_NAME_LIMIT = MAX_TOOL_NAME_LENGTH;\n","export const MY_ORGANIZATIONS = `\n query MyOrganizations($limit: Int, $offset: Int) {\n myOrganizations(limit: $limit, offset: $offset) {\n items {\n id\n name\n slug\n tenantId\n description\n status\n createdAt\n updatedAt\n }\n total\n hasMore\n }\n }\n`;\n\nexport const MY_ORGANIZATION_INVITES = `\n query MyOrganizationInvites($status: InviteStatus, $limit: Int, $offset: Int) {\n myOrganizationInvites(status: $status, limit: $limit, offset: $offset) {\n items {\n id\n organizationId\n email\n role\n status\n expiresAt\n message\n createdAt\n }\n total\n hasMore\n }\n }\n`;\n\nexport const ACCEPT_ORG_INVITE = `\n mutation AcceptOrganizationInvite($inviteId: ID!) {\n acceptOrganizationInvite(inviteId: $inviteId) {\n id\n userId\n organizationId\n role\n joinedAt\n }\n }\n`;\n\nexport const REJECT_ORG_INVITE = `\n mutation RejectOrganizationInvite($inviteId: ID!) {\n rejectOrganizationInvite(inviteId: $inviteId) {\n id\n status\n respondedAt\n }\n }\n`;\n\nexport const GET_ORG = `\n query Organization($id: ID!) {\n organization(id: $id) {\n id\n tenantId\n name\n slug\n description\n status\n memberCount\n workspaceCount\n createdAt\n updatedAt\n }\n }\n`;\n\nexport const LIST_ORG_MEMBERS = `\n query OrganizationMembers($organizationId: String!, $limit: Int, $offset: Int) {\n organizationMembers(organizationId: $organizationId, limit: $limit, offset: $offset) {\n items {\n id\n organizationId\n userId\n role\n joinedAt\n invitedBy\n }\n total\n hasMore\n limit\n offset\n }\n }\n`;\n\nexport const INVITE_ORG_MEMBER = `\n mutation InviteOrganizationMember($input: InviteOrganizationMemberInput!) {\n inviteOrganizationMember(input: $input) {\n id\n organizationId\n email\n role\n status\n invitedBy\n expiresAt\n createdAt\n }\n }\n`;\n\nexport const REMOVE_ORG_MEMBER = `\n mutation RemoveOrganizationMember($organizationId: String!, $userId: String!) {\n removeOrganizationMember(organizationId: $organizationId, userId: $userId)\n }\n`;\n\nexport const UPDATE_ORG_MEMBER_ROLE = `\n mutation UpdateOrganizationMember(\n $organizationId: String!\n $userId: String!\n $input: UpdateOrganizationMemberInput!\n ) {\n updateOrganizationMember(\n organizationId: $organizationId\n userId: $userId\n input: $input\n ) {\n id\n organizationId\n userId\n role\n joinedAt\n invitedBy\n }\n }\n`;\n","import { z } from 'zod';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { jsonResult, errorResult, mcpToolName, type McpContext } from '../../core/index.js';\nimport {\n MY_ORGANIZATIONS,\n MY_ORGANIZATION_INVITES,\n ACCEPT_ORG_INVITE,\n REJECT_ORG_INVITE,\n GET_ORG,\n LIST_ORG_MEMBERS,\n INVITE_ORG_MEMBER,\n REMOVE_ORG_MEMBER,\n UPDATE_ORG_MEMBER_ROLE,\n} from './operations.js';\n\nconst InviteStatusEnum = z.enum(['PENDING', 'ACCEPTED', 'REJECTED', 'EXPIRED', 'REVOKED']);\n\nconst UserRoleEnum = z\n .enum(['GUEST', 'MEMBER', 'ORG_ADMIN', 'SUPER_ADMIN', 'TENANT_ADMIN', 'WORKSPACE_ADMIN'])\n .describe('Role within the organization (MEMBER is the safest default for invites)');\n\nexport function registerOrganizationsTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n server.registerTool(\n track(mcpToolName(ctx.productName, 'organizations_list')),\n {\n title: 'List Organizations',\n description: 'List organizations the current user is a member of.',\n inputSchema: {\n limit: z.number().optional().describe('Page size'),\n offset: z.number().optional().describe('Offset for pagination'),\n },\n },\n async ({ limit, offset }) => {\n try {\n const data = await ctx.gql.global.request<{ myOrganizations: unknown }>(MY_ORGANIZATIONS, {\n limit: limit ?? 50,\n offset: offset ?? 0,\n });\n return jsonResult(data.myOrganizations);\n } catch (error) {\n ctx.logger.error('organizations_list failed', { error: String(error) });\n return errorResult(\n `Failed to list organizations: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'organizations_current')),\n {\n title: 'Current Organization',\n description: 'Return the current organization context from the auth store.',\n inputSchema: {},\n },\n async () => {\n try {\n const auth = ctx.auth.read();\n if (!auth?.organizationId) {\n return errorResult(\n 'No active organization context. Run the auth login flow to bind a tenant.',\n );\n }\n return jsonResult({\n organizationId: auth.organizationId,\n workspaceId: auth.workspaceId ?? null,\n });\n } catch (error) {\n ctx.logger.error('organizations_current failed', { error: String(error) });\n return errorResult(\n `Failed to read current organization: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'organizations_invites_list')),\n {\n title: 'List Organization Invites',\n description: 'List organization invites for the current user.',\n inputSchema: {\n status: InviteStatusEnum.optional().describe('Filter by invite status (default: PENDING)'),\n limit: z.number().optional().describe('Page size'),\n offset: z.number().optional().describe('Offset for pagination'),\n },\n },\n async ({ status, limit, offset }) => {\n try {\n const data = await ctx.gql.global.request<{ myOrganizationInvites: unknown }>(\n MY_ORGANIZATION_INVITES,\n {\n status: status ?? 'PENDING',\n limit: limit ?? 50,\n offset: offset ?? 0,\n },\n );\n return jsonResult(data.myOrganizationInvites);\n } catch (error) {\n ctx.logger.error('organizations_invites_list failed', { error: String(error) });\n return errorResult(\n `Failed to list organization invites: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'organizations_invites_accept')),\n {\n title: 'Accept Organization Invite',\n description: 'Accept a pending organization invite.',\n inputSchema: {\n invitationId: z.string().describe('Invite ID'),\n },\n },\n async ({ invitationId }) => {\n try {\n const data = await ctx.gql.global.request<{ acceptOrganizationInvite: unknown }>(\n ACCEPT_ORG_INVITE,\n { inviteId: invitationId },\n );\n return jsonResult(data.acceptOrganizationInvite);\n } catch (error) {\n ctx.logger.error('organizations_invites_accept failed', { error: String(error) });\n return errorResult(\n `Failed to accept invite: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'organizations_invites_decline')),\n {\n title: 'Decline Organization Invite',\n description: 'Decline a pending organization invite.',\n inputSchema: {\n invitationId: z.string().describe('Invite ID'),\n },\n },\n async ({ invitationId }) => {\n try {\n const data = await ctx.gql.global.request<{ rejectOrganizationInvite: unknown }>(\n REJECT_ORG_INVITE,\n { inviteId: invitationId },\n );\n return jsonResult(data.rejectOrganizationInvite);\n } catch (error) {\n ctx.logger.error('organizations_invites_decline failed', { error: String(error) });\n return errorResult(\n `Failed to decline invite: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Get ────────────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'organizations_get')),\n {\n title: 'Get Organization',\n description:\n 'Fetch a single organization by ID. Returns the full organization detail (tenant, slug, status, member/workspace counts).',\n inputSchema: {\n id: z.string().describe('Organization ID'),\n },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.global.request<{ organization: unknown | null }>(GET_ORG, {\n id,\n });\n if (!data.organization) {\n return errorResult(`Organization ${id} not found`);\n }\n return jsonResult(data.organization);\n } catch (error) {\n ctx.logger.error('organizations_get failed', { error: String(error) });\n return errorResult(\n `Failed to get organization: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Members ────────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'organizations_members_list')),\n {\n title: 'List Organization Members',\n description:\n 'List the members of an organization with pagination. Returns { items, total, hasMore, limit, offset }.',\n inputSchema: {\n organizationId: z.string().describe('Organization ID'),\n limit: z.number().optional().describe('Page size (default 10 on server)'),\n offset: z.number().optional().describe('Offset for pagination (default 0)'),\n },\n },\n async ({ organizationId, limit, offset }) => {\n try {\n const data = await ctx.gql.global.request<{ organizationMembers: unknown }>(\n LIST_ORG_MEMBERS,\n { organizationId, limit, offset },\n );\n return jsonResult(data.organizationMembers);\n } catch (error) {\n ctx.logger.error('organizations_members_list failed', { error: String(error) });\n return errorResult(\n `Failed to list organization members: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'organizations_members_invite')),\n {\n title: 'Invite Organization Member',\n description:\n 'Send an invitation to join an organization. The invitee receives an email-style invite with the chosen role; returns the created OrganizationInvite.',\n inputSchema: {\n organizationId: z.string().describe('Organization ID to invite the user into'),\n email: z.string().describe('Email address of the invitee'),\n role: UserRoleEnum.optional().describe('Role to grant on acceptance (defaults to MEMBER)'),\n message: z.string().optional().describe('Optional message included with the invite'),\n },\n },\n async ({ organizationId, email, role, message }) => {\n try {\n const input: Record<string, unknown> = { organizationId, email };\n if (role !== undefined) input.role = role;\n if (message !== undefined) input.message = message;\n const data = await ctx.gql.global.request<{ inviteOrganizationMember: unknown }>(\n INVITE_ORG_MEMBER,\n { input },\n );\n return jsonResult(data.inviteOrganizationMember);\n } catch (error) {\n ctx.logger.error('organizations_members_invite failed', { error: String(error) });\n return errorResult(\n `Failed to invite organization member: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'organizations_members_remove')),\n {\n title: 'Remove Organization Member',\n description:\n 'Remove a user from an organization. Returns { removed: boolean, organizationId, userId }.',\n inputSchema: {\n organizationId: z.string().describe('Organization ID'),\n userId: z.string().describe('User ID to remove from the organization'),\n },\n },\n async ({ organizationId, userId }) => {\n try {\n const data = await ctx.gql.global.request<{ removeOrganizationMember: boolean }>(\n REMOVE_ORG_MEMBER,\n { organizationId, userId },\n );\n return jsonResult({\n removed: data.removeOrganizationMember,\n organizationId,\n userId,\n });\n } catch (error) {\n ctx.logger.error('organizations_members_remove failed', { error: String(error) });\n return errorResult(\n `Failed to remove organization member: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'organizations_members_role')),\n {\n title: 'Update Organization Member Role',\n description:\n 'Update the role of an existing organization member. Returns the updated OrganizationMember.',\n inputSchema: {\n organizationId: z.string().describe('Organization ID'),\n userId: z.string().describe('User ID whose role will change'),\n role: UserRoleEnum.describe('New role for the member'),\n },\n },\n async ({ organizationId, userId, role }) => {\n try {\n const data = await ctx.gql.global.request<{ updateOrganizationMember: unknown }>(\n UPDATE_ORG_MEMBER_ROLE,\n { organizationId, userId, input: { role } },\n );\n return jsonResult(data.updateOrganizationMember);\n } catch (error) {\n ctx.logger.error('organizations_members_role failed', { error: String(error) });\n return errorResult(\n `Failed to update organization member role: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n}\n","/**\n * Organizations module — multi-tenant org membership + invite acceptance.\n *\n * Tools:\n * <product>_organizations_{list,current}\n * <product>_organizations_invites_{list,accept,decline}\n *\n * Backend: ~/products/global/tenant/global-tenant-svc/.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { McpContext, McpModule, ModuleRegistration } from '../../core/index.js';\nimport { registerOrganizationsTools } from './tools.js';\n\nconst organizationsModule: McpModule = {\n id: 'organizations',\n version: '0.0.1',\n displayName: 'Organizations',\n dependsOn: ['auth'],\n capabilities: { tools: {} },\n\n register(server: McpServer, ctx: McpContext): ModuleRegistration {\n const tools: string[] = [];\n const track = (n: string): string => {\n tools.push(n);\n return n;\n };\n\n registerOrganizationsTools(server, ctx, track);\n\n return { tools, resources: [], prompts: [] };\n },\n};\n\nexport default organizationsModule;\n"]}
1
+ {"version":3,"sources":["../../../src/core/errors.ts","../../../src/core/tool-name.ts","../../../src/core/result.ts","../../../src/modules/organizations/operations.ts","../../../src/modules/organizations/tools.ts","../../../src/modules/organizations/index.ts"],"names":["z"],"mappings":";;;;;;;;;;;AA8BO,IAAM,gBAAA,GAAN,cAA+B,KAAA,CAAM;AAAA,EACjB,KAAA;AAAA,EAEzB,WAAA,CAAY,SAAiB,KAAA,EAAiB;AAC5C,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,kBAAA;AACZ,IAAA,IAAA,CAAK,KAAA,GAAQ,KAAA;AAAA,EACf;AACF,CAAA;;;AC1BA,IAAM,oBAAA,GAAuB,EAAA;AAE7B,SAAS,cAAA,CAAe,MAAc,IAAA,EAA8C;AAClF,EAAA,IAAuB,IAAA,CAAK,MAAA,GAAS,oBAAA,EAAsB;AACzD,IAAA,MAAM,IAAI,gBAAA;AAAA,MACR,CAAA,WAAA,EAAc,IAAI,CAAA,UAAA,EAAa,oBAAoB,CAAA,8CAAA;AAAA,KACrD;AAAA,EACF;AACA,EAAA,OAAO,IAAA;AACT;AAMO,SAAS,WAAA,CAAY,gBAAwB,KAAA,EAAyB;AAC3E,EAAA,IAAI,CAAC,WAAA,EAAa;AAChB,IAAA,MAAM,IAAI,iBAAiB,sCAAsC,CAAA;AAAA,EACnE;AACA,EAAA,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AA;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 * 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\n/**\n * Name-based hint heuristics for MCP `annotations` (readOnlyHint /\n * destructiveHint). Used by tool-governance.ts to auto-fill annotations for\n * the fleet of product modules that call `server.registerTool` directly\n * (bypassing the `registerTool()` core helper) and so never set them\n * explicitly today (BOFF-3903). Deliberately conservative — matched against\n * whole `_`-delimited segments so e.g. `timeentries_delete` and\n * `pomodoro_delete_goal` match, but a hypothetical `undeletable_check`\n * would not.\n *\n * A module can always override the inference by passing an explicit\n * `annotations` object to `registerTool()` / `server.registerTool()`.\n */\nconst DESTRUCTIVE_NAME_SEGMENT = /(?:^|_)delete(?:_|$)/i;\nconst READ_ONLY_NAME_SEGMENT = /(?:^|_)(?:list|get|search|check|read|count|stats|by_date)(?:_|$)/i;\n\n/** True when a tool name looks destructive (irreversibly deletes data) by naming convention. */\nexport function inferDestructiveHint(toolName: string): boolean {\n return DESTRUCTIVE_NAME_SEGMENT.test(toolName);\n}\n\n/**\n * True when a tool name looks read-only by naming convention. Never true for\n * a name that also looks destructive (a tool can't be both).\n */\nexport function inferReadOnlyHint(toolName: string): boolean {\n return !inferDestructiveHint(toolName) && READ_ONLY_NAME_SEGMENT.test(toolName);\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';\nimport type { ToolAnnotations } from './tool-governance.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 * Explicit MCP annotations (readOnlyHint / destructiveHint / ...). Optional\n * — when omitted, `wrapServerWithToolGovernance` (applied centrally in\n * `createMcpServer`) infers them from the tool name. Set this to override\n * the inference for a tool whose name doesn't match the naming convention.\n */\n annotations?: ToolAnnotations;\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 ...(metadata.annotations ? { annotations: metadata.annotations } : {}),\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","export const MY_ORGANIZATIONS = `\n query MyOrganizations($limit: Int, $offset: Int) {\n myOrganizations(limit: $limit, offset: $offset) {\n items {\n id\n name\n slug\n tenantId\n description\n status\n createdAt\n updatedAt\n }\n total\n hasMore\n }\n }\n`;\n\nexport const MY_ORGANIZATION_INVITES = `\n query MyOrganizationInvites($status: InviteStatus, $limit: Int, $offset: Int) {\n myOrganizationInvites(status: $status, limit: $limit, offset: $offset) {\n items {\n id\n organizationId\n email\n role\n status\n expiresAt\n message\n createdAt\n }\n total\n hasMore\n }\n }\n`;\n\nexport const ACCEPT_ORG_INVITE = `\n mutation AcceptOrganizationInvite($inviteId: ID!) {\n acceptOrganizationInvite(inviteId: $inviteId) {\n id\n userId\n organizationId\n role\n joinedAt\n }\n }\n`;\n\nexport const REJECT_ORG_INVITE = `\n mutation RejectOrganizationInvite($inviteId: ID!) {\n rejectOrganizationInvite(inviteId: $inviteId) {\n id\n status\n respondedAt\n }\n }\n`;\n\nexport const GET_ORG = `\n query Organization($id: ID!) {\n organization(id: $id) {\n id\n tenantId\n name\n slug\n description\n status\n memberCount\n workspaceCount\n createdAt\n updatedAt\n }\n }\n`;\n\nexport const LIST_ORG_MEMBERS = `\n query OrganizationMembers($organizationId: String!, $limit: Int, $offset: Int) {\n organizationMembers(organizationId: $organizationId, limit: $limit, offset: $offset) {\n items {\n id\n organizationId\n userId\n role\n joinedAt\n invitedBy\n }\n total\n hasMore\n limit\n offset\n }\n }\n`;\n\nexport const INVITE_ORG_MEMBER = `\n mutation InviteOrganizationMember($input: InviteOrganizationMemberInput!) {\n inviteOrganizationMember(input: $input) {\n id\n organizationId\n email\n role\n status\n invitedBy\n expiresAt\n createdAt\n }\n }\n`;\n\nexport const REMOVE_ORG_MEMBER = `\n mutation RemoveOrganizationMember($organizationId: String!, $userId: String!) {\n removeOrganizationMember(organizationId: $organizationId, userId: $userId)\n }\n`;\n\nexport const UPDATE_ORG_MEMBER_ROLE = `\n mutation UpdateOrganizationMember(\n $organizationId: String!\n $userId: String!\n $input: UpdateOrganizationMemberInput!\n ) {\n updateOrganizationMember(\n organizationId: $organizationId\n userId: $userId\n input: $input\n ) {\n id\n organizationId\n userId\n role\n joinedAt\n invitedBy\n }\n }\n`;\n","import { z } from 'zod';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { jsonResult, errorResult, mcpToolName, type McpContext } from '../../core/index.js';\nimport {\n MY_ORGANIZATIONS,\n MY_ORGANIZATION_INVITES,\n ACCEPT_ORG_INVITE,\n REJECT_ORG_INVITE,\n GET_ORG,\n LIST_ORG_MEMBERS,\n INVITE_ORG_MEMBER,\n REMOVE_ORG_MEMBER,\n UPDATE_ORG_MEMBER_ROLE,\n} from './operations.js';\n\nconst InviteStatusEnum = z.enum(['PENDING', 'ACCEPTED', 'REJECTED', 'EXPIRED', 'REVOKED']);\n\nconst UserRoleEnum = z\n .enum(['GUEST', 'MEMBER', 'ORG_ADMIN', 'SUPER_ADMIN', 'TENANT_ADMIN', 'WORKSPACE_ADMIN'])\n .describe('Role within the organization (MEMBER is the safest default for invites)');\n\nexport function registerOrganizationsTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n server.registerTool(\n track(mcpToolName(ctx.productName, 'organizations_list')),\n {\n title: 'List Organizations',\n description: 'List organizations the current user is a member of.',\n inputSchema: {\n limit: z.number().optional().describe('Page size'),\n offset: z.number().optional().describe('Offset for pagination'),\n },\n },\n async ({ limit, offset }) => {\n try {\n const data = await ctx.gql.global.request<{ myOrganizations: unknown }>(MY_ORGANIZATIONS, {\n limit: limit ?? 50,\n offset: offset ?? 0,\n });\n return jsonResult(data.myOrganizations);\n } catch (error) {\n ctx.logger.error('organizations_list failed', { error: String(error) });\n return errorResult(\n `Failed to list organizations: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'organizations_current')),\n {\n title: 'Current Organization',\n description: 'Return the current organization context from the auth store.',\n inputSchema: {},\n },\n async () => {\n try {\n const auth = ctx.auth.read();\n if (!auth?.organizationId) {\n return errorResult(\n 'No active organization context. Run the auth login flow to bind a tenant.',\n );\n }\n return jsonResult({\n organizationId: auth.organizationId,\n workspaceId: auth.workspaceId ?? null,\n });\n } catch (error) {\n ctx.logger.error('organizations_current failed', { error: String(error) });\n return errorResult(\n `Failed to read current organization: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'organizations_invites_list')),\n {\n title: 'List Organization Invites',\n description: 'List organization invites for the current user.',\n inputSchema: {\n status: InviteStatusEnum.optional().describe('Filter by invite status (default: PENDING)'),\n limit: z.number().optional().describe('Page size'),\n offset: z.number().optional().describe('Offset for pagination'),\n },\n },\n async ({ status, limit, offset }) => {\n try {\n const data = await ctx.gql.global.request<{ myOrganizationInvites: unknown }>(\n MY_ORGANIZATION_INVITES,\n {\n status: status ?? 'PENDING',\n limit: limit ?? 50,\n offset: offset ?? 0,\n },\n );\n return jsonResult(data.myOrganizationInvites);\n } catch (error) {\n ctx.logger.error('organizations_invites_list failed', { error: String(error) });\n return errorResult(\n `Failed to list organization invites: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'organizations_invites_accept')),\n {\n title: 'Accept Organization Invite',\n description: 'Accept a pending organization invite.',\n inputSchema: {\n invitationId: z.string().describe('Invite ID'),\n },\n },\n async ({ invitationId }) => {\n try {\n const data = await ctx.gql.global.request<{ acceptOrganizationInvite: unknown }>(\n ACCEPT_ORG_INVITE,\n { inviteId: invitationId },\n );\n return jsonResult(data.acceptOrganizationInvite);\n } catch (error) {\n ctx.logger.error('organizations_invites_accept failed', { error: String(error) });\n return errorResult(\n `Failed to accept invite: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'organizations_invites_decline')),\n {\n title: 'Decline Organization Invite',\n description: 'Decline a pending organization invite.',\n inputSchema: {\n invitationId: z.string().describe('Invite ID'),\n },\n },\n async ({ invitationId }) => {\n try {\n const data = await ctx.gql.global.request<{ rejectOrganizationInvite: unknown }>(\n REJECT_ORG_INVITE,\n { inviteId: invitationId },\n );\n return jsonResult(data.rejectOrganizationInvite);\n } catch (error) {\n ctx.logger.error('organizations_invites_decline failed', { error: String(error) });\n return errorResult(\n `Failed to decline invite: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Get ────────────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'organizations_get')),\n {\n title: 'Get Organization',\n description:\n 'Fetch a single organization by ID. Returns the full organization detail (tenant, slug, status, member/workspace counts).',\n inputSchema: {\n id: z.string().describe('Organization ID'),\n },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.global.request<{ organization: unknown | null }>(GET_ORG, {\n id,\n });\n if (!data.organization) {\n return errorResult(`Organization ${id} not found`);\n }\n return jsonResult(data.organization);\n } catch (error) {\n ctx.logger.error('organizations_get failed', { error: String(error) });\n return errorResult(\n `Failed to get organization: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Members ────────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'organizations_members_list')),\n {\n title: 'List Organization Members',\n description:\n 'List the members of an organization with pagination. Returns { items, total, hasMore, limit, offset }.',\n inputSchema: {\n organizationId: z.string().describe('Organization ID'),\n limit: z.number().optional().describe('Page size (default 10 on server)'),\n offset: z.number().optional().describe('Offset for pagination (default 0)'),\n },\n },\n async ({ organizationId, limit, offset }) => {\n try {\n const data = await ctx.gql.global.request<{ organizationMembers: unknown }>(\n LIST_ORG_MEMBERS,\n { organizationId, limit, offset },\n );\n return jsonResult(data.organizationMembers);\n } catch (error) {\n ctx.logger.error('organizations_members_list failed', { error: String(error) });\n return errorResult(\n `Failed to list organization members: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'organizations_members_invite')),\n {\n title: 'Invite Organization Member',\n description:\n 'Send an invitation to join an organization. The invitee receives an email-style invite with the chosen role; returns the created OrganizationInvite.',\n inputSchema: {\n organizationId: z.string().describe('Organization ID to invite the user into'),\n email: z.string().describe('Email address of the invitee'),\n role: UserRoleEnum.optional().describe('Role to grant on acceptance (defaults to MEMBER)'),\n message: z.string().optional().describe('Optional message included with the invite'),\n },\n },\n async ({ organizationId, email, role, message }) => {\n try {\n const input: Record<string, unknown> = { organizationId, email };\n if (role !== undefined) input.role = role;\n if (message !== undefined) input.message = message;\n const data = await ctx.gql.global.request<{ inviteOrganizationMember: unknown }>(\n INVITE_ORG_MEMBER,\n { input },\n );\n return jsonResult(data.inviteOrganizationMember);\n } catch (error) {\n ctx.logger.error('organizations_members_invite failed', { error: String(error) });\n return errorResult(\n `Failed to invite organization member: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'organizations_members_remove')),\n {\n title: 'Remove Organization Member',\n description:\n 'Remove a user from an organization. Returns { removed: boolean, organizationId, userId }.',\n inputSchema: {\n organizationId: z.string().describe('Organization ID'),\n userId: z.string().describe('User ID to remove from the organization'),\n },\n },\n async ({ organizationId, userId }) => {\n try {\n const data = await ctx.gql.global.request<{ removeOrganizationMember: boolean }>(\n REMOVE_ORG_MEMBER,\n { organizationId, userId },\n );\n return jsonResult({\n removed: data.removeOrganizationMember,\n organizationId,\n userId,\n });\n } catch (error) {\n ctx.logger.error('organizations_members_remove failed', { error: String(error) });\n return errorResult(\n `Failed to remove organization member: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'organizations_members_role')),\n {\n title: 'Update Organization Member Role',\n description:\n 'Update the role of an existing organization member. Returns the updated OrganizationMember.',\n inputSchema: {\n organizationId: z.string().describe('Organization ID'),\n userId: z.string().describe('User ID whose role will change'),\n role: UserRoleEnum.describe('New role for the member'),\n },\n },\n async ({ organizationId, userId, role }) => {\n try {\n const data = await ctx.gql.global.request<{ updateOrganizationMember: unknown }>(\n UPDATE_ORG_MEMBER_ROLE,\n { organizationId, userId, input: { role } },\n );\n return jsonResult(data.updateOrganizationMember);\n } catch (error) {\n ctx.logger.error('organizations_members_role failed', { error: String(error) });\n return errorResult(\n `Failed to update organization member role: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n}\n","/**\n * Organizations module — multi-tenant org membership + invite acceptance.\n *\n * Tools:\n * <product>_organizations_{list,current}\n * <product>_organizations_invites_{list,accept,decline}\n *\n * Backend: ~/products/global/tenant/global-tenant-svc/.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { McpContext, McpModule, ModuleRegistration } from '../../core/index.js';\nimport { registerOrganizationsTools } from './tools.js';\n\nconst organizationsModule: McpModule = {\n id: 'organizations',\n version: '0.0.1',\n displayName: 'Organizations',\n dependsOn: ['auth'],\n capabilities: { tools: {} },\n\n register(server: McpServer, ctx: McpContext): ModuleRegistration {\n const tools: string[] = [];\n const track = (n: string): string => {\n tools.push(n);\n return n;\n };\n\n registerOrganizationsTools(server, ctx, track);\n\n return { tools, resources: [], prompts: [] };\n },\n};\n\nexport default organizationsModule;\n"]}
@@ -1,4 +1,4 @@
1
- import { mcpToolName, jsonResult, errorResult } from '../../chunk-H2OYWLOA.js';
1
+ import { mcpToolName, jsonResult, errorResult } from '../../chunk-YOSQUY3M.js';
2
2
  import { z } from 'zod';
3
3
 
4
4
  // src/modules/organizations/operations.ts
@@ -18,20 +18,6 @@ var McpInternalError = class extends Error {
18
18
  }
19
19
  };
20
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
21
  // src/core/tool-name.ts
36
22
  var MAX_TOOL_NAME_LENGTH = 63;
37
23
  function assertSafeName(name, kind) {
@@ -62,6 +48,20 @@ function mcpPromptName(productName, ...parts) {
62
48
  return [productName, ...parts].filter(Boolean).join("-");
63
49
  }
64
50
 
51
+ // src/core/result.ts
52
+ function jsonResult(data, structured) {
53
+ const result = {
54
+ content: [{ type: "text", text: JSON.stringify(data, null, 2) }]
55
+ };
56
+ return result;
57
+ }
58
+ function errorResult(message, hint) {
59
+ const text = hint ? `${message}
60
+
61
+ Hint: ${hint}` : message;
62
+ return { content: [{ type: "text", text }], isError: true };
63
+ }
64
+
65
65
  // src/modules/planmagnet/operations.ts
66
66
  var PAGE_INFO = `
67
67
  totalCount