@atoms-tech/atoms-mcp 0.1.0

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 (110) hide show
  1. package/bin/atoms-mcp.js +2 -0
  2. package/dist/auth/login.d.ts +23 -0
  3. package/dist/auth/login.d.ts.map +1 -0
  4. package/dist/auth/login.js +246 -0
  5. package/dist/auth/login.js.map +1 -0
  6. package/dist/auth/refresh.d.ts +17 -0
  7. package/dist/auth/refresh.d.ts.map +1 -0
  8. package/dist/auth/refresh.js +82 -0
  9. package/dist/auth/refresh.js.map +1 -0
  10. package/dist/auth/token-store.d.ts +34 -0
  11. package/dist/auth/token-store.d.ts.map +1 -0
  12. package/dist/auth/token-store.js +61 -0
  13. package/dist/auth/token-store.js.map +1 -0
  14. package/dist/config.d.ts +17 -0
  15. package/dist/config.d.ts.map +1 -0
  16. package/dist/config.js +17 -0
  17. package/dist/config.js.map +1 -0
  18. package/dist/db/client.d.ts +30 -0
  19. package/dist/db/client.d.ts.map +1 -0
  20. package/dist/db/client.js +110 -0
  21. package/dist/db/client.js.map +1 -0
  22. package/dist/db/graph.d.ts +8 -0
  23. package/dist/db/graph.d.ts.map +1 -0
  24. package/dist/db/graph.js +8 -0
  25. package/dist/db/graph.js.map +1 -0
  26. package/dist/db/queries.d.ts +77 -0
  27. package/dist/db/queries.d.ts.map +1 -0
  28. package/dist/db/queries.js +210 -0
  29. package/dist/db/queries.js.map +1 -0
  30. package/dist/index.d.ts +12 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +92 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/middleware/audit.d.ts +26 -0
  35. package/dist/middleware/audit.d.ts.map +1 -0
  36. package/dist/middleware/audit.js +44 -0
  37. package/dist/middleware/audit.js.map +1 -0
  38. package/dist/middleware/rate-limiter.d.ts +21 -0
  39. package/dist/middleware/rate-limiter.d.ts.map +1 -0
  40. package/dist/middleware/rate-limiter.js +43 -0
  41. package/dist/middleware/rate-limiter.js.map +1 -0
  42. package/dist/middleware/validator.d.ts +22 -0
  43. package/dist/middleware/validator.d.ts.map +1 -0
  44. package/dist/middleware/validator.js +91 -0
  45. package/dist/middleware/validator.js.map +1 -0
  46. package/dist/server.d.ts +14 -0
  47. package/dist/server.d.ts.map +1 -0
  48. package/dist/server.js +511 -0
  49. package/dist/server.js.map +1 -0
  50. package/dist/tools/_base.d.ts +58 -0
  51. package/dist/tools/_base.d.ts.map +1 -0
  52. package/dist/tools/_base.js +109 -0
  53. package/dist/tools/_base.js.map +1 -0
  54. package/dist/tools/create-item.d.ts +43 -0
  55. package/dist/tools/create-item.d.ts.map +1 -0
  56. package/dist/tools/create-item.js +118 -0
  57. package/dist/tools/create-item.js.map +1 -0
  58. package/dist/tools/delete-item.d.ts +38 -0
  59. package/dist/tools/delete-item.d.ts.map +1 -0
  60. package/dist/tools/delete-item.js +69 -0
  61. package/dist/tools/delete-item.js.map +1 -0
  62. package/dist/tools/export-mermaid.d.ts +36 -0
  63. package/dist/tools/export-mermaid.d.ts.map +1 -0
  64. package/dist/tools/export-mermaid.js +125 -0
  65. package/dist/tools/export-mermaid.js.map +1 -0
  66. package/dist/tools/get-coverage.d.ts +34 -0
  67. package/dist/tools/get-coverage.d.ts.map +1 -0
  68. package/dist/tools/get-coverage.js +36 -0
  69. package/dist/tools/get-coverage.js.map +1 -0
  70. package/dist/tools/get-history.d.ts +34 -0
  71. package/dist/tools/get-history.d.ts.map +1 -0
  72. package/dist/tools/get-history.js +53 -0
  73. package/dist/tools/get-history.js.map +1 -0
  74. package/dist/tools/get-item.d.ts +62 -0
  75. package/dist/tools/get-item.d.ts.map +1 -0
  76. package/dist/tools/get-item.js +93 -0
  77. package/dist/tools/get-item.js.map +1 -0
  78. package/dist/tools/link-items.d.ts +41 -0
  79. package/dist/tools/link-items.d.ts.map +1 -0
  80. package/dist/tools/link-items.js +150 -0
  81. package/dist/tools/link-items.js.map +1 -0
  82. package/dist/tools/list-items.d.ts +37 -0
  83. package/dist/tools/list-items.d.ts.map +1 -0
  84. package/dist/tools/list-items.js +36 -0
  85. package/dist/tools/list-items.js.map +1 -0
  86. package/dist/tools/list-projects.d.ts +38 -0
  87. package/dist/tools/list-projects.d.ts.map +1 -0
  88. package/dist/tools/list-projects.js +28 -0
  89. package/dist/tools/list-projects.js.map +1 -0
  90. package/dist/tools/record-test-result.d.ts +41 -0
  91. package/dist/tools/record-test-result.d.ts.map +1 -0
  92. package/dist/tools/record-test-result.js +80 -0
  93. package/dist/tools/record-test-result.js.map +1 -0
  94. package/dist/tools/search.d.ts +34 -0
  95. package/dist/tools/search.d.ts.map +1 -0
  96. package/dist/tools/search.js +28 -0
  97. package/dist/tools/search.js.map +1 -0
  98. package/dist/tools/update-item.d.ts +43 -0
  99. package/dist/tools/update-item.d.ts.map +1 -0
  100. package/dist/tools/update-item.js +98 -0
  101. package/dist/tools/update-item.js.map +1 -0
  102. package/dist/types/responses.d.ts +58 -0
  103. package/dist/types/responses.d.ts.map +1 -0
  104. package/dist/types/responses.js +6 -0
  105. package/dist/types/responses.js.map +1 -0
  106. package/dist/types/work-item.d.ts +69 -0
  107. package/dist/types/work-item.d.ts.map +1 -0
  108. package/dist/types/work-item.js +8 -0
  109. package/dist/types/work-item.js.map +1 -0
  110. package/package.json +50 -0
package/dist/server.js ADDED
@@ -0,0 +1,511 @@
1
+ /**
2
+ * ATOMS MCP Server — Tool registration and initialization.
3
+ *
4
+ * Registers all 10 tools with the MCP SDK using server.registerTool().
5
+ * Tools are implemented in separate files under src/tools/.
6
+ *
7
+ * Naming: atoms_{action}_{resource} (snake_case with service prefix)
8
+ * Server name: atoms-mcp-server (follows {service}-mcp-server convention)
9
+ */
10
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
11
+ import { z } from "zod";
12
+ import { logAudit, startTimer } from "./middleware/audit.js";
13
+ import { checkRateLimit } from "./middleware/rate-limiter.js";
14
+ import { getClient, getUserId } from "./db/client.js";
15
+ import { formatErrorResult, rateLimitError } from "./tools/_base.js";
16
+ import { randomUUID } from "crypto";
17
+ export const server = new McpServer({
18
+ name: "atoms-mcp-server",
19
+ version: "0.1.0",
20
+ });
21
+ // Session ID for grouping tool calls in audit log
22
+ const SESSION_ID = randomUUID();
23
+ const CLIENT_NAME = process.env.ATOMS_CLIENT_NAME ?? "unknown";
24
+ /**
25
+ * Wrap a tool handler with rate limiting + audit logging.
26
+ * This is the middleware pipeline for every tool call.
27
+ */
28
+ function withMiddleware(toolName, handler) {
29
+ return async (params) => {
30
+ // Rate limit check
31
+ let userId;
32
+ try {
33
+ await getClient(); // ensure auth
34
+ userId = getUserId();
35
+ }
36
+ catch {
37
+ // Auth will fail inside the handler with proper error
38
+ return handler(params);
39
+ }
40
+ const rateCheck = checkRateLimit(userId);
41
+ if (!rateCheck.allowed) {
42
+ return formatErrorResult(rateLimitError(rateCheck.retryAfterSeconds));
43
+ }
44
+ // Execute with timing
45
+ const elapsed = startTimer();
46
+ let status = "success";
47
+ let errorMsg;
48
+ try {
49
+ const result = await handler(params);
50
+ // Detect error responses
51
+ const resultObj = result;
52
+ if (resultObj?.isError === true) {
53
+ status = "error";
54
+ const content = resultObj?.content;
55
+ if (content?.[0]?.text) {
56
+ try {
57
+ const parsed = JSON.parse(content[0].text);
58
+ errorMsg = parsed.message;
59
+ }
60
+ catch { /* not JSON */ }
61
+ }
62
+ }
63
+ return result;
64
+ }
65
+ catch (err) {
66
+ status = "error";
67
+ errorMsg = err instanceof Error ? err.message : String(err);
68
+ throw err;
69
+ }
70
+ finally {
71
+ // Fire-and-forget audit log
72
+ const entry = {
73
+ tool_name: toolName,
74
+ params: params,
75
+ status,
76
+ duration_ms: elapsed(),
77
+ error_msg: errorMsg,
78
+ project_id: params.project_id,
79
+ session_id: SESSION_ID,
80
+ client_name: CLIENT_NAME,
81
+ };
82
+ try {
83
+ const client = await getClient();
84
+ logAudit(client, userId, entry);
85
+ }
86
+ catch { /* non-fatal */ }
87
+ }
88
+ };
89
+ }
90
+ /** Expose session ID for change_history writes */
91
+ export function getMcpSessionId() {
92
+ return SESSION_ID;
93
+ }
94
+ // ---------------------------------------------------------------------------
95
+ // Tool Registration — Entry Point
96
+ // ---------------------------------------------------------------------------
97
+ server.registerTool("atoms_list_projects", {
98
+ title: "List ATOMS Projects",
99
+ description: `List all projects the authenticated user has access to.
100
+
101
+ This is the ENTRY POINT tool. Call this first to discover project IDs,
102
+ then use those IDs with all other tools.
103
+
104
+ Args: None
105
+
106
+ Returns:
107
+ { status: "success", data: [{ id, name, description, org_id, created_at }] }
108
+
109
+ Examples:
110
+ - "What projects do I have?" → atoms_list_projects()
111
+ - "Show my projects" → atoms_list_projects()
112
+
113
+ Workflow:
114
+ atoms_list_projects → atoms_list_items(project_id) → atoms_get_item(project_id, item_id)`,
115
+ inputSchema: {},
116
+ annotations: {
117
+ readOnlyHint: true,
118
+ destructiveHint: false,
119
+ idempotentHint: true,
120
+ openWorldHint: false,
121
+ },
122
+ }, withMiddleware("atoms_list_projects", async () => {
123
+ const { listProjectsHandler } = await import("./tools/list-projects.js");
124
+ return listProjectsHandler();
125
+ }));
126
+ // ---------------------------------------------------------------------------
127
+ // Tool Registration — Phase 2 (Read Tools)
128
+ // ---------------------------------------------------------------------------
129
+ server.registerTool("atoms_list_items", {
130
+ title: "List ATOMS Items",
131
+ description: `List items in an ATOMS project with optional type/domain/level filters.
132
+
133
+ This is the primary ENTRY POINT for discovering items. Use it to browse
134
+ project contents before drilling into specific items with atoms_get_item.
135
+
136
+ Args:
137
+ - project_id (string, UUID): The project to list items from
138
+ - type (string, optional): Filter: requirement|test-case|note|table
139
+ - domain (string, optional): Filter by domain tag
140
+ - level (string, optional): Filter by level (System, Subsystem, Component)
141
+ - limit (number, optional): Max results, 1-200 (default 50)
142
+ - offset (number, optional): Pagination offset (default 0)
143
+
144
+ Returns:
145
+ { status: "success", data: [{ id, title, type, status, domains, level }], meta: { total_count, limit, offset, has_more } }
146
+
147
+ Examples:
148
+ - "Show me all requirements" → atoms_list_items(project_id, type="requirement")
149
+ - "What test cases exist?" → atoms_list_items(project_id, type="test-case")
150
+
151
+ Errors:
152
+ - "Project not found" → verify project_id
153
+ - "Access denied" → check org membership`,
154
+ inputSchema: {
155
+ project_id: z.string().uuid("Must be a valid project UUID")
156
+ .describe("UUID of the project"),
157
+ type: z.enum(["requirement", "test-case", "note", "table"]).optional()
158
+ .describe("Filter by item type"),
159
+ domain: z.string().optional()
160
+ .describe("Filter by domain tag (e.g., 'Safety', 'Performance')"),
161
+ level: z.string().optional()
162
+ .describe("Filter by level (System, Subsystem, Component)"),
163
+ limit: z.number().int().min(1).max(200).default(50)
164
+ .describe("Max results (default 50, max 200)"),
165
+ offset: z.number().int().min(0).default(0)
166
+ .describe("Pagination offset (default 0)"),
167
+ },
168
+ annotations: {
169
+ readOnlyHint: true,
170
+ destructiveHint: false,
171
+ idempotentHint: true,
172
+ openWorldHint: false,
173
+ },
174
+ }, withMiddleware("atoms_list_items", async (params) => {
175
+ const { listItemsHandler } = await import("./tools/list-items.js");
176
+ return listItemsHandler(params);
177
+ }));
178
+ server.registerTool("atoms_get_item", {
179
+ title: "Get ATOMS Item Details",
180
+ description: `Get full details of a single item including relationships, test history, and ownership.
181
+
182
+ Use after atoms_list_items or atoms_search to drill into a specific item.
183
+
184
+ Args:
185
+ - project_id (string, UUID): The project containing the item
186
+ - item_id (string): Item ID (e.g., "REQ-00001", "TC-00050")
187
+
188
+ Returns:
189
+ Full WorkItem with relationships, test runs, ownership, metadata.
190
+
191
+ Examples:
192
+ - "Show me requirement REQ-00001" → atoms_get_item(project_id, "REQ-00001")
193
+ - "Get test case details" → atoms_get_item(project_id, "TC-00050")`,
194
+ inputSchema: {
195
+ project_id: z.string().uuid().describe("UUID of the project"),
196
+ item_id: z.string().min(1).max(20).describe("Item ID (e.g., REQ-00001)"),
197
+ },
198
+ annotations: {
199
+ readOnlyHint: true,
200
+ destructiveHint: false,
201
+ idempotentHint: true,
202
+ openWorldHint: false,
203
+ },
204
+ }, withMiddleware("atoms_get_item", async (params) => {
205
+ const { getItemHandler } = await import("./tools/get-item.js");
206
+ return getItemHandler(params);
207
+ }));
208
+ server.registerTool("atoms_search", {
209
+ title: "Search ATOMS Items",
210
+ description: `Full-text search across items in a project. Searches title, body, and summary.
211
+
212
+ Alternative entry point to atoms_list_items when you know what you're looking for.
213
+
214
+ Args:
215
+ - project_id (string, UUID): The project to search in
216
+ - query (string): Search text (max 1000 chars)
217
+ - type (string, optional): Filter by type
218
+ - limit (number, optional): Max results, 1-100 (default 25)
219
+
220
+ Returns:
221
+ Matching items with @basic fields, ranked by relevance.
222
+
223
+ Examples:
224
+ - "Find braking requirements" → atoms_search(project_id, "braking system")
225
+ - "Search for safety tests" → atoms_search(project_id, "safety", type="test-case")`,
226
+ inputSchema: {
227
+ project_id: z.string().uuid().describe("UUID of the project"),
228
+ query: z.string().min(1).max(1000).describe("Search text"),
229
+ type: z.enum(["requirement", "test-case", "note", "table"]).optional()
230
+ .describe("Filter by item type"),
231
+ limit: z.number().int().min(1).max(100).default(25)
232
+ .describe("Max results (default 25, max 100)"),
233
+ },
234
+ annotations: {
235
+ readOnlyHint: true,
236
+ destructiveHint: false,
237
+ idempotentHint: true,
238
+ openWorldHint: false,
239
+ },
240
+ }, withMiddleware("atoms_search", async (params) => {
241
+ const { searchHandler } = await import("./tools/search.js");
242
+ return searchHandler(params);
243
+ }));
244
+ server.registerTool("atoms_get_coverage", {
245
+ title: "Get Test Coverage Report",
246
+ description: `Find requirements without linked test cases (coverage gaps).
247
+
248
+ Essential for compliance reporting in safety-critical industries.
249
+
250
+ Args:
251
+ - project_id (string, UUID): The project to analyze
252
+ - domain (string, optional): Filter by domain
253
+ - level (string, optional): Filter by level
254
+
255
+ Returns:
256
+ { covered, uncovered, total, coverage_percent, uncovered_items: [...] }
257
+
258
+ Examples:
259
+ - "What's our test coverage?" → atoms_get_coverage(project_id)
260
+ - "Safety coverage gaps?" → atoms_get_coverage(project_id, domain="Safety")`,
261
+ inputSchema: {
262
+ project_id: z.string().uuid().describe("UUID of the project"),
263
+ domain: z.string().optional().describe("Filter by domain tag"),
264
+ level: z.string().optional().describe("Filter by level"),
265
+ },
266
+ annotations: {
267
+ readOnlyHint: true,
268
+ destructiveHint: false,
269
+ idempotentHint: true,
270
+ openWorldHint: false,
271
+ },
272
+ }, withMiddleware("atoms_get_coverage", async (params) => {
273
+ const { getCoverageHandler } = await import("./tools/get-coverage.js");
274
+ return getCoverageHandler(params);
275
+ }));
276
+ server.registerTool("atoms_get_history", {
277
+ title: "Get Item Change History",
278
+ description: `Audit trail for an item — who changed what, when, and whether it was human or AI.
279
+
280
+ Shows actor attribution (user vs mcp_claude) and session grouping.
281
+
282
+ Args:
283
+ - project_id (string, UUID): The project containing the item
284
+ - item_id (string): Item ID
285
+ - limit (number, optional): Max entries (default 20, max 100)
286
+
287
+ Returns:
288
+ Change entries with actor, session_id, event_type, changed_at, fields_changed.`,
289
+ inputSchema: {
290
+ project_id: z.string().uuid().describe("UUID of the project"),
291
+ item_id: z.string().min(1).max(20).describe("Item ID"),
292
+ limit: z.number().int().min(1).max(100).default(20)
293
+ .describe("Max entries (default 20)"),
294
+ },
295
+ annotations: {
296
+ readOnlyHint: true,
297
+ destructiveHint: false,
298
+ idempotentHint: true,
299
+ openWorldHint: false,
300
+ },
301
+ }, withMiddleware("atoms_get_history", async (params) => {
302
+ const { getHistoryHandler } = await import("./tools/get-history.js");
303
+ return getHistoryHandler(params);
304
+ }));
305
+ server.registerTool("atoms_export_mermaid", {
306
+ title: "Export Mermaid Diagram",
307
+ description: `Generate a Mermaid diagram of the requirement/test hierarchy.
308
+
309
+ Output is paste-ready for markdown docs. Shows parent-child relationships
310
+ and requirement-to-test-case verification links.
311
+
312
+ Args:
313
+ - project_id (string, UUID): The project to visualize
314
+ - root_item_id (string, optional): Start node (default: all roots)
315
+ - depth (number, optional): Max depth (default 3, max 10)
316
+ - include_tests (boolean, optional): Show test case links (default true)
317
+
318
+ Returns:
319
+ Mermaid graph string.`,
320
+ inputSchema: {
321
+ project_id: z.string().uuid().describe("UUID of the project"),
322
+ root_item_id: z.string().optional().describe("Root item ID to start from"),
323
+ depth: z.number().int().min(1).max(10).default(3).describe("Max depth"),
324
+ include_tests: z.boolean().default(true).describe("Include test case links"),
325
+ },
326
+ annotations: {
327
+ readOnlyHint: true,
328
+ destructiveHint: false,
329
+ idempotentHint: true,
330
+ openWorldHint: false,
331
+ },
332
+ }, withMiddleware("atoms_export_mermaid", async (params) => {
333
+ const { exportMermaidHandler } = await import("./tools/export-mermaid.js");
334
+ return exportMermaidHandler(params);
335
+ }));
336
+ // ---------------------------------------------------------------------------
337
+ // Tool Registration — Phase 3 (Write Tools)
338
+ // ---------------------------------------------------------------------------
339
+ server.registerTool("atoms_create_item", {
340
+ title: "Create ATOMS Item",
341
+ description: `Create a new requirement, test case, or note in a project.
342
+
343
+ Requires editor or admin role. Changes are logged with AI actor attribution.
344
+
345
+ Args:
346
+ - project_id (string, UUID): Target project
347
+ - type (string): requirement|test-case|note
348
+ - title (string): Item title (max 500 chars)
349
+ - body (string, optional): Rich text body
350
+ - summary (string, optional): Brief summary
351
+ - domains (string[], optional): Domain tags
352
+ - level (string, optional): System|Subsystem|Component
353
+ - parent_ids (string[], optional): Parent item IDs to link
354
+
355
+ Returns:
356
+ Created item with generated ID (e.g., "REQ-00058")
357
+
358
+ Side effects:
359
+ - Logs to change_history with actor='mcp_claude'
360
+ - Creates relationships if parent_ids provided`,
361
+ inputSchema: {
362
+ project_id: z.string().uuid().describe("UUID of the target project"),
363
+ type: z.enum(["requirement", "test-case", "note"]).describe("Item type"),
364
+ title: z.string().min(1).max(500).describe("Item title"),
365
+ body: z.string().optional().describe("Rich text body"),
366
+ summary: z.string().optional().describe("Brief summary"),
367
+ domains: z.array(z.string()).optional().describe("Domain tags"),
368
+ level: z.string().optional().describe("System|Subsystem|Component"),
369
+ parent_ids: z.array(z.string()).optional().describe("Parent item IDs to link"),
370
+ },
371
+ annotations: {
372
+ readOnlyHint: false,
373
+ destructiveHint: false,
374
+ idempotentHint: false,
375
+ openWorldHint: false,
376
+ },
377
+ }, withMiddleware("atoms_create_item", async (params) => {
378
+ const { createItemHandler } = await import("./tools/create-item.js");
379
+ return createItemHandler(params);
380
+ }));
381
+ server.registerTool("atoms_update_item", {
382
+ title: "Update ATOMS Item",
383
+ description: `Update an existing item's fields. Only provided fields are changed.
384
+
385
+ Requires editor or admin role. Logs old/new data diff to change history.
386
+
387
+ Args:
388
+ - project_id (string, UUID): Project containing the item
389
+ - item_id (string): Item to update
390
+ - title, body, summary, domains, level, status: Fields to update (all optional)
391
+
392
+ Returns:
393
+ Updated item.`,
394
+ inputSchema: {
395
+ project_id: z.string().uuid().describe("UUID of the project"),
396
+ item_id: z.string().min(1).max(20).describe("Item ID to update"),
397
+ title: z.string().min(1).max(500).optional().describe("New title"),
398
+ body: z.string().optional().describe("New body"),
399
+ summary: z.string().optional().describe("New summary"),
400
+ domains: z.array(z.string()).optional().describe("New domain tags"),
401
+ level: z.string().optional().describe("New level"),
402
+ status: z.enum(["passed", "failed", "blocked", "not-run"]).optional()
403
+ .describe("Test case status"),
404
+ },
405
+ annotations: {
406
+ readOnlyHint: false,
407
+ destructiveHint: false,
408
+ idempotentHint: true,
409
+ openWorldHint: false,
410
+ },
411
+ }, withMiddleware("atoms_update_item", async (params) => {
412
+ const { updateItemHandler } = await import("./tools/update-item.js");
413
+ return updateItemHandler(params);
414
+ }));
415
+ server.registerTool("atoms_delete_item", {
416
+ title: "Delete ATOMS Item",
417
+ description: `Soft-delete an item (sets deleted_at, preserves for audit trail).
418
+
419
+ Requires editor or admin role. The item is never truly removed.
420
+
421
+ Args:
422
+ - project_id (string, UUID): Project containing the item
423
+ - item_id (string): Item to delete
424
+
425
+ Returns:
426
+ Confirmation with deleted item summary.`,
427
+ inputSchema: {
428
+ project_id: z.string().uuid().describe("UUID of the project"),
429
+ item_id: z.string().min(1).max(20).describe("Item ID to soft-delete"),
430
+ },
431
+ annotations: {
432
+ readOnlyHint: false,
433
+ destructiveHint: true,
434
+ idempotentHint: true,
435
+ openWorldHint: false,
436
+ },
437
+ }, withMiddleware("atoms_delete_item", async (params) => {
438
+ const { deleteItemHandler } = await import("./tools/delete-item.js");
439
+ return deleteItemHandler(params);
440
+ }));
441
+ server.registerTool("atoms_link_items", {
442
+ title: "Link ATOMS Items",
443
+ description: `Add or remove relationships between items.
444
+
445
+ Supports: parent, child, related, verifies, verified_by.
446
+ Updates both items' JSONB data and the shadow table.
447
+
448
+ Args:
449
+ - project_id (string, UUID): Project containing both items
450
+ - from_id (string): Source item
451
+ - to_id (string): Target item
452
+ - type (string): parent|child|related|verifies|verified_by
453
+ - action (string): add|remove
454
+
455
+ Returns:
456
+ Updated relationship state for both items.`,
457
+ inputSchema: {
458
+ project_id: z.string().uuid().describe("UUID of the project"),
459
+ from_id: z.string().min(1).max(20).describe("Source item ID"),
460
+ to_id: z.string().min(1).max(20).describe("Target item ID"),
461
+ type: z.enum(["parent", "child", "related", "verifies", "verified_by"])
462
+ .describe("Relationship type"),
463
+ action: z.enum(["add", "remove"]).describe("Add or remove the relationship"),
464
+ },
465
+ annotations: {
466
+ readOnlyHint: false,
467
+ destructiveHint: false,
468
+ idempotentHint: true,
469
+ openWorldHint: false,
470
+ },
471
+ }, withMiddleware("atoms_link_items", async (params) => {
472
+ const { linkItemsHandler } = await import("./tools/link-items.js");
473
+ return linkItemsHandler(params);
474
+ }));
475
+ server.registerTool("atoms_record_test_result", {
476
+ title: "Record Test Result",
477
+ description: `Record a pass/fail/blocked result for a test case.
478
+
479
+ Appends to the test results history. Use atoms_get_item to see all results.
480
+
481
+ Args:
482
+ - project_id (string, UUID): Project containing the test case
483
+ - item_id (string): Test case ID (e.g., "TC-00001")
484
+ - result (string): passed|failed|blocked|not-run
485
+ - note (string, optional): Reason or comment for this result
486
+
487
+ Returns:
488
+ Recorded result with timestamp.
489
+
490
+ Side effects:
491
+ - Appends to test_results table
492
+ - Logs to change_history with actor='mcp_claude'`,
493
+ inputSchema: {
494
+ project_id: z.string().uuid().describe("UUID of the project"),
495
+ item_id: z.string().min(1).max(20).describe("Test case ID (e.g., TC-00001)"),
496
+ result: z.enum(["passed", "failed", "blocked", "not-run"])
497
+ .describe("Test result"),
498
+ note: z.string().max(1000).optional()
499
+ .describe("Reason or comment for this result"),
500
+ },
501
+ annotations: {
502
+ readOnlyHint: false,
503
+ destructiveHint: false,
504
+ idempotentHint: false,
505
+ openWorldHint: false,
506
+ },
507
+ }, withMiddleware("atoms_record_test_result", async (params) => {
508
+ const { recordTestResultHandler } = await import("./tools/record-test-result.js");
509
+ return recordTestResultHandler(params);
510
+ }));
511
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAmB,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;IAClC,IAAI,EAAE,kBAAkB;IACxB,OAAO,EAAE,OAAO;CACjB,CAAC,CAAC;AAEH,kDAAkD;AAClD,MAAM,UAAU,GAAG,UAAU,EAAE,CAAC;AAChC,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,SAAS,CAAC;AAE/D;;;GAGG;AACH,SAAS,cAAc,CACrB,QAAgB,EAChB,OAAkC;IAElC,OA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AAM,EAAE,uBAAuB,EAAE,GAAG,MAAM,MAAM,CAAC,+BAA+B,CAAC,CAAC;IAClF,OAAO,uBAAuB,CAAC,MAAM,CAAC,CAAC;AACzC,CAAC,CAAC,CACH,CAAC"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Shared error handling and response formatting for all MCP tools.
3
+ *
4
+ * Every error MUST include `next_steps` — actionable guidance for the LLM.
5
+ * This is the #1 pattern from the Polarion MCP that improves agent reliability.
6
+ */
7
+ import type { ToolError, ToolSuccess, PaginationMeta } from "../types/responses.js";
8
+ /** Maximum response size in characters. Truncate with clear message if exceeded. */
9
+ export declare const CHARACTER_LIMIT = 25000;
10
+ export declare function success<T>(data: T, meta?: PaginationMeta): ToolSuccess<T>;
11
+ export declare function paginationMeta(totalCount: number, limit: number, offset: number): PaginationMeta;
12
+ export declare function errorResponse(message: string, nextSteps: string[]): ToolError;
13
+ export declare function notFoundError(resource: string, id: string): ToolError;
14
+ export declare function accessDeniedError(role: string): ToolError;
15
+ export declare function validationError(message: string): ToolError;
16
+ export declare function authError(): ToolError;
17
+ export declare function rateLimitError(retryAfterSeconds: number): ToolError;
18
+ export declare function dbError(message: string): ToolError;
19
+ /**
20
+ * Format a tool result as JSON string + structuredContent for the MCP SDK.
21
+ * Applies CHARACTER_LIMIT truncation if needed.
22
+ */
23
+ export declare function formatToolResult<T>(result: ToolSuccess<T> | ToolError): {
24
+ content: {
25
+ type: "text";
26
+ text: string;
27
+ }[];
28
+ structuredContent: {
29
+ data: any[];
30
+ meta: {
31
+ truncated: boolean;
32
+ truncation_message: string;
33
+ total_count?: number | undefined;
34
+ limit?: number | undefined;
35
+ offset?: number | undefined;
36
+ has_more?: boolean | undefined;
37
+ };
38
+ status: "success";
39
+ };
40
+ } | {
41
+ content: {
42
+ type: "text";
43
+ text: string;
44
+ }[];
45
+ structuredContent: ToolError | ToolSuccess<T>;
46
+ };
47
+ /**
48
+ * Format an error result for the MCP SDK.
49
+ */
50
+ export declare function formatErrorResult(error: ToolError): {
51
+ content: {
52
+ type: "text";
53
+ text: string;
54
+ }[];
55
+ structuredContent: ToolError;
56
+ isError: boolean;
57
+ };
58
+ //# sourceMappingURL=_base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_base.d.ts","sourceRoot":"","sources":["../../src/tools/_base.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEpF,oFAAoF;AACpF,eAAO,MAAM,eAAe,QAAS,CAAC;AAMtC,wBAAgB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,cAAc,GAAG,WAAW,CAAC,CAAC,CAAC,CAEzE;AAED,wBAAgB,cAAc,CAC5B,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,cAAc,CAOhB;AAMD,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,SAAS,CAE7E;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,SAAS,CAKrE;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAKzD;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAK1D;AAED,wBAAgB,SAAS,IAAI,SAAS,CAKrC;AAED,wBAAgB,cAAc,CAAC,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAKnE;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAKlD;AAMD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;EA6BrE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS;;;;;;;EAMjD"}