@burdenoff/mcp-libs 2026.704.1 → 2026.719.2

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 +16 -42
  112. package/dist/modules/movethewheels/index.cjs.map +1 -1
  113. package/dist/modules/movethewheels/index.js +3 -29
  114. package/dist/modules/movethewheels/index.js.map +1 -1
  115. package/dist/modules/mybodyshield/index.cjs +14 -14
  116. package/dist/modules/mybodyshield/index.cjs.map +1 -1
  117. package/dist/modules/mybodyshield/index.js +1 -1
  118. package/dist/modules/notifications/index.cjs +14 -14
  119. package/dist/modules/notifications/index.cjs.map +1 -1
  120. package/dist/modules/notifications/index.js +1 -1
  121. package/dist/modules/organizations/index.cjs +14 -14
  122. package/dist/modules/organizations/index.cjs.map +1 -1
  123. package/dist/modules/organizations/index.js +1 -1
  124. package/dist/modules/planmagnet/index.cjs +14 -14
  125. package/dist/modules/planmagnet/index.cjs.map +1 -1
  126. package/dist/modules/planmagnet/index.js +1 -1
  127. package/dist/modules/products/index.cjs +14 -14
  128. package/dist/modules/products/index.cjs.map +1 -1
  129. package/dist/modules/products/index.js +1 -1
  130. package/dist/modules/proserviceworld/index.cjs +14 -14
  131. package/dist/modules/proserviceworld/index.cjs.map +1 -1
  132. package/dist/modules/proserviceworld/index.js +1 -1
  133. package/dist/modules/rbac/index.cjs +14 -14
  134. package/dist/modules/rbac/index.cjs.map +1 -1
  135. package/dist/modules/rbac/index.js +1 -1
  136. package/dist/modules/sandbox/index.cjs +14 -14
  137. package/dist/modules/sandbox/index.cjs.map +1 -1
  138. package/dist/modules/sandbox/index.js +1 -1
  139. package/dist/modules/scheduler/index.cjs +14 -14
  140. package/dist/modules/scheduler/index.cjs.map +1 -1
  141. package/dist/modules/scheduler/index.js +1 -1
  142. package/dist/modules/security/index.cjs +14 -14
  143. package/dist/modules/security/index.cjs.map +1 -1
  144. package/dist/modules/security/index.js +1 -1
  145. package/dist/modules/semanticfed/index.cjs +14 -14
  146. package/dist/modules/semanticfed/index.cjs.map +1 -1
  147. package/dist/modules/semanticfed/index.js +1 -1
  148. package/dist/modules/store/index.cjs +14 -14
  149. package/dist/modules/store/index.cjs.map +1 -1
  150. package/dist/modules/store/index.js +1 -1
  151. package/dist/modules/subscriberbot/index.cjs +14 -14
  152. package/dist/modules/subscriberbot/index.cjs.map +1 -1
  153. package/dist/modules/subscriberbot/index.js +1 -1
  154. package/dist/modules/support/index.cjs +14 -14
  155. package/dist/modules/support/index.cjs.map +1 -1
  156. package/dist/modules/support/index.js +1 -1
  157. package/dist/modules/tags/index.cjs +14 -14
  158. package/dist/modules/tags/index.cjs.map +1 -1
  159. package/dist/modules/tags/index.js +1 -1
  160. package/dist/modules/technospam/index.cjs +14 -14
  161. package/dist/modules/technospam/index.cjs.map +1 -1
  162. package/dist/modules/technospam/index.js +1 -1
  163. package/dist/modules/theculturepost/index.cjs +14 -14
  164. package/dist/modules/theculturepost/index.cjs.map +1 -1
  165. package/dist/modules/theculturepost/index.js +1 -1
  166. package/dist/modules/theglobalfuel/index.cjs +14 -14
  167. package/dist/modules/theglobalfuel/index.cjs.map +1 -1
  168. package/dist/modules/theglobalfuel/index.js +1 -1
  169. package/dist/modules/timecampus/index.cjs +21 -16
  170. package/dist/modules/timecampus/index.cjs.map +1 -1
  171. package/dist/modules/timecampus/index.js +8 -3
  172. package/dist/modules/timecampus/index.js.map +1 -1
  173. package/dist/modules/tours/index.cjs +14 -14
  174. package/dist/modules/tours/index.cjs.map +1 -1
  175. package/dist/modules/tours/index.js +1 -1
  176. package/dist/modules/vibecontrols/index.cjs +14 -14
  177. package/dist/modules/vibecontrols/index.cjs.map +1 -1
  178. package/dist/modules/vibecontrols/index.js +2 -2
  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/subscriberbot/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/support/operations.ts
54
54
  var LIST_SUPPORT_TICKETS = `
55
55
  query ListSupportTickets($filter: SupportTicketFilterInput, $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/support/operations.ts","../../../src/modules/support/tools.ts","../../../src/modules/support/index.ts"],"names":["z"],"mappings":";;;;;;;;;;;AA8B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kB,EAAC;AACzB,IAAA,MAAM,KAAA,GAAQ,CAAC,CAAA,KAAsB;AACnC,MAAA,KAAA,CAAM,KAAK,CAAC,CAAA;AACZ,MAAA,OAAO,CAAA;AAAA,IACT,CAAA;AAEA,IAAA,oBAAA,CAAqB,MAAA,EAAQ,KAAK,KAAK,CAAA;AAEvC,IAAA,OAAO,EAAE,KAAA,EAAO,SAAA,EAAW,EAAC,EAAG,OAAA,EAAS,EAAC,EAAE;AAAA,EAC7C;AACF,CAAA;AAEA,IAAO,eAAA,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_SUPPORT_TICKETS = `\n query ListSupportTickets($filter: SupportTicketFilterInput, $limit: Int, $offset: Int) {\n supportTickets(filter: $filter, limit: $limit, offset: $offset) {\n nodes { id ticketNumber subject status priority category createdAt }\n totalCount\n }\n }\n`;\n\nexport const GET_SUPPORT_TICKET = `\n query GetSupportTicket($id: ID!) {\n supportTicket(id: $id) {\n id ticketNumber subject description status priority category createdAt\n messages { id message createdAt isInternal }\n }\n }\n`;\n\nexport const CREATE_SUPPORT_TICKET = `\n mutation CreateSupportTicket($input: CreateSupportTicketInput!) {\n createSupportTicket(input: $input) {\n id ticketNumber status priority\n }\n }\n`;\n\nexport const CREATE_SUPPORT_MESSAGE = `\n mutation CreateSupportMessage($input: CreateSupportMessageInput!) {\n createSupportMessage(input: $input) {\n id message createdAt isInternal\n }\n }\n`;\n\nexport const CLOSE_SUPPORT_TICKET = `\n mutation CloseSupportTicket($id: ID!) {\n closeSupportTicket(id: $id) {\n id status closedAt\n }\n }\n`;\n\nexport const SEARCH_KNOWLEDGE_BASE = `\n query SearchKnowledgeBase($query: String!, $limit: Int, $offset: Int) {\n searchKnowledgeBase(query: $query, limit: $limit, offset: $offset) {\n id title slug helpfulnessScore\n }\n }\n`;\n","/**\n * Support MCP tools — support tickets + knowledge base.\n * Surface mirrors cli-sdk/src/modules/support/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 TicketRow {\n id: string;\n ticketNumber?: string;\n subject?: string;\n description?: string;\n status?: string;\n priority?: string;\n category?: string;\n createdAt?: string;\n closedAt?: string;\n}\n\ninterface KbArticle {\n id: string;\n title: string;\n slug: string;\n helpfulnessScore: number;\n}\n\nexport function registerSupportTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n server.registerTool(\n track(mcpToolName(ctx.productName, 'support_tickets_list')),\n {\n title: 'List Support Tickets',\n description: 'List support tickets with optional status/priority filters.',\n inputSchema: {\n status: z.string().optional().describe('Filter by status (will be uppercased)'),\n priority: z.string().optional().describe('Filter by priority (will be uppercased)'),\n limit: z.number().optional().describe('Page size (default 50)'),\n },\n },\n async ({ status, priority, limit }) => {\n try {\n const filter: Record<string, unknown> = {};\n if (status !== undefined) filter.status = status.toUpperCase();\n if (priority !== undefined) filter.priority = priority.toUpperCase();\n const data = await ctx.gql.global.request<{\n supportTickets: { nodes: TicketRow[]; totalCount: number };\n }>(ops.LIST_SUPPORT_TICKETS, {\n filter: Object.keys(filter).length ? filter : undefined,\n limit: limit ?? 50,\n offset: 0,\n });\n return jsonResult(data.supportTickets);\n } catch (error) {\n ctx.logger.error('support_tickets_list failed', { error: String(error) });\n return errorResult(\n `Failed to list support tickets: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'support_tickets_get')),\n {\n title: 'Get Support Ticket',\n description: 'Get a support ticket by ID, including messages.',\n inputSchema: { id: z.string().describe('Ticket ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.global.request<{ supportTicket: TicketRow | null }>(\n ops.GET_SUPPORT_TICKET,\n { id },\n );\n if (!data.supportTicket) return errorResult(`Ticket ${id} not found`);\n return jsonResult(data.supportTicket);\n } catch (error) {\n ctx.logger.error('support_tickets_get failed', { error: String(error) });\n return errorResult(\n `Failed to get support ticket: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'support_tickets_create')),\n {\n title: 'Create Support Ticket',\n description: 'Open a support ticket.',\n inputSchema: {\n subject: z.string().describe('Ticket subject'),\n description: z.string().describe('Ticket description'),\n priority: z.string().optional().describe('LOW|NORMAL|HIGH|URGENT (default NORMAL)'),\n category: z\n .string()\n .optional()\n .describe('TECHNICAL_SUPPORT|BILLING|FEATURE_REQUEST|OTHER (default TECHNICAL_SUPPORT)'),\n },\n },\n async ({ subject, description, priority, category }) => {\n try {\n const input: Record<string, unknown> = {\n subject,\n description,\n priority: (priority ?? 'NORMAL').toUpperCase(),\n category: (category ?? 'TECHNICAL_SUPPORT').toUpperCase(),\n };\n const data = await ctx.gql.global.request<{ createSupportTicket: TicketRow }>(\n ops.CREATE_SUPPORT_TICKET,\n { input },\n );\n return jsonResult(data.createSupportTicket);\n } catch (error) {\n ctx.logger.error('support_tickets_create failed', { error: String(error) });\n return errorResult(\n `Failed to create support ticket: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'support_tickets_comment')),\n {\n title: 'Add Support Ticket Comment',\n description: 'Add a comment to a support ticket.',\n inputSchema: {\n ticketId: z.string().describe('Ticket ID'),\n message: z.string().describe('Comment message'),\n internal: z.boolean().optional().describe('Internal staff-only comment (default false)'),\n },\n },\n async ({ ticketId, message, internal }) => {\n try {\n const input: Record<string, unknown> = {\n ticketId,\n message,\n isInternal: internal === true,\n };\n const data = await ctx.gql.global.request<{\n createSupportMessage: {\n id: string;\n message: string;\n createdAt: string;\n isInternal: boolean;\n };\n }>(ops.CREATE_SUPPORT_MESSAGE, { input });\n return jsonResult(data.createSupportMessage);\n } catch (error) {\n ctx.logger.error('support_tickets_comment failed', { error: String(error) });\n return errorResult(\n `Failed to add support ticket comment: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'support_tickets_close')),\n {\n title: 'Close Support Ticket',\n description: 'Close a support ticket.',\n inputSchema: { id: z.string().describe('Ticket ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.global.request<{ closeSupportTicket: TicketRow }>(\n ops.CLOSE_SUPPORT_TICKET,\n { id },\n );\n return jsonResult(data.closeSupportTicket);\n } catch (error) {\n ctx.logger.error('support_tickets_close failed', { error: String(error) });\n return errorResult(\n `Failed to close support ticket: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'support_kb_search')),\n {\n title: 'Search Knowledge Base',\n description: 'Search knowledge base articles.',\n inputSchema: {\n query: z.string().describe('Search query'),\n limit: z.number().optional().describe('Page size (default 20)'),\n },\n },\n async ({ query, limit }) => {\n try {\n const data = await ctx.gql.global.request<{ searchKnowledgeBase: KbArticle[] }>(\n ops.SEARCH_KNOWLEDGE_BASE,\n { query, limit: limit ?? 20, offset: 0 },\n );\n return jsonResult(data.searchKnowledgeBase);\n } catch (error) {\n ctx.logger.error('support_kb_search failed', { error: String(error) });\n return errorResult(\n `Failed to search knowledge base: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n}\n","/**\n * Support module — support tickets CRUD + comments + close + KB search.\n * Surface mirrors cli-sdk/src/modules/support/.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { McpContext, McpModule, ModuleRegistration } from '../../core/index.js';\nimport { registerSupportTools } from './tools.js';\n\nconst supportModule: McpModule = {\n id: 'support',\n version: '0.0.1',\n displayName: 'Support',\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 registerSupportTools(server, ctx, track);\n\n return { tools, resources: [], prompts: [] };\n },\n};\n\nexport default supportModule;\n"]}
1
+ {"version":3,"sources":["../../../src/core/errors.ts","../../../src/core/tool-name.ts","../../../src/core/result.ts","../../../src/modules/support/operations.ts","../../../src/modules/support/tools.ts","../../../src/modules/support/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,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AA,EAC7C;AACF,CAAA;AAEA,IAAO,eAAA,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 LIST_SUPPORT_TICKETS = `\n query ListSupportTickets($filter: SupportTicketFilterInput, $limit: Int, $offset: Int) {\n supportTickets(filter: $filter, limit: $limit, offset: $offset) {\n nodes { id ticketNumber subject status priority category createdAt }\n totalCount\n }\n }\n`;\n\nexport const GET_SUPPORT_TICKET = `\n query GetSupportTicket($id: ID!) {\n supportTicket(id: $id) {\n id ticketNumber subject description status priority category createdAt\n messages { id message createdAt isInternal }\n }\n }\n`;\n\nexport const CREATE_SUPPORT_TICKET = `\n mutation CreateSupportTicket($input: CreateSupportTicketInput!) {\n createSupportTicket(input: $input) {\n id ticketNumber status priority\n }\n }\n`;\n\nexport const CREATE_SUPPORT_MESSAGE = `\n mutation CreateSupportMessage($input: CreateSupportMessageInput!) {\n createSupportMessage(input: $input) {\n id message createdAt isInternal\n }\n }\n`;\n\nexport const CLOSE_SUPPORT_TICKET = `\n mutation CloseSupportTicket($id: ID!) {\n closeSupportTicket(id: $id) {\n id status closedAt\n }\n }\n`;\n\nexport const SEARCH_KNOWLEDGE_BASE = `\n query SearchKnowledgeBase($query: String!, $limit: Int, $offset: Int) {\n searchKnowledgeBase(query: $query, limit: $limit, offset: $offset) {\n id title slug helpfulnessScore\n }\n }\n`;\n","/**\n * Support MCP tools — support tickets + knowledge base.\n * Surface mirrors cli-sdk/src/modules/support/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 TicketRow {\n id: string;\n ticketNumber?: string;\n subject?: string;\n description?: string;\n status?: string;\n priority?: string;\n category?: string;\n createdAt?: string;\n closedAt?: string;\n}\n\ninterface KbArticle {\n id: string;\n title: string;\n slug: string;\n helpfulnessScore: number;\n}\n\nexport function registerSupportTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n server.registerTool(\n track(mcpToolName(ctx.productName, 'support_tickets_list')),\n {\n title: 'List Support Tickets',\n description: 'List support tickets with optional status/priority filters.',\n inputSchema: {\n status: z.string().optional().describe('Filter by status (will be uppercased)'),\n priority: z.string().optional().describe('Filter by priority (will be uppercased)'),\n limit: z.number().optional().describe('Page size (default 50)'),\n },\n },\n async ({ status, priority, limit }) => {\n try {\n const filter: Record<string, unknown> = {};\n if (status !== undefined) filter.status = status.toUpperCase();\n if (priority !== undefined) filter.priority = priority.toUpperCase();\n const data = await ctx.gql.global.request<{\n supportTickets: { nodes: TicketRow[]; totalCount: number };\n }>(ops.LIST_SUPPORT_TICKETS, {\n filter: Object.keys(filter).length ? filter : undefined,\n limit: limit ?? 50,\n offset: 0,\n });\n return jsonResult(data.supportTickets);\n } catch (error) {\n ctx.logger.error('support_tickets_list failed', { error: String(error) });\n return errorResult(\n `Failed to list support tickets: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'support_tickets_get')),\n {\n title: 'Get Support Ticket',\n description: 'Get a support ticket by ID, including messages.',\n inputSchema: { id: z.string().describe('Ticket ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.global.request<{ supportTicket: TicketRow | null }>(\n ops.GET_SUPPORT_TICKET,\n { id },\n );\n if (!data.supportTicket) return errorResult(`Ticket ${id} not found`);\n return jsonResult(data.supportTicket);\n } catch (error) {\n ctx.logger.error('support_tickets_get failed', { error: String(error) });\n return errorResult(\n `Failed to get support ticket: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'support_tickets_create')),\n {\n title: 'Create Support Ticket',\n description: 'Open a support ticket.',\n inputSchema: {\n subject: z.string().describe('Ticket subject'),\n description: z.string().describe('Ticket description'),\n priority: z.string().optional().describe('LOW|NORMAL|HIGH|URGENT (default NORMAL)'),\n category: z\n .string()\n .optional()\n .describe('TECHNICAL_SUPPORT|BILLING|FEATURE_REQUEST|OTHER (default TECHNICAL_SUPPORT)'),\n },\n },\n async ({ subject, description, priority, category }) => {\n try {\n const input: Record<string, unknown> = {\n subject,\n description,\n priority: (priority ?? 'NORMAL').toUpperCase(),\n category: (category ?? 'TECHNICAL_SUPPORT').toUpperCase(),\n };\n const data = await ctx.gql.global.request<{ createSupportTicket: TicketRow }>(\n ops.CREATE_SUPPORT_TICKET,\n { input },\n );\n return jsonResult(data.createSupportTicket);\n } catch (error) {\n ctx.logger.error('support_tickets_create failed', { error: String(error) });\n return errorResult(\n `Failed to create support ticket: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'support_tickets_comment')),\n {\n title: 'Add Support Ticket Comment',\n description: 'Add a comment to a support ticket.',\n inputSchema: {\n ticketId: z.string().describe('Ticket ID'),\n message: z.string().describe('Comment message'),\n internal: z.boolean().optional().describe('Internal staff-only comment (default false)'),\n },\n },\n async ({ ticketId, message, internal }) => {\n try {\n const input: Record<string, unknown> = {\n ticketId,\n message,\n isInternal: internal === true,\n };\n const data = await ctx.gql.global.request<{\n createSupportMessage: {\n id: string;\n message: string;\n createdAt: string;\n isInternal: boolean;\n };\n }>(ops.CREATE_SUPPORT_MESSAGE, { input });\n return jsonResult(data.createSupportMessage);\n } catch (error) {\n ctx.logger.error('support_tickets_comment failed', { error: String(error) });\n return errorResult(\n `Failed to add support ticket comment: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'support_tickets_close')),\n {\n title: 'Close Support Ticket',\n description: 'Close a support ticket.',\n inputSchema: { id: z.string().describe('Ticket ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.global.request<{ closeSupportTicket: TicketRow }>(\n ops.CLOSE_SUPPORT_TICKET,\n { id },\n );\n return jsonResult(data.closeSupportTicket);\n } catch (error) {\n ctx.logger.error('support_tickets_close failed', { error: String(error) });\n return errorResult(\n `Failed to close support ticket: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'support_kb_search')),\n {\n title: 'Search Knowledge Base',\n description: 'Search knowledge base articles.',\n inputSchema: {\n query: z.string().describe('Search query'),\n limit: z.number().optional().describe('Page size (default 20)'),\n },\n },\n async ({ query, limit }) => {\n try {\n const data = await ctx.gql.global.request<{ searchKnowledgeBase: KbArticle[] }>(\n ops.SEARCH_KNOWLEDGE_BASE,\n { query, limit: limit ?? 20, offset: 0 },\n );\n return jsonResult(data.searchKnowledgeBase);\n } catch (error) {\n ctx.logger.error('support_kb_search failed', { error: String(error) });\n return errorResult(\n `Failed to search knowledge base: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n}\n","/**\n * Support module — support tickets CRUD + comments + close + KB search.\n * Surface mirrors cli-sdk/src/modules/support/.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { McpContext, McpModule, ModuleRegistration } from '../../core/index.js';\nimport { registerSupportTools } from './tools.js';\n\nconst supportModule: McpModule = {\n id: 'support',\n version: '0.0.1',\n displayName: 'Support',\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 registerSupportTools(server, ctx, track);\n\n return { tools, resources: [], prompts: [] };\n },\n};\n\nexport default supportModule;\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/support/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/tags/operations.ts
54
54
  var LIST_TAGS = `
55
55
  query TagsList($filter: TagFilterInput, $pagination: TagsPaginationInput) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/errors.ts","../../../src/core/result.ts","../../../src/core/tool-name.ts","../../../src/modules/tags/operations.ts","../../../src/modules/tags/tools.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SAAA,EAAW,EAAC,EAAG,OAAA,EAAS,EAAC,EAAE;AAAA,EAC7C;AACF,CAAA;AAEA,IAAO,YAAA,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","/**\n * Tags module GraphQL operations — CRUD + analytics + relations.\n * Ported verbatim from cli-sdk/src/modules/tags/operations.ts.\n *\n * Backend: ~/products/wspace/tags/wspace-tags-svc/.\n * Hive service name: `tags` (boundary prefix + `-svc` suffix stripped).\n */\n\nexport const LIST_TAGS = `\n query TagsList($filter: TagFilterInput, $pagination: TagsPaginationInput) {\n getTags(filter: $filter, pagination: $pagination) {\n items { id key label description scope displayOrder }\n total hasMore\n }\n }\n`;\n\nexport const GET_TAG = `\n query GetTag($id: ID!) {\n getTag(id: $id) {\n id key label description color icon scope vocabularyId parentId\n displayOrder assignmentCount usageCount hierarchyLevel hierarchyPath\n }\n }\n`;\n\nexport const CREATE_TAG = `\n mutation CreateTag($input: CreateTagInput!) {\n createTag(input: $input) {\n id key label description scope displayOrder createdAt\n }\n }\n`;\n\nexport const UPDATE_TAG = `\n mutation UpdateTag($id: ID!, $input: UpdateTagInput!) {\n updateTag(id: $id, input: $input) {\n id label description color icon parentId displayOrder updatedAt\n }\n }\n`;\n\nexport const DELETE_TAG = `\n mutation DeleteTag($id: ID!) {\n deleteTag(id: $id)\n }\n`;\n\nexport const TAG_ANALYTICS = `\n query TagAnalytics($tagId: ID!, $startDate: DateTime!, $endDate: DateTime!) {\n getTagAnalytics(tagId: $tagId, startDate: $startDate, endDate: $endDate) {\n assignmentCount date entityTypeBreakdown uniqueUsers uniqueEntities\n }\n }\n`;\n\nexport const TAG_RELATIONS = `\n query GetRelatedTags($tagId: ID!) {\n getRelatedTags(tagId: $tagId) {\n tag { id label }\n relationType\n }\n }\n`;\n\nexport const CREATE_TAG_RELATION = `\n mutation CreateTagRelation($input: CreateTagRelationInput!) {\n createTagRelation(input: $input) {\n id fromTagId toTagId relationType bidirectional\n }\n }\n`;\n\nexport const DELETE_TAG_RELATION = `\n mutation DeleteTagRelation($id: ID!) {\n deleteTagRelation(id: $id)\n }\n`;\n","/**\n * Tags MCP tools — CANONICAL reference module per CLAUDE.md.\n *\n * Surface (6 tools + 3 relation tools = 9): CRUD + analytics + relations.{list,grant,revoke}.\n * Mirrors cli-sdk/src/modules/tags/commands.ts (\"tags permissions\" Commander group ↔\n * the relation tools below — the underlying mutations are the same; \"permissions\"\n * is the user-facing surface name on the CLI side).\n *\n * Quality bar:\n * - Tight zod enums for every backend enum (TagScope, TagRelationType)\n * - Descriptive title + description on every tool (Claude Desktop renders these)\n * - Detailed `.describe()` on every input field for tool-call grounding\n * - Workspace-context guard surfaces a precise re-auth hint via errorResult\n * - Strict types: no `any`; `unknown` + cast only at request boundaries\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 TagRow {\n id: string;\n key: string;\n label: string;\n description?: string | null;\n scope?: string;\n displayOrder?: number;\n}\n\ninterface TagDetail extends TagRow {\n color?: string | null;\n icon?: string | null;\n vocabularyId?: string | null;\n parentId?: string | null;\n assignmentCount?: number;\n usageCount?: number;\n hierarchyLevel?: number;\n hierarchyPath?: string[];\n}\n\ninterface RelatedTag {\n tag: { id: string; label: string };\n relationType: string;\n}\n\nconst TagScopeEnum = z\n .enum(['WORKSPACE', 'GLOBAL', 'VIBE'])\n .describe('Visibility scope of the tag');\n\nconst TagRelationTypeEnum = z\n .enum(['SYNONYM', 'ANTONYM', 'BROADER', 'NARROWER', 'RELATED', 'IMPLIES', 'EXCLUDES'])\n .describe(\n 'Semantic relationship between two tags (SYNONYM = same-meaning, BROADER/NARROWER = hierarchy, IMPLIES/EXCLUDES = behaviour, RELATED = generic)',\n );\n\ninterface WorkspaceCtx {\n workspaceId: string;\n}\n\n/**\n * Resolve the bound workspace context from the auth store. The tags service\n * requires `context.workspaceId` on every mutation input.\n *\n * Returns `errorResult` shape via the `error` channel when no workspace is\n * bound — the caller MUST short-circuit on that signal.\n */\nfunction resolveWorkspaceContext(\n ctx: McpContext,\n): { ok: true; ctx: WorkspaceCtx } | { ok: false; error: ReturnType<typeof errorResult> } {\n const auth = ctx.auth.read();\n const workspaceId = auth?.workspaceId;\n if (!workspaceId) {\n return {\n ok: false,\n error: errorResult(\n 'No workspace selected. Bind one with <product>_auth_select_workspace before calling tag tools.',\n ),\n };\n }\n return { ok: true, ctx: { workspaceId } };\n}\n\nexport function registerTagsTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n // ── CRUD ────────────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'tags_list')),\n {\n title: 'List Tags',\n description:\n 'List tags in the currently-bound workspace, with optional scope/search filters and pagination. Returns { items, total, hasMore }.',\n inputSchema: {\n scope: TagScopeEnum.optional().describe('Filter by scope'),\n search: z.string().optional().describe('Free-text search across key/label/description'),\n limit: z.number().optional().describe('Page size (default 100)'),\n offset: z.number().optional().describe('Pagination offset (default 0)'),\n },\n },\n async ({ scope, search, limit, offset }) => {\n try {\n const wctx = resolveWorkspaceContext(ctx);\n if (!wctx.ok) return wctx.error;\n\n const filter: Record<string, unknown> = { workspaceId: wctx.ctx.workspaceId };\n if (scope !== undefined) filter.scope = scope;\n if (search !== undefined) filter.search = search;\n\n const data = await ctx.gql.workspace.request<{\n getTags: { items: TagRow[]; total: number; hasMore: boolean };\n }>(ops.LIST_TAGS, {\n filter,\n pagination: { limit: limit ?? 100, offset: offset ?? 0 },\n });\n return jsonResult(data.getTags);\n } catch (error) {\n ctx.logger.error('tags_list failed', { error: String(error) });\n return errorResult(\n `Failed to list tags: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'tags_get')),\n {\n title: 'Get Tag',\n description:\n 'Fetch a single tag by ID. Returns the full detail shape (color, icon, hierarchy, usage counters).',\n inputSchema: { id: z.string().describe('Tag ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.workspace.request<{ getTag: TagDetail | null }>(ops.GET_TAG, {\n id,\n });\n if (!data.getTag) {\n return errorResult(`Tag ${id} not found`);\n }\n return jsonResult(data.getTag);\n } catch (error) {\n ctx.logger.error('tags_get failed', { error: String(error) });\n return errorResult(\n `Failed to get tag: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'tags_create')),\n {\n title: 'Create Tag',\n description:\n 'Create a tag in the currently-bound workspace. `key` must be unique within the (workspace, scope) tuple; `label` is the human-readable display name.',\n inputSchema: {\n key: z\n .string()\n .min(1)\n .describe('Stable identifier (kebab-case recommended); unique within workspace+scope'),\n label: z.string().min(1).describe('Human-readable display name'),\n description: z.string().optional().describe('Free-form description'),\n color: z\n .string()\n .optional()\n .describe('Hex color (e.g. #ff8800) — must be a semantic theme token in UI'),\n icon: z.string().optional().describe('Icon name (lucide-react identifier)'),\n scope: TagScopeEnum.optional().describe('Tag scope (default WORKSPACE)'),\n parentId: z.string().optional().describe('Parent tag ID for hierarchical taxonomies'),\n },\n },\n async ({ key, label, description, color, icon, scope, parentId }) => {\n try {\n const wctx = resolveWorkspaceContext(ctx);\n if (!wctx.ok) return wctx.error;\n\n const input: Record<string, unknown> = {\n context: wctx.ctx,\n key,\n label,\n scope: scope ?? 'WORKSPACE',\n };\n if (description !== undefined) input.description = description;\n if (color !== undefined) input.color = color;\n if (icon !== undefined) input.icon = icon;\n if (parentId !== undefined) input.parentId = parentId;\n\n const data = await ctx.gql.workspace.request<{ createTag: TagRow }>(ops.CREATE_TAG, {\n input,\n });\n return jsonResult(data.createTag);\n } catch (error) {\n ctx.logger.error('tags_create failed', { error: String(error) });\n return errorResult(\n `Failed to create tag: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'tags_update')),\n {\n title: 'Update Tag',\n description:\n 'Update a tag. At least one mutable field (label / description / color / icon / parentId / displayOrder) must be provided. The workspace context is implicit.',\n inputSchema: {\n id: z.string().describe('Tag ID'),\n label: z.string().optional().describe('Updated display name'),\n description: z\n .string()\n .optional()\n .describe('Updated description (pass empty string to clear)'),\n color: z.string().optional().describe('Updated hex color'),\n icon: z.string().optional().describe('Updated icon name'),\n parentId: z.string().optional().describe('Updated parent tag ID'),\n displayOrder: z\n .number()\n .int()\n .optional()\n .describe('Updated display order within parent (lower sorts first)'),\n },\n },\n async ({ id, label, description, color, icon, parentId, displayOrder }) => {\n try {\n const wctx = resolveWorkspaceContext(ctx);\n if (!wctx.ok) return wctx.error;\n\n const input: Record<string, unknown> = { context: wctx.ctx };\n if (label !== undefined) input.label = label;\n if (description !== undefined) input.description = description;\n if (color !== undefined) input.color = color;\n if (icon !== undefined) input.icon = icon;\n if (parentId !== undefined) input.parentId = parentId;\n if (displayOrder !== undefined) input.displayOrder = displayOrder;\n\n // `context` is always present so length === 1 means no real updates.\n if (Object.keys(input).length === 1) {\n return errorResult(\n 'No updates specified — provide at least one of label/description/color/icon/parentId/displayOrder',\n );\n }\n\n const data = await ctx.gql.workspace.request<{ updateTag: TagRow }>(ops.UPDATE_TAG, {\n id,\n input,\n });\n return jsonResult(data.updateTag);\n } catch (error) {\n ctx.logger.error('tags_update failed', { error: String(error) });\n return errorResult(\n `Failed to update tag: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'tags_delete')),\n {\n title: 'Delete Tag',\n description:\n 'Permanently delete a tag and all its assignments. This is destructive — there is no soft-delete on the tags service.',\n inputSchema: { id: z.string().describe('Tag ID to delete') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.workspace.request<{ deleteTag: boolean }>(ops.DELETE_TAG, {\n id,\n });\n return jsonResult({ deleted: data.deleteTag, tagId: id });\n } catch (error) {\n ctx.logger.error('tags_delete failed', { error: String(error) });\n return errorResult(\n `Failed to delete tag: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Analytics ───────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'tags_analytics')),\n {\n title: 'Tag Usage Analytics',\n description:\n 'Time-bucketed analytics for a tag: assignmentCount, uniqueUsers, uniqueEntities, and entityType breakdown over the [from, to] window.',\n inputSchema: {\n tagId: z.string().describe('Tag ID to analyse'),\n from: z.string().describe('Start of the window in ISO-8601 (DateTime)'),\n to: z.string().describe('End of the window in ISO-8601 (DateTime)'),\n },\n },\n async ({ tagId, from, to }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n getTagAnalytics: Record<string, unknown>;\n }>(ops.TAG_ANALYTICS, { tagId, startDate: from, endDate: to });\n return jsonResult(data.getTagAnalytics);\n } catch (error) {\n ctx.logger.error('tags_analytics failed', { error: String(error) });\n return errorResult(\n `Failed to get tag analytics: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Relations (CLI's \"permissions\" group is named for the user-facing\n // semantic — under the hood these are tag-relation mutations) ──────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'tags_permissions_list')),\n {\n title: 'List Tag Relations',\n description:\n 'List all tag relations originating from the given tag (synonyms, hierarchy, implies/excludes, etc.).',\n inputSchema: { tagId: z.string().describe('Tag ID') },\n },\n async ({ tagId }) => {\n try {\n const data = await ctx.gql.workspace.request<{ getRelatedTags: RelatedTag[] }>(\n ops.TAG_RELATIONS,\n { tagId },\n );\n return jsonResult(data.getRelatedTags);\n } catch (error) {\n ctx.logger.error('tags_permissions_list failed', { error: String(error) });\n return errorResult(\n `Failed to list tag relations: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'tags_permissions_grant')),\n {\n title: 'Create Tag Relation',\n description:\n 'Create a typed relation between two tags. Set bidirectional=true to mirror the relation in both directions (only meaningful for symmetric types like SYNONYM, ANTONYM, RELATED).',\n inputSchema: {\n fromTagId: z.string().describe('Source tag ID'),\n toTagId: z.string().describe('Target tag ID'),\n relationType: TagRelationTypeEnum.describe('Relation type'),\n bidirectional: z\n .boolean()\n .optional()\n .describe('Mirror the relation in the reverse direction (default false)'),\n },\n },\n async ({ fromTagId, toTagId, relationType, bidirectional }) => {\n try {\n const wctx = resolveWorkspaceContext(ctx);\n if (!wctx.ok) return wctx.error;\n\n const input: Record<string, unknown> = {\n context: wctx.ctx,\n fromTagId,\n toTagId,\n relationType,\n bidirectional: bidirectional ?? false,\n };\n const data = await ctx.gql.workspace.request<{\n createTagRelation: Record<string, unknown>;\n }>(ops.CREATE_TAG_RELATION, { input });\n return jsonResult(data.createTagRelation);\n } catch (error) {\n ctx.logger.error('tags_permissions_grant failed', { error: String(error) });\n return errorResult(\n `Failed to create tag relation: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'tags_permissions_revoke')),\n {\n title: 'Delete Tag Relation',\n description: 'Delete a tag relation by its relation ID.',\n inputSchema: { relationId: z.string().describe('Relation ID to delete') },\n },\n async ({ relationId }) => {\n try {\n const data = await ctx.gql.workspace.request<{ deleteTagRelation: boolean }>(\n ops.DELETE_TAG_RELATION,\n { id: relationId },\n );\n return jsonResult({ deleted: data.deleteTagRelation, relationId });\n } catch (error) {\n ctx.logger.error('tags_permissions_revoke failed', { error: String(error) });\n return errorResult(\n `Failed to delete tag relation: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n}\n","/**\n * Tags module — CANONICAL reference module per CLAUDE.md.\n *\n * Tools: <product>_tags_{list,get,create,update,delete,analytics} +\n * <product>_tags_relations_{list,grant,revoke}.\n *\n * Backend: ~/products/wspace/tags/wspace-tags-svc/.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { McpContext, McpModule, ModuleRegistration } from '../../core/index.js';\nimport { registerTagsTools } from './tools.js';\n\nconst tagsModule: McpModule = {\n id: 'tags',\n version: '0.0.1',\n displayName: 'Tags',\n dependsOn: ['auth'],\n capabilities: { tools: {} },\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 registerTagsTools(server, ctx, track);\n return { tools, resources: [], prompts: [] };\n },\n};\n\nexport default tagsModule;\n"]}
1
+ {"version":3,"sources":["../../../src/core/errors.ts","../../../src/core/tool-name.ts","../../../src/core/result.ts","../../../src/modules/tags/operations.ts","../../../src/modules/tags/tools.ts","../../../src/modules/tags/index.ts"],"names":["z"],"mappings":";;;;;;;;;;;AA8BO,IAAM,gBAAA,GAAN,cAA+B,KAAA,CAAM;AAAA,EACjB,KAAA;AAAA,EAEzB,WAAA,CAAY,SAA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Content":["/**\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","/**\n * Tags module GraphQL operations — CRUD + analytics + relations.\n * Ported verbatim from cli-sdk/src/modules/tags/operations.ts.\n *\n * Backend: ~/products/wspace/tags/wspace-tags-svc/.\n * Hive service name: `tags` (boundary prefix + `-svc` suffix stripped).\n */\n\nexport const LIST_TAGS = `\n query TagsList($filter: TagFilterInput, $pagination: TagsPaginationInput) {\n getTags(filter: $filter, pagination: $pagination) {\n items { id key label description scope displayOrder }\n total hasMore\n }\n }\n`;\n\nexport const GET_TAG = `\n query GetTag($id: ID!) {\n getTag(id: $id) {\n id key label description color icon scope vocabularyId parentId\n displayOrder assignmentCount usageCount hierarchyLevel hierarchyPath\n }\n }\n`;\n\nexport const CREATE_TAG = `\n mutation CreateTag($input: CreateTagInput!) {\n createTag(input: $input) {\n id key label description scope displayOrder createdAt\n }\n }\n`;\n\nexport const UPDATE_TAG = `\n mutation UpdateTag($id: ID!, $input: UpdateTagInput!) {\n updateTag(id: $id, input: $input) {\n id label description color icon parentId displayOrder updatedAt\n }\n }\n`;\n\nexport const DELETE_TAG = `\n mutation DeleteTag($id: ID!) {\n deleteTag(id: $id)\n }\n`;\n\nexport const TAG_ANALYTICS = `\n query TagAnalytics($tagId: ID!, $startDate: DateTime!, $endDate: DateTime!) {\n getTagAnalytics(tagId: $tagId, startDate: $startDate, endDate: $endDate) {\n assignmentCount date entityTypeBreakdown uniqueUsers uniqueEntities\n }\n }\n`;\n\nexport const TAG_RELATIONS = `\n query GetRelatedTags($tagId: ID!) {\n getRelatedTags(tagId: $tagId) {\n tag { id label }\n relationType\n }\n }\n`;\n\nexport const CREATE_TAG_RELATION = `\n mutation CreateTagRelation($input: CreateTagRelationInput!) {\n createTagRelation(input: $input) {\n id fromTagId toTagId relationType bidirectional\n }\n }\n`;\n\nexport const DELETE_TAG_RELATION = `\n mutation DeleteTagRelation($id: ID!) {\n deleteTagRelation(id: $id)\n }\n`;\n","/**\n * Tags MCP tools — CANONICAL reference module per CLAUDE.md.\n *\n * Surface (6 tools + 3 relation tools = 9): CRUD + analytics + relations.{list,grant,revoke}.\n * Mirrors cli-sdk/src/modules/tags/commands.ts (\"tags permissions\" Commander group ↔\n * the relation tools below — the underlying mutations are the same; \"permissions\"\n * is the user-facing surface name on the CLI side).\n *\n * Quality bar:\n * - Tight zod enums for every backend enum (TagScope, TagRelationType)\n * - Descriptive title + description on every tool (Claude Desktop renders these)\n * - Detailed `.describe()` on every input field for tool-call grounding\n * - Workspace-context guard surfaces a precise re-auth hint via errorResult\n * - Strict types: no `any`; `unknown` + cast only at request boundaries\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 TagRow {\n id: string;\n key: string;\n label: string;\n description?: string | null;\n scope?: string;\n displayOrder?: number;\n}\n\ninterface TagDetail extends TagRow {\n color?: string | null;\n icon?: string | null;\n vocabularyId?: string | null;\n parentId?: string | null;\n assignmentCount?: number;\n usageCount?: number;\n hierarchyLevel?: number;\n hierarchyPath?: string[];\n}\n\ninterface RelatedTag {\n tag: { id: string; label: string };\n relationType: string;\n}\n\nconst TagScopeEnum = z\n .enum(['WORKSPACE', 'GLOBAL', 'VIBE'])\n .describe('Visibility scope of the tag');\n\nconst TagRelationTypeEnum = z\n .enum(['SYNONYM', 'ANTONYM', 'BROADER', 'NARROWER', 'RELATED', 'IMPLIES', 'EXCLUDES'])\n .describe(\n 'Semantic relationship between two tags (SYNONYM = same-meaning, BROADER/NARROWER = hierarchy, IMPLIES/EXCLUDES = behaviour, RELATED = generic)',\n );\n\ninterface WorkspaceCtx {\n workspaceId: string;\n}\n\n/**\n * Resolve the bound workspace context from the auth store. The tags service\n * requires `context.workspaceId` on every mutation input.\n *\n * Returns `errorResult` shape via the `error` channel when no workspace is\n * bound — the caller MUST short-circuit on that signal.\n */\nfunction resolveWorkspaceContext(\n ctx: McpContext,\n): { ok: true; ctx: WorkspaceCtx } | { ok: false; error: ReturnType<typeof errorResult> } {\n const auth = ctx.auth.read();\n const workspaceId = auth?.workspaceId;\n if (!workspaceId) {\n return {\n ok: false,\n error: errorResult(\n 'No workspace selected. Bind one with <product>_auth_select_workspace before calling tag tools.',\n ),\n };\n }\n return { ok: true, ctx: { workspaceId } };\n}\n\nexport function registerTagsTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n // ── CRUD ────────────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'tags_list')),\n {\n title: 'List Tags',\n description:\n 'List tags in the currently-bound workspace, with optional scope/search filters and pagination. Returns { items, total, hasMore }.',\n inputSchema: {\n scope: TagScopeEnum.optional().describe('Filter by scope'),\n search: z.string().optional().describe('Free-text search across key/label/description'),\n limit: z.number().optional().describe('Page size (default 100)'),\n offset: z.number().optional().describe('Pagination offset (default 0)'),\n },\n },\n async ({ scope, search, limit, offset }) => {\n try {\n const wctx = resolveWorkspaceContext(ctx);\n if (!wctx.ok) return wctx.error;\n\n const filter: Record<string, unknown> = { workspaceId: wctx.ctx.workspaceId };\n if (scope !== undefined) filter.scope = scope;\n if (search !== undefined) filter.search = search;\n\n const data = await ctx.gql.workspace.request<{\n getTags: { items: TagRow[]; total: number; hasMore: boolean };\n }>(ops.LIST_TAGS, {\n filter,\n pagination: { limit: limit ?? 100, offset: offset ?? 0 },\n });\n return jsonResult(data.getTags);\n } catch (error) {\n ctx.logger.error('tags_list failed', { error: String(error) });\n return errorResult(\n `Failed to list tags: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'tags_get')),\n {\n title: 'Get Tag',\n description:\n 'Fetch a single tag by ID. Returns the full detail shape (color, icon, hierarchy, usage counters).',\n inputSchema: { id: z.string().describe('Tag ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.workspace.request<{ getTag: TagDetail | null }>(ops.GET_TAG, {\n id,\n });\n if (!data.getTag) {\n return errorResult(`Tag ${id} not found`);\n }\n return jsonResult(data.getTag);\n } catch (error) {\n ctx.logger.error('tags_get failed', { error: String(error) });\n return errorResult(\n `Failed to get tag: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'tags_create')),\n {\n title: 'Create Tag',\n description:\n 'Create a tag in the currently-bound workspace. `key` must be unique within the (workspace, scope) tuple; `label` is the human-readable display name.',\n inputSchema: {\n key: z\n .string()\n .min(1)\n .describe('Stable identifier (kebab-case recommended); unique within workspace+scope'),\n label: z.string().min(1).describe('Human-readable display name'),\n description: z.string().optional().describe('Free-form description'),\n color: z\n .string()\n .optional()\n .describe('Hex color (e.g. #ff8800) — must be a semantic theme token in UI'),\n icon: z.string().optional().describe('Icon name (lucide-react identifier)'),\n scope: TagScopeEnum.optional().describe('Tag scope (default WORKSPACE)'),\n parentId: z.string().optional().describe('Parent tag ID for hierarchical taxonomies'),\n },\n },\n async ({ key, label, description, color, icon, scope, parentId }) => {\n try {\n const wctx = resolveWorkspaceContext(ctx);\n if (!wctx.ok) return wctx.error;\n\n const input: Record<string, unknown> = {\n context: wctx.ctx,\n key,\n label,\n scope: scope ?? 'WORKSPACE',\n };\n if (description !== undefined) input.description = description;\n if (color !== undefined) input.color = color;\n if (icon !== undefined) input.icon = icon;\n if (parentId !== undefined) input.parentId = parentId;\n\n const data = await ctx.gql.workspace.request<{ createTag: TagRow }>(ops.CREATE_TAG, {\n input,\n });\n return jsonResult(data.createTag);\n } catch (error) {\n ctx.logger.error('tags_create failed', { error: String(error) });\n return errorResult(\n `Failed to create tag: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'tags_update')),\n {\n title: 'Update Tag',\n description:\n 'Update a tag. At least one mutable field (label / description / color / icon / parentId / displayOrder) must be provided. The workspace context is implicit.',\n inputSchema: {\n id: z.string().describe('Tag ID'),\n label: z.string().optional().describe('Updated display name'),\n description: z\n .string()\n .optional()\n .describe('Updated description (pass empty string to clear)'),\n color: z.string().optional().describe('Updated hex color'),\n icon: z.string().optional().describe('Updated icon name'),\n parentId: z.string().optional().describe('Updated parent tag ID'),\n displayOrder: z\n .number()\n .int()\n .optional()\n .describe('Updated display order within parent (lower sorts first)'),\n },\n },\n async ({ id, label, description, color, icon, parentId, displayOrder }) => {\n try {\n const wctx = resolveWorkspaceContext(ctx);\n if (!wctx.ok) return wctx.error;\n\n const input: Record<string, unknown> = { context: wctx.ctx };\n if (label !== undefined) input.label = label;\n if (description !== undefined) input.description = description;\n if (color !== undefined) input.color = color;\n if (icon !== undefined) input.icon = icon;\n if (parentId !== undefined) input.parentId = parentId;\n if (displayOrder !== undefined) input.displayOrder = displayOrder;\n\n // `context` is always present so length === 1 means no real updates.\n if (Object.keys(input).length === 1) {\n return errorResult(\n 'No updates specified — provide at least one of label/description/color/icon/parentId/displayOrder',\n );\n }\n\n const data = await ctx.gql.workspace.request<{ updateTag: TagRow }>(ops.UPDATE_TAG, {\n id,\n input,\n });\n return jsonResult(data.updateTag);\n } catch (error) {\n ctx.logger.error('tags_update failed', { error: String(error) });\n return errorResult(\n `Failed to update tag: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'tags_delete')),\n {\n title: 'Delete Tag',\n description:\n 'Permanently delete a tag and all its assignments. This is destructive — there is no soft-delete on the tags service.',\n inputSchema: { id: z.string().describe('Tag ID to delete') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.workspace.request<{ deleteTag: boolean }>(ops.DELETE_TAG, {\n id,\n });\n return jsonResult({ deleted: data.deleteTag, tagId: id });\n } catch (error) {\n ctx.logger.error('tags_delete failed', { error: String(error) });\n return errorResult(\n `Failed to delete tag: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Analytics ───────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'tags_analytics')),\n {\n title: 'Tag Usage Analytics',\n description:\n 'Time-bucketed analytics for a tag: assignmentCount, uniqueUsers, uniqueEntities, and entityType breakdown over the [from, to] window.',\n inputSchema: {\n tagId: z.string().describe('Tag ID to analyse'),\n from: z.string().describe('Start of the window in ISO-8601 (DateTime)'),\n to: z.string().describe('End of the window in ISO-8601 (DateTime)'),\n },\n },\n async ({ tagId, from, to }) => {\n try {\n const data = await ctx.gql.workspace.request<{\n getTagAnalytics: Record<string, unknown>;\n }>(ops.TAG_ANALYTICS, { tagId, startDate: from, endDate: to });\n return jsonResult(data.getTagAnalytics);\n } catch (error) {\n ctx.logger.error('tags_analytics failed', { error: String(error) });\n return errorResult(\n `Failed to get tag analytics: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Relations (CLI's \"permissions\" group is named for the user-facing\n // semantic — under the hood these are tag-relation mutations) ──────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'tags_permissions_list')),\n {\n title: 'List Tag Relations',\n description:\n 'List all tag relations originating from the given tag (synonyms, hierarchy, implies/excludes, etc.).',\n inputSchema: { tagId: z.string().describe('Tag ID') },\n },\n async ({ tagId }) => {\n try {\n const data = await ctx.gql.workspace.request<{ getRelatedTags: RelatedTag[] }>(\n ops.TAG_RELATIONS,\n { tagId },\n );\n return jsonResult(data.getRelatedTags);\n } catch (error) {\n ctx.logger.error('tags_permissions_list failed', { error: String(error) });\n return errorResult(\n `Failed to list tag relations: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'tags_permissions_grant')),\n {\n title: 'Create Tag Relation',\n description:\n 'Create a typed relation between two tags. Set bidirectional=true to mirror the relation in both directions (only meaningful for symmetric types like SYNONYM, ANTONYM, RELATED).',\n inputSchema: {\n fromTagId: z.string().describe('Source tag ID'),\n toTagId: z.string().describe('Target tag ID'),\n relationType: TagRelationTypeEnum.describe('Relation type'),\n bidirectional: z\n .boolean()\n .optional()\n .describe('Mirror the relation in the reverse direction (default false)'),\n },\n },\n async ({ fromTagId, toTagId, relationType, bidirectional }) => {\n try {\n const wctx = resolveWorkspaceContext(ctx);\n if (!wctx.ok) return wctx.error;\n\n const input: Record<string, unknown> = {\n context: wctx.ctx,\n fromTagId,\n toTagId,\n relationType,\n bidirectional: bidirectional ?? false,\n };\n const data = await ctx.gql.workspace.request<{\n createTagRelation: Record<string, unknown>;\n }>(ops.CREATE_TAG_RELATION, { input });\n return jsonResult(data.createTagRelation);\n } catch (error) {\n ctx.logger.error('tags_permissions_grant failed', { error: String(error) });\n return errorResult(\n `Failed to create tag relation: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'tags_permissions_revoke')),\n {\n title: 'Delete Tag Relation',\n description: 'Delete a tag relation by its relation ID.',\n inputSchema: { relationId: z.string().describe('Relation ID to delete') },\n },\n async ({ relationId }) => {\n try {\n const data = await ctx.gql.workspace.request<{ deleteTagRelation: boolean }>(\n ops.DELETE_TAG_RELATION,\n { id: relationId },\n );\n return jsonResult({ deleted: data.deleteTagRelation, relationId });\n } catch (error) {\n ctx.logger.error('tags_permissions_revoke failed', { error: String(error) });\n return errorResult(\n `Failed to delete tag relation: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n}\n","/**\n * Tags module — CANONICAL reference module per CLAUDE.md.\n *\n * Tools: <product>_tags_{list,get,create,update,delete,analytics} +\n * <product>_tags_relations_{list,grant,revoke}.\n *\n * Backend: ~/products/wspace/tags/wspace-tags-svc/.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { McpContext, McpModule, ModuleRegistration } from '../../core/index.js';\nimport { registerTagsTools } from './tools.js';\n\nconst tagsModule: McpModule = {\n id: 'tags',\n version: '0.0.1',\n displayName: 'Tags',\n dependsOn: ['auth'],\n capabilities: { tools: {} },\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 registerTagsTools(server, ctx, track);\n return { tools, resources: [], prompts: [] };\n },\n};\n\nexport default tagsModule;\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/tags/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/technospam/operations.ts
66
66
  var COURSE_FIELDS = `
67
67
  id slug title summary topic level status estimatedMinutes instructorId