@atoms-tech/atoms-mcp 0.3.0 → 0.3.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 (65) hide show
  1. package/README.md +1 -1
  2. package/dist/index.cjs +2 -0
  3. package/dist/index.js +1 -90
  4. package/package.json +12 -3
  5. package/dist/apps/register.d.ts +0 -36
  6. package/dist/apps/register.js +0 -65
  7. package/dist/auth/login.d.ts +0 -24
  8. package/dist/auth/login.js +0 -413
  9. package/dist/auth/refresh.d.ts +0 -16
  10. package/dist/auth/refresh.js +0 -81
  11. package/dist/auth/token-store.d.ts +0 -33
  12. package/dist/auth/token-store.js +0 -60
  13. package/dist/config.d.ts +0 -18
  14. package/dist/config.js +0 -18
  15. package/dist/db/client.d.ts +0 -29
  16. package/dist/db/client.js +0 -109
  17. package/dist/db/graph.d.ts +0 -7
  18. package/dist/db/graph.js +0 -7
  19. package/dist/db/queries.d.ts +0 -76
  20. package/dist/db/queries.js +0 -209
  21. package/dist/index.d.ts +0 -11
  22. package/dist/middleware/audit.d.ts +0 -25
  23. package/dist/middleware/audit.js +0 -43
  24. package/dist/middleware/rate-limiter.d.ts +0 -20
  25. package/dist/middleware/rate-limiter.js +0 -42
  26. package/dist/middleware/validator.d.ts +0 -21
  27. package/dist/middleware/validator.js +0 -90
  28. package/dist/server.d.ts +0 -14
  29. package/dist/server.js +0 -679
  30. package/dist/tools/_base.d.ts +0 -57
  31. package/dist/tools/_base.js +0 -108
  32. package/dist/tools/bulk-import.d.ts +0 -69
  33. package/dist/tools/bulk-import.js +0 -187
  34. package/dist/tools/create-item.d.ts +0 -42
  35. package/dist/tools/create-item.js +0 -117
  36. package/dist/tools/delete-item.d.ts +0 -37
  37. package/dist/tools/delete-item.js +0 -68
  38. package/dist/tools/export-mermaid.d.ts +0 -35
  39. package/dist/tools/export-mermaid.js +0 -124
  40. package/dist/tools/get-coverage.d.ts +0 -33
  41. package/dist/tools/get-coverage.js +0 -35
  42. package/dist/tools/get-history.d.ts +0 -33
  43. package/dist/tools/get-history.js +0 -52
  44. package/dist/tools/get-item.d.ts +0 -61
  45. package/dist/tools/get-item.js +0 -92
  46. package/dist/tools/link-items.d.ts +0 -40
  47. package/dist/tools/link-items.js +0 -149
  48. package/dist/tools/list-items.d.ts +0 -36
  49. package/dist/tools/list-items.js +0 -35
  50. package/dist/tools/list-projects.d.ts +0 -37
  51. package/dist/tools/list-projects.js +0 -27
  52. package/dist/tools/project-summary.d.ts +0 -63
  53. package/dist/tools/project-summary.js +0 -169
  54. package/dist/tools/record-test-result.d.ts +0 -40
  55. package/dist/tools/record-test-result.js +0 -79
  56. package/dist/tools/search.d.ts +0 -33
  57. package/dist/tools/search.js +0 -27
  58. package/dist/tools/trace.d.ts +0 -52
  59. package/dist/tools/trace.js +0 -165
  60. package/dist/tools/update-item.d.ts +0 -42
  61. package/dist/tools/update-item.js +0 -97
  62. package/dist/types/responses.d.ts +0 -57
  63. package/dist/types/responses.js +0 -5
  64. package/dist/types/work-item.d.ts +0 -68
  65. package/dist/types/work-item.js +0 -7
package/dist/server.js DELETED
@@ -1,679 +0,0 @@
1
- /**
2
- * ATOMS MCP Server — Tool registration and initialization.
3
- *
4
- * Registers 15 tools: 10 via server.registerTool(), 5 as MCP Apps via registerAtomsApp().
5
- * MCP App tools (mermaid, summary, trace) render interactive UIs in capable hosts
6
- * while falling back to text for non-UI clients.
7
- *
8
- * Naming: atoms_{action}_{resource} (snake_case with service prefix)
9
- * Server name: atoms-mcp-server (follows {service}-mcp-server convention)
10
- */
11
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
12
- import { z } from "zod";
13
- import { logAudit, startTimer } from "./middleware/audit.js";
14
- import { checkRateLimit } from "./middleware/rate-limiter.js";
15
- import { getClient, getUserId } from "./db/client.js";
16
- import { formatErrorResult, rateLimitError } from "./tools/_base.js";
17
- import { registerAtomsApp } from "./apps/register.js";
18
- import { randomUUID } from "crypto";
19
- export const server = new McpServer({
20
- name: "atoms-mcp-server",
21
- version: "0.1.0",
22
- });
23
- // Session ID for grouping tool calls in audit log
24
- const SESSION_ID = randomUUID();
25
- const CLIENT_NAME = process.env.ATOMS_CLIENT_NAME ?? "unknown";
26
- /**
27
- * Wrap a tool handler with rate limiting + audit logging.
28
- * This is the middleware pipeline for every tool call.
29
- */
30
- function withMiddleware(toolName, handler) {
31
- return async (params) => {
32
- // Rate limit check
33
- let userId;
34
- try {
35
- await getClient(); // ensure auth
36
- userId = getUserId();
37
- }
38
- catch {
39
- // Auth will fail inside the handler with proper error
40
- return handler(params);
41
- }
42
- const rateCheck = checkRateLimit(userId);
43
- if (!rateCheck.allowed) {
44
- return formatErrorResult(rateLimitError(rateCheck.retryAfterSeconds));
45
- }
46
- // Execute with timing
47
- const elapsed = startTimer();
48
- let status = "success";
49
- let errorMsg;
50
- try {
51
- const result = await handler(params);
52
- // Detect error responses
53
- const resultObj = result;
54
- if (resultObj?.isError === true) {
55
- status = "error";
56
- const content = resultObj?.content;
57
- if (content?.[0]?.text) {
58
- try {
59
- const parsed = JSON.parse(content[0].text);
60
- errorMsg = parsed.message;
61
- }
62
- catch { /* not JSON */ }
63
- }
64
- }
65
- return result;
66
- }
67
- catch (err) {
68
- status = "error";
69
- errorMsg = err instanceof Error ? err.message : String(err);
70
- throw err;
71
- }
72
- finally {
73
- // Fire-and-forget audit log
74
- const entry = {
75
- tool_name: toolName,
76
- params: params,
77
- status,
78
- duration_ms: elapsed(),
79
- error_msg: errorMsg,
80
- project_id: params.project_id,
81
- session_id: SESSION_ID,
82
- client_name: CLIENT_NAME,
83
- };
84
- try {
85
- const client = await getClient();
86
- logAudit(client, userId, entry);
87
- }
88
- catch { /* non-fatal */ }
89
- }
90
- };
91
- }
92
- /** Expose session ID for change_history writes */
93
- export function getMcpSessionId() {
94
- return SESSION_ID;
95
- }
96
- // ---------------------------------------------------------------------------
97
- // Tool Registration — Entry Point
98
- // ---------------------------------------------------------------------------
99
- server.registerTool("atoms_list_projects", {
100
- title: "List ATOMS Projects",
101
- description: `List all projects the authenticated user has access to.
102
-
103
- This is the ENTRY POINT tool. Call this first to discover project IDs,
104
- then use those IDs with all other tools.
105
-
106
- Args: None
107
-
108
- Returns:
109
- { status: "success", data: [{ id, name, description, org_id, created_at }] }
110
-
111
- Examples:
112
- - "What projects do I have?" → atoms_list_projects()
113
- - "Show my projects" → atoms_list_projects()
114
-
115
- Workflow:
116
- atoms_list_projects → atoms_list_items(project_id) → atoms_get_item(project_id, item_id)`,
117
- inputSchema: {},
118
- annotations: {
119
- readOnlyHint: true,
120
- destructiveHint: false,
121
- idempotentHint: true,
122
- openWorldHint: false,
123
- },
124
- }, withMiddleware("atoms_list_projects", async () => {
125
- const { listProjectsHandler } = await import("./tools/list-projects.js");
126
- return listProjectsHandler();
127
- }));
128
- // ---------------------------------------------------------------------------
129
- // Tool Registration — Phase 2 (Read Tools)
130
- // ---------------------------------------------------------------------------
131
- server.registerTool("atoms_list_items", {
132
- title: "List ATOMS Items",
133
- description: `List items in an ATOMS project with optional type/domain/level filters.
134
-
135
- This is the primary ENTRY POINT for discovering items. Use it to browse
136
- project contents before drilling into specific items with atoms_get_item.
137
-
138
- Args:
139
- - project_id (string, UUID): The project to list items from
140
- - type (string, optional): Filter: requirement|test-case|note|table
141
- - domain (string, optional): Filter by domain tag
142
- - level (string, optional): Filter by level (System, Subsystem, Component)
143
- - limit (number, optional): Max results, 1-200 (default 50)
144
- - offset (number, optional): Pagination offset (default 0)
145
-
146
- Returns:
147
- { status: "success", data: [{ id, title, type, status, domains, level }], meta: { total_count, limit, offset, has_more } }
148
-
149
- Examples:
150
- - "Show me all requirements" → atoms_list_items(project_id, type="requirement")
151
- - "What test cases exist?" → atoms_list_items(project_id, type="test-case")
152
-
153
- Errors:
154
- - "Project not found" → verify project_id
155
- - "Access denied" → check org membership`,
156
- inputSchema: {
157
- project_id: z.string().uuid("Must be a valid project UUID")
158
- .describe("UUID of the project"),
159
- type: z.enum(["requirement", "test-case", "note", "table"]).optional()
160
- .describe("Filter by item type"),
161
- domain: z.string().optional()
162
- .describe("Filter by domain tag (e.g., 'Safety', 'Performance')"),
163
- level: z.string().optional()
164
- .describe("Filter by level (System, Subsystem, Component)"),
165
- limit: z.number().int().min(1).max(200).default(50)
166
- .describe("Max results (default 50, max 200)"),
167
- offset: z.number().int().min(0).default(0)
168
- .describe("Pagination offset (default 0)"),
169
- },
170
- annotations: {
171
- readOnlyHint: true,
172
- destructiveHint: false,
173
- idempotentHint: true,
174
- openWorldHint: false,
175
- },
176
- }, withMiddleware("atoms_list_items", async (params) => {
177
- const { listItemsHandler } = await import("./tools/list-items.js");
178
- return listItemsHandler(params);
179
- }));
180
- server.registerTool("atoms_get_item", {
181
- title: "Get ATOMS Item Details",
182
- description: `Get full details of a single item including relationships, test history, and ownership.
183
-
184
- Use after atoms_list_items or atoms_search to drill into a specific item.
185
-
186
- Args:
187
- - project_id (string, UUID): The project containing the item
188
- - item_id (string): Item ID (e.g., "REQ-00001", "TC-00050")
189
-
190
- Returns:
191
- Full WorkItem with relationships, test runs, ownership, metadata.
192
-
193
- Examples:
194
- - "Show me requirement REQ-00001" → atoms_get_item(project_id, "REQ-00001")
195
- - "Get test case details" → atoms_get_item(project_id, "TC-00050")`,
196
- inputSchema: {
197
- project_id: z.string().uuid().describe("UUID of the project"),
198
- item_id: z.string().min(1).max(20).describe("Item ID (e.g., REQ-00001)"),
199
- },
200
- annotations: {
201
- readOnlyHint: true,
202
- destructiveHint: false,
203
- idempotentHint: true,
204
- openWorldHint: false,
205
- },
206
- }, withMiddleware("atoms_get_item", async (params) => {
207
- const { getItemHandler } = await import("./tools/get-item.js");
208
- return getItemHandler(params);
209
- }));
210
- server.registerTool("atoms_search", {
211
- title: "Search ATOMS Items",
212
- description: `Full-text search across items in a project. Searches title, body, and summary.
213
-
214
- Alternative entry point to atoms_list_items when you know what you're looking for.
215
-
216
- Args:
217
- - project_id (string, UUID): The project to search in
218
- - query (string): Search text (max 1000 chars)
219
- - type (string, optional): Filter by type
220
- - limit (number, optional): Max results, 1-100 (default 25)
221
-
222
- Returns:
223
- Matching items with @basic fields, ranked by relevance.
224
-
225
- Examples:
226
- - "Find braking requirements" → atoms_search(project_id, "braking system")
227
- - "Search for safety tests" → atoms_search(project_id, "safety", type="test-case")`,
228
- inputSchema: {
229
- project_id: z.string().uuid().describe("UUID of the project"),
230
- query: z.string().min(1).max(1000).describe("Search text"),
231
- type: z.enum(["requirement", "test-case", "note", "table"]).optional()
232
- .describe("Filter by item type"),
233
- limit: z.number().int().min(1).max(100).default(25)
234
- .describe("Max results (default 25, max 100)"),
235
- },
236
- annotations: {
237
- readOnlyHint: true,
238
- destructiveHint: false,
239
- idempotentHint: true,
240
- openWorldHint: false,
241
- },
242
- }, withMiddleware("atoms_search", async (params) => {
243
- const { searchHandler } = await import("./tools/search.js");
244
- return searchHandler(params);
245
- }));
246
- // MCP App: Coverage Heatmap — renders coverage visualization in UI-capable hosts
247
- registerAtomsApp(server, {
248
- appName: "coverage",
249
- htmlFile: "coverage-app.html",
250
- toolName: "atoms_get_coverage",
251
- title: "Get Test Coverage Report",
252
- description: `Find requirements without linked test cases (coverage gaps).
253
-
254
- Essential for compliance reporting in safety-critical industries.
255
-
256
- In MCP App hosts (Claude, ChatGPT), renders a visual coverage heatmap.
257
- Falls back to JSON for non-UI clients.
258
-
259
- Args:
260
- - project_id (string, UUID): The project to analyze
261
- - domain (string, optional): Filter by domain
262
- - level (string, optional): Filter by level
263
-
264
- Returns:
265
- { covered, uncovered, total, coverage_percent, uncovered_items: [...] }
266
-
267
- Examples:
268
- - "What's our test coverage?" → atoms_get_coverage(project_id)
269
- - "Safety coverage gaps?" → atoms_get_coverage(project_id, domain="Safety")`,
270
- inputSchema: {
271
- project_id: z.string().uuid().describe("UUID of the project"),
272
- domain: z.string().optional().describe("Filter by domain tag"),
273
- level: z.string().optional().describe("Filter by level"),
274
- },
275
- annotations: {
276
- readOnlyHint: true,
277
- destructiveHint: false,
278
- idempotentHint: true,
279
- openWorldHint: false,
280
- },
281
- handler: withMiddleware("atoms_get_coverage", async (params) => {
282
- const { getCoverageHandler } = await import("./tools/get-coverage.js");
283
- return getCoverageHandler(params);
284
- }),
285
- });
286
- server.registerTool("atoms_get_history", {
287
- title: "Get Item Change History",
288
- description: `Audit trail for an item — who changed what, when, and whether it was human or AI.
289
-
290
- Shows actor attribution (user vs mcp_claude) and session grouping.
291
-
292
- Args:
293
- - project_id (string, UUID): The project containing the item
294
- - item_id (string): Item ID
295
- - limit (number, optional): Max entries (default 20, max 100)
296
-
297
- Returns:
298
- Change entries with actor, session_id, event_type, changed_at, fields_changed.`,
299
- inputSchema: {
300
- project_id: z.string().uuid().describe("UUID of the project"),
301
- item_id: z.string().min(1).max(20).describe("Item ID"),
302
- limit: z.number().int().min(1).max(100).default(20)
303
- .describe("Max entries (default 20)"),
304
- },
305
- annotations: {
306
- readOnlyHint: true,
307
- destructiveHint: false,
308
- idempotentHint: true,
309
- openWorldHint: false,
310
- },
311
- }, withMiddleware("atoms_get_history", async (params) => {
312
- const { getHistoryHandler } = await import("./tools/get-history.js");
313
- return getHistoryHandler(params);
314
- }));
315
- // MCP App: Mermaid Diagram — renders interactive diagram in UI-capable hosts
316
- registerAtomsApp(server, {
317
- appName: "mermaid",
318
- htmlFile: "mermaid-app.html",
319
- toolName: "atoms_export_mermaid",
320
- title: "Export Mermaid Diagram",
321
- description: `Generate a Mermaid diagram of the requirement/test hierarchy.
322
-
323
- Output is paste-ready for markdown docs. Shows parent-child relationships
324
- and requirement-to-test-case verification links.
325
-
326
- In MCP App hosts (Claude, ChatGPT), renders an interactive pan/zoom diagram.
327
- Falls back to Mermaid text for non-UI clients.
328
-
329
- Args:
330
- - project_id (string, UUID): The project to visualize
331
- - root_item_id (string, optional): Start node (default: all roots)
332
- - depth (number, optional): Max depth (default 3, max 10)
333
- - include_tests (boolean, optional): Show test case links (default true)
334
-
335
- Returns:
336
- Mermaid graph string.`,
337
- inputSchema: {
338
- project_id: z.string().uuid().describe("UUID of the project"),
339
- root_item_id: z.string().optional().describe("Root item ID to start from"),
340
- depth: z.number().int().min(1).max(10).default(3).describe("Max depth"),
341
- include_tests: z.boolean().default(true).describe("Include test case links"),
342
- },
343
- annotations: {
344
- readOnlyHint: true,
345
- destructiveHint: false,
346
- idempotentHint: true,
347
- openWorldHint: false,
348
- },
349
- extraResourceDomains: ["cdn.jsdelivr.net"],
350
- handler: withMiddleware("atoms_export_mermaid", async (params) => {
351
- const { exportMermaidHandler } = await import("./tools/export-mermaid.js");
352
- return exportMermaidHandler(params);
353
- }),
354
- });
355
- // ---------------------------------------------------------------------------
356
- // Tool Registration — Phase 3 (Write Tools)
357
- // ---------------------------------------------------------------------------
358
- server.registerTool("atoms_create_item", {
359
- title: "Create ATOMS Item",
360
- description: `Create a new requirement, test case, or note in a project.
361
-
362
- Requires editor or admin role. Changes are logged with AI actor attribution.
363
-
364
- Args:
365
- - project_id (string, UUID): Target project
366
- - type (string): requirement|test-case|note
367
- - title (string): Item title (max 500 chars)
368
- - body (string, optional): Rich text body
369
- - summary (string, optional): Brief summary
370
- - domains (string[], optional): Domain tags
371
- - level (string, optional): System|Subsystem|Component
372
- - parent_ids (string[], optional): Parent item IDs to link
373
-
374
- Returns:
375
- Created item with generated ID (e.g., "REQ-00058")
376
-
377
- Side effects:
378
- - Logs to change_history with actor='mcp_claude'
379
- - Creates relationships if parent_ids provided`,
380
- inputSchema: {
381
- project_id: z.string().uuid().describe("UUID of the target project"),
382
- type: z.enum(["requirement", "test-case", "note"]).describe("Item type"),
383
- title: z.string().min(1).max(500).describe("Item title"),
384
- body: z.string().optional().describe("Rich text body"),
385
- summary: z.string().optional().describe("Brief summary"),
386
- domains: z.array(z.string()).optional().describe("Domain tags"),
387
- level: z.string().optional().describe("System|Subsystem|Component"),
388
- parent_ids: z.array(z.string()).optional().describe("Parent item IDs to link"),
389
- },
390
- annotations: {
391
- readOnlyHint: false,
392
- destructiveHint: false,
393
- idempotentHint: false,
394
- openWorldHint: false,
395
- },
396
- }, withMiddleware("atoms_create_item", async (params) => {
397
- const { createItemHandler } = await import("./tools/create-item.js");
398
- return createItemHandler(params);
399
- }));
400
- server.registerTool("atoms_update_item", {
401
- title: "Update ATOMS Item",
402
- description: `Update an existing item's fields. Only provided fields are changed.
403
-
404
- Requires editor or admin role. Logs old/new data diff to change history.
405
-
406
- Args:
407
- - project_id (string, UUID): Project containing the item
408
- - item_id (string): Item to update
409
- - title, body, summary, domains, level, status: Fields to update (all optional)
410
-
411
- Returns:
412
- Updated item.`,
413
- inputSchema: {
414
- project_id: z.string().uuid().describe("UUID of the project"),
415
- item_id: z.string().min(1).max(20).describe("Item ID to update"),
416
- title: z.string().min(1).max(500).optional().describe("New title"),
417
- body: z.string().optional().describe("New body"),
418
- summary: z.string().optional().describe("New summary"),
419
- domains: z.array(z.string()).optional().describe("New domain tags"),
420
- level: z.string().optional().describe("New level"),
421
- status: z.enum(["passed", "failed", "blocked", "not-run"]).optional()
422
- .describe("Test case status"),
423
- },
424
- annotations: {
425
- readOnlyHint: false,
426
- destructiveHint: false,
427
- idempotentHint: true,
428
- openWorldHint: false,
429
- },
430
- }, withMiddleware("atoms_update_item", async (params) => {
431
- const { updateItemHandler } = await import("./tools/update-item.js");
432
- return updateItemHandler(params);
433
- }));
434
- server.registerTool("atoms_delete_item", {
435
- title: "Delete ATOMS Item",
436
- description: `Soft-delete an item (sets deleted_at, preserves for audit trail).
437
-
438
- Requires editor or admin role. The item is never truly removed.
439
-
440
- Args:
441
- - project_id (string, UUID): Project containing the item
442
- - item_id (string): Item to delete
443
-
444
- Returns:
445
- Confirmation with deleted item summary.`,
446
- inputSchema: {
447
- project_id: z.string().uuid().describe("UUID of the project"),
448
- item_id: z.string().min(1).max(20).describe("Item ID to soft-delete"),
449
- },
450
- annotations: {
451
- readOnlyHint: false,
452
- destructiveHint: true,
453
- idempotentHint: true,
454
- openWorldHint: false,
455
- },
456
- }, withMiddleware("atoms_delete_item", async (params) => {
457
- const { deleteItemHandler } = await import("./tools/delete-item.js");
458
- return deleteItemHandler(params);
459
- }));
460
- server.registerTool("atoms_link_items", {
461
- title: "Link ATOMS Items",
462
- description: `Add or remove relationships between items.
463
-
464
- Supports: parent, child, related, verifies, verified_by.
465
- Updates both items' JSONB data and the shadow table.
466
-
467
- Args:
468
- - project_id (string, UUID): Project containing both items
469
- - from_id (string): Source item
470
- - to_id (string): Target item
471
- - type (string): parent|child|related|verifies|verified_by
472
- - action (string): add|remove
473
-
474
- Returns:
475
- Updated relationship state for both items.`,
476
- inputSchema: {
477
- project_id: z.string().uuid().describe("UUID of the project"),
478
- from_id: z.string().min(1).max(20).describe("Source item ID"),
479
- to_id: z.string().min(1).max(20).describe("Target item ID"),
480
- type: z.enum(["parent", "child", "related", "verifies", "verified_by"])
481
- .describe("Relationship type"),
482
- action: z.enum(["add", "remove"]).describe("Add or remove the relationship"),
483
- },
484
- annotations: {
485
- readOnlyHint: false,
486
- destructiveHint: false,
487
- idempotentHint: true,
488
- openWorldHint: false,
489
- },
490
- }, withMiddleware("atoms_link_items", async (params) => {
491
- const { linkItemsHandler } = await import("./tools/link-items.js");
492
- return linkItemsHandler(params);
493
- }));
494
- // MCP App: Bulk Import — renders import results table in UI-capable hosts
495
- registerAtomsApp(server, {
496
- appName: "import",
497
- htmlFile: "import-app.html",
498
- toolName: "atoms_bulk_import",
499
- title: "Bulk Import ATOMS Items",
500
- description: `Bulk create multiple items in a single tool call. Essential for AI agents
501
- that generate 20+ requirements at once.
502
-
503
- Checks write access once, generates sequential IDs, batch inserts all items,
504
- and reports per-item errors without aborting the entire batch.
505
-
506
- In MCP App hosts (Claude, ChatGPT), renders an interactive results table.
507
- Falls back to JSON for non-UI clients.
508
-
509
- Args:
510
- - project_id (string, UUID): Target project
511
- - items (array): Up to 100 items to create, each with:
512
- - type (string): requirement|test-case|note
513
- - title (string): Item title (max 500 chars)
514
- - body (string, optional): Rich text body
515
- - summary (string, optional): Brief summary
516
- - domains (string[], optional): Domain tags
517
- - level (string, optional): System|Subsystem|Component
518
- - parent_id (string, optional): Parent item ID to link
519
-
520
- Returns:
521
- { created: number, items: [{ id, title, type }], errors: [] }
522
-
523
- Limits:
524
- - Maximum 100 items per call
525
- - If any item fails, others still succeed — errors reported separately
526
-
527
- Side effects:
528
- - Logs to change_history with actor='mcp_claude' for each created item
529
- - Creates parent relationships for items with parent_id`,
530
- inputSchema: {
531
- project_id: z.string().uuid().describe("UUID of the target project"),
532
- items: z.array(z.object({
533
- type: z.enum(["requirement", "test-case", "note"]).describe("Item type"),
534
- title: z.string().min(1).max(500).describe("Item title"),
535
- body: z.string().optional().describe("Rich text body"),
536
- summary: z.string().optional().describe("Brief summary"),
537
- domains: z.array(z.string()).optional().describe("Domain tags"),
538
- level: z.string().optional().describe("System|Subsystem|Component"),
539
- parent_id: z.string().optional().describe("Parent item ID to link"),
540
- })).min(1).max(100).describe("Items to create (1-100)"),
541
- },
542
- annotations: {
543
- readOnlyHint: false,
544
- destructiveHint: false,
545
- idempotentHint: false,
546
- openWorldHint: false,
547
- },
548
- handler: withMiddleware("atoms_bulk_import", async (params) => {
549
- const { bulkImportHandler } = await import("./tools/bulk-import.js");
550
- return bulkImportHandler(params);
551
- }),
552
- });
553
- server.registerTool("atoms_record_test_result", {
554
- title: "Record Test Result",
555
- description: `Record a pass/fail/blocked result for a test case.
556
-
557
- Appends to the test results history. Use atoms_get_item to see all results.
558
-
559
- Args:
560
- - project_id (string, UUID): Project containing the test case
561
- - item_id (string): Test case ID (e.g., "TC-00001")
562
- - result (string): passed|failed|blocked|not-run
563
- - note (string, optional): Reason or comment for this result
564
-
565
- Returns:
566
- Recorded result with timestamp.
567
-
568
- Side effects:
569
- - Appends to test_results table
570
- - Logs to change_history with actor='mcp_claude'`,
571
- inputSchema: {
572
- project_id: z.string().uuid().describe("UUID of the project"),
573
- item_id: z.string().min(1).max(20).describe("Test case ID (e.g., TC-00001)"),
574
- result: z.enum(["passed", "failed", "blocked", "not-run"])
575
- .describe("Test result"),
576
- note: z.string().max(1000).optional()
577
- .describe("Reason or comment for this result"),
578
- },
579
- annotations: {
580
- readOnlyHint: false,
581
- destructiveHint: false,
582
- idempotentHint: false,
583
- openWorldHint: false,
584
- },
585
- }, withMiddleware("atoms_record_test_result", async (params) => {
586
- const { recordTestResultHandler } = await import("./tools/record-test-result.js");
587
- return recordTestResultHandler(params);
588
- }));
589
- // ---------------------------------------------------------------------------
590
- // Tool Registration — Phase 4 (Advanced Tools)
591
- // ---------------------------------------------------------------------------
592
- // MCP App: Trace Graph — renders interactive force-directed graph in UI-capable hosts
593
- registerAtomsApp(server, {
594
- appName: "trace",
595
- htmlFile: "trace-app.html",
596
- toolName: "atoms_trace",
597
- title: "Trace Item Relationships",
598
- description: `Walk the traceability graph from a starting item.
599
-
600
- Answers questions like "which requirements does TC-00003 verify?" or
601
- "if I change REQ-00001, what's affected downstream?"
602
-
603
- In MCP App hosts (Claude, ChatGPT), renders an interactive graph visualization.
604
- Falls back to flat list for non-UI clients.
605
-
606
- Args:
607
- - project_id (string, UUID): Project containing the item
608
- - item_id (string): Starting item ID
609
- - direction (string): upstream|downstream|both
610
- - upstream: follow parent/verifies links (dependencies)
611
- - downstream: follow child/verified_by links (dependents)
612
- - both: trace in both directions
613
- - depth (number, optional): Max traversal depth (default 5, max 10)
614
- - relationship_types (string[], optional): Filter to specific types (parent, child, related, verifies, verified_by)
615
-
616
- Returns:
617
- { root, direction, items: [{ id, title, type, relationship, depth }], total_count }
618
-
619
- Examples:
620
- - "What does TC-00003 verify?" → atoms_trace(project_id, "TC-00003", "upstream")
621
- - "What's affected by REQ-00001?" → atoms_trace(project_id, "REQ-00001", "downstream")`,
622
- inputSchema: {
623
- project_id: z.string().uuid().describe("UUID of the project"),
624
- item_id: z.string().min(1).max(20).describe("Starting item ID"),
625
- direction: z.enum(["upstream", "downstream", "both"])
626
- .describe("Traversal direction"),
627
- depth: z.number().int().min(1).max(10).default(5)
628
- .describe("Max traversal depth (default 5)"),
629
- relationship_types: z.array(z.enum(["parent", "child", "related", "verifies", "verified_by"])).optional()
630
- .describe("Filter to specific relationship types"),
631
- },
632
- annotations: {
633
- readOnlyHint: true,
634
- destructiveHint: false,
635
- idempotentHint: true,
636
- openWorldHint: false,
637
- },
638
- handler: withMiddleware("atoms_trace", async (params) => {
639
- const { traceHandler } = await import("./tools/trace.js");
640
- return traceHandler(params);
641
- }),
642
- });
643
- // MCP App: Project Summary Dashboard — renders interactive compliance dashboard in UI-capable hosts
644
- registerAtomsApp(server, {
645
- appName: "summary",
646
- htmlFile: "summary-app.html",
647
- toolName: "atoms_project_summary",
648
- title: "Project Compliance Summary",
649
- description: `One-call project health and compliance dashboard.
650
-
651
- Returns item counts by type, test execution status, requirement coverage
652
- (overall and by domain), and recent change activity.
653
-
654
- In MCP App hosts (Claude, ChatGPT), renders an interactive dashboard with charts.
655
- Falls back to JSON for non-UI clients.
656
-
657
- Args:
658
- - project_id (string, UUID): Project to summarize
659
-
660
- Returns:
661
- { project_name, counts, test_status, coverage, coverage_by_domain, recent_changes, last_updated }
662
-
663
- Examples:
664
- - "Give me a compliance snapshot" → atoms_project_summary(project_id)
665
- - "How's our test coverage?" → atoms_project_summary(project_id)`,
666
- inputSchema: {
667
- project_id: z.string().uuid().describe("UUID of the project"),
668
- },
669
- annotations: {
670
- readOnlyHint: true,
671
- destructiveHint: false,
672
- idempotentHint: true,
673
- openWorldHint: false,
674
- },
675
- handler: withMiddleware("atoms_project_summary", async (params) => {
676
- const { projectSummaryHandler } = await import("./tools/project-summary.js");
677
- return projectSummaryHandler(params);
678
- }),
679
- });