ai-cli-mcp 2.1.0 → 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.
- package/dist/server.js +36 -20
- package/package.json +1 -1
- package/src/server.ts +50 -24
package/dist/server.js
CHANGED
|
@@ -9,7 +9,7 @@ import { join, resolve as pathResolve } from 'node:path';
|
|
|
9
9
|
import * as path from 'path';
|
|
10
10
|
import { parseCodexOutput, parseClaudeOutput, parseGeminiOutput } from './parsers.js';
|
|
11
11
|
// Server version - update this when releasing new versions
|
|
12
|
-
const SERVER_VERSION = "2.0
|
|
12
|
+
const SERVER_VERSION = "2.2.0";
|
|
13
13
|
// Model alias mappings for user-friendly model names
|
|
14
14
|
const MODEL_ALIASES = {
|
|
15
15
|
'haiku': 'claude-3-5-haiku-20241022'
|
|
@@ -288,7 +288,7 @@ export class ClaudeCodeServer {
|
|
|
288
288
|
},
|
|
289
289
|
{
|
|
290
290
|
name: 'list_processes',
|
|
291
|
-
description: 'List all running and completed AI agent processes
|
|
291
|
+
description: 'List all running and completed AI agent processes. Returns a simple list with PID, agent type, and status for each process.',
|
|
292
292
|
inputSchema: {
|
|
293
293
|
type: 'object',
|
|
294
294
|
properties: {},
|
|
@@ -321,6 +321,14 @@ export class ClaudeCodeServer {
|
|
|
321
321
|
},
|
|
322
322
|
required: ['pid'],
|
|
323
323
|
},
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
name: 'cleanup_processes',
|
|
327
|
+
description: 'Remove all completed and failed processes from the process list to free up memory.',
|
|
328
|
+
inputSchema: {
|
|
329
|
+
type: 'object',
|
|
330
|
+
properties: {},
|
|
331
|
+
},
|
|
324
332
|
}
|
|
325
333
|
],
|
|
326
334
|
}));
|
|
@@ -339,6 +347,8 @@ export class ClaudeCodeServer {
|
|
|
339
347
|
return this.handleGetResult(toolArguments);
|
|
340
348
|
case 'kill_process':
|
|
341
349
|
return this.handleKillProcess(toolArguments);
|
|
350
|
+
case 'cleanup_processes':
|
|
351
|
+
return this.handleCleanupProcesses();
|
|
342
352
|
default:
|
|
343
353
|
throw new McpError(ErrorCode.MethodNotFound, `Tool ${toolName} not found`);
|
|
344
354
|
}
|
|
@@ -520,25 +530,8 @@ export class ClaudeCodeServer {
|
|
|
520
530
|
const processInfo = {
|
|
521
531
|
pid,
|
|
522
532
|
agent: process.toolType,
|
|
523
|
-
status: process.status
|
|
524
|
-
startTime: process.startTime,
|
|
525
|
-
prompt: process.prompt.substring(0, 100) + (process.prompt.length > 100 ? '...' : ''),
|
|
526
|
-
workFolder: process.workFolder,
|
|
527
|
-
model: process.model,
|
|
528
|
-
exitCode: process.exitCode
|
|
533
|
+
status: process.status
|
|
529
534
|
};
|
|
530
|
-
// Try to extract session_id from JSON output if available
|
|
531
|
-
if (process.stdout) {
|
|
532
|
-
try {
|
|
533
|
-
const claudeOutput = JSON.parse(process.stdout);
|
|
534
|
-
if (claudeOutput.session_id) {
|
|
535
|
-
processInfo.session_id = claudeOutput.session_id;
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
catch (e) {
|
|
539
|
-
// Ignore parsing errors
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
535
|
processes.push(processInfo);
|
|
543
536
|
}
|
|
544
537
|
return {
|
|
@@ -647,6 +640,29 @@ export class ClaudeCodeServer {
|
|
|
647
640
|
throw new McpError(ErrorCode.InternalError, `Failed to terminate process: ${error.message}`);
|
|
648
641
|
}
|
|
649
642
|
}
|
|
643
|
+
/**
|
|
644
|
+
* Handle cleanup_processes tool
|
|
645
|
+
*/
|
|
646
|
+
async handleCleanupProcesses() {
|
|
647
|
+
const removedPids = [];
|
|
648
|
+
// Iterate through all processes and collect PIDs to remove
|
|
649
|
+
for (const [pid, process] of processManager.entries()) {
|
|
650
|
+
if (process.status === 'completed' || process.status === 'failed') {
|
|
651
|
+
removedPids.push(pid);
|
|
652
|
+
processManager.delete(pid);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
return {
|
|
656
|
+
content: [{
|
|
657
|
+
type: 'text',
|
|
658
|
+
text: JSON.stringify({
|
|
659
|
+
removed: removedPids.length,
|
|
660
|
+
removedPids,
|
|
661
|
+
message: `Cleaned up ${removedPids.length} finished process(es)`
|
|
662
|
+
}, null, 2)
|
|
663
|
+
}]
|
|
664
|
+
};
|
|
665
|
+
}
|
|
650
666
|
/**
|
|
651
667
|
* Start the MCP server
|
|
652
668
|
*/
|
package/package.json
CHANGED
package/src/server.ts
CHANGED
|
@@ -16,7 +16,7 @@ import * as path from 'path';
|
|
|
16
16
|
import { parseCodexOutput, parseClaudeOutput, parseGeminiOutput } from './parsers.js';
|
|
17
17
|
|
|
18
18
|
// Server version - update this when releasing new versions
|
|
19
|
-
const SERVER_VERSION = "2.
|
|
19
|
+
const SERVER_VERSION = "2.2.0";
|
|
20
20
|
|
|
21
21
|
// Model alias mappings for user-friendly model names
|
|
22
22
|
const MODEL_ALIASES: Record<string, string> = {
|
|
@@ -47,6 +47,13 @@ interface ClaudeProcess {
|
|
|
47
47
|
exitCode?: number;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
// Type definition for list_processes return value
|
|
51
|
+
interface ProcessListItem {
|
|
52
|
+
pid: number; // プロセスID
|
|
53
|
+
agent: 'claude' | 'codex' | 'gemini'; // エージェントタイプ
|
|
54
|
+
status: 'running' | 'completed' | 'failed'; // プロセスの状態
|
|
55
|
+
}
|
|
56
|
+
|
|
50
57
|
// Global process manager
|
|
51
58
|
const processManager = new Map<number, ClaudeProcess>();
|
|
52
59
|
|
|
@@ -372,7 +379,7 @@ export class ClaudeCodeServer {
|
|
|
372
379
|
},
|
|
373
380
|
{
|
|
374
381
|
name: 'list_processes',
|
|
375
|
-
description: 'List all running and completed AI agent processes
|
|
382
|
+
description: 'List all running and completed AI agent processes. Returns a simple list with PID, agent type, and status for each process.',
|
|
376
383
|
inputSchema: {
|
|
377
384
|
type: 'object',
|
|
378
385
|
properties: {},
|
|
@@ -405,6 +412,14 @@ export class ClaudeCodeServer {
|
|
|
405
412
|
},
|
|
406
413
|
required: ['pid'],
|
|
407
414
|
},
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
name: 'cleanup_processes',
|
|
418
|
+
description: 'Remove all completed and failed processes from the process list to free up memory.',
|
|
419
|
+
inputSchema: {
|
|
420
|
+
type: 'object',
|
|
421
|
+
properties: {},
|
|
422
|
+
},
|
|
408
423
|
}
|
|
409
424
|
],
|
|
410
425
|
}));
|
|
@@ -427,6 +442,8 @@ export class ClaudeCodeServer {
|
|
|
427
442
|
return this.handleGetResult(toolArguments);
|
|
428
443
|
case 'kill_process':
|
|
429
444
|
return this.handleKillProcess(toolArguments);
|
|
445
|
+
case 'cleanup_processes':
|
|
446
|
+
return this.handleCleanupProcesses();
|
|
430
447
|
default:
|
|
431
448
|
throw new McpError(ErrorCode.MethodNotFound, `Tool ${toolName} not found`);
|
|
432
449
|
}
|
|
@@ -628,32 +645,15 @@ export class ClaudeCodeServer {
|
|
|
628
645
|
* Handle list_processes tool
|
|
629
646
|
*/
|
|
630
647
|
private async handleListProcesses(): Promise<ServerResult> {
|
|
631
|
-
const processes:
|
|
632
|
-
|
|
648
|
+
const processes: ProcessListItem[] = [];
|
|
649
|
+
|
|
633
650
|
for (const [pid, process] of processManager.entries()) {
|
|
634
|
-
const processInfo:
|
|
651
|
+
const processInfo: ProcessListItem = {
|
|
635
652
|
pid,
|
|
636
653
|
agent: process.toolType,
|
|
637
|
-
status: process.status
|
|
638
|
-
startTime: process.startTime,
|
|
639
|
-
prompt: process.prompt.substring(0, 100) + (process.prompt.length > 100 ? '...' : ''),
|
|
640
|
-
workFolder: process.workFolder,
|
|
641
|
-
model: process.model,
|
|
642
|
-
exitCode: process.exitCode
|
|
654
|
+
status: process.status
|
|
643
655
|
};
|
|
644
656
|
|
|
645
|
-
// Try to extract session_id from JSON output if available
|
|
646
|
-
if (process.stdout) {
|
|
647
|
-
try {
|
|
648
|
-
const claudeOutput = JSON.parse(process.stdout);
|
|
649
|
-
if (claudeOutput.session_id) {
|
|
650
|
-
processInfo.session_id = claudeOutput.session_id;
|
|
651
|
-
}
|
|
652
|
-
} catch (e) {
|
|
653
|
-
// Ignore parsing errors
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
|
|
657
657
|
processes.push(processInfo);
|
|
658
658
|
}
|
|
659
659
|
|
|
@@ -773,6 +773,32 @@ export class ClaudeCodeServer {
|
|
|
773
773
|
}
|
|
774
774
|
}
|
|
775
775
|
|
|
776
|
+
/**
|
|
777
|
+
* Handle cleanup_processes tool
|
|
778
|
+
*/
|
|
779
|
+
private async handleCleanupProcesses(): Promise<ServerResult> {
|
|
780
|
+
const removedPids: number[] = [];
|
|
781
|
+
|
|
782
|
+
// Iterate through all processes and collect PIDs to remove
|
|
783
|
+
for (const [pid, process] of processManager.entries()) {
|
|
784
|
+
if (process.status === 'completed' || process.status === 'failed') {
|
|
785
|
+
removedPids.push(pid);
|
|
786
|
+
processManager.delete(pid);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
return {
|
|
791
|
+
content: [{
|
|
792
|
+
type: 'text',
|
|
793
|
+
text: JSON.stringify({
|
|
794
|
+
removed: removedPids.length,
|
|
795
|
+
removedPids,
|
|
796
|
+
message: `Cleaned up ${removedPids.length} finished process(es)`
|
|
797
|
+
}, null, 2)
|
|
798
|
+
}]
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
|
|
776
802
|
/**
|
|
777
803
|
* Start the MCP server
|
|
778
804
|
*/
|
|
@@ -796,4 +822,4 @@ export class ClaudeCodeServer {
|
|
|
796
822
|
|
|
797
823
|
// Create and run the server if this is the main module
|
|
798
824
|
const server = new ClaudeCodeServer();
|
|
799
|
-
server.run().catch(console.error);
|
|
825
|
+
server.run().catch(console.error);
|