coalesce-transform-mcp 0.3.0 → 0.4.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 (279) hide show
  1. package/README.md +74 -3
  2. package/dist/client.d.ts.map +1 -1
  3. package/dist/client.js +6 -2
  4. package/dist/client.js.map +1 -1
  5. package/dist/coalesce/api/environments.d.ts +0 -12
  6. package/dist/coalesce/api/environments.d.ts.map +1 -1
  7. package/dist/coalesce/api/environments.js +0 -4
  8. package/dist/coalesce/api/environments.js.map +1 -1
  9. package/dist/coalesce/api/jobs.d.ts +3 -5
  10. package/dist/coalesce/api/jobs.d.ts.map +1 -1
  11. package/dist/coalesce/api/jobs.js +3 -6
  12. package/dist/coalesce/api/jobs.js.map +1 -1
  13. package/dist/coalesce/api/nodes.d.ts +3 -3
  14. package/dist/coalesce/api/nodes.d.ts.map +1 -1
  15. package/dist/coalesce/api/nodes.js +6 -4
  16. package/dist/coalesce/api/nodes.js.map +1 -1
  17. package/dist/coalesce/api/runs.d.ts.map +1 -1
  18. package/dist/coalesce/api/runs.js +11 -1
  19. package/dist/coalesce/api/runs.js.map +1 -1
  20. package/dist/coalesce/api/scan.d.ts +14 -0
  21. package/dist/coalesce/api/scan.d.ts.map +1 -0
  22. package/dist/coalesce/api/scan.js +64 -0
  23. package/dist/coalesce/api/scan.js.map +1 -0
  24. package/dist/coalesce/api/subgraphs.d.ts +3 -2
  25. package/dist/coalesce/api/subgraphs.d.ts.map +1 -1
  26. package/dist/coalesce/api/subgraphs.js +3 -2
  27. package/dist/coalesce/api/subgraphs.js.map +1 -1
  28. package/dist/coalesce/run-schemas.d.ts.map +1 -1
  29. package/dist/coalesce/run-schemas.js +26 -16
  30. package/dist/coalesce/run-schemas.js.map +1 -1
  31. package/dist/coalesce/tool-response.d.ts +1 -13
  32. package/dist/coalesce/tool-response.d.ts.map +1 -1
  33. package/dist/coalesce/tool-response.js +20 -6
  34. package/dist/coalesce/tool-response.js.map +1 -1
  35. package/dist/coalesce/tool-schemas.d.ts +1 -2
  36. package/dist/coalesce/tool-schemas.d.ts.map +1 -1
  37. package/dist/coalesce/tool-schemas.js +368 -5
  38. package/dist/coalesce/tool-schemas.js.map +1 -1
  39. package/dist/coalesce/types.d.ts +8 -0
  40. package/dist/coalesce/types.d.ts.map +1 -1
  41. package/dist/coalesce/types.js +3 -1
  42. package/dist/coalesce/types.js.map +1 -1
  43. package/dist/constants.d.ts +18 -0
  44. package/dist/constants.d.ts.map +1 -0
  45. package/dist/constants.js +21 -0
  46. package/dist/constants.js.map +1 -0
  47. package/dist/mcp/cache.d.ts +2 -1
  48. package/dist/mcp/cache.d.ts.map +1 -1
  49. package/dist/mcp/cache.js +122 -138
  50. package/dist/mcp/cache.js.map +1 -1
  51. package/dist/mcp/environments.d.ts +2 -1
  52. package/dist/mcp/environments.d.ts.map +1 -1
  53. package/dist/mcp/environments.js +56 -112
  54. package/dist/mcp/environments.js.map +1 -1
  55. package/dist/mcp/git-accounts.d.ts +2 -1
  56. package/dist/mcp/git-accounts.d.ts.map +1 -1
  57. package/dist/mcp/git-accounts.js +74 -96
  58. package/dist/mcp/git-accounts.js.map +1 -1
  59. package/dist/mcp/jobs.d.ts +2 -1
  60. package/dist/mcp/jobs.d.ts.map +1 -1
  61. package/dist/mcp/jobs.js +68 -122
  62. package/dist/mcp/jobs.js.map +1 -1
  63. package/dist/mcp/lineage.d.ts +5 -0
  64. package/dist/mcp/lineage.d.ts.map +1 -0
  65. package/dist/mcp/lineage.js +410 -0
  66. package/dist/mcp/lineage.js.map +1 -0
  67. package/dist/mcp/node-type-corpus.d.ts +2 -1
  68. package/dist/mcp/node-type-corpus.d.ts.map +1 -1
  69. package/dist/mcp/node-type-corpus.js +148 -151
  70. package/dist/mcp/node-type-corpus.js.map +1 -1
  71. package/dist/mcp/nodes.d.ts +2 -1
  72. package/dist/mcp/nodes.d.ts.map +1 -1
  73. package/dist/mcp/nodes.js +358 -464
  74. package/dist/mcp/nodes.js.map +1 -1
  75. package/dist/mcp/pipelines.d.ts +2 -1
  76. package/dist/mcp/pipelines.d.ts.map +1 -1
  77. package/dist/mcp/pipelines.js +514 -314
  78. package/dist/mcp/pipelines.js.map +1 -1
  79. package/dist/mcp/projects.d.ts +2 -1
  80. package/dist/mcp/projects.d.ts.map +1 -1
  81. package/dist/mcp/projects.js +66 -100
  82. package/dist/mcp/projects.js.map +1 -1
  83. package/dist/mcp/repo-node-types.d.ts +2 -1
  84. package/dist/mcp/repo-node-types.d.ts.map +1 -1
  85. package/dist/mcp/repo-node-types.js +92 -121
  86. package/dist/mcp/repo-node-types.js.map +1 -1
  87. package/dist/mcp/runs.d.ts +3 -2
  88. package/dist/mcp/runs.d.ts.map +1 -1
  89. package/dist/mcp/runs.js +93 -148
  90. package/dist/mcp/runs.js.map +1 -1
  91. package/dist/mcp/skills.d.ts +13 -0
  92. package/dist/mcp/skills.d.ts.map +1 -0
  93. package/dist/mcp/skills.js +85 -0
  94. package/dist/mcp/skills.js.map +1 -0
  95. package/dist/mcp/subgraphs.d.ts +2 -1
  96. package/dist/mcp/subgraphs.d.ts.map +1 -1
  97. package/dist/mcp/subgraphs.js +61 -98
  98. package/dist/mcp/subgraphs.js.map +1 -1
  99. package/dist/mcp/tool-helpers.d.ts +37 -0
  100. package/dist/mcp/tool-helpers.d.ts.map +1 -0
  101. package/dist/mcp/tool-helpers.js +82 -0
  102. package/dist/mcp/tool-helpers.js.map +1 -0
  103. package/dist/mcp/users.d.ts +2 -1
  104. package/dist/mcp/users.d.ts.map +1 -1
  105. package/dist/mcp/users.js +92 -145
  106. package/dist/mcp/users.js.map +1 -1
  107. package/dist/mcp/workshop.d.ts +2 -1
  108. package/dist/mcp/workshop.d.ts.map +1 -1
  109. package/dist/mcp/workshop.js +66 -101
  110. package/dist/mcp/workshop.js.map +1 -1
  111. package/dist/mcp/workspaces.d.ts +2 -1
  112. package/dist/mcp/workspaces.d.ts.map +1 -1
  113. package/dist/mcp/workspaces.js +19 -34
  114. package/dist/mcp/workspaces.js.map +1 -1
  115. package/dist/prompts/index.d.ts.map +1 -1
  116. package/dist/prompts/index.js +85 -0
  117. package/dist/prompts/index.js.map +1 -1
  118. package/dist/resources/context/pipeline-workshop-guide.md +1 -1
  119. package/dist/resources/context/tool-usage.md +7 -0
  120. package/dist/resources/index.d.ts +13 -0
  121. package/dist/resources/index.d.ts.map +1 -1
  122. package/dist/resources/index.js +105 -5
  123. package/dist/resources/index.js.map +1 -1
  124. package/dist/schemas/node-payloads.d.ts +2 -2
  125. package/dist/server.d.ts +2 -1
  126. package/dist/server.d.ts.map +1 -1
  127. package/dist/server.js +158 -41
  128. package/dist/server.js.map +1 -1
  129. package/dist/services/cache/snapshots.d.ts.map +1 -1
  130. package/dist/services/cache/snapshots.js +9 -5
  131. package/dist/services/cache/snapshots.js.map +1 -1
  132. package/dist/services/config/schema-resolver.d.ts.map +1 -1
  133. package/dist/services/config/schema-resolver.js +3 -6
  134. package/dist/services/config/schema-resolver.js.map +1 -1
  135. package/dist/services/lineage/lineage-cache.d.ts +53 -0
  136. package/dist/services/lineage/lineage-cache.d.ts.map +1 -0
  137. package/dist/services/lineage/lineage-cache.js +335 -0
  138. package/dist/services/lineage/lineage-cache.js.map +1 -0
  139. package/dist/services/lineage/lineage-documentation.d.ts +29 -0
  140. package/dist/services/lineage/lineage-documentation.d.ts.map +1 -0
  141. package/dist/services/lineage/lineage-documentation.js +80 -0
  142. package/dist/services/lineage/lineage-documentation.js.map +1 -0
  143. package/dist/services/lineage/lineage-propagation.d.ts +47 -0
  144. package/dist/services/lineage/lineage-propagation.d.ts.map +1 -0
  145. package/dist/services/lineage/lineage-propagation.js +176 -0
  146. package/dist/services/lineage/lineage-propagation.js.map +1 -0
  147. package/dist/services/lineage/lineage-search.d.ts +33 -0
  148. package/dist/services/lineage/lineage-search.d.ts.map +1 -0
  149. package/dist/services/lineage/lineage-search.js +133 -0
  150. package/dist/services/lineage/lineage-search.js.map +1 -0
  151. package/dist/services/lineage/lineage-traversal.d.ts +34 -0
  152. package/dist/services/lineage/lineage-traversal.d.ts.map +1 -0
  153. package/dist/services/lineage/lineage-traversal.js +283 -0
  154. package/dist/services/lineage/lineage-traversal.js.map +1 -0
  155. package/dist/services/pipelines/clause-extraction.d.ts +3 -0
  156. package/dist/services/pipelines/clause-extraction.d.ts.map +1 -0
  157. package/dist/services/pipelines/clause-extraction.js +27 -0
  158. package/dist/services/pipelines/clause-extraction.js.map +1 -0
  159. package/dist/services/pipelines/column-helpers.d.ts +8 -0
  160. package/dist/services/pipelines/column-helpers.d.ts.map +1 -0
  161. package/dist/services/pipelines/column-helpers.js +125 -0
  162. package/dist/services/pipelines/column-helpers.js.map +1 -0
  163. package/dist/services/pipelines/cte-parsing.d.ts +29 -0
  164. package/dist/services/pipelines/cte-parsing.d.ts.map +1 -0
  165. package/dist/services/pipelines/cte-parsing.js +160 -0
  166. package/dist/services/pipelines/cte-parsing.js.map +1 -0
  167. package/dist/services/pipelines/cte-planning.d.ts +22 -0
  168. package/dist/services/pipelines/cte-planning.d.ts.map +1 -0
  169. package/dist/services/pipelines/cte-planning.js +206 -0
  170. package/dist/services/pipelines/cte-planning.js.map +1 -0
  171. package/dist/services/pipelines/execution.d.ts.map +1 -1
  172. package/dist/services/pipelines/execution.js +0 -1
  173. package/dist/services/pipelines/execution.js.map +1 -1
  174. package/dist/services/pipelines/intent-parsing.d.ts +24 -0
  175. package/dist/services/pipelines/intent-parsing.d.ts.map +1 -0
  176. package/dist/services/pipelines/intent-parsing.js +245 -0
  177. package/dist/services/pipelines/intent-parsing.js.map +1 -0
  178. package/dist/services/pipelines/intent-resolution.d.ts +24 -0
  179. package/dist/services/pipelines/intent-resolution.d.ts.map +1 -0
  180. package/dist/services/pipelines/intent-resolution.js +141 -0
  181. package/dist/services/pipelines/intent-resolution.js.map +1 -0
  182. package/dist/services/pipelines/intent.d.ts +4 -45
  183. package/dist/services/pipelines/intent.d.ts.map +1 -1
  184. package/dist/services/pipelines/intent.js +14 -408
  185. package/dist/services/pipelines/intent.js.map +1 -1
  186. package/dist/services/pipelines/node-type-candidates.d.ts +6 -0
  187. package/dist/services/pipelines/node-type-candidates.d.ts.map +1 -0
  188. package/dist/services/pipelines/node-type-candidates.js +165 -0
  189. package/dist/services/pipelines/node-type-candidates.js.map +1 -0
  190. package/dist/services/pipelines/node-type-intent.d.ts +1 -5
  191. package/dist/services/pipelines/node-type-intent.d.ts.map +1 -1
  192. package/dist/services/pipelines/node-type-intent.js +1 -5
  193. package/dist/services/pipelines/node-type-intent.js.map +1 -1
  194. package/dist/services/pipelines/node-type-scoring.d.ts +13 -0
  195. package/dist/services/pipelines/node-type-scoring.d.ts.map +1 -0
  196. package/dist/services/pipelines/node-type-scoring.js +322 -0
  197. package/dist/services/pipelines/node-type-scoring.js.map +1 -0
  198. package/dist/services/pipelines/node-type-selection.d.ts +22 -2
  199. package/dist/services/pipelines/node-type-selection.d.ts.map +1 -1
  200. package/dist/services/pipelines/node-type-selection.js +16 -538
  201. package/dist/services/pipelines/node-type-selection.js.map +1 -1
  202. package/dist/services/pipelines/plan-builder.d.ts +33 -0
  203. package/dist/services/pipelines/plan-builder.d.ts.map +1 -0
  204. package/dist/services/pipelines/plan-builder.js +224 -0
  205. package/dist/services/pipelines/plan-builder.js.map +1 -0
  206. package/dist/services/pipelines/planning-types.d.ts +543 -0
  207. package/dist/services/pipelines/planning-types.d.ts.map +1 -0
  208. package/dist/services/pipelines/planning-types.js +85 -0
  209. package/dist/services/pipelines/planning-types.js.map +1 -0
  210. package/dist/services/pipelines/planning.d.ts +8 -537
  211. package/dist/services/pipelines/planning.d.ts.map +1 -1
  212. package/dist/services/pipelines/planning.js +10 -1956
  213. package/dist/services/pipelines/planning.js.map +1 -1
  214. package/dist/services/pipelines/review.d.ts.map +1 -1
  215. package/dist/services/pipelines/review.js +3 -8
  216. package/dist/services/pipelines/review.js.map +1 -1
  217. package/dist/services/pipelines/select-parsing.d.ts +7 -0
  218. package/dist/services/pipelines/select-parsing.d.ts.map +1 -0
  219. package/dist/services/pipelines/select-parsing.js +185 -0
  220. package/dist/services/pipelines/select-parsing.js.map +1 -0
  221. package/dist/services/pipelines/source-parsing.d.ts +8 -0
  222. package/dist/services/pipelines/source-parsing.d.ts.map +1 -0
  223. package/dist/services/pipelines/source-parsing.js +151 -0
  224. package/dist/services/pipelines/source-parsing.js.map +1 -0
  225. package/dist/services/pipelines/sql-parsing.d.ts +8 -0
  226. package/dist/services/pipelines/sql-parsing.d.ts.map +1 -0
  227. package/dist/services/pipelines/sql-parsing.js +9 -0
  228. package/dist/services/pipelines/sql-parsing.js.map +1 -0
  229. package/dist/services/pipelines/sql-tokenizer.d.ts +42 -0
  230. package/dist/services/pipelines/sql-tokenizer.d.ts.map +1 -0
  231. package/dist/services/pipelines/sql-tokenizer.js +493 -0
  232. package/dist/services/pipelines/sql-tokenizer.js.map +1 -0
  233. package/dist/services/pipelines/sql-utils.d.ts +30 -0
  234. package/dist/services/pipelines/sql-utils.d.ts.map +1 -0
  235. package/dist/services/pipelines/sql-utils.js +62 -0
  236. package/dist/services/pipelines/sql-utils.js.map +1 -0
  237. package/dist/services/pipelines/workshop.d.ts.map +1 -1
  238. package/dist/services/pipelines/workshop.js +53 -25
  239. package/dist/services/pipelines/workshop.js.map +1 -1
  240. package/dist/services/pipelines/workspace-resolution.d.ts +18 -0
  241. package/dist/services/pipelines/workspace-resolution.d.ts.map +1 -0
  242. package/dist/services/pipelines/workspace-resolution.js +279 -0
  243. package/dist/services/pipelines/workspace-resolution.js.map +1 -0
  244. package/dist/services/runs/diagnostics.d.ts.map +1 -1
  245. package/dist/services/runs/diagnostics.js +3 -8
  246. package/dist/services/runs/diagnostics.js.map +1 -1
  247. package/dist/services/shared/elicitation.d.ts +14 -0
  248. package/dist/services/shared/elicitation.d.ts.map +1 -0
  249. package/dist/services/shared/elicitation.js +56 -0
  250. package/dist/services/shared/elicitation.js.map +1 -0
  251. package/dist/services/workspace/node-creation.d.ts.map +1 -1
  252. package/dist/services/workspace/node-creation.js +5 -1
  253. package/dist/services/workspace/node-creation.js.map +1 -1
  254. package/dist/services/workspace/node-update-helpers.d.ts.map +1 -1
  255. package/dist/services/workspace/node-update-helpers.js +3 -8
  256. package/dist/services/workspace/node-update-helpers.js.map +1 -1
  257. package/dist/utils.d.ts +11 -0
  258. package/dist/utils.d.ts.map +1 -1
  259. package/dist/utils.js +20 -1
  260. package/dist/utils.js.map +1 -1
  261. package/dist/workflows/get-environment-health.d.ts +49 -0
  262. package/dist/workflows/get-environment-health.d.ts.map +1 -0
  263. package/dist/workflows/get-environment-health.js +310 -0
  264. package/dist/workflows/get-environment-health.js.map +1 -0
  265. package/dist/workflows/get-environment-overview.d.ts +2 -1
  266. package/dist/workflows/get-environment-overview.d.ts.map +1 -1
  267. package/dist/workflows/get-environment-overview.js +13 -19
  268. package/dist/workflows/get-environment-overview.js.map +1 -1
  269. package/dist/workflows/get-run-details.d.ts +2 -2
  270. package/dist/workflows/get-run-details.d.ts.map +1 -1
  271. package/dist/workflows/get-run-details.js +14 -19
  272. package/dist/workflows/get-run-details.js.map +1 -1
  273. package/dist/workflows/retry-and-wait.d.ts.map +1 -1
  274. package/dist/workflows/retry-and-wait.js +3 -2
  275. package/dist/workflows/retry-and-wait.js.map +1 -1
  276. package/dist/workflows/run-and-wait.d.ts.map +1 -1
  277. package/dist/workflows/run-and-wait.js +3 -2
  278. package/dist/workflows/run-and-wait.js.map +1 -1
  279. package/package.json +2 -2
@@ -1,102 +1,65 @@
1
1
  import { z } from "zod";
2
2
  import { listWorkspaceSubgraphs, getWorkspaceSubgraph, createWorkspaceSubgraph, updateWorkspaceSubgraph, deleteWorkspaceSubgraph, } from "../coalesce/api/subgraphs.js";
3
- import { PaginationParams, buildJsonToolResponse, handleToolError, getToolOutputSchema, READ_ONLY_ANNOTATIONS, WRITE_ANNOTATIONS, DESTRUCTIVE_ANNOTATIONS, } from "../coalesce/types.js";
4
- export function registerSubgraphTools(server, client) {
5
- server.registerTool("list_workspace_subgraphs", {
6
- title: "List Workspace Subgraphs",
7
- description: "List all subgraphs in a Coalesce workspace. Use this to discover subgraph IDs.\n\nArgs:\n - workspaceID (string, required): The workspace ID\n - limit, startingFrom, orderBy, orderByDirection: Pagination\n\nReturns:\n { data: Subgraph[], next?: string, total?: number }",
8
- inputSchema: PaginationParams.extend({
9
- workspaceID: z.string().describe("The workspace ID"),
10
- }),
11
- outputSchema: getToolOutputSchema("list_workspace_subgraphs"),
12
- annotations: READ_ONLY_ANNOTATIONS,
13
- }, async (params) => {
14
- try {
15
- const result = await listWorkspaceSubgraphs(client, params);
16
- return buildJsonToolResponse("list_workspace_subgraphs", result);
17
- }
18
- catch (error) {
19
- return handleToolError(error);
20
- }
21
- });
22
- server.registerTool("get_workspace_subgraph", {
23
- title: "Get Workspace Subgraph",
24
- description: "Get details of a specific subgraph.\n\nArgs:\n - workspaceID (string, required): The workspace ID\n - subgraphID (string, required): The subgraph ID\n\nReturns:\n Subgraph object with name and node steps.",
25
- inputSchema: z.object({
26
- workspaceID: z.string().describe("The workspace ID"),
27
- subgraphID: z.string().describe("The subgraph ID"),
28
- }),
29
- outputSchema: getToolOutputSchema("get_workspace_subgraph"),
30
- annotations: READ_ONLY_ANNOTATIONS,
31
- }, async (params) => {
32
- try {
33
- const result = await getWorkspaceSubgraph(client, params);
34
- return buildJsonToolResponse("get_workspace_subgraph", result);
35
- }
36
- catch (error) {
37
- return handleToolError(error);
38
- }
39
- });
40
- server.registerTool("create_workspace_subgraph", {
41
- title: "Create Workspace Subgraph",
42
- description: "Create a subgraph in a Coalesce workspace. Subgraphs group nodes visually.\n\nArgs:\n - workspaceID (string, required): The workspace ID\n - name (string, required): Subgraph name\n - steps (string[], required): Array of node IDs to include\n\nReturns:\n Created subgraph with assigned ID.",
43
- inputSchema: z.object({
44
- workspaceID: z.string().describe("The workspace ID"),
45
- name: z.string().describe("Name for the subgraph"),
46
- steps: z
47
- .array(z.string())
48
- .describe("Array of node IDs to include in the subgraph"),
49
- }),
50
- outputSchema: getToolOutputSchema("create_workspace_subgraph"),
51
- annotations: WRITE_ANNOTATIONS,
52
- }, async (params) => {
53
- try {
54
- const result = await createWorkspaceSubgraph(client, params);
55
- return buildJsonToolResponse("create_workspace_subgraph", result);
56
- }
57
- catch (error) {
58
- return handleToolError(error);
59
- }
60
- });
61
- server.registerTool("update_workspace_subgraph", {
62
- title: "Update Workspace Subgraph",
63
- description: "Update a subgraph's name and member nodes. Replaces the entire steps array.\n\nArgs:\n - workspaceID (string, required): The workspace ID\n - subgraphID (string, required): The subgraph ID\n - name (string, required): Updated name\n - steps (string[], required): Updated node IDs\n\nReturns:\n Updated subgraph object.",
64
- inputSchema: z.object({
65
- workspaceID: z.string().describe("The workspace ID"),
66
- subgraphID: z.string().describe("The subgraph ID to update"),
67
- name: z.string().describe("Updated name for the subgraph"),
68
- steps: z
69
- .array(z.string())
70
- .describe("Updated array of node IDs to include in the subgraph"),
71
- }),
72
- outputSchema: getToolOutputSchema("update_workspace_subgraph"),
73
- annotations: WRITE_ANNOTATIONS,
74
- }, async (params) => {
75
- try {
76
- const result = await updateWorkspaceSubgraph(client, params);
77
- return buildJsonToolResponse("update_workspace_subgraph", result);
78
- }
79
- catch (error) {
80
- return handleToolError(error);
81
- }
82
- });
83
- server.registerTool("delete_workspace_subgraph", {
84
- title: "Delete Workspace Subgraph",
85
- description: "Delete a subgraph from a workspace. Destructive — the subgraph is removed but its member nodes are NOT deleted.\n\nArgs:\n - workspaceID (string, required): The workspace ID\n - subgraphID (string, required): The subgraph ID\n\nReturns:\n Confirmation message.",
86
- inputSchema: z.object({
87
- workspaceID: z.string().describe("The workspace ID"),
88
- subgraphID: z.string().describe("The subgraph ID to delete"),
89
- }),
90
- outputSchema: getToolOutputSchema("delete_workspace_subgraph"),
91
- annotations: DESTRUCTIVE_ANNOTATIONS,
92
- }, async (params) => {
93
- try {
94
- const result = await deleteWorkspaceSubgraph(client, params);
95
- return buildJsonToolResponse("delete_workspace_subgraph", result);
96
- }
97
- catch (error) {
98
- return handleToolError(error);
99
- }
100
- });
3
+ import { PaginationParams, READ_ONLY_ANNOTATIONS, WRITE_ANNOTATIONS, DESTRUCTIVE_ANNOTATIONS, } from "../coalesce/types.js";
4
+ import { defineSimpleTool, defineDestructiveTool } from "./tool-helpers.js";
5
+ export function defineSubgraphTools(server, client) {
6
+ return [
7
+ defineSimpleTool(client, "list_workspace_subgraphs", {
8
+ title: "List Workspace Subgraphs",
9
+ description: "List all subgraphs in a Coalesce workspace. Use this to discover subgraph IDs.\n\nArgs:\n - workspaceID (string, required): The workspace ID\n - limit, startingFrom, orderBy, orderByDirection: Pagination\n\nReturns:\n { data: Subgraph[], next?: string, total?: number }",
10
+ inputSchema: PaginationParams.extend({
11
+ workspaceID: z.string().describe("The workspace ID"),
12
+ }),
13
+ annotations: READ_ONLY_ANNOTATIONS,
14
+ }, listWorkspaceSubgraphs),
15
+ defineSimpleTool(client, "get_workspace_subgraph", {
16
+ title: "Get Workspace Subgraph",
17
+ description: "Get details of a specific subgraph.\n\nArgs:\n - workspaceID (string, required): The workspace ID\n - subgraphID (string, required): The subgraph ID\n\nReturns:\n Subgraph object with name and node steps.",
18
+ inputSchema: z.object({
19
+ workspaceID: z.string().describe("The workspace ID"),
20
+ subgraphID: z.string().describe("The subgraph ID"),
21
+ }),
22
+ annotations: READ_ONLY_ANNOTATIONS,
23
+ }, getWorkspaceSubgraph),
24
+ defineSimpleTool(client, "create_workspace_subgraph", {
25
+ title: "Create Workspace Subgraph",
26
+ description: "Create a subgraph in a Coalesce workspace. Subgraphs group nodes visually.\n\nArgs:\n - workspaceID (string, required): The workspace ID\n - name (string, required): Subgraph name\n - steps (string[], required): Array of node IDs to include\n\nReturns:\n Created subgraph with assigned ID.",
27
+ inputSchema: z.object({
28
+ workspaceID: z.string().describe("The workspace ID"),
29
+ name: z.string().describe("Name for the subgraph"),
30
+ steps: z
31
+ .array(z.string())
32
+ .describe("Array of node IDs to include in the subgraph"),
33
+ }),
34
+ annotations: WRITE_ANNOTATIONS,
35
+ }, createWorkspaceSubgraph),
36
+ defineSimpleTool(client, "update_workspace_subgraph", {
37
+ title: "Update Workspace Subgraph",
38
+ description: "Update a subgraph's name and member nodes. Replaces the entire steps array.\n\nArgs:\n - workspaceID (string, required): The workspace ID\n - subgraphID (string, required): The subgraph ID\n - name (string, required): Updated name\n - steps (string[], required): Updated node IDs\n\nReturns:\n Updated subgraph object.",
39
+ inputSchema: z.object({
40
+ workspaceID: z.string().describe("The workspace ID"),
41
+ subgraphID: z.string().describe("The subgraph ID to update"),
42
+ name: z.string().describe("Updated name for the subgraph"),
43
+ steps: z
44
+ .array(z.string())
45
+ .describe("Updated array of node IDs to include in the subgraph"),
46
+ }),
47
+ annotations: WRITE_ANNOTATIONS,
48
+ }, updateWorkspaceSubgraph),
49
+ defineDestructiveTool(server, client, "delete_workspace_subgraph", {
50
+ title: "Delete Workspace Subgraph",
51
+ description: "Delete a subgraph from a workspace. Destructive — the subgraph is removed but its member nodes are NOT deleted.\n\nArgs:\n - workspaceID (string, required): The workspace ID\n - subgraphID (string, required): The subgraph ID\n - confirmed (boolean, optional): Set to true after the user explicitly confirms deletion\n\nReturns:\n Confirmation message.",
52
+ inputSchema: z.object({
53
+ workspaceID: z.string().describe("The workspace ID"),
54
+ subgraphID: z.string().describe("The subgraph ID to delete"),
55
+ confirmed: z
56
+ .boolean()
57
+ .optional()
58
+ .describe("Set to true after the user explicitly confirms the deletion."),
59
+ }),
60
+ annotations: DESTRUCTIVE_ANNOTATIONS,
61
+ confirmMessage: (params) => `This will permanently delete subgraph "${params.subgraphID}" from workspace "${params.workspaceID}". Member nodes will NOT be deleted.`,
62
+ }, deleteWorkspaceSubgraph),
63
+ ];
101
64
  }
102
65
  //# sourceMappingURL=subgraphs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"subgraphs.js","sourceRoot":"","sources":["../../src/mcp/subgraphs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAC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AClC,WAAW,EACT,qWAAqW;YACvW,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;gBACpB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC;gBACpD,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,2BAA2B,CAAC;gBAC5D,SAAS,EAAE,CAAC;qBACT,OAAO,EAAE;qBACT,QAAQ,EAAE;qBACV,QAAQ,CAAC,8DAA8D,CAAC;aAC5E,CAAC;YACF,WAAW,EAAE,uBAAuB;YACpC,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,0CAA0C,MAAM,CAAC,UAAU,qBAAqB,MAAM,CAAC,WAAW,sCAAsC;SACrK,EAAE,uBAAuB,CAAC;KAC1B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,37 @@
1
+ import type { z } from "zod";
2
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import type { CoalesceClient } from "../client.js";
4
+ import { type ToolDefinition } from "../coalesce/types.js";
5
+ type ToolAnnotations = {
6
+ readOnlyHint?: boolean;
7
+ idempotentHint?: boolean;
8
+ destructiveHint?: boolean;
9
+ openWorldHint?: boolean;
10
+ };
11
+ type ToolDef<S extends z.ZodType> = {
12
+ title: string;
13
+ description: string;
14
+ inputSchema: S;
15
+ annotations: ToolAnnotations;
16
+ sanitize?: boolean;
17
+ };
18
+ /**
19
+ * Define a simple passthrough tool: calls an API function with (client, params)
20
+ * and wraps the result in buildJsonToolResponse / handleToolError.
21
+ */
22
+ export declare function defineSimpleTool<S extends z.ZodType>(client: CoalesceClient, name: string, def: ToolDef<S>, apiFunc: (client: CoalesceClient, params: z.infer<S>) => Promise<unknown>): ToolDefinition;
23
+ /**
24
+ * Define a local-only tool that does not call the Coalesce API.
25
+ * Provides the same error handling and response formatting as defineSimpleTool
26
+ * without requiring a CoalesceClient dependency.
27
+ */
28
+ export declare function defineLocalTool<S extends z.ZodType>(name: string, def: ToolDef<S>, handler: (params: z.infer<S>) => unknown | Promise<unknown>): ToolDefinition;
29
+ /**
30
+ * Define a destructive tool that requires user confirmation before executing.
31
+ * The `server` parameter is still needed for elicitation.
32
+ */
33
+ export declare function defineDestructiveTool<S extends z.ZodType>(server: McpServer, client: CoalesceClient, name: string, def: ToolDef<S> & {
34
+ confirmMessage: (params: z.infer<S>) => string;
35
+ }, apiFunc: (client: CoalesceClient, params: z.infer<S>) => Promise<unknown>): ToolDefinition;
36
+ export {};
37
+ //# sourceMappingURL=tool-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-helpers.d.ts","sourceRoot":"","sources":["../../src/mcp/tool-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAKL,KAAK,cAAc,EACpB,MAAM,sBAAsB,CAAC;AAG9B,KAAK,eAAe,GAAG;IACrB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,KAAK,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,IAAI;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,CAAC,CAAC;IACf,WAAW,EAAE,eAAe,CAAC;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAQF;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EAClD,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,EACf,OAAO,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,GACxE,cAAc,CAmBhB;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EACjD,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,EACf,OAAO,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAC1D,cAAc,CAmBhB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EACvD,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG;IAAE,cAAc,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,MAAM,CAAA;CAAE,EACpE,OAAO,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,GACxE,cAAc,CA2BhB"}
@@ -0,0 +1,82 @@
1
+ import { buildJsonToolResponse, handleToolError, getToolOutputSchema, sanitizeResponse, } from "../coalesce/types.js";
2
+ import { requireDestructiveConfirmation } from "../services/shared/elicitation.js";
3
+ /**
4
+ * Define a simple passthrough tool: calls an API function with (client, params)
5
+ * and wraps the result in buildJsonToolResponse / handleToolError.
6
+ */
7
+ export function defineSimpleTool(client, name, def, apiFunc) {
8
+ return [
9
+ name,
10
+ {
11
+ title: def.title,
12
+ description: def.description,
13
+ inputSchema: def.inputSchema,
14
+ outputSchema: getToolOutputSchema(name),
15
+ annotations: def.annotations,
16
+ },
17
+ (async (params) => {
18
+ try {
19
+ const result = await apiFunc(client, params);
20
+ return buildJsonToolResponse(name, def.sanitize ? sanitizeResponse(result) : result);
21
+ }
22
+ catch (error) {
23
+ return handleToolError(error);
24
+ }
25
+ }),
26
+ ];
27
+ }
28
+ /**
29
+ * Define a local-only tool that does not call the Coalesce API.
30
+ * Provides the same error handling and response formatting as defineSimpleTool
31
+ * without requiring a CoalesceClient dependency.
32
+ */
33
+ export function defineLocalTool(name, def, handler) {
34
+ return [
35
+ name,
36
+ {
37
+ title: def.title,
38
+ description: def.description,
39
+ inputSchema: def.inputSchema,
40
+ outputSchema: getToolOutputSchema(name),
41
+ annotations: def.annotations,
42
+ },
43
+ (async (params) => {
44
+ try {
45
+ const result = await handler(params);
46
+ return buildJsonToolResponse(name, def.sanitize ? sanitizeResponse(result) : result);
47
+ }
48
+ catch (error) {
49
+ return handleToolError(error);
50
+ }
51
+ }),
52
+ ];
53
+ }
54
+ /**
55
+ * Define a destructive tool that requires user confirmation before executing.
56
+ * The `server` parameter is still needed for elicitation.
57
+ */
58
+ export function defineDestructiveTool(server, client, name, def, apiFunc) {
59
+ return [
60
+ name,
61
+ {
62
+ title: def.title,
63
+ description: def.description,
64
+ inputSchema: def.inputSchema,
65
+ outputSchema: getToolOutputSchema(name),
66
+ annotations: def.annotations,
67
+ },
68
+ (async (params) => {
69
+ try {
70
+ const approvalResponse = await requireDestructiveConfirmation(server, name, def.confirmMessage(params), params.confirmed);
71
+ if (approvalResponse)
72
+ return approvalResponse;
73
+ const result = await apiFunc(client, params);
74
+ return buildJsonToolResponse(name, def.sanitize ? sanitizeResponse(result) : result);
75
+ }
76
+ catch (error) {
77
+ return handleToolError(error);
78
+ }
79
+ }),
80
+ ];
81
+ }
82
+ //# sourceMappingURL=tool-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-helpers.js","sourceRoot":"","sources":["../../src/mcp/tool-helpers.ts"],"names":[],"mappings":"AAGA,OAAO,EAC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ACH,CAAC,CAAiB;KACnB,CAAC;AACJ,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
  import type { CoalesceClient } from "../client.js";
3
- export declare function registerUserTools(server: McpServer, client: CoalesceClient): void;
3
+ import { type ToolDefinition } from "../coalesce/types.js";
4
+ export declare function defineUserTools(server: McpServer, client: CoalesceClient): ToolDefinition[];
4
5
  //# sourceMappingURL=users.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../src/mcp/users.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAqBnD,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,cAAc,GACrB,IAAI,CA2LN"}
1
+ {"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../src/mcp/users.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAWnD,OAAO,EAKL,KAAK,cAAc,EACpB,MAAM,sBAAsB,CAAC;AAG9B,wBAAgB,eAAe,CAC7B,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,cAAc,GACrB,cAAc,EAAE,CA6GlB"}
package/dist/mcp/users.js CHANGED
@@ -1,153 +1,100 @@
1
1
  import { z } from "zod";
2
2
  import { listOrgUsers, getUserRoles, listUserRoles, setOrgRole, setProjectRole, deleteProjectRole, setEnvRole, deleteEnvRole, } from "../coalesce/api/users.js";
3
- import { PaginationParams, buildJsonToolResponse, handleToolError, getToolOutputSchema, READ_ONLY_ANNOTATIONS, IDEMPOTENT_WRITE_ANNOTATIONS, DESTRUCTIVE_ANNOTATIONS, } from "../coalesce/types.js";
4
- export function registerUserTools(server, client) {
5
- server.registerTool("list_org_users", {
6
- title: "List Org Users",
7
- description: "List all users in the Coalesce organization.\n\nArgs:\n - limit, startingFrom, orderBy, orderByDirection: Pagination controls\n\nReturns:\n { data: User[], next?: string, total?: number }",
8
- inputSchema: PaginationParams,
9
- outputSchema: getToolOutputSchema("list_org_users"),
10
- annotations: READ_ONLY_ANNOTATIONS,
11
- }, async (params) => {
12
- try {
13
- const result = await listOrgUsers(client, params);
14
- return buildJsonToolResponse("list_org_users", result);
15
- }
16
- catch (error) {
17
- return handleToolError(error);
18
- }
19
- });
20
- server.registerTool("get_user_roles", {
21
- title: "Get User Roles",
22
- description: "Get roles assigned to a specific user, optionally scoped to a project or environment.\n\nArgs:\n - userID (string, required): The user ID\n - projectID (string, optional): Scope to a specific project\n - environmentID (string, optional): Scope to a specific environment\n\nReturns:\n Role assignments for the user.",
23
- inputSchema: z.object({
24
- userID: z.string().describe("The user ID"),
25
- projectID: z.string().optional().describe("Optional project scope filter"),
26
- environmentID: z.string().optional().describe("Optional environment scope filter"),
27
- }),
28
- outputSchema: getToolOutputSchema("get_user_roles"),
29
- annotations: READ_ONLY_ANNOTATIONS,
30
- }, async (params) => {
31
- try {
32
- const result = await getUserRoles(client, params);
33
- return buildJsonToolResponse("get_user_roles", result);
34
- }
35
- catch (error) {
36
- return handleToolError(error);
37
- }
38
- });
39
- server.registerTool("list_user_roles", {
40
- title: "List User Roles",
41
- description: "List roles for all users in the organization, optionally scoped.\n\nArgs:\n - projectID (string, optional): Scope to a project\n - environmentID (string, optional): Scope to an environment\n\nReturns:\n { data: RoleAssignment[], next?: string, total?: number }",
42
- inputSchema: z.object({
43
- projectID: z.string().optional().describe("Optional project scope filter"),
44
- environmentID: z.string().optional().describe("Optional environment scope filter"),
45
- }),
46
- outputSchema: getToolOutputSchema("list_user_roles"),
47
- annotations: READ_ONLY_ANNOTATIONS,
48
- }, async (params) => {
49
- try {
50
- const result = await listUserRoles(client, params);
51
- return buildJsonToolResponse("list_user_roles", result);
52
- }
53
- catch (error) {
54
- return handleToolError(error);
55
- }
56
- });
57
- server.registerTool("set_org_role", {
58
- title: "Set Org Role",
59
- description: "Set the organization-level role for a user. Idempotent — safe to call multiple times.\n\nArgs:\n - userID (string, required): The user ID\n - role (string, required): Role to assign (e.g., 'admin', 'member', 'viewer')\n\nReturns:\n Updated role assignment.",
60
- inputSchema: z.object({
61
- userID: z.string().describe("The user ID"),
62
- role: z.string().describe("The organization role to assign (e.g., 'admin', 'member', 'viewer')"),
63
- }),
64
- outputSchema: getToolOutputSchema("set_org_role"),
65
- annotations: IDEMPOTENT_WRITE_ANNOTATIONS,
66
- }, async (params) => {
67
- try {
3
+ import { PaginationParams, READ_ONLY_ANNOTATIONS, IDEMPOTENT_WRITE_ANNOTATIONS, DESTRUCTIVE_ANNOTATIONS, } from "../coalesce/types.js";
4
+ import { defineSimpleTool, defineDestructiveTool } from "./tool-helpers.js";
5
+ export function defineUserTools(server, client) {
6
+ return [
7
+ defineSimpleTool(client, "list_org_users", {
8
+ title: "List Org Users",
9
+ description: "List all users in the Coalesce organization.\n\nArgs:\n - limit, startingFrom, orderBy, orderByDirection: Pagination controls\n\nReturns:\n { data: User[], next?: string, total?: number }",
10
+ inputSchema: PaginationParams,
11
+ annotations: READ_ONLY_ANNOTATIONS,
12
+ }, listOrgUsers),
13
+ defineSimpleTool(client, "get_user_roles", {
14
+ title: "Get User Roles",
15
+ description: "Get roles assigned to a specific user, optionally scoped to a project or environment.\n\nArgs:\n - userID (string, required): The user ID\n - projectID (string, optional): Scope to a specific project\n - environmentID (string, optional): Scope to a specific environment\n\nReturns:\n Role assignments for the user.",
16
+ inputSchema: z.object({
17
+ userID: z.string().describe("The user ID"),
18
+ projectID: z.string().optional().describe("Optional project scope filter"),
19
+ environmentID: z.string().optional().describe("Optional environment scope filter"),
20
+ }),
21
+ annotations: READ_ONLY_ANNOTATIONS,
22
+ }, getUserRoles),
23
+ defineSimpleTool(client, "list_user_roles", {
24
+ title: "List User Roles",
25
+ description: "List roles for all users in the organization, optionally scoped.\n\nArgs:\n - projectID (string, optional): Scope to a project\n - environmentID (string, optional): Scope to an environment\n\nReturns:\n { data: RoleAssignment[], next?: string, total?: number }",
26
+ inputSchema: z.object({
27
+ projectID: z.string().optional().describe("Optional project scope filter"),
28
+ environmentID: z.string().optional().describe("Optional environment scope filter"),
29
+ }),
30
+ annotations: READ_ONLY_ANNOTATIONS,
31
+ }, listUserRoles),
32
+ defineSimpleTool(client, "set_org_role", {
33
+ title: "Set Org Role",
34
+ description: "Set the organization-level role for a user. Idempotent — safe to call multiple times.\n\nArgs:\n - userID (string, required): The user ID\n - role (string, required): Role to assign (e.g., 'admin', 'member', 'viewer')\n\nReturns:\n Updated role assignment.",
35
+ inputSchema: z.object({
36
+ userID: z.string().describe("The user ID"),
37
+ role: z.string().describe("The organization role to assign (e.g., 'admin', 'member', 'viewer')"),
38
+ }),
39
+ annotations: IDEMPOTENT_WRITE_ANNOTATIONS,
40
+ }, (client, params) => {
68
41
  const { userID, ...body } = params;
69
- const result = await setOrgRole(client, { userID, body });
70
- return buildJsonToolResponse("set_org_role", result);
71
- }
72
- catch (error) {
73
- return handleToolError(error);
74
- }
75
- });
76
- server.registerTool("set_project_role", {
77
- title: "Set Project Role",
78
- description: "Set a user's role for a specific project. Idempotent.\n\nArgs:\n - userID (string, required): The user ID\n - projectID (string, required): The project ID\n - role (string, required): Role to assign (e.g., 'admin', 'developer', 'viewer')\n\nReturns:\n Updated role assignment.",
79
- inputSchema: z.object({
80
- userID: z.string().describe("The user ID"),
81
- projectID: z.string().describe("The project ID"),
82
- role: z.string().describe("The project role to assign (e.g., 'admin', 'developer', 'viewer')"),
83
- }),
84
- outputSchema: getToolOutputSchema("set_project_role"),
85
- annotations: IDEMPOTENT_WRITE_ANNOTATIONS,
86
- }, async (params) => {
87
- try {
88
- const { userID, projectID, ...body } = params;
89
- const result = await setProjectRole(client, { userID, projectID, body });
90
- return buildJsonToolResponse("set_project_role", result);
91
- }
92
- catch (error) {
93
- return handleToolError(error);
94
- }
95
- });
96
- server.registerTool("delete_project_role", {
97
- title: "Delete Project Role",
98
- description: "Remove a user's role from a specific project. Destructive — the user will lose project access.\n\nArgs:\n - userID (string, required): The user ID\n - projectID (string, required): The project ID\n\nReturns:\n Confirmation message.",
99
- inputSchema: z.object({
100
- userID: z.string().describe("The user ID"),
101
- projectID: z.string().describe("The project ID"),
42
+ return setOrgRole(client, { userID, body });
102
43
  }),
103
- outputSchema: getToolOutputSchema("delete_project_role"),
104
- annotations: DESTRUCTIVE_ANNOTATIONS,
105
- }, async (params) => {
106
- try {
107
- const result = await deleteProjectRole(client, params);
108
- return buildJsonToolResponse("delete_project_role", result);
109
- }
110
- catch (error) {
111
- return handleToolError(error);
112
- }
113
- });
114
- server.registerTool("set_env_role", {
115
- title: "Set Env Role",
116
- description: "Set a user's role for a specific environment. Idempotent.\n\nArgs:\n - userID (string, required): The user ID\n - environmentID (string, required): The environment ID\n - role (string, required): Role to assign\n\nReturns:\n Updated role assignment.",
117
- inputSchema: z.object({
118
- userID: z.string().describe("The user ID"),
119
- environmentID: z.string().describe("The environment ID"),
120
- role: z.string().describe("The environment role to assign (e.g., 'admin', 'developer', 'viewer')"),
44
+ defineSimpleTool(client, "set_project_role", {
45
+ title: "Set Project Role",
46
+ description: "Set a user's role for a specific project. Idempotent.\n\nArgs:\n - userID (string, required): The user ID\n - projectID (string, required): The project ID\n - role (string, required): Role to assign (e.g., 'admin', 'developer', 'viewer')\n\nReturns:\n Updated role assignment.",
47
+ inputSchema: z.object({
48
+ userID: z.string().describe("The user ID"),
49
+ projectID: z.string().describe("The project ID"),
50
+ role: z.string().describe("The project role to assign (e.g., 'admin', 'developer', 'viewer')"),
51
+ }),
52
+ annotations: IDEMPOTENT_WRITE_ANNOTATIONS,
53
+ }, (client, params) => {
54
+ const { userID, projectID, role } = params;
55
+ return setProjectRole(client, { userID, projectID, body: { projectRole: role } });
121
56
  }),
122
- outputSchema: getToolOutputSchema("set_env_role"),
123
- annotations: IDEMPOTENT_WRITE_ANNOTATIONS,
124
- }, async (params) => {
125
- try {
126
- const { userID, environmentID, ...body } = params;
127
- const result = await setEnvRole(client, { userID, environmentID, body });
128
- return buildJsonToolResponse("set_env_role", result);
129
- }
130
- catch (error) {
131
- return handleToolError(error);
132
- }
133
- });
134
- server.registerTool("delete_env_role", {
135
- title: "Delete Env Role",
136
- description: "Remove a user's role from a specific environment. Destructive.\n\nArgs:\n - userID (string, required): The user ID\n - environmentID (string, required): The environment ID\n\nReturns:\n Confirmation message.",
137
- inputSchema: z.object({
138
- userID: z.string().describe("The user ID"),
139
- environmentID: z.string().describe("The environment ID"),
57
+ defineDestructiveTool(server, client, "delete_project_role", {
58
+ title: "Delete Project Role",
59
+ description: "Remove a user's role from a specific project. Destructive — the user will lose project access immediately.\n\nArgs:\n - userID (string, required): The user ID\n - projectID (string, required): The project ID\n - confirmed (boolean, optional): Set to true after the user explicitly confirms the role removal\n\nReturns:\n Confirmation message.",
60
+ inputSchema: z.object({
61
+ userID: z.string().describe("The user ID"),
62
+ projectID: z.string().describe("The project ID"),
63
+ confirmed: z
64
+ .boolean()
65
+ .optional()
66
+ .describe("Set to true after the user explicitly confirms the role removal."),
67
+ }),
68
+ annotations: DESTRUCTIVE_ANNOTATIONS,
69
+ confirmMessage: (params) => `This will remove the project role for user "${params.userID}" on project "${params.projectID}". The user will lose project access immediately.`,
70
+ }, deleteProjectRole),
71
+ defineSimpleTool(client, "set_env_role", {
72
+ title: "Set Env Role",
73
+ description: "Set a user's role for a specific environment. Idempotent.\n\nArgs:\n - userID (string, required): The user ID\n - environmentID (string, required): The environment ID\n - role (string, required): Role to assign\n\nReturns:\n Updated role assignment.",
74
+ inputSchema: z.object({
75
+ userID: z.string().describe("The user ID"),
76
+ environmentID: z.string().describe("The environment ID"),
77
+ role: z.string().describe("The environment role to assign (e.g., 'admin', 'developer', 'viewer')"),
78
+ }),
79
+ annotations: IDEMPOTENT_WRITE_ANNOTATIONS,
80
+ }, (client, params) => {
81
+ const { userID, environmentID, role } = params;
82
+ return setEnvRole(client, { userID, environmentID, body: { environmentRole: role } });
140
83
  }),
141
- outputSchema: getToolOutputSchema("delete_env_role"),
142
- annotations: DESTRUCTIVE_ANNOTATIONS,
143
- }, async (params) => {
144
- try {
145
- const result = await deleteEnvRole(client, params);
146
- return buildJsonToolResponse("delete_env_role", result);
147
- }
148
- catch (error) {
149
- return handleToolError(error);
150
- }
151
- });
84
+ defineDestructiveTool(server, client, "delete_env_role", {
85
+ title: "Delete Env Role",
86
+ description: "Remove a user's role from a specific environment. Destructive — the user will lose environment access immediately.\n\nArgs:\n - userID (string, required): The user ID\n - environmentID (string, required): The environment ID\n - confirmed (boolean, optional): Set to true after the user explicitly confirms the role removal\n\nReturns:\n Confirmation message.",
87
+ inputSchema: z.object({
88
+ userID: z.string().describe("The user ID"),
89
+ environmentID: z.string().describe("The environment ID"),
90
+ confirmed: z
91
+ .boolean()
92
+ .optional()
93
+ .describe("Set to true after the user explicitly confirms the role removal."),
94
+ }),
95
+ annotations: DESTRUCTIVE_ANNOTATIONS,
96
+ confirmMessage: (params) => `This will remove the environment role for user "${params.userID}" on environment "${params.environmentID}". The user will lose environment access immediately.`,
97
+ }, deleteEnvRole),
98
+ ];
152
99
  }
153
100
  //# sourceMappingURL=users.js.map