init project
This commit is contained in:
Vendored
+41
@@ -0,0 +1,41 @@
|
||||
import { z } from 'zod';
|
||||
import { errorResult, jsonResult, toErrorMessage } from '../shared.js';
|
||||
import { dockerManager } from './dockerManager.js';
|
||||
export function registerDockerStopRemoveTools(server) {
|
||||
server.registerTool('docker_stop_container', {
|
||||
title: 'Docker Stop Container',
|
||||
description: 'Stop a Docker container started by this server.',
|
||||
inputSchema: {
|
||||
containerId: z.string().min(1).describe('Container ID returned by docker_run_container.'),
|
||||
timeout: z.number().int().positive().optional().default(10).describe('Seconds to wait before killing.'),
|
||||
},
|
||||
}, async ({ containerId, timeout }) => {
|
||||
try {
|
||||
await dockerManager.ensureReachable();
|
||||
await dockerManager.getDocker().getContainer(containerId).stop({ t: timeout });
|
||||
return jsonResult({ stopped: true, containerId });
|
||||
}
|
||||
catch (error) {
|
||||
return errorResult(toErrorMessage(error));
|
||||
}
|
||||
});
|
||||
server.registerTool('docker_remove_container', {
|
||||
title: 'Docker Remove Container',
|
||||
description: 'Remove a Docker container started by this server.',
|
||||
inputSchema: {
|
||||
containerId: z.string().min(1).describe('Container ID returned by docker_run_container.'),
|
||||
force: z.boolean().optional().default(false).describe('Force removal even if running.'),
|
||||
},
|
||||
}, async ({ containerId, force }) => {
|
||||
try {
|
||||
await dockerManager.ensureReachable();
|
||||
await dockerManager.getDocker().getContainer(containerId).remove({ force });
|
||||
dockerManager.untrack(containerId);
|
||||
return jsonResult({ removed: true, containerId });
|
||||
}
|
||||
catch (error) {
|
||||
return errorResult(toErrorMessage(error));
|
||||
}
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=stopRemove.js.map
|
||||
Reference in New Issue
Block a user