write_to_terminal
Send text or commands to the Windows terminal through the WinTerm MCP server, enabling AI models to interact with the command line interface.
Instructions
Write text or commands to the terminal
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| command | Yes | The text or command to write to the terminal |
Implementation Reference
- src/index.ts:89-123 (handler)Handler for 'write_to_terminal' tool: spawns a shell process with the given command, captures stdout/stderr output, stores in outputBuffer, and resolves with the output and exit code.case 'write_to_terminal': { const { command } = request.params.arguments as { command: string }; return new Promise((resolve, reject) => { const shell = os.platform() === 'win32' ? 'cmd.exe' : 'bash'; const shellArgs = os.platform() === 'win32' ? ['/c', command] : ['-c', command]; const proc = spawn(shell, shellArgs); let output = ''; proc.stdout.on('data', (data) => { output += data.toString(); this.outputBuffer.push(...data.toString().split('\n')); }); proc.stderr.on('data', (data) => { output += data.toString(); this.outputBuffer.push(...data.toString().split('\n')); }); proc.on('close', (code) => { resolve({ content: [ { type: 'text', text: `Command executed with exit code ${code}. Output:\n${output}`, }, ], }); }); proc.on('error', (err) => { reject(new McpError(ErrorCode.InternalError, err.message)); }); }); }
- src/index.ts:42-55 (registration)Registration of the 'write_to_terminal' tool in ListToolsRequestHandler, including name, description, and input schema for the command parameter.{ name: 'write_to_terminal', description: 'Write text or commands to the terminal', inputSchema: { type: 'object', properties: { command: { type: 'string', description: 'The text or command to write to the terminal', }, }, required: ['command'], }, },
- src/index.ts:45-54 (schema)Input schema definition for the 'write_to_terminal' tool, specifying a required 'command' string.inputSchema: { type: 'object', properties: { command: { type: 'string', description: 'The text or command to write to the terminal', }, }, required: ['command'], },