mavis_comm_send
Control running sessions by sending commands: prompt, abort, kill, summarize, fork, or spawn.
Instructions
Send a message or command to a running session (prompt/abort/kill/summarize/fork/spawn).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | Yes | Target session ID | |
| command | Yes | Command to send | |
| content | No | Message content (for prompt command) | |
| from | No | Sender session ID (default: parent session) |
Implementation Reference
- src/index.js:192-208 (registration)Tool registration for mavis_comm_send in the tools array. Defines name, description, inputSchema (with Zod validation for to, command, content, from), and buildArgs that constructs CLI arguments.
{ name: 'mavis_comm_send', description: 'Send a message or command to a running session (prompt/abort/kill/summarize/fork/spawn).', inputSchema: z.object({ to: z.string().describe('Target session ID'), command: z.enum(['prompt', 'abort', 'kill', 'summarize', 'fork', 'spawn']).describe('Command to send'), content: z.string().optional().describe('Message content (for prompt command)'), from: z.string().optional().describe('Sender session ID (default: parent session)') }), buildArgs: ({ to, command, content, from }) => { const args = ['communication', 'send']; if (from) args.push('--from', from); args.push('--to', to, '--command', command); if (content) args.push('--content', content); return args; } }, - src/index.js:77-92 (handler)Generic handler runner. Since mavis_comm_send does NOT define execFn or outputMode, it defaults to execMavisJSON (which calls execMavis and parses JSON output). The buildArgs function constructs the CLI args ['communication', 'send', '--to', to, '--command', command, ...].
function runTool(spec, parsedArgs) { const { execFn, outputMode, stdin, buildArgs } = spec; const args = buildArgs(parsedArgs); const input = typeof stdin === 'function' ? stdin(parsedArgs) : stdin; const execPromise = execFn ? execMavis(args, input || '') : execMavisJSON(args); return execPromise.then(result => { const text = outputMode === OUTPUT_RAW ? (result || '') : JSON.stringify(result, null, 2); return [{ type: 'text', text }]; }); } - src/index.js:195-200 (schema)Zod input schema for mavis_comm_send: 'to' (required string), 'command' (enum of 6 commands), 'content' (optional string), 'from' (optional string).
inputSchema: z.object({ to: z.string().describe('Target session ID'), command: z.enum(['prompt', 'abort', 'kill', 'summarize', 'fork', 'spawn']).describe('Command to send'), content: z.string().optional().describe('Message content (for prompt command)'), from: z.string().optional().describe('Sender session ID (default: parent session)') }), - src/index.js:32-53 (helper)Core exec helper (execMavis). Spawns the mavis CLI binary. Since 'communication' is in SESSION_COMMANDS, it will append --session with the parent session ID if available.
function execMavis(args, input = '') { return new Promise((resolve, reject) => { const SESSION_COMMANDS = new Set(['communication', 'session', 'spawn']); const sessionId = process.env.__MAVIS_PARENT_SESSION_ID; const subcmd = args[0]; const needsSession = SESSION_COMMANDS.has(subcmd) && sessionId; const finalArgs = needsSession ? [...args, '--session', sessionId] : args; const proc = spawn(MAVIS_BIN, finalArgs, { stdio: ['pipe', 'pipe', 'pipe'] }); let stdout = ''; let stderr = ''; proc.stdout.on('data', d => stdout += d.toString()); proc.stderr.on('data', d => stderr += d.toString()); proc.on('close', code => { if (code === 0) resolve(stdout.trim()); else reject(new Error(stderr.split('\n')[0] || `exit code ${code}`)); }); proc.on('error', reject); if (input) proc.stdin.write(input), proc.stdin.end(); }); }