code-auditor-mcp 2.0.2 → 2.2.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 (82) hide show
  1. package/README.md +41 -3
  2. package/dist/analyzers/universal/UniversalDataAccessAnalyzer.d.ts.map +1 -1
  3. package/dist/analyzers/universal/UniversalDataAccessAnalyzer.js +50 -35
  4. package/dist/analyzers/universal/UniversalDataAccessAnalyzer.js.map +1 -1
  5. package/dist/applyDataDirEnv.d.ts +2 -0
  6. package/dist/applyDataDirEnv.d.ts.map +1 -0
  7. package/dist/applyDataDirEnv.js +21 -0
  8. package/dist/applyDataDirEnv.js.map +1 -0
  9. package/dist/auditRunner.d.ts.map +1 -1
  10. package/dist/auditRunner.js +48 -13
  11. package/dist/auditRunner.js.map +1 -1
  12. package/dist/codeIndexDB-enhanced.d.ts +2 -3
  13. package/dist/codeIndexDB-enhanced.d.ts.map +1 -1
  14. package/dist/codeIndexDB-enhanced.js +41 -15
  15. package/dist/codeIndexDB-enhanced.js.map +1 -1
  16. package/dist/codeIndexDb.d.ts +30 -1
  17. package/dist/codeIndexDb.d.ts.map +1 -1
  18. package/dist/codeIndexDb.js +114 -15
  19. package/dist/codeIndexDb.js.map +1 -1
  20. package/dist/codeIndexService.d.ts +7 -3
  21. package/dist/codeIndexService.d.ts.map +1 -1
  22. package/dist/codeIndexService.js +14 -22
  23. package/dist/codeIndexService.js.map +1 -1
  24. package/dist/constants.d.ts +2 -0
  25. package/dist/constants.d.ts.map +1 -1
  26. package/dist/constants.js +6 -0
  27. package/dist/constants.js.map +1 -1
  28. package/dist/dataPaths.d.ts +10 -0
  29. package/dist/dataPaths.d.ts.map +1 -0
  30. package/dist/dataPaths.js +19 -0
  31. package/dist/dataPaths.js.map +1 -0
  32. package/dist/languages/UniversalAnalyzer.d.ts.map +1 -1
  33. package/dist/languages/UniversalAnalyzer.js +23 -7
  34. package/dist/languages/UniversalAnalyzer.js.map +1 -1
  35. package/dist/mcp-index.d.ts +3 -1
  36. package/dist/mcp-index.d.ts.map +1 -1
  37. package/dist/mcp-index.js +30 -8
  38. package/dist/mcp-index.js.map +1 -1
  39. package/dist/mcp-standalone.d.ts +1 -1
  40. package/dist/mcp-standalone.d.ts.map +1 -1
  41. package/dist/mcp-standalone.js +160 -55
  42. package/dist/mcp-standalone.js.map +1 -1
  43. package/dist/mcp-tools/projectTasks.d.ts +69 -0
  44. package/dist/mcp-tools/projectTasks.d.ts.map +1 -0
  45. package/dist/mcp-tools/projectTasks.js +129 -0
  46. package/dist/mcp-tools/projectTasks.js.map +1 -0
  47. package/dist/mcp-tools-shared.d.ts.map +1 -1
  48. package/dist/mcp-tools-shared.js +3 -3
  49. package/dist/mcp-tools-shared.js.map +1 -1
  50. package/dist/mcp-ui-simple.d.ts.map +1 -1
  51. package/dist/mcp-ui-simple.js +3 -2
  52. package/dist/mcp-ui-simple.js.map +1 -1
  53. package/dist/mcp.js +203 -61
  54. package/dist/mcp.js.map +1 -1
  55. package/dist/mcpAutoIndex.d.ts +2 -0
  56. package/dist/mcpAutoIndex.d.ts.map +1 -0
  57. package/dist/mcpAutoIndex.js +71 -0
  58. package/dist/mcpAutoIndex.js.map +1 -0
  59. package/dist/mcpDiagnostics.d.ts +11 -0
  60. package/dist/mcpDiagnostics.d.ts.map +1 -0
  61. package/dist/mcpDiagnostics.js +54 -0
  62. package/dist/mcpDiagnostics.js.map +1 -0
  63. package/dist/mcpToolErrors.d.ts +21 -0
  64. package/dist/mcpToolErrors.d.ts.map +1 -0
  65. package/dist/mcpToolErrors.js +81 -0
  66. package/dist/mcpToolErrors.js.map +1 -0
  67. package/dist/search/QueryParser.d.ts.map +1 -1
  68. package/dist/search/QueryParser.js +11 -12
  69. package/dist/search/QueryParser.js.map +1 -1
  70. package/dist/services/ProjectTaskRepository.d.ts +20 -0
  71. package/dist/services/ProjectTaskRepository.d.ts.map +1 -0
  72. package/dist/services/ProjectTaskRepository.js +96 -0
  73. package/dist/services/ProjectTaskRepository.js.map +1 -0
  74. package/dist/services/projectTaskHelpers.d.ts +23 -0
  75. package/dist/services/projectTaskHelpers.d.ts.map +1 -0
  76. package/dist/services/projectTaskHelpers.js +232 -0
  77. package/dist/services/projectTaskHelpers.js.map +1 -0
  78. package/dist/types/projectTask.d.ts +64 -0
  79. package/dist/types/projectTask.d.ts.map +1 -0
  80. package/dist/types/projectTask.js +6 -0
  81. package/dist/types/projectTask.js.map +1 -0
  82. package/package.json +34 -27
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import { LanguageRegistry } from './LanguageRegistry.js';
5
5
  import { promises as fs } from 'fs';
6
+ import { IS_DEV_MODE } from '../constants.js';
6
7
  export class UniversalAnalyzer {
7
8
  /**
8
9
  * Main entry point - processes files and returns violations
@@ -19,26 +20,40 @@ export class UniversalAnalyzer {
19
20
  const totalFiles = files.length;
20
21
  // Process each language group
21
22
  for (const [adapter, adapterFiles] of filesByAdapter) {
22
- console.error(`[DEBUG] ${this.name}: Processing ${adapterFiles.length} files with adapter:`, adapter.constructor.name);
23
+ if (IS_DEV_MODE) {
24
+ console.error(`[DEBUG] ${this.name}: Processing ${adapterFiles.length} files with adapter:`, adapter.constructor.name);
25
+ }
23
26
  for (const file of adapterFiles) {
24
- console.error(`[DEBUG] ${this.name}: Processing file:`, file);
27
+ if (IS_DEV_MODE) {
28
+ console.error(`[DEBUG] ${this.name}: Processing file:`, file);
29
+ }
25
30
  try {
26
31
  const content = await fs.readFile(file, 'utf8');
27
- console.error(`[DEBUG] ${this.name}: Read file content, length:`, content.length);
32
+ if (IS_DEV_MODE) {
33
+ console.error(`[DEBUG] ${this.name}: Read file content, length:`, content.length);
34
+ }
28
35
  const ast = await adapter.parse(file, content);
29
- console.error(`[DEBUG] ${this.name}: Parsed AST, errors:`, ast.errors.length);
36
+ if (IS_DEV_MODE) {
37
+ console.error(`[DEBUG] ${this.name}: Parsed AST, errors:`, ast.errors.length);
38
+ }
30
39
  if (ast.errors.length > 0) {
31
40
  // Record parse errors but continue
32
- console.error(`[DEBUG] ${this.name}: Parse errors:`, ast.errors);
41
+ if (IS_DEV_MODE) {
42
+ console.error(`[DEBUG] ${this.name}: Parse errors:`, ast.errors);
43
+ }
33
44
  errors.push(...ast.errors.map(e => ({
34
45
  file,
35
46
  error: `Parse error: ${e.message}`
36
47
  })));
37
48
  }
38
49
  // Run language-agnostic analysis
39
- console.error(`[DEBUG] ${this.name}: About to call analyzeAST for:`, file);
50
+ if (IS_DEV_MODE) {
51
+ console.error(`[DEBUG] ${this.name}: About to call analyzeAST for:`, file);
52
+ }
40
53
  const fileViolations = await this.analyzeAST(ast, adapter, config, content);
41
- console.error(`[DEBUG] ${this.name}: analyzeAST returned ${fileViolations.length} violations for:`, file);
54
+ if (IS_DEV_MODE) {
55
+ console.error(`[DEBUG] ${this.name}: analyzeAST returned ${fileViolations.length} violations for:`, file);
56
+ }
42
57
  violations.push(...fileViolations);
43
58
  filesProcessed++;
44
59
  if (options.progressCallback) {
@@ -46,6 +61,7 @@ export class UniversalAnalyzer {
46
61
  }
47
62
  }
48
63
  catch (error) {
64
+ // Always log errors, not just in dev mode
49
65
  console.error(`[DEBUG] ${this.name}: ERROR processing file ${file}:`, error);
50
66
  errors.push({
51
67
  file,
@@ -1 +1 @@
1
- {"version":3,"file":"UniversalAnalyzer.js","sourceRoot":"","sources":["../../src/languages/UniversalAnalyzer.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC;AAOpC,MAAM,OAAgB,iBAAiB;IAKrC;;OAEG;IACH,KAAK,CAAC,OAAO,CACX,KAAe,EACf,SAAc,EAAE,EAChB,UAAoC,EAAE;QAEtC,OAAO,CAAC,KAAK,CAAC,WAAW,IAAI,CAAC,IAAI,kDAAkD,EAAE,KAAK,CAAC,CAAC;QAC7F,MAAM,UAAU,GAAgB,EAAE,CAAC;QACnC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I,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,OAAO,GAAG,QAAQ,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;YACjD,IAAI,OAAO,EAAE,CAAC;gBACZ,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;gBAC/C,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACxB,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;YACpC,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;OAEG;IACO,eAAe,CACvB,IAAY,EACZ,QAA0C,EAC1C,OAAe,EACf,QAA+C,EAC/C,IAAY,EACZ,GAA0C;QAE1C,OAAO;YACL,IAAI;YACJ,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,QAAQ;YACR,OAAO;YACP,IAAI;YACJ,QAAQ,EAAE,IAAI,CAAC,IAAI;YACnB,GAAG;SACJ,CAAC;IACJ,CAAC;CACF"}
@@ -6,6 +6,8 @@
6
6
  * node mcp-index.js # stdio mode (default)
7
7
  * node mcp-index.js --ui # HTTP/UI mode
8
8
  * node mcp-index.js --stdio # explicit stdio mode
9
+ * node mcp-index.js --data-dir /abs/path # persist index under that directory
10
+ * node mcp-index.js --auto-index /project # index-only harness (no MCP stdio); logs to stderr
9
11
  */
10
- export {};
12
+ import './applyDataDirEnv.js';
11
13
  //# sourceMappingURL=mcp-index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-index.d.ts","sourceRoot":"","sources":["../src/mcp-index.ts"],"names":[],"mappings":";AAEA;;;;;;;GAOG"}
1
+ {"version":3,"file":"mcp-index.d.ts","sourceRoot":"","sources":["../src/mcp-index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;GASG;AAEH,OAAO,sBAAsB,CAAC"}
package/dist/mcp-index.js CHANGED
@@ -6,14 +6,12 @@
6
6
  * node mcp-index.js # stdio mode (default)
7
7
  * node mcp-index.js --ui # HTTP/UI mode
8
8
  * node mcp-index.js --stdio # explicit stdio mode
9
+ * node mcp-index.js --data-dir /abs/path # persist index under that directory
10
+ * node mcp-index.js --auto-index /project # index-only harness (no MCP stdio); logs to stderr
9
11
  */
12
+ import './applyDataDirEnv.js';
10
13
  import chalk from 'chalk';
11
- // Parse command line arguments
12
- const args = process.argv.slice(2);
13
- const uiMode = args.includes('--ui');
14
- const stdioMode = args.includes('--stdio');
15
- const helpMode = args.includes('--help') || args.includes('-h');
16
- if (helpMode) {
14
+ function printHelp() {
17
15
  console.log(`
18
16
  ${chalk.blue('MCP Code Auditor Server')}
19
17
 
@@ -21,6 +19,8 @@ Usage:
21
19
  ${chalk.cyan('node mcp-index.js')} # stdio mode (default)
22
20
  ${chalk.cyan('node mcp-index.js --ui')} # HTTP/UI mode
23
21
  ${chalk.cyan('node mcp-index.js --stdio')} # explicit stdio mode
22
+ ${chalk.cyan('node mcp-index.js --data-dir /path')} # index DB at /path/index.db
23
+ ${chalk.cyan('node mcp-index.js --auto-index /project')} # discover + index only (testing)
24
24
 
25
25
  Modes:
26
26
  ${chalk.yellow('stdio')} - Standard MCP protocol over stdin/stdout (for Claude Desktop, VS Code)
@@ -30,15 +30,37 @@ Examples:
30
30
  ${chalk.gray('# For Claude Desktop')}
31
31
  node mcp-index.js
32
32
 
33
- ${chalk.gray('# For interactive web dashboards')}
34
- node mcp-index.js --ui
33
+ ${chalk.gray('# Index a repo without MCP (stderr logs; use CODE_AUDITOR_DEBUG=1 for verbose)')}
34
+ CODE_AUDITOR_DEBUG=1 node mcp-index.js --auto-index /path/to/repo
35
35
 
36
36
  Environment Variables:
37
37
  ${chalk.cyan('MCP_UI_PORT')}=3001 # Port for UI mode (default: 3001)
38
38
  ${chalk.cyan('MCP_MODE')}=stdio|ui # Override mode detection
39
+ ${chalk.cyan('CODE_AUDITOR_DATA_DIR')}=/path # Storage directory; index file is /path/index.db
40
+ ${chalk.cyan('CODE_AUDITOR_DEBUG')}=1 # Verbose mcpDiagnostics traces
41
+ ${chalk.cyan('CODE_AUDITOR_LOG_FILE')}=/path # Append diagnostics lines to this file
39
42
  `);
43
+ }
44
+ // Parse command line arguments
45
+ const args = process.argv.slice(2);
46
+ const helpMode = args.includes('--help') || args.includes('-h');
47
+ if (helpMode) {
48
+ printHelp();
49
+ process.exit(0);
50
+ }
51
+ const autoIndexPos = args.findIndex((a) => a === '--auto-index');
52
+ if (autoIndexPos >= 0) {
53
+ const projectPath = args[autoIndexPos + 1];
54
+ if (!projectPath || projectPath.startsWith('-')) {
55
+ console.error('Usage: node mcp-index.js --auto-index <project-root>');
56
+ process.exit(1);
57
+ }
58
+ const { runAutoIndex } = await import('./mcpAutoIndex.js');
59
+ await runAutoIndex(projectPath);
40
60
  process.exit(0);
41
61
  }
62
+ const uiMode = args.includes('--ui');
63
+ const stdioMode = args.includes('--stdio');
42
64
  // Determine mode
43
65
  let mode;
44
66
  if (process.env.MCP_MODE) {
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-index.js","sourceRoot":"","sources":["../src/mcp-index.ts"],"names":[],"mappings":";AAEA;;;;;;;GAOG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,+BAA+B;AAC/B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnC,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACrC,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAEhE,IAAI,QAAQ,EAAE,CAAC;IACb,OAAO,CAAC,GAAG,CAAC;EACZ,KAAK,CAAC,IAAI,CAAC,yBAAyB,CAAC;;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CAAC,CAAC;AAEH,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,KAAK,EAAE,EAAE;IACxC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,qBAAqB,EAAE,KAAK,CAAC,CAAC;IACtE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IAC3D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;IACnD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,yBAAyB,EAAE,OAAO,CAAC,CAAC;IAC5E,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IACvD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,mBAAmB;AACnB,WAAW,EAAE,CAAC"}
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- export {};
2
+ import './applyDataDirEnv.js';
3
3
  //# sourceMappingURL=mcp-standalone.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-standalone.d.ts","sourceRoot":"","sources":["../src/mcp-standalone.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"mcp-standalone.d.ts","sourceRoot":"","sources":["../src/mcp-standalone.ts"],"names":[],"mappings":";AAEA,OAAO,sBAAsB,CAAC"}
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import './applyDataDirEnv.js';
2
3
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
3
4
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
5
  import { CallToolRequestSchema, ListToolsRequestSchema, InitializeRequestSchema } from '@modelcontextprotocol/sdk/types.js';
@@ -6,10 +7,12 @@ import { createAuditRunner } from './auditRunner.js';
6
7
  import { syncFileIndex, searchFunctions, findDefinition, clearIndex } from './codeIndexService.js';
7
8
  import { CodeIndexDB } from './codeIndexDB.js';
8
9
  import { ConfigGeneratorFactory } from './generators/ConfigGeneratorFactory.js';
9
- import { IS_DEV_MODE } from './constants.js';
10
+ import { IS_DEV_MODE, PACKAGE_VERSION } from './constants.js';
10
11
  import { scanFunctionsInDirectory } from './functionScanner.js';
11
12
  import path from 'node:path';
12
13
  import chalk from 'chalk';
14
+ import { assertAuditPathExists, formatMcpToolErrorPayload } from './mcpToolErrors.js';
15
+ import { logMcpInfo, mcpDebugStderr } from './mcpDiagnostics.js';
13
16
  import { createWriteStream } from 'node:fs';
14
17
  // Set up file logging (only in development mode)
15
18
  let logStream = null;
@@ -181,13 +184,13 @@ const tools = [
181
184
  },
182
185
  {
183
186
  name: 'sync_index',
184
- description: 'Synchronize, cleanup, or reset the code index',
187
+ description: 'Synchronize, cleanup, or reset analysis-derived data (indexed functions, cached audits, code maps, schema overlays). Project tasks, analyzer configs, and whitelist entries are preserved on reset.',
185
188
  parameters: [
186
189
  {
187
190
  name: 'mode',
188
191
  type: 'string',
189
192
  required: false,
190
- description: 'Operation mode: sync (update), cleanup (remove stale), or reset (clear all)',
193
+ description: 'sync: update index from files; cleanup: remove index rows for deleted files; reset: clear all analysis-derived data (not tasks/config/whitelist)',
191
194
  default: 'sync',
192
195
  enum: ['sync', 'cleanup', 'reset'],
193
196
  },
@@ -388,6 +391,124 @@ const tools = [
388
391
  },
389
392
  ],
390
393
  },
394
+ {
395
+ name: 'project_tasks',
396
+ description: 'Manage a persistent per-project task queue. Tasks and analyzer configs survive sync_index reset; reset clears function index, cached audits, code maps, and schema overlays. Use delete to remove a task.',
397
+ parameters: [
398
+ {
399
+ name: 'action',
400
+ type: 'string',
401
+ required: true,
402
+ description: 'list | create | get | update | delete. list/create use projectPath or default to process.cwd(); create also needs title; get/update/delete need taskId; update needs patch object.',
403
+ enum: ['list', 'create', 'get', 'update', 'delete'],
404
+ },
405
+ {
406
+ name: 'projectPath',
407
+ type: 'string',
408
+ required: false,
409
+ description: 'Project root (resolved). Omit to use the MCP server working directory; response includes projectPathDefaulted when omitted.',
410
+ },
411
+ {
412
+ name: 'taskId',
413
+ type: 'string',
414
+ required: false,
415
+ description: 'Stable task id (UUID). Required for get, update, delete.',
416
+ },
417
+ {
418
+ name: 'title',
419
+ type: 'string',
420
+ required: false,
421
+ description: 'Task title. Required for create.',
422
+ },
423
+ {
424
+ name: 'description',
425
+ type: 'string',
426
+ required: false,
427
+ description: 'Longer description / notes.',
428
+ },
429
+ {
430
+ name: 'status',
431
+ type: 'string',
432
+ required: false,
433
+ description: 'pending | in_progress | blocked | done | cancelled. Filter for list; initial status for create; can be set via update patch.',
434
+ enum: ['pending', 'in_progress', 'blocked', 'done', 'cancelled'],
435
+ },
436
+ {
437
+ name: 'priority',
438
+ type: 'string',
439
+ required: false,
440
+ description: 'Optional priority for create/update patch.',
441
+ enum: ['low', 'medium', 'high'],
442
+ },
443
+ {
444
+ name: 'labels',
445
+ type: 'array',
446
+ required: false,
447
+ description: 'String tags (e.g. ["audit","refactor"]).',
448
+ },
449
+ {
450
+ name: 'metadata',
451
+ type: 'object',
452
+ required: false,
453
+ description: 'Arbitrary JSON object: related file paths, links, audit IDs, etc.',
454
+ },
455
+ {
456
+ name: 'parentTaskId',
457
+ type: 'string',
458
+ required: false,
459
+ description: 'Optional parent task for subtasks.',
460
+ },
461
+ {
462
+ name: 'source',
463
+ type: 'string',
464
+ required: false,
465
+ description: 'manual | audit | mcp. Filter for list; provenance for create; can be set via update patch.',
466
+ enum: ['manual', 'audit', 'mcp'],
467
+ },
468
+ {
469
+ name: 'blockedBy',
470
+ type: 'array',
471
+ required: false,
472
+ description: 'Task IDs this item is blocked by (waiting-on).',
473
+ },
474
+ {
475
+ name: 'dueAt',
476
+ type: 'string',
477
+ required: false,
478
+ description: 'ISO 8601 due datetime for create; omit or null in patch to clear.',
479
+ },
480
+ {
481
+ name: 'sortOrder',
482
+ type: 'number',
483
+ required: false,
484
+ description: 'Lower numbers sort first within a project (default 0).',
485
+ },
486
+ {
487
+ name: 'relatedFiles',
488
+ type: 'array',
489
+ required: false,
490
+ description: 'Repo-relative or absolute file paths tied to the task.',
491
+ },
492
+ {
493
+ name: 'relatedSymbols',
494
+ type: 'array',
495
+ required: false,
496
+ description: 'Function, class, or component names for cross-linking.',
497
+ },
498
+ {
499
+ name: 'patch',
500
+ type: 'object',
501
+ required: false,
502
+ description: 'For update: partial fields (title, description, status, priority, labels, metadata, parentTaskId, source, blockedBy, dueAt, sortOrder, relatedFiles, relatedSymbols).',
503
+ },
504
+ {
505
+ name: 'limit',
506
+ type: 'number',
507
+ required: false,
508
+ description: 'Max tasks to return for list (default 500, max 1000).',
509
+ },
510
+ ],
511
+ },
391
512
  ];
392
513
  function getAllViolations(result) {
393
514
  const violations = [];
@@ -424,29 +545,27 @@ function calculateHealthScore(result) {
424
545
  return Math.max(0, Math.round(Math.min(100, score)));
425
546
  }
426
547
  async function startMcpServer() {
427
- console.error(chalk.blue('[INFO]'), 'Starting Code Auditor MCP Server (standalone)...');
428
- console.error(chalk.blue('[DEBUG]'), `Process PID: ${process.pid}`);
429
- console.error(chalk.blue('[DEBUG]'), `Node version: ${process.version}`);
430
- console.error(chalk.blue('[DEBUG]'), `Working directory: ${process.cwd()}`);
548
+ logMcpInfo('startup', `code-auditor-mcp ${PACKAGE_VERSION} (standalone stdio)`, {
549
+ pid: process.pid,
550
+ cwd: process.cwd(),
551
+ dataDir: process.env.CODE_AUDITOR_DATA_DIR ?? '(default)'
552
+ });
553
+ mcpDebugStderr(chalk.blue('[DEBUG]'), `Node ${process.version} · cwd ${process.cwd()}`);
431
554
  const server = new Server({
432
555
  name: 'code-auditor',
556
+ version: PACKAGE_VERSION,
433
557
  }, {
434
558
  capabilities: {
435
559
  tools: {},
436
560
  },
437
561
  });
438
- console.error(chalk.blue('[INFO]'), 'Server instance created');
439
- console.error(chalk.blue('[DEBUG]'), 'Server capabilities:', JSON.stringify({ tools: {} }));
440
562
  // Add error handler
441
563
  server.onerror = (error) => {
442
564
  console.error(chalk.red('[ERROR]'), 'Server error occurred:', error);
443
565
  console.error(chalk.red('[ERROR]'), 'Error stack:', error.stack);
444
566
  };
445
- // Handle tool listing
446
- console.error(chalk.blue('[INFO]'), 'Setting up request handlers...');
447
567
  server.setRequestHandler(ListToolsRequestSchema, async (request) => {
448
- console.error(chalk.blue('[DEBUG]'), 'Received ListTools request');
449
- console.error(chalk.blue('[DEBUG]'), 'Request:', JSON.stringify(request, null, 2));
568
+ mcpDebugStderr(chalk.blue('[DEBUG]'), 'ListTools', JSON.stringify(request, null, 2));
450
569
  const response = {
451
570
  tools: tools.map(tool => ({
452
571
  name: tool.name,
@@ -466,15 +585,11 @@ async function startMcpServer() {
466
585
  },
467
586
  })),
468
587
  };
469
- console.error(chalk.blue('[DEBUG]'), `Returning ${response.tools.length} tools`);
470
- console.error(chalk.blue('[DEBUG]'), 'ListTools response:', JSON.stringify(response, null, 2));
588
+ mcpDebugStderr(chalk.blue('[DEBUG]'), `ListTools ${response.tools.length} tools`);
471
589
  return response;
472
590
  });
473
- console.error(chalk.blue('[INFO]'), `Registered ${tools.length} tools`);
474
- // Add handler for initialize request
475
591
  server.setRequestHandler(InitializeRequestSchema, async (request) => {
476
- console.error(chalk.blue('[DEBUG]'), 'Received initialize request');
477
- console.error(chalk.blue('[DEBUG]'), 'Request:', JSON.stringify(request, null, 2));
592
+ mcpDebugStderr(chalk.blue('[DEBUG]'), 'initialize', JSON.stringify(request, null, 2));
478
593
  const response = {
479
594
  protocolVersion: '2024-11-05',
480
595
  capabilities: {
@@ -482,21 +597,17 @@ async function startMcpServer() {
482
597
  },
483
598
  serverInfo: {
484
599
  name: 'code-auditor',
485
- version: '1.0.0',
600
+ version: PACKAGE_VERSION,
486
601
  },
487
602
  };
488
- console.error(chalk.blue('[DEBUG]'), 'Initialize response:', JSON.stringify(response, null, 2));
603
+ mcpDebugStderr(chalk.blue('[DEBUG]'), 'initialize response', JSON.stringify(response, null, 2));
489
604
  return response;
490
605
  });
491
- // Handle tool execution
492
606
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
493
- console.error(chalk.blue('[DEBUG]'), 'Received CallTool request');
494
- console.error(chalk.blue('[DEBUG]'), 'Request:', JSON.stringify(request, null, 2));
607
+ mcpDebugStderr(chalk.blue('[DEBUG]'), 'CallTool raw', JSON.stringify(request, null, 2));
495
608
  const { name, arguments: args } = request.params;
496
- console.error(chalk.blue('[DEBUG]'), `Tool name: ${name}`);
497
- console.error(chalk.blue('[DEBUG]'), `Tool arguments:`, JSON.stringify(args, null, 2));
609
+ mcpDebugStderr(chalk.blue('[DEBUG]'), `CallTool ${name}`, JSON.stringify(args, null, 2));
498
610
  try {
499
- console.error(chalk.blue('[DEBUG]'), `Starting tool execution for: ${name}`);
500
611
  let result;
501
612
  switch (name) {
502
613
  case 'audit': {
@@ -504,19 +615,20 @@ async function startMcpServer() {
504
615
  const indexFunctions = args.indexFunctions !== false; // Default true
505
616
  const analyzers = args.analyzers || ['solid', 'dry'];
506
617
  const minSeverity = args.minSeverity;
507
- const limit = Math.min(args.limit || 50, 100); // Max 100
508
- const offset = args.offset || 0;
618
+ const limit = Math.min(Math.max(0, Number(args.limit)) || 50, 100); // Max 100
619
+ const offset = Math.max(0, Number(args.offset) || 0);
509
620
  const useCache = args.useCache !== false; // Default true
510
621
  const providedAuditId = args.auditId;
511
622
  let auditResult;
512
623
  let auditId = providedAuditId;
624
+ const db = CodeIndexDB.getInstance();
625
+ await db.initialize();
513
626
  // Check if we should use cached results
514
627
  if (providedAuditId) {
515
- const db = CodeIndexDB.getInstance();
516
628
  const cachedResult = await db.getAuditResults(providedAuditId);
517
629
  if (cachedResult) {
518
630
  auditResult = cachedResult;
519
- console.error(chalk.blue('[INFO]'), `Using cached audit results: ${providedAuditId}`);
631
+ mcpDebugStderr(chalk.blue('[INFO]'), `Using cached audit results: ${providedAuditId}`);
520
632
  }
521
633
  else {
522
634
  console.error(chalk.yellow('[WARN]'), `Cached audit not found: ${providedAuditId}, running new audit`);
@@ -524,9 +636,8 @@ async function startMcpServer() {
524
636
  }
525
637
  // Run new audit if no cached result
526
638
  if (!auditResult) {
639
+ await assertAuditPathExists(auditPath);
527
640
  // Get stored analyzer configs from database
528
- const db = CodeIndexDB.getInstance();
529
- await db.initialize();
530
641
  const storedConfigs = await db.getAllAnalyzerConfigs(auditPath);
531
642
  // Merge stored configs with any provided configs
532
643
  const analyzerConfigs = {
@@ -545,9 +656,8 @@ async function startMcpServer() {
545
656
  const runResult = await runner.run();
546
657
  // Store in cache if requested
547
658
  if (useCache) {
548
- const db = CodeIndexDB.getInstance();
549
659
  auditId = await db.storeAuditResults(runResult, auditPath);
550
- console.error(chalk.blue('[INFO]'), `Stored audit results with ID: ${auditId}`);
660
+ mcpDebugStderr(chalk.blue('[INFO]'), `Stored audit results with ID: ${auditId}`);
551
661
  }
552
662
  auditResult = runResult;
553
663
  }
@@ -569,14 +679,14 @@ async function startMcpServer() {
569
679
  failed: 0,
570
680
  syncStats
571
681
  };
572
- console.error(chalk.blue('[INFO]'), `Synced functions: ${syncStats.added} added, ${syncStats.updated} updated, ${syncStats.removed} removed`);
682
+ mcpDebugStderr(chalk.blue('[INFO]'), `Synced functions: ${syncStats.added} added, ${syncStats.updated} updated, ${syncStats.removed} removed`);
573
683
  // Auto-detect and populate whitelist entries after indexing
574
684
  try {
575
685
  const { WhitelistService } = await import('./services/whitelistService.js');
576
686
  const whitelistService = WhitelistService.getInstance();
577
687
  const whitelistResult = await whitelistService.whitelistAllDependencies(auditPath);
578
688
  if (whitelistResult.added > 0) {
579
- console.error(chalk.blue('[INFO]'), `Auto-added ${whitelistResult.added} whitelist entries`);
689
+ mcpDebugStderr(chalk.blue('[INFO]'), `Auto-added ${whitelistResult.added} whitelist entries`);
580
690
  }
581
691
  }
582
692
  catch (error) {
@@ -618,6 +728,7 @@ async function startMcpServer() {
618
728
  }
619
729
  case 'audit_health': {
620
730
  const auditPath = path.resolve(args.path || process.cwd());
731
+ await assertAuditPathExists(auditPath);
621
732
  const indexFunctions = args.indexFunctions !== false; // Default true
622
733
  // Get stored analyzer configs from database
623
734
  const db = CodeIndexDB.getInstance();
@@ -656,7 +767,7 @@ async function startMcpServer() {
656
767
  failed: 0,
657
768
  syncStats
658
769
  };
659
- console.error(chalk.blue('[INFO]'), `Synced functions: ${syncStats.added} added, ${syncStats.updated} updated, ${syncStats.removed} removed`);
770
+ mcpDebugStderr(chalk.blue('[INFO]'), `Synced functions: ${syncStats.added} added, ${syncStats.updated} updated, ${syncStats.removed} removed`);
660
771
  }
661
772
  catch (error) {
662
773
  console.error(chalk.yellow('[WARN]'), 'Failed to index functions:', error);
@@ -767,7 +878,7 @@ async function startMcpServer() {
767
878
  result = {
768
879
  success: true,
769
880
  mode: 'reset',
770
- message: 'Index cleared successfully'
881
+ message: 'Analysis-derived data cleared (functions, search index, cached audits, code maps, schemas). Project tasks, whitelist, and analyzer configs were preserved.'
771
882
  };
772
883
  break;
773
884
  }
@@ -961,6 +1072,11 @@ async function startMcpServer() {
961
1072
  result = await handleWhitelistDetect(args);
962
1073
  break;
963
1074
  }
1075
+ case 'project_tasks': {
1076
+ const { handleProjectTasks } = await import('./mcp-tools/projectTasks.js');
1077
+ result = await handleProjectTasks((args || {}));
1078
+ break;
1079
+ }
964
1080
  default:
965
1081
  throw new Error(`Unknown tool: ${name}`);
966
1082
  }
@@ -972,8 +1088,7 @@ async function startMcpServer() {
972
1088
  },
973
1089
  ],
974
1090
  };
975
- console.error(chalk.blue('[DEBUG]'), `Tool ${name} executed successfully`);
976
- console.error(chalk.blue('[DEBUG]'), 'CallTool response:', JSON.stringify(response, null, 2).substring(0, 500) + '...');
1091
+ mcpDebugStderr(chalk.blue('[DEBUG]'), `Tool ${name} ok`, JSON.stringify(response, null, 2).substring(0, 500) + '...');
977
1092
  return response;
978
1093
  }
979
1094
  catch (error) {
@@ -983,19 +1098,14 @@ async function startMcpServer() {
983
1098
  content: [
984
1099
  {
985
1100
  type: 'text',
986
- text: JSON.stringify({
987
- error: error instanceof Error ? error.message : 'Unknown error',
988
- tool: name,
989
- }),
1101
+ text: JSON.stringify(formatMcpToolErrorPayload(name, error), null, 2),
990
1102
  },
991
1103
  ],
992
1104
  isError: true,
993
1105
  };
994
1106
  }
995
1107
  });
996
- console.error(chalk.blue('[INFO]'), 'Request handlers configured');
997
1108
  const transport = new StdioServerTransport();
998
- console.error(chalk.blue('[INFO]'), 'Creating stdio transport...');
999
1109
  // Add transport event handlers if available
1000
1110
  if (transport.onclose) {
1001
1111
  transport.onclose = () => {
@@ -1007,16 +1117,13 @@ async function startMcpServer() {
1007
1117
  console.error(chalk.red('[ERROR]'), 'Transport error:', error);
1008
1118
  };
1009
1119
  }
1010
- console.error(chalk.blue('[DEBUG]'), 'Connecting server to transport...');
1011
1120
  await server.connect(transport);
1012
- console.error(chalk.blue('[DEBUG]'), 'Server connected to transport');
1013
1121
  console.error(chalk.green('✓ Code Auditor MCP Server started (standalone mode)'));
1014
- console.error(chalk.gray('Listening on stdio...'));
1015
- console.error(chalk.blue('[DEBUG]'), 'Server state after initialization:', {
1122
+ console.error(chalk.gray(`Listening on stdio · ${tools.length} tools · ${PACKAGE_VERSION}`));
1123
+ mcpDebugStderr(chalk.blue('[DEBUG]'), 'Server ready', {
1016
1124
  name: 'code-auditor',
1017
1125
  transport: 'stdio',
1018
- handlers: ['ListTools', 'CallTool', 'initialize'],
1019
- toolCount: tools.length,
1126
+ toolCount: tools.length
1020
1127
  });
1021
1128
  }
1022
1129
  // Error handlers
@@ -1048,8 +1155,6 @@ process.stdin.on('error', (error) => {
1048
1155
  process.stdout.on('error', (error) => {
1049
1156
  console.error(chalk.red('[ERROR]'), 'stdout error:', error);
1050
1157
  });
1051
- // Start server
1052
- console.error(chalk.blue('[INFO]'), 'Initializing server...');
1053
1158
  startMcpServer().catch(error => {
1054
1159
  console.error(chalk.red('[ERROR]'), 'Failed to start MCP server:', error);
1055
1160
  console.error(chalk.red('[ERROR]'), 'Stack:', error.stack);