ssh_send_input
Send commands or text input to an active SSH shell session, with optional human-like typing simulation for interactive applications.
Instructions
Send input to an interactive shell session with optional typing simulation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input | Yes | Input to send to the shell | |
| sessionId | Yes | Interactive session ID | |
| simulateTyping | No | Simulate human typing with delays |
Implementation Reference
- src/index.ts:958-1002 (handler)Main execution handler for ssh_send_input tool. Validates parameters using SendInputSchema, retrieves active shell session, sends input directly or with simulated typing delays, returns confirmation.private async handleSendInput(args: unknown) { const params = SendInputSchema.parse(args); const session = shellSessions.get(params.sessionId); if (!session) { throw new McpError( ErrorCode.InvalidParams, `Session ID '${params.sessionId}' not found` ); } if (!session.isActive) { throw new McpError( ErrorCode.InvalidParams, `Session '${params.sessionId}' is not active` ); } try { if (params.simulateTyping) { // Simulate human typing with random delays for (const char of params.input) { session.shell.write(char); // Random delay between 50-150ms per character await new Promise(resolve => setTimeout(resolve, 50 + Math.random() * 100)); } } else { session.shell.write(params.input); } return { content: [ { type: 'text', text: `Input sent to session '${params.sessionId}'${params.simulateTyping ? ' (with typing simulation)' : ''}\nInput: ${params.input}`, }, ], }; } catch (error) { throw new McpError( ErrorCode.InternalError, `Failed to send input: ${error instanceof Error ? error.message : String(error)}` ); } }
- src/index.ts:107-111 (schema)Zod schema defining input parameters for ssh_send_input: sessionId (required), input (required), simulateTyping (optional boolean).const SendInputSchema = z.object({ sessionId: z.string().describe('Interactive session ID'), input: z.string().describe('Input to send to the shell'), simulateTyping: z.boolean().default(false).describe('Simulate human typing with delays') });
- src/index.ts:335-346 (registration)Tool registration in ListTools response, including name, description, and input schema definition.name: 'ssh_send_input', description: 'Send input to an interactive shell session with optional typing simulation', inputSchema: { type: 'object', properties: { sessionId: { type: 'string', description: 'Interactive session ID' }, input: { type: 'string', description: 'Input to send to the shell' }, simulateTyping: { type: 'boolean', default: false, description: 'Simulate human typing with delays' } }, required: ['sessionId', 'input'] }, },
- src/index.ts:499-500 (registration)Dispatch registration in CallToolRequestSchema switch statement, mapping 'ssh_send_input' to handleSendInput method.case 'ssh_send_input': return await this.handleSendInput(args);
- src/index.ts:57-57 (helper)Global Map storing active shell sessions, used by ssh_send_input to retrieve session by sessionId.const shellSessions = new Map<string, ShellSession>();