vnc_type_text
Types text into a remote system connected via VNC. Optionally presses Enter after typing.
Instructions
Type text string
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | Single line of text to type | |
| enter | No | Press Enter after typing text |
Implementation Reference
- src/server.ts:89-99 (registration)Tool registration for 'vnc_type_text' with name, description, and inputSchema (text string, optional enter boolean)
{ name: 'vnc_type_text', description: 'Type text string', inputSchema: { type: 'object', properties: { text: { type: 'string', description: 'Single line of text to type' }, enter: { type: 'boolean', description: 'Press Enter after typing text', default: false } }, required: ['text'] } - src/tools/input.ts:114-135 (handler)Main handler function 'handleTypeText' - types text using typeString(), optionally presses Enter, returns result text
export async function handleTypeText( vncManager: VncConnectionManager, args: { text: string; enter?: boolean } ) { return vncManager.executeWithConnection(async (client) => { // Single-line text input only await typeString(client, args.text); // Press Enter only if explicitly requested if (args.enter) { const enterKeysym = getKeysym('Return'); client.sendKeyEvent(enterKeysym, true); await new Promise(resolve => setTimeout(resolve, 50)); client.sendKeyEvent(enterKeysym, false); } const enterText = args.enter ? ' + Enter' : ''; return { content: [{ type: 'text', text: `Typed text: ${args.text}${enterText}` }] }; }); } - src/server.ts:143-144 (registration)Routes 'vnc_type_text' tool calls to handleTypeText function via switch-case
case 'vnc_type_text': return await handleTypeText(this.vncManager, args as any); - src/tools/input.ts:160-173 (helper)Helper function 'typeString' - iterates over each character, determines typing speed based on text complexity, calls typeCharacter
async function typeString(client: any, text: string) { // Determine if this text needs slower typing const hasSpecialChars = /[|:;&<>?/\\~`!@#$%^*()+=\[\]{}'",-]/.test(text); const isLongText = text.length > 10; const useSlowTyping = hasSpecialChars || isLongText; // Use different timing based on text complexity const keyHoldTime = useSlowTyping ? 75 : 50; const betweenKeyDelay = useSlowTyping ? 100 : 50; for (const char of text) { await typeCharacter(client, char, keyHoldTime, betweenKeyDelay); } } - src/tools/input.ts:175-212 (helper)Helper function 'typeCharacter' - sends VNC key events per character, handles Shift for uppercase/symbols
async function typeCharacter( vncClient: VncClient, char: string, keyHoldTime: number, betweenKeyDelay: number ) { // Check if this is a character that needs shift const needsShift = charNeedsShift(char); const keysym = getKeysym(needsShift ? getUnshiftedChar(char) : char); const shiftKeysym = getKeysym('Shift'); console.error(`Typing '${char}' with keysym 0x${keysym.toString(16)}${needsShift ? ' (with Shift)' : ''}`); try { // Press Shift if needed if (needsShift) { vncClient.sendKeyEvent(shiftKeysym, true); await new Promise(resolve => setTimeout(resolve, 10)); } // Press and release the key vncClient.sendKeyEvent(keysym, true); await new Promise(resolve => setTimeout(resolve, keyHoldTime)); vncClient.sendKeyEvent(keysym, false); // Release Shift if it was pressed if (needsShift) { await new Promise(resolve => setTimeout(resolve, 10)); vncClient.sendKeyEvent(shiftKeysym, false); } await new Promise(resolve => setTimeout(resolve, betweenKeyDelay)); } catch (error) { console.error(`VNC library error typing character '${char}':`, error); // Rethrow to fail the entire text operation and allow client retry throw new Error(`VNC buffer error typing character '${char}'. This may be a temporary issue - please retry the operation.`); } }