stop_server
Stop a running server by specifying its process name to terminate the process and free system resources.
Instructions
Stop a running server
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Process name |
Implementation Reference
- src/services/ProcessService.ts:160-201 (handler)The main handler for the stop_server tool. Looks up the process by name, sends SIGTERM (graceful), waits 1 second, then force kills with SIGKILL if still running. Returns success or error message.
async stopServer(args: StopServerArgs): Promise<ToolResult> { const { name } = args; ValidationUtils.validateRequired({ name }, ['name']); const processInfo = this.activeProcesses.get(name); if (!processInfo) { return { content: [{ type: 'text', text: `No process found with name: ${name}`, }], }; } try { processInfo.process.kill('SIGTERM'); // Wait a bit for graceful shutdown await new Promise(resolve => setTimeout(resolve, 1000)); // Force kill if still running if (!processInfo.process.killed) { processInfo.process.kill('SIGKILL'); } this.activeProcesses.delete(name); return { content: [{ type: 'text', text: `Server "${name}" stopped successfully`, }], }; } catch (error) { return { content: [{ type: 'text', text: `Error stopping server "${name}": ${error instanceof Error ? error.message : 'Unknown error'}`, }], }; } } - src/services/ProcessService.ts:22-24 (schema)TypeScript interface for stop_server arguments - requires a 'name' string field.
export interface StopServerArgs { name: string; } - src/toolDefinitions.ts:391-401 (registration)Tool definition registration for stop_server with input schema requiring a 'name' property.
{ name: 'stop_server', description: 'Stop a running server', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Process name' }, }, required: ['name'], }, }, - src/index.ts:243-244 (registration)Routing logic in executeToolCommand that dispatches 'stop_server' calls to ProcessService.stopServer().
case 'stop_server': return await this.processService.stopServer(args as StopServerArgs); - Helper method that stops all active processes by calling stopServer for each one, used during cleanup.
async stopAllProcesses(): Promise<void> { const promises = Array.from(this.activeProcesses.keys()).map(name => this.stopServer({ name }).catch(() => { // Ignore errors during cleanup }) ); await Promise.all(promises); }