m9k_restart
Restart the MCP server to load fresh code after building, enabling automatic reconnection with updated builds.
Instructions
Restart the MCP server. Use after npm run build to load fresh code. The server disconnects; next MCP call auto-reconnects with the new build.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| force | No | Use SIGKILL instead of SIGTERM (for stuck processes) |
Implementation Reference
- src/tools/manage.ts:234-286 (handler)Registration and implementation of the 'm9k_restart' tool, which schedules a process termination (SIGTERM or SIGKILL) to allow for server restart.
server.registerTool( 'm9k_restart', { description: 'Restart the MCP server. Use after npm run build to load fresh code. ' + 'The server disconnects; next MCP call auto-reconnects with the new build.', inputSchema: { force: z .boolean() .optional() .default(false) .describe('Use SIGKILL instead of SIGTERM (for stuck processes)'), }, annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false, }, }, async ({ force }) => { // Detect daemon vs local mode let mode: 'daemon' | 'local' = 'local'; try { const pidStr = fs.readFileSync(DAEMON_PID_PATH, 'utf8').trim(); if (parseInt(pidStr, 10) === process.pid) { mode = 'daemon'; } } catch { // No PID file → local mode } const signal = force ? 'SIGKILL' : 'SIGTERM'; // Schedule kill after 200ms to let the MCP response flush setTimeout(() => { process.kill(process.pid, signal); }, 200); return { content: [ { type: 'text' as const, text: JSON.stringify({ restarting: true, mode, graceful: !force, }), }, ], }; }, );