@burdenoff/mcp-libs 2026.1031.2 → 2026.1101.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/dist/{chunk-FVLIANOQ.js → chunk-LUXDBCVJ.js} +3 -3
  2. package/dist/{chunk-FVLIANOQ.js.map → chunk-LUXDBCVJ.js.map} +1 -1
  3. package/dist/{chunk-76RGHRRS.js → chunk-WYCRYHHY.js} +83 -33
  4. package/dist/chunk-WYCRYHHY.js.map +1 -0
  5. package/dist/core/auth/store.d.ts +1 -0
  6. package/dist/core/gql/client.d.ts +6 -0
  7. package/dist/core/index.cjs +83 -30
  8. package/dist/core/index.cjs.map +1 -1
  9. package/dist/core/index.d.ts +2 -2
  10. package/dist/core/index.js +1 -1
  11. package/dist/index.cjs +80 -30
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.js +1 -1
  14. package/dist/modules/adaptercloud/index.js +1 -1
  15. package/dist/modules/artistrybase/index.js +1 -1
  16. package/dist/modules/assethandler/index.js +1 -1
  17. package/dist/modules/atheletebridge/index.js +1 -1
  18. package/dist/modules/auth/index.cjs +1 -1
  19. package/dist/modules/auth/index.cjs.map +1 -1
  20. package/dist/modules/auth/index.js +4 -4
  21. package/dist/modules/auth/index.js.map +1 -1
  22. package/dist/modules/auth/operations.d.ts +2 -2
  23. package/dist/modules/billing/index.cjs +45 -19
  24. package/dist/modules/billing/index.cjs.map +1 -1
  25. package/dist/modules/billing/index.js +46 -20
  26. package/dist/modules/billing/index.js.map +1 -1
  27. package/dist/modules/billing/operations.d.ts +4 -4
  28. package/dist/modules/brainyrich/index.js +1 -1
  29. package/dist/modules/buildmyiq/index.js +1 -1
  30. package/dist/modules/channels/index.cjs +0 -35
  31. package/dist/modules/channels/index.cjs.map +1 -1
  32. package/dist/modules/channels/index.js +1 -36
  33. package/dist/modules/channels/index.js.map +1 -1
  34. package/dist/modules/channels/operations.d.ts +0 -1
  35. package/dist/modules/collabkin/index.js +1 -1
  36. package/dist/modules/comradecircle/index.js +1 -1
  37. package/dist/modules/conversations/index.cjs +6 -6
  38. package/dist/modules/conversations/index.cjs.map +1 -1
  39. package/dist/modules/conversations/index.js +7 -7
  40. package/dist/modules/conversations/index.js.map +1 -1
  41. package/dist/modules/conversations/operations.d.ts +1 -1
  42. package/dist/modules/coolandlovely/index.js +1 -1
  43. package/dist/modules/cosmicintersection/index.js +1 -1
  44. package/dist/modules/crewfoundry/index.js +1 -1
  45. package/dist/modules/devportal/index.js +1 -1
  46. package/dist/modules/ecoimpacthub/index.js +1 -1
  47. package/dist/modules/eventfullymanaged/index.js +1 -1
  48. package/dist/modules/export/index.js +1 -1
  49. package/dist/modules/files/index.cjs +421 -101
  50. package/dist/modules/files/index.cjs.map +1 -1
  51. package/dist/modules/files/index.js +412 -97
  52. package/dist/modules/files/index.js.map +1 -1
  53. package/dist/modules/files/operations.d.ts +9 -8
  54. package/dist/modules/files/tools.d.ts +2 -0
  55. package/dist/modules/fluidgrids/index.js +1 -1
  56. package/dist/modules/ggnomad/index.js +1 -1
  57. package/dist/modules/govcitizenhub/index.js +1 -1
  58. package/dist/modules/groups/index.js +1 -1
  59. package/dist/modules/headshotmarketing/index.js +1 -1
  60. package/dist/modules/health/index.js +1 -1
  61. package/dist/modules/healthybowl/index.js +1 -1
  62. package/dist/modules/hookmovies/index.js +1 -1
  63. package/dist/modules/housingvista/index.js +1 -1
  64. package/dist/modules/integrations/index.js +1 -1
  65. package/dist/modules/intelwatchtower/index.js +1 -1
  66. package/dist/modules/kadaikodi/index.js +1 -1
  67. package/dist/modules/labsofscience/index.js +1 -1
  68. package/dist/modules/manufacturedops/index.js +1 -1
  69. package/dist/modules/movethewheels/index.js +1 -1
  70. package/dist/modules/mybodyshield/index.js +1 -1
  71. package/dist/modules/notifications/index.js +1 -1
  72. package/dist/modules/organizations/index.js +1 -1
  73. package/dist/modules/planmagnet/index.js +1 -1
  74. package/dist/modules/products/index.cjs +1 -1
  75. package/dist/modules/products/index.cjs.map +1 -1
  76. package/dist/modules/products/index.js +2 -2
  77. package/dist/modules/products/index.js.map +1 -1
  78. package/dist/modules/products/operations.d.ts +1 -1
  79. package/dist/modules/proserviceworld/index.js +1 -1
  80. package/dist/modules/rbac/index.cjs +0 -64
  81. package/dist/modules/rbac/index.cjs.map +1 -1
  82. package/dist/modules/rbac/index.js +1 -65
  83. package/dist/modules/rbac/index.js.map +1 -1
  84. package/dist/modules/rbac/operations.d.ts +0 -2
  85. package/dist/modules/sandbox/index.js +1 -1
  86. package/dist/modules/scheduler/index.cjs +4 -4
  87. package/dist/modules/scheduler/index.cjs.map +1 -1
  88. package/dist/modules/scheduler/index.js +5 -5
  89. package/dist/modules/scheduler/index.js.map +1 -1
  90. package/dist/modules/scheduler/operations.d.ts +3 -3
  91. package/dist/modules/security/index.js +1 -1
  92. package/dist/modules/semanticfed/index.js +1 -1
  93. package/dist/modules/store/index.js +1 -1
  94. package/dist/modules/subscriberbot/index.js +1 -1
  95. package/dist/modules/support/index.js +1 -1
  96. package/dist/modules/tags/index.cjs +454 -48
  97. package/dist/modules/tags/index.cjs.map +1 -1
  98. package/dist/modules/tags/index.js +443 -42
  99. package/dist/modules/tags/index.js.map +1 -1
  100. package/dist/modules/tags/operations.d.ts +10 -6
  101. package/dist/modules/tags/tools.d.ts +1 -1
  102. package/dist/modules/technospam/index.js +1 -1
  103. package/dist/modules/theculturepost/index.js +1 -1
  104. package/dist/modules/theglobalfuel/index.js +1 -1
  105. package/dist/modules/timecampus/index.js +1 -1
  106. package/dist/modules/tours/index.js +1 -1
  107. package/dist/modules/vibecontrols/index.cjs +8 -8
  108. package/dist/modules/vibecontrols/index.cjs.map +1 -1
  109. package/dist/modules/vibecontrols/index.js +10 -10
  110. package/dist/modules/vibecontrols/index.js.map +1 -1
  111. package/dist/modules/workspaces/index.cjs +235 -5
  112. package/dist/modules/workspaces/index.cjs.map +1 -1
  113. package/dist/modules/workspaces/index.js +224 -6
  114. package/dist/modules/workspaces/index.js.map +1 -1
  115. package/dist/modules/workspaces/operations.d.ts +2 -2
  116. package/dist/modules/workspaces/prompts.d.ts +3 -0
  117. package/dist/modules/workspaces/resources.d.ts +4 -0
  118. package/package.json +1 -1
  119. package/dist/chunk-76RGHRRS.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/errors.ts","../../../src/core/tool-name.ts","../../../src/core/result.ts","../../../src/modules/tags/tools.ts","../../../src/modules/tags/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AA8BO,IAAM,gBAAA,GAAN,cAA+B,KAAA,CAAM;AAAA,EACjB,KAAA;AAAA,EAEzB,WAAA,CAAY,SAAiB,KAAA,EAAiB;AAC5C,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,kBAAA;AACZ,IAAA,IAAA,CAAK,KAAA,GAAQ,KAAA;AAAA,EACf;AACF,CAAA;;;AC1BA,IAAM,oBAAA,GAAuB,EAAA;AAE7B,SAAS,cAAA,CAAe,MAAc,IAAA,EAA8C;AAClF,EAAA,IAAuB,IAAA,CAAK,MAAA,GAAS,oBAAA,EAAsB;AACzD,IAAA,MAAM,IAAI,gBAAA;AAAA,MACR,CAAA,WAAA,EAAc,IAAI,CAAA,UAAA,EAAa,oBAAoB,CAAA,8CAAA;AAAA,KACrD;AAAA,EACF;AACA,EAAA,OAAO,IAAA;AACT;AAMO,SAAS,WAAA,CAAY,gBAAwB,KAAA,EAAyB;AAC3E,EAAA,IAAI,CAAC,WAAA,EAAa;AAChB,IAAA,MAAM,IAAI,iBAAiB,sCAAsC,CAAA;AAAA,EACnE;AACA,EAAA,MAAM,IAAA,GAAO,CAAC,WAAA,EAAa,GAAG,KAAK,EAAE,MAAA,CAAO,OAAO,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA;AAC7D,EAAA,OAAO,cAAA,CAAe,IAAY,CAAA;AACpC;;;AC4BO,SAAS,WAAA,CAAY,SAAiB,IAAA,EAA2B;AACt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A,EAA0B,sBAAA,EAAwB,yBAAyB,CAAA;AAAA,IAC5E,CAAC,yBAAA,EAA2B,uBAAA,EAAyB,0BAA0B;AAAA,GACjF;AACA,EAAA,KAAA,MAAW,CAAC,IAAA,EAAM,KAAA,EAAO,IAAI,KAAK,KAAA,EAAO;AACvC,IAAA,WAAA;AAAA,MACE,MAAA;AAAA,MACA,KAAA,CAAM,WAAA,CAAY,IAAA,CAAK,WAAA,EAAa,IAAI,CAAC,CAAA;AAAA,MACzC,KAAA;AAAA,MACA,IAAA;AAAA,MACA,WAAA;AAAA,MACA,EAAC;AAAA,MACD;AAAA,KACF;AAAA,EACF;AACF;;;AC3DA,IAAM,UAAA,GAAwB;AAAA,EAC5B,EAAA,EAAI,MAAA;AAAA,EACJ,OAAA,EAAS,OAAA;AAAA,EACT,WAAA,EAAa,MAAA;AAAA,EACb,SAAA,EAAW,CAAC,MAAM,CAAA;AAAA,EAClB,YAAA,EAAc,EAAE,KAAA,EAAO,EAAC,EAAE;AAAA,EAC1B,QAAA,CAAS,QAAmB,GAAA,EAAqC;AAC/D,IAAA,MAAM,QAAkB,EAAC;AACzB,IAAA,MAAM,KAAA,GAAQ,CAAC,CAAA,KAAsB;AACnC,MAAA,KAAA,CAAM,KAAK,CAAC,CAAA;AACZ,MAAA,OAAO,CAAA;AAAA,IACT,CAAA;AACA,IAAA,iBAAA,CAAkB,MAAA,EAAQ,KAAK,KAAK,CAAA;AACpC,IAAA,OAAO,EAAE,KAAA,EAAO,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 * 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 * The destructive verb set covers more than `delete`: stopping, killing or\n * terminating a running process, revoking or rotating a credential/share,\n * resetting settings and removing/purging/uninstalling are all actions an\n * MCP client must not auto-run without the user's intent (VC/FG parity G57 —\n * e.g. `vibecontrols_sessions_kill`, `vibecontrols_tunnels_rotate_credentials`\n * were previously reported as non-destructive).\n *\n * A module can always override the inference by passing an explicit\n * `annotations` object to `registerTool()` / `server.registerTool()` — do\n * that for the rare verb match that is harmless (e.g. a typing indicator's\n * `typing_stop`).\n */\nexport const DESTRUCTIVE_NAME_VERBS = [\n 'delete',\n 'destroy',\n 'erase',\n 'kill',\n 'purge',\n 'remove',\n 'reset',\n 'revoke',\n 'rotate',\n 'stop',\n 'terminate',\n 'uninstall',\n 'wipe',\n] as const;\nconst DESTRUCTIVE_NAME_SEGMENT = new RegExp(\n `(?:^|_)(?:${DESTRUCTIVE_NAME_VERBS.join('|')})(?:_|$)`,\n 'i',\n);\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 } } | 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","import { z } from 'zod';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { errorResult, mcpToolName, type McpContext } from '../../core/index.js';\n\ntype StubInputSchema = Record<string, z.ZodTypeAny>;\nfunction stubbedTool(\n server: McpServer,\n toolName: string,\n title: string,\n description: string,\n featureNote: string,\n inputSchema: StubInputSchema,\n altSuggestions: string[],\n): void {\n server.registerTool(\n toolName,\n {\n title,\n description: `${description} [STUB]`,\n inputSchema,\n },\n async () =>\n errorResult(\n `[stubbed] ${featureNote} Use ${altSuggestions.join(', ')} instead. The tool remains registered so callers receive a meaningful response instead of a schema-validation error.`,\n ),\n );\n}\n\nexport function registerTagsTools(\n server: McpServer,\n _ctx: McpContext,\n track: (n: string) => string,\n): void {\n // BOFF-8201: `Query.tags` on the live alpha gateway is fundamentally\n // broken — even a selection of just `{ name }` returns an\n // INTERNAL_SERVER_ERROR. The whole tags surface is unreachable\n // until alpha ships a fix. Stub all 9 tools so callers get a clean\n // \"[stubbed]\" error and the per-call wiring is in place for the day\n // the tags service recovers.\n const featureNote =\n 'Live alpha has `Query.tags` returning INTERNAL_SERVER_ERROR on even the simplest selection (`{ name }`). The whole tags surface is down until the service recovers.';\n const alts = [\n 'the next alpha release that restores the tags surface',\n 'the SDK tags API (which the MCP will mirror once it lands)',\n ];\n\n const tools: Array<[string, string, string]> = [\n ['tags_list', 'List Tags', 'List tags in the active workspace.'],\n ['tags_get', 'Get Tag', 'Get a tag by ID.'],\n ['tags_create', 'Create Tag', 'Create a new tag (requires `vocabularyId` on alpha).'],\n ['tags_update', 'Update Tag', 'Update an existing tag.'],\n ['tags_delete', 'Delete Tag', 'Delete a tag by ID.'],\n ['tags_analytics', 'Tag Analytics', 'Get analytics for a tag (assignment / usage counts).'],\n [\n 'tags_permissions_list',\n 'List Tag Permissions',\n 'List tag-permission grants in the workspace.',\n ],\n ['tags_permissions_grant', 'Grant Tag Permission', 'Grant a tag permission.'],\n ['tags_permissions_revoke', 'Revoke Tag Permission', 'Revoke a tag permission.'],\n ];\n for (const [tool, title, desc] of tools) {\n stubbedTool(\n server,\n track(mcpToolName(_ctx.productName, tool)),\n title,\n desc,\n featureNote,\n {},\n alts,\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":["message","z"],"mappings":";;;;;;;;;;;;AA8BO,IAAM,gBAAA,GAAN,cAA+B,KAAA,CAAM;AAAA,EACjB,KAAA;AAAA,EAEzB,WAAA,CAAYA,UAAiB,KAAA,EAAiB;AAC5C,IAAA,KAAA,CAAMA,QAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,kBAAA;AACZ,IAAA,IAAA,CAAK,KAAA,GAAQ,KAAA;AAAA,EACf;AACF,CAAA;;;AC1BA,IAAM,oBAAA,GAAuB,EAAA;AAE7B,SAAS,cAAA,CAAe,MAAc,IAAA,EAA8C;AAClF,EAAA,IAAuB,IAAA,CAAK,MAAA,GAAS,oBAAA,EAAsB;AACzD,IAAA,MAAM,IAAI,gBAAA;AAAA,MACR,CAAA,WAAA,EAAc,IAAI,CAAA,UAAA,EAAa,oBAAoB,CAAA,8CAAA;AAAA,KACrD;AAAA,EACF;AACA,EAAA,OAAO,IAAA;AACT;AAMO,SAAS,WAAA,CAAY,gBAAwB,KAAA,EAAyB;AAC3E,EAAA,IAAI,CAAC,WAAA,EAAa;AAChB,IAAA,MAAM,IAAI,iBAAiB,sCAAsC,CAAA;AAAA,EACnE;AACA,EAAA,MAAM,IAAA,GAAO,CAAC,WAAA,EAAa,GAAG,KAAK,EAAE,MAAA,CAAO,OAAO,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA;AAC7D,EAAA,OAAO,cAAA,CAAe,IAAY,CAAA;AACpC;;;ACOO,SAAS,UAAA,CAAW,MAAe,UAAA,EAAkD;AAC1F,EAAA,MA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A,EAAoC,OAAA,CAAQ,KAAK,CAAC,CAAA,CAAE,CAAA;AAAA,MACzE;AAAA,IACF;AAAA,GACF;AACF;;;ACjaA,IAAM,UAAA,GAAwB;AAAA,EAC5B,EAAA,EAAI,MAAA;AAAA,EACJ,OAAA,EAAS,OAAA;AAAA,EACT,WAAA,EAAa,MAAA;AAAA,EACb,SAAA,EAAW,CAAC,MAAM,CAAA;AAAA,EAClB,YAAA,EAAc,EAAE,KAAA,EAAO,EAAC,EAAE;AAAA,EAC1B,QAAA,CAAS,QAAmB,GAAA,EAAqC;AAC/D,IAAA,MAAM,QAAkB,EAAC;AACzB,IAAA,MAAM,KAAA,GAAQ,CAAC,CAAA,KAAsB;AACnC,MAAA,KAAA,CAAM,KAAK,CAAC,CAAA;AACZ,MAAA,OAAO,CAAA;AAAA,IACT,CAAA;AACA,IAAA,iBAAA,CAAkB,MAAA,EAAQ,KAAK,KAAK,CAAA;AACpC,IAAA,OAAO,EAAE,KAAA,EAAO,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 * 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 * The destructive verb set covers more than `delete`: stopping, killing or\n * terminating a running process, revoking or rotating a credential/share,\n * resetting settings and removing/purging/uninstalling are all actions an\n * MCP client must not auto-run without the user's intent (VC/FG parity G57 —\n * e.g. `vibecontrols_sessions_kill`, `vibecontrols_tunnels_rotate_credentials`\n * were previously reported as non-destructive).\n *\n * A module can always override the inference by passing an explicit\n * `annotations` object to `registerTool()` / `server.registerTool()` — do\n * that for the rare verb match that is harmless (e.g. a typing indicator's\n * `typing_stop`).\n */\nexport const DESTRUCTIVE_NAME_VERBS = [\n 'delete',\n 'destroy',\n 'erase',\n 'kill',\n 'purge',\n 'remove',\n 'reset',\n 'revoke',\n 'rotate',\n 'stop',\n 'terminate',\n 'uninstall',\n 'wipe',\n] as const;\nconst DESTRUCTIVE_NAME_SEGMENT = new RegExp(\n `(?:^|_)(?:${DESTRUCTIVE_NAME_VERBS.join('|')})(?:_|$)`,\n 'i',\n);\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 } } | 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 — vocabularies, tag CRUD, analytics,\n * relations and entity assignments on wspace-tags-svc.\n *\n * Backend: ~/products/wspace/tags/wspace-tags-svc/.\n * Hive service name: `tags` (boundary prefix + `-svc` suffix stripped).\n *\n * Every document here is validated against the composed supergraph by\n * tests/unit/platform-supergraph-contract.test.ts (BOFF-4413).\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 vocabularyId parentId displayOrder usageCount }\n total hasMore nextCursor\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 createdAt updatedAt\n }\n }\n`;\n\nexport const LIST_VOCABULARIES = `\n query TagVocabularies($filter: VocabularyFilterInput, $pagination: TagsPaginationInput) {\n getVocabularies(filter: $filter, pagination: $pagination) {\n items {\n id key name description kind scope dataType cardinality\n allowCustomTags predefinedValuesOnly applicableEntityTypes tagCount\n }\n total hasMore nextCursor\n }\n }\n`;\n\nexport const CREATE_TAG = `\n mutation CreateTag($input: CreateTagInput!) {\n createTag(input: $input) {\n id key label description scope vocabularyId parentId 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 date assignmentCount removalCount uniqueUsers uniqueEntities entityTypeBreakdown\n }\n }\n`;\n\nexport const TAG_RELATIONS = `\n query GetRelatedTags($tagId: ID!, $relationType: TagRelationType) {\n getRelatedTags(tagId: $tagId, relationType: $relationType) {\n relationType\n tag { id key label }\n }\n }\n`;\n\nexport const CREATE_TAG_RELATION = `\n mutation CreateTagRelation($input: CreateTagRelationInput!) {\n createTagRelation(input: $input) {\n id fromTagId toTagId relationType bidirectional createdAt\n }\n }\n`;\n\nexport const DELETE_TAG_RELATION = `\n mutation DeleteTagRelation($id: ID!) {\n deleteTagRelation(id: $id)\n }\n`;\n\nexport const ASSIGN_TAG = `\n mutation AssignTag($input: AssignTagInput!) {\n assignTag(input: $input) {\n id tagId entityType entityId source createdAt\n tag { id key label }\n }\n }\n`;\n\nexport const ENTITY_TAGS = `\n query EntityTags($entityType: String!, $entityId: ID!) {\n getEntityTags(entityType: $entityType, entityId: $entityId) {\n id tagId entityType entityId source isCurrentlyValid createdAt\n tag { id key label vocabularyId }\n }\n }\n`;\n\nexport const REMOVE_TAG_ASSIGNMENT = `\n mutation RemoveTagAssignment($id: ID!) {\n removeTagAssignment(id: $id)\n }\n`;\n","/**\n * Tags MCP tools — vocabularies, tag CRUD, analytics, relations and entity\n * assignments against wspace-tags-svc on the workspace gateway.\n *\n * The workspace comes from the gateway headers bound by\n * <product>_auth_select_workspace; the service ignores any workspace id in\n * the inputs, so none is sent.\n *\n * History: BOFF-8201 stubbed this whole module because `Query.tags` failed\n * on alpha. The module never used that field — it calls `getTags`,\n * `getTag`, `getVocabularies` and friends, which are live — so BOFF-4413\n * restored the real tools and pinned every document to the supergraph\n * (tests/unit/platform-supergraph-contract.test.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 TagRow {\n id: string;\n key: string;\n label: string;\n description?: string | null;\n scope?: string;\n vocabularyId?: string;\n parentId?: string | null;\n displayOrder?: number;\n usageCount?: number;\n}\n\ninterface Page<T> {\n items: T[];\n total: number;\n hasMore: boolean;\n nextCursor?: string | null;\n}\n\ninterface AssignmentRow {\n id: string;\n tagId: string;\n entityType: string;\n entityId: string;\n source?: string;\n createdAt?: string;\n tag?: { id: string; key: string; label: string };\n}\n\nconst TagScopeEnum = z.enum(['WORKSPACE', 'PRIVATE', 'TENANT', 'GLOBAL']);\n\nconst TagRelationTypeEnum = z\n .enum(['SYNONYM', 'ANTONYM', 'BROADER', 'NARROWER', 'RELATED', 'IMPLIES', 'EXCLUDES'])\n .describe(\n 'Semantic relationship (SYNONYM = same meaning, BROADER/NARROWER = hierarchy, IMPLIES/EXCLUDES = behaviour, RELATED = generic)',\n );\n\nfunction message(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nfunction pagination(limit?: number, offset?: number): { limit: number; offset: number } {\n return { limit: limit ?? 50, offset: offset ?? 0 };\n}\n\nexport function registerTagsTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n // ── Read ────────────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'tags_list')),\n {\n title: 'List Tags',\n description:\n 'List tags in the current workspace, optionally filtered by text, vocabulary or parent. Returns { items, total, hasMore, nextCursor }.',\n inputSchema: {\n search: z.string().optional().describe('Free-text search across key/label'),\n vocabularyId: z.string().optional().describe('Only tags in this vocabulary'),\n parentId: z.string().optional().describe('Only direct children of this tag'),\n limit: z.number().int().min(1).max(200).optional().describe('Page size (default 50)'),\n offset: z.number().int().min(0).optional().describe('Pagination offset (default 0)'),\n },\n },\n async ({ search, vocabularyId, parentId, limit, offset }) => {\n try {\n const filter: Record<string, unknown> = {};\n if (search !== undefined) filter.search = search;\n if (vocabularyId !== undefined) filter.vocabularyId = vocabularyId;\n if (parentId !== undefined) filter.parentId = parentId;\n const data = await ctx.gql.workspace.request<{ getTags: Page<TagRow> }>(ops.LIST_TAGS, {\n filter: Object.keys(filter).length ? filter : undefined,\n pagination: pagination(limit, offset),\n });\n return jsonResult(data.getTags);\n } catch (error) {\n ctx.logger.error('tags_list failed', { error: String(error) });\n return errorResult(`Failed to list tags: ${message(error)}`);\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'tags_get')),\n {\n title: 'Get Tag',\n description: 'Get one tag with its hierarchy position and usage counts.',\n inputSchema: { id: z.string().describe('Tag ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.workspace.request<{ getTag: TagRow | null }>(ops.GET_TAG, {\n id,\n });\n if (!data.getTag) return errorResult(`Tag ${id} not found`);\n return jsonResult(data.getTag);\n } catch (error) {\n ctx.logger.error('tags_get failed', { error: String(error) });\n return errorResult(`Failed to get tag: ${message(error)}`);\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'tags_vocabularies_list')),\n {\n title: 'List Tag Vocabularies',\n description:\n 'List the tag vocabularies (taxonomies) available in the current workspace. Every tag belongs to a vocabulary, so call this before tags_create.',\n inputSchema: {\n applicableEntityType: z\n .string()\n .optional()\n .describe('Only vocabularies that apply to this entity type (e.g. file)'),\n limit: z.number().int().min(1).max(200).optional().describe('Page size (default 50)'),\n offset: z.number().int().min(0).optional().describe('Pagination offset (default 0)'),\n },\n },\n async ({ applicableEntityType, limit, offset }) => {\n try {\n const data = await ctx.gql.workspace.request<{ getVocabularies: Page<unknown> }>(\n ops.LIST_VOCABULARIES,\n {\n filter: applicableEntityType ? { applicableEntityType } : undefined,\n pagination: pagination(limit, offset),\n },\n );\n return jsonResult(data.getVocabularies);\n } catch (error) {\n ctx.logger.error('tags_vocabularies_list failed', { error: String(error) });\n return errorResult(`Failed to list vocabularies: ${message(error)}`);\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'tags_analytics')),\n {\n title: 'Tag Analytics',\n description: 'Daily assignment / removal / unique-user counts for a tag over a time window.',\n inputSchema: {\n tagId: z.string().describe('Tag ID'),\n from: z.string().describe('Window start (ISO-8601 date-time)'),\n to: z.string().describe('Window end (ISO-8601 date-time)'),\n },\n },\n async ({ tagId, from, to }) => {\n try {\n const data = await ctx.gql.workspace.request<{ getTagAnalytics: unknown[] }>(\n ops.TAG_ANALYTICS,\n { tagId, startDate: from, endDate: to },\n );\n return jsonResult(data.getTagAnalytics);\n } catch (error) {\n ctx.logger.error('tags_analytics failed', { error: String(error) });\n return errorResult(`Failed to load tag analytics: ${message(error)}`);\n }\n },\n );\n\n // ── Write ───────────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'tags_create')),\n {\n title: 'Create Tag',\n description:\n 'Create a tag in the current workspace. `key` must be unique within the vocabulary; get a vocabularyId from tags_vocabularies_list.',\n inputSchema: {\n vocabularyId: z.string().describe('Vocabulary the tag belongs to'),\n key: z.string().min(1).describe('Stable identifier (kebab-case recommended)'),\n label: z.string().min(1).describe('Human-readable display name'),\n description: z.string().optional().describe('Free-form description'),\n color: z.string().optional().describe('Color value stored with the tag'),\n icon: z.string().optional().describe('Icon name (lucide identifier)'),\n scope: TagScopeEnum.optional().describe('Visibility scope (default WORKSPACE)'),\n parentId: z.string().optional().describe('Parent tag ID for hierarchical taxonomies'),\n },\n },\n async ({ vocabularyId, key, label, description, color, icon, scope, parentId }) => {\n try {\n const input: Record<string, unknown> = {\n vocabularyId,\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 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(`Failed to create tag: ${message(error)}`);\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. Provide at least one of label, description, color, icon, parentId or displayOrder.',\n inputSchema: {\n id: z.string().describe('Tag ID'),\n label: z.string().optional().describe('New display name'),\n description: z.string().optional().describe('New description (empty string clears it)'),\n color: z.string().optional().describe('New color value'),\n icon: z.string().optional().describe('New icon name'),\n parentId: z.string().optional().describe('New parent tag ID'),\n displayOrder: z.number().int().optional().describe('New order within the parent'),\n },\n },\n async ({ id, label, description, color, icon, parentId, displayOrder }) => {\n try {\n const input: Record<string, unknown> = {};\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 if (Object.keys(input).length === 0) {\n return errorResult(\n 'No updates specified: provide at least one of label, description, color, icon, parentId or displayOrder.',\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(`Failed to update tag: ${message(error)}`);\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'tags_delete')),\n {\n title: 'Delete Tag',\n description: 'Delete a tag. Its assignments are removed with it.',\n inputSchema: { id: z.string().describe('Tag ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.workspace.request<{ deleteTag: boolean }>(ops.DELETE_TAG, {\n id,\n });\n if (!data.deleteTag) return errorResult(`Tag ${id} was not deleted`);\n return jsonResult({ deleted: true, id });\n } catch (error) {\n ctx.logger.error('tags_delete failed', { error: String(error) });\n return errorResult(`Failed to delete tag: ${message(error)}`);\n }\n },\n );\n\n // ── Relations ───────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'tags_relations_list')),\n {\n title: 'List Related Tags',\n description: 'List tags related to a tag, optionally restricted to one relation type.',\n inputSchema: {\n tagId: z.string().describe('Tag ID'),\n relationType: TagRelationTypeEnum.optional(),\n },\n },\n async ({ tagId, relationType }) => {\n try {\n const data = await ctx.gql.workspace.request<{ getRelatedTags: unknown[] }>(\n ops.TAG_RELATIONS,\n { tagId, relationType },\n );\n return jsonResult(data.getRelatedTags);\n } catch (error) {\n ctx.logger.error('tags_relations_list failed', { error: String(error) });\n return errorResult(`Failed to list related tags: ${message(error)}`);\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'tags_relations_create')),\n {\n title: 'Relate Two Tags',\n description: 'Create a semantic relation between two tags.',\n inputSchema: {\n fromTagId: z.string().describe('Source tag ID'),\n toTagId: z.string().describe('Target tag ID'),\n relationType: TagRelationTypeEnum,\n bidirectional: z.boolean().optional().describe('Also relate target to source'),\n },\n },\n async ({ fromTagId, toTagId, relationType, bidirectional }) => {\n try {\n const input: Record<string, unknown> = { fromTagId, toTagId, relationType };\n if (bidirectional !== undefined) input.bidirectional = bidirectional;\n const data = await ctx.gql.workspace.request<{ createTagRelation: unknown }>(\n ops.CREATE_TAG_RELATION,\n { input },\n );\n return jsonResult(data.createTagRelation);\n } catch (error) {\n ctx.logger.error('tags_relations_create failed', { error: String(error) });\n return errorResult(`Failed to relate tags: ${message(error)}`);\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'tags_relations_delete')),\n {\n title: 'Delete Tag Relation',\n description: 'Delete a tag relation by its ID.',\n inputSchema: { id: z.string().describe('Relation ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.workspace.request<{ deleteTagRelation: boolean }>(\n ops.DELETE_TAG_RELATION,\n { id },\n );\n if (!data.deleteTagRelation) return errorResult(`Relation ${id} was not deleted`);\n return jsonResult({ deleted: true, id });\n } catch (error) {\n ctx.logger.error('tags_relations_delete failed', { error: String(error) });\n return errorResult(`Failed to delete tag relation: ${message(error)}`);\n }\n },\n );\n\n // ── Assignments ─────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'tags_assign')),\n {\n title: 'Tag an Entity',\n description:\n 'Attach a tag to a workspace entity, for example a file (entityType \"file\") or a project.',\n inputSchema: {\n tagId: z.string().describe('Tag ID'),\n entityType: z.string().min(1).describe('Entity type, e.g. file, folder, project'),\n entityId: z.string().describe('Entity ID'),\n },\n },\n async ({ tagId, entityType, entityId }) => {\n try {\n const data = await ctx.gql.workspace.request<{ assignTag: AssignmentRow }>(ops.ASSIGN_TAG, {\n input: { tagId, entityType, entityId },\n });\n return jsonResult(data.assignTag);\n } catch (error) {\n ctx.logger.error('tags_assign failed', { error: String(error) });\n return errorResult(`Failed to tag entity: ${message(error)}`);\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'tags_entity_list')),\n {\n title: 'List Tags on an Entity',\n description: 'List the tag assignments on one workspace entity.',\n inputSchema: {\n entityType: z.string().min(1).describe('Entity type, e.g. file, folder, project'),\n entityId: z.string().describe('Entity ID'),\n },\n },\n async ({ entityType, entityId }) => {\n try {\n const data = await ctx.gql.workspace.request<{ getEntityTags: AssignmentRow[] }>(\n ops.ENTITY_TAGS,\n { entityType, entityId },\n );\n return jsonResult(data.getEntityTags);\n } catch (error) {\n ctx.logger.error('tags_entity_list failed', { error: String(error) });\n return errorResult(`Failed to list entity tags: ${message(error)}`);\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'tags_assignment_remove')),\n {\n title: 'Remove a Tag Assignment',\n description: 'Remove one tag assignment (by assignment ID from tags_entity_list).',\n inputSchema: { id: z.string().describe('Tag assignment ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.workspace.request<{ removeTagAssignment: boolean }>(\n ops.REMOVE_TAG_ASSIGNMENT,\n { id },\n );\n if (!data.removeTagAssignment) return errorResult(`Assignment ${id} was not removed`);\n return jsonResult({ removed: true, id });\n } catch (error) {\n ctx.logger.error('tags_assignment_remove failed', { error: String(error) });\n return errorResult(`Failed to remove tag assignment: ${message(error)}`);\n }\n },\n );\n}\n","/**\n * Tags module — CANONICAL reference module per CLAUDE.md.\n *\n * Tools: <product>_tags_{list,get,vocabularies_list,create,update,delete,analytics},\n * <product>_tags_relations_{list,create,delete} and the entity assignment\n * tools <product>_tags_{assign,entity_list,assignment_remove}.\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,51 +1,452 @@
1
- import { mcpToolName, errorResult } from '../../chunk-76RGHRRS.js';
1
+ import { mcpToolName, jsonResult, errorResult } from '../../chunk-WYCRYHHY.js';
2
+ import { z } from 'zod';
3
+
4
+ // src/modules/tags/operations.ts
5
+ var LIST_TAGS = `
6
+ query TagsList($filter: TagFilterInput, $pagination: TagsPaginationInput) {
7
+ getTags(filter: $filter, pagination: $pagination) {
8
+ items { id key label description scope vocabularyId parentId displayOrder usageCount }
9
+ total hasMore nextCursor
10
+ }
11
+ }
12
+ `;
13
+ var GET_TAG = `
14
+ query GetTag($id: ID!) {
15
+ getTag(id: $id) {
16
+ id key label description color icon scope vocabularyId parentId
17
+ displayOrder assignmentCount usageCount hierarchyLevel hierarchyPath
18
+ createdAt updatedAt
19
+ }
20
+ }
21
+ `;
22
+ var LIST_VOCABULARIES = `
23
+ query TagVocabularies($filter: VocabularyFilterInput, $pagination: TagsPaginationInput) {
24
+ getVocabularies(filter: $filter, pagination: $pagination) {
25
+ items {
26
+ id key name description kind scope dataType cardinality
27
+ allowCustomTags predefinedValuesOnly applicableEntityTypes tagCount
28
+ }
29
+ total hasMore nextCursor
30
+ }
31
+ }
32
+ `;
33
+ var CREATE_TAG = `
34
+ mutation CreateTag($input: CreateTagInput!) {
35
+ createTag(input: $input) {
36
+ id key label description scope vocabularyId parentId displayOrder createdAt
37
+ }
38
+ }
39
+ `;
40
+ var UPDATE_TAG = `
41
+ mutation UpdateTag($id: ID!, $input: UpdateTagInput!) {
42
+ updateTag(id: $id, input: $input) {
43
+ id label description color icon parentId displayOrder updatedAt
44
+ }
45
+ }
46
+ `;
47
+ var DELETE_TAG = `
48
+ mutation DeleteTag($id: ID!) {
49
+ deleteTag(id: $id)
50
+ }
51
+ `;
52
+ var TAG_ANALYTICS = `
53
+ query TagAnalytics($tagId: ID!, $startDate: DateTime!, $endDate: DateTime!) {
54
+ getTagAnalytics(tagId: $tagId, startDate: $startDate, endDate: $endDate) {
55
+ date assignmentCount removalCount uniqueUsers uniqueEntities entityTypeBreakdown
56
+ }
57
+ }
58
+ `;
59
+ var TAG_RELATIONS = `
60
+ query GetRelatedTags($tagId: ID!, $relationType: TagRelationType) {
61
+ getRelatedTags(tagId: $tagId, relationType: $relationType) {
62
+ relationType
63
+ tag { id key label }
64
+ }
65
+ }
66
+ `;
67
+ var CREATE_TAG_RELATION = `
68
+ mutation CreateTagRelation($input: CreateTagRelationInput!) {
69
+ createTagRelation(input: $input) {
70
+ id fromTagId toTagId relationType bidirectional createdAt
71
+ }
72
+ }
73
+ `;
74
+ var DELETE_TAG_RELATION = `
75
+ mutation DeleteTagRelation($id: ID!) {
76
+ deleteTagRelation(id: $id)
77
+ }
78
+ `;
79
+ var ASSIGN_TAG = `
80
+ mutation AssignTag($input: AssignTagInput!) {
81
+ assignTag(input: $input) {
82
+ id tagId entityType entityId source createdAt
83
+ tag { id key label }
84
+ }
85
+ }
86
+ `;
87
+ var ENTITY_TAGS = `
88
+ query EntityTags($entityType: String!, $entityId: ID!) {
89
+ getEntityTags(entityType: $entityType, entityId: $entityId) {
90
+ id tagId entityType entityId source isCurrentlyValid createdAt
91
+ tag { id key label vocabularyId }
92
+ }
93
+ }
94
+ `;
95
+ var REMOVE_TAG_ASSIGNMENT = `
96
+ mutation RemoveTagAssignment($id: ID!) {
97
+ removeTagAssignment(id: $id)
98
+ }
99
+ `;
2
100
 
3
101
  // src/modules/tags/tools.ts
4
- function stubbedTool(server, toolName, title, description, featureNote, inputSchema, altSuggestions) {
102
+ var TagScopeEnum = z.enum(["WORKSPACE", "PRIVATE", "TENANT", "GLOBAL"]);
103
+ var TagRelationTypeEnum = z.enum(["SYNONYM", "ANTONYM", "BROADER", "NARROWER", "RELATED", "IMPLIES", "EXCLUDES"]).describe(
104
+ "Semantic relationship (SYNONYM = same meaning, BROADER/NARROWER = hierarchy, IMPLIES/EXCLUDES = behaviour, RELATED = generic)"
105
+ );
106
+ function message(error) {
107
+ return error instanceof Error ? error.message : String(error);
108
+ }
109
+ function pagination(limit, offset) {
110
+ return { limit: limit ?? 50, offset: offset ?? 0 };
111
+ }
112
+ function registerTagsTools(server, ctx, track) {
5
113
  server.registerTool(
6
- toolName,
114
+ track(mcpToolName(ctx.productName, "tags_list")),
7
115
  {
8
- title,
9
- description: `${description} [STUB]`,
10
- inputSchema
116
+ title: "List Tags",
117
+ description: "List tags in the current workspace, optionally filtered by text, vocabulary or parent. Returns { items, total, hasMore, nextCursor }.",
118
+ inputSchema: {
119
+ search: z.string().optional().describe("Free-text search across key/label"),
120
+ vocabularyId: z.string().optional().describe("Only tags in this vocabulary"),
121
+ parentId: z.string().optional().describe("Only direct children of this tag"),
122
+ limit: z.number().int().min(1).max(200).optional().describe("Page size (default 50)"),
123
+ offset: z.number().int().min(0).optional().describe("Pagination offset (default 0)")
124
+ }
11
125
  },
12
- async () => errorResult(
13
- `[stubbed] ${featureNote} Use ${altSuggestions.join(", ")} instead. The tool remains registered so callers receive a meaningful response instead of a schema-validation error.`
14
- )
126
+ async ({ search, vocabularyId, parentId, limit, offset }) => {
127
+ try {
128
+ const filter = {};
129
+ if (search !== void 0) filter.search = search;
130
+ if (vocabularyId !== void 0) filter.vocabularyId = vocabularyId;
131
+ if (parentId !== void 0) filter.parentId = parentId;
132
+ const data = await ctx.gql.workspace.request(LIST_TAGS, {
133
+ filter: Object.keys(filter).length ? filter : void 0,
134
+ pagination: pagination(limit, offset)
135
+ });
136
+ return jsonResult(data.getTags);
137
+ } catch (error) {
138
+ ctx.logger.error("tags_list failed", { error: String(error) });
139
+ return errorResult(`Failed to list tags: ${message(error)}`);
140
+ }
141
+ }
142
+ );
143
+ server.registerTool(
144
+ track(mcpToolName(ctx.productName, "tags_get")),
145
+ {
146
+ title: "Get Tag",
147
+ description: "Get one tag with its hierarchy position and usage counts.",
148
+ inputSchema: { id: z.string().describe("Tag ID") }
149
+ },
150
+ async ({ id }) => {
151
+ try {
152
+ const data = await ctx.gql.workspace.request(GET_TAG, {
153
+ id
154
+ });
155
+ if (!data.getTag) return errorResult(`Tag ${id} not found`);
156
+ return jsonResult(data.getTag);
157
+ } catch (error) {
158
+ ctx.logger.error("tags_get failed", { error: String(error) });
159
+ return errorResult(`Failed to get tag: ${message(error)}`);
160
+ }
161
+ }
162
+ );
163
+ server.registerTool(
164
+ track(mcpToolName(ctx.productName, "tags_vocabularies_list")),
165
+ {
166
+ title: "List Tag Vocabularies",
167
+ description: "List the tag vocabularies (taxonomies) available in the current workspace. Every tag belongs to a vocabulary, so call this before tags_create.",
168
+ inputSchema: {
169
+ applicableEntityType: z.string().optional().describe("Only vocabularies that apply to this entity type (e.g. file)"),
170
+ limit: z.number().int().min(1).max(200).optional().describe("Page size (default 50)"),
171
+ offset: z.number().int().min(0).optional().describe("Pagination offset (default 0)")
172
+ }
173
+ },
174
+ async ({ applicableEntityType, limit, offset }) => {
175
+ try {
176
+ const data = await ctx.gql.workspace.request(
177
+ LIST_VOCABULARIES,
178
+ {
179
+ filter: applicableEntityType ? { applicableEntityType } : void 0,
180
+ pagination: pagination(limit, offset)
181
+ }
182
+ );
183
+ return jsonResult(data.getVocabularies);
184
+ } catch (error) {
185
+ ctx.logger.error("tags_vocabularies_list failed", { error: String(error) });
186
+ return errorResult(`Failed to list vocabularies: ${message(error)}`);
187
+ }
188
+ }
189
+ );
190
+ server.registerTool(
191
+ track(mcpToolName(ctx.productName, "tags_analytics")),
192
+ {
193
+ title: "Tag Analytics",
194
+ description: "Daily assignment / removal / unique-user counts for a tag over a time window.",
195
+ inputSchema: {
196
+ tagId: z.string().describe("Tag ID"),
197
+ from: z.string().describe("Window start (ISO-8601 date-time)"),
198
+ to: z.string().describe("Window end (ISO-8601 date-time)")
199
+ }
200
+ },
201
+ async ({ tagId, from, to }) => {
202
+ try {
203
+ const data = await ctx.gql.workspace.request(
204
+ TAG_ANALYTICS,
205
+ { tagId, startDate: from, endDate: to }
206
+ );
207
+ return jsonResult(data.getTagAnalytics);
208
+ } catch (error) {
209
+ ctx.logger.error("tags_analytics failed", { error: String(error) });
210
+ return errorResult(`Failed to load tag analytics: ${message(error)}`);
211
+ }
212
+ }
213
+ );
214
+ server.registerTool(
215
+ track(mcpToolName(ctx.productName, "tags_create")),
216
+ {
217
+ title: "Create Tag",
218
+ description: "Create a tag in the current workspace. `key` must be unique within the vocabulary; get a vocabularyId from tags_vocabularies_list.",
219
+ inputSchema: {
220
+ vocabularyId: z.string().describe("Vocabulary the tag belongs to"),
221
+ key: z.string().min(1).describe("Stable identifier (kebab-case recommended)"),
222
+ label: z.string().min(1).describe("Human-readable display name"),
223
+ description: z.string().optional().describe("Free-form description"),
224
+ color: z.string().optional().describe("Color value stored with the tag"),
225
+ icon: z.string().optional().describe("Icon name (lucide identifier)"),
226
+ scope: TagScopeEnum.optional().describe("Visibility scope (default WORKSPACE)"),
227
+ parentId: z.string().optional().describe("Parent tag ID for hierarchical taxonomies")
228
+ }
229
+ },
230
+ async ({ vocabularyId, key, label, description, color, icon, scope, parentId }) => {
231
+ try {
232
+ const input = {
233
+ vocabularyId,
234
+ key,
235
+ label,
236
+ scope: scope ?? "WORKSPACE"
237
+ };
238
+ if (description !== void 0) input.description = description;
239
+ if (color !== void 0) input.color = color;
240
+ if (icon !== void 0) input.icon = icon;
241
+ if (parentId !== void 0) input.parentId = parentId;
242
+ const data = await ctx.gql.workspace.request(CREATE_TAG, {
243
+ input
244
+ });
245
+ return jsonResult(data.createTag);
246
+ } catch (error) {
247
+ ctx.logger.error("tags_create failed", { error: String(error) });
248
+ return errorResult(`Failed to create tag: ${message(error)}`);
249
+ }
250
+ }
251
+ );
252
+ server.registerTool(
253
+ track(mcpToolName(ctx.productName, "tags_update")),
254
+ {
255
+ title: "Update Tag",
256
+ description: "Update a tag. Provide at least one of label, description, color, icon, parentId or displayOrder.",
257
+ inputSchema: {
258
+ id: z.string().describe("Tag ID"),
259
+ label: z.string().optional().describe("New display name"),
260
+ description: z.string().optional().describe("New description (empty string clears it)"),
261
+ color: z.string().optional().describe("New color value"),
262
+ icon: z.string().optional().describe("New icon name"),
263
+ parentId: z.string().optional().describe("New parent tag ID"),
264
+ displayOrder: z.number().int().optional().describe("New order within the parent")
265
+ }
266
+ },
267
+ async ({ id, label, description, color, icon, parentId, displayOrder }) => {
268
+ try {
269
+ const input = {};
270
+ if (label !== void 0) input.label = label;
271
+ if (description !== void 0) input.description = description;
272
+ if (color !== void 0) input.color = color;
273
+ if (icon !== void 0) input.icon = icon;
274
+ if (parentId !== void 0) input.parentId = parentId;
275
+ if (displayOrder !== void 0) input.displayOrder = displayOrder;
276
+ if (Object.keys(input).length === 0) {
277
+ return errorResult(
278
+ "No updates specified: provide at least one of label, description, color, icon, parentId or displayOrder."
279
+ );
280
+ }
281
+ const data = await ctx.gql.workspace.request(UPDATE_TAG, {
282
+ id,
283
+ input
284
+ });
285
+ return jsonResult(data.updateTag);
286
+ } catch (error) {
287
+ ctx.logger.error("tags_update failed", { error: String(error) });
288
+ return errorResult(`Failed to update tag: ${message(error)}`);
289
+ }
290
+ }
291
+ );
292
+ server.registerTool(
293
+ track(mcpToolName(ctx.productName, "tags_delete")),
294
+ {
295
+ title: "Delete Tag",
296
+ description: "Delete a tag. Its assignments are removed with it.",
297
+ inputSchema: { id: z.string().describe("Tag ID") }
298
+ },
299
+ async ({ id }) => {
300
+ try {
301
+ const data = await ctx.gql.workspace.request(DELETE_TAG, {
302
+ id
303
+ });
304
+ if (!data.deleteTag) return errorResult(`Tag ${id} was not deleted`);
305
+ return jsonResult({ deleted: true, id });
306
+ } catch (error) {
307
+ ctx.logger.error("tags_delete failed", { error: String(error) });
308
+ return errorResult(`Failed to delete tag: ${message(error)}`);
309
+ }
310
+ }
311
+ );
312
+ server.registerTool(
313
+ track(mcpToolName(ctx.productName, "tags_relations_list")),
314
+ {
315
+ title: "List Related Tags",
316
+ description: "List tags related to a tag, optionally restricted to one relation type.",
317
+ inputSchema: {
318
+ tagId: z.string().describe("Tag ID"),
319
+ relationType: TagRelationTypeEnum.optional()
320
+ }
321
+ },
322
+ async ({ tagId, relationType }) => {
323
+ try {
324
+ const data = await ctx.gql.workspace.request(
325
+ TAG_RELATIONS,
326
+ { tagId, relationType }
327
+ );
328
+ return jsonResult(data.getRelatedTags);
329
+ } catch (error) {
330
+ ctx.logger.error("tags_relations_list failed", { error: String(error) });
331
+ return errorResult(`Failed to list related tags: ${message(error)}`);
332
+ }
333
+ }
334
+ );
335
+ server.registerTool(
336
+ track(mcpToolName(ctx.productName, "tags_relations_create")),
337
+ {
338
+ title: "Relate Two Tags",
339
+ description: "Create a semantic relation between two tags.",
340
+ inputSchema: {
341
+ fromTagId: z.string().describe("Source tag ID"),
342
+ toTagId: z.string().describe("Target tag ID"),
343
+ relationType: TagRelationTypeEnum,
344
+ bidirectional: z.boolean().optional().describe("Also relate target to source")
345
+ }
346
+ },
347
+ async ({ fromTagId, toTagId, relationType, bidirectional }) => {
348
+ try {
349
+ const input = { fromTagId, toTagId, relationType };
350
+ if (bidirectional !== void 0) input.bidirectional = bidirectional;
351
+ const data = await ctx.gql.workspace.request(
352
+ CREATE_TAG_RELATION,
353
+ { input }
354
+ );
355
+ return jsonResult(data.createTagRelation);
356
+ } catch (error) {
357
+ ctx.logger.error("tags_relations_create failed", { error: String(error) });
358
+ return errorResult(`Failed to relate tags: ${message(error)}`);
359
+ }
360
+ }
361
+ );
362
+ server.registerTool(
363
+ track(mcpToolName(ctx.productName, "tags_relations_delete")),
364
+ {
365
+ title: "Delete Tag Relation",
366
+ description: "Delete a tag relation by its ID.",
367
+ inputSchema: { id: z.string().describe("Relation ID") }
368
+ },
369
+ async ({ id }) => {
370
+ try {
371
+ const data = await ctx.gql.workspace.request(
372
+ DELETE_TAG_RELATION,
373
+ { id }
374
+ );
375
+ if (!data.deleteTagRelation) return errorResult(`Relation ${id} was not deleted`);
376
+ return jsonResult({ deleted: true, id });
377
+ } catch (error) {
378
+ ctx.logger.error("tags_relations_delete failed", { error: String(error) });
379
+ return errorResult(`Failed to delete tag relation: ${message(error)}`);
380
+ }
381
+ }
382
+ );
383
+ server.registerTool(
384
+ track(mcpToolName(ctx.productName, "tags_assign")),
385
+ {
386
+ title: "Tag an Entity",
387
+ description: 'Attach a tag to a workspace entity, for example a file (entityType "file") or a project.',
388
+ inputSchema: {
389
+ tagId: z.string().describe("Tag ID"),
390
+ entityType: z.string().min(1).describe("Entity type, e.g. file, folder, project"),
391
+ entityId: z.string().describe("Entity ID")
392
+ }
393
+ },
394
+ async ({ tagId, entityType, entityId }) => {
395
+ try {
396
+ const data = await ctx.gql.workspace.request(ASSIGN_TAG, {
397
+ input: { tagId, entityType, entityId }
398
+ });
399
+ return jsonResult(data.assignTag);
400
+ } catch (error) {
401
+ ctx.logger.error("tags_assign failed", { error: String(error) });
402
+ return errorResult(`Failed to tag entity: ${message(error)}`);
403
+ }
404
+ }
405
+ );
406
+ server.registerTool(
407
+ track(mcpToolName(ctx.productName, "tags_entity_list")),
408
+ {
409
+ title: "List Tags on an Entity",
410
+ description: "List the tag assignments on one workspace entity.",
411
+ inputSchema: {
412
+ entityType: z.string().min(1).describe("Entity type, e.g. file, folder, project"),
413
+ entityId: z.string().describe("Entity ID")
414
+ }
415
+ },
416
+ async ({ entityType, entityId }) => {
417
+ try {
418
+ const data = await ctx.gql.workspace.request(
419
+ ENTITY_TAGS,
420
+ { entityType, entityId }
421
+ );
422
+ return jsonResult(data.getEntityTags);
423
+ } catch (error) {
424
+ ctx.logger.error("tags_entity_list failed", { error: String(error) });
425
+ return errorResult(`Failed to list entity tags: ${message(error)}`);
426
+ }
427
+ }
428
+ );
429
+ server.registerTool(
430
+ track(mcpToolName(ctx.productName, "tags_assignment_remove")),
431
+ {
432
+ title: "Remove a Tag Assignment",
433
+ description: "Remove one tag assignment (by assignment ID from tags_entity_list).",
434
+ inputSchema: { id: z.string().describe("Tag assignment ID") }
435
+ },
436
+ async ({ id }) => {
437
+ try {
438
+ const data = await ctx.gql.workspace.request(
439
+ REMOVE_TAG_ASSIGNMENT,
440
+ { id }
441
+ );
442
+ if (!data.removeTagAssignment) return errorResult(`Assignment ${id} was not removed`);
443
+ return jsonResult({ removed: true, id });
444
+ } catch (error) {
445
+ ctx.logger.error("tags_assignment_remove failed", { error: String(error) });
446
+ return errorResult(`Failed to remove tag assignment: ${message(error)}`);
447
+ }
448
+ }
15
449
  );
16
- }
17
- function registerTagsTools(server, _ctx, track) {
18
- const featureNote = "Live alpha has `Query.tags` returning INTERNAL_SERVER_ERROR on even the simplest selection (`{ name }`). The whole tags surface is down until the service recovers.";
19
- const alts = [
20
- "the next alpha release that restores the tags surface",
21
- "the SDK tags API (which the MCP will mirror once it lands)"
22
- ];
23
- const tools = [
24
- ["tags_list", "List Tags", "List tags in the active workspace."],
25
- ["tags_get", "Get Tag", "Get a tag by ID."],
26
- ["tags_create", "Create Tag", "Create a new tag (requires `vocabularyId` on alpha)."],
27
- ["tags_update", "Update Tag", "Update an existing tag."],
28
- ["tags_delete", "Delete Tag", "Delete a tag by ID."],
29
- ["tags_analytics", "Tag Analytics", "Get analytics for a tag (assignment / usage counts)."],
30
- [
31
- "tags_permissions_list",
32
- "List Tag Permissions",
33
- "List tag-permission grants in the workspace."
34
- ],
35
- ["tags_permissions_grant", "Grant Tag Permission", "Grant a tag permission."],
36
- ["tags_permissions_revoke", "Revoke Tag Permission", "Revoke a tag permission."]
37
- ];
38
- for (const [tool, title, desc] of tools) {
39
- stubbedTool(
40
- server,
41
- track(mcpToolName(_ctx.productName, tool)),
42
- title,
43
- desc,
44
- featureNote,
45
- {},
46
- alts
47
- );
48
- }
49
450
  }
50
451
 
51
452
  // src/modules/tags/index.ts