GEMINI.md•1.84 kB
# Ubuntu VM Control MCP Server - Implementation Details
This document provides details about the implementation of the Ubuntu VM Control MCP server.
## Tools Overview
- **`execute_command(command: str)`**: This tool is a direct interface to the VM's shell. It uses `ssh` to run the provided command. The output of the command is returned.
- **`type_text(text: str)`**: This tool uses `xdotool type` to simulate keyboard input. The text is quoted to handle most special characters.
- **`click(x: str, y: str, button: str)`**: This uses `xdotool mousemove` and `xdotool click` to position the mouse and simulate a click. The default button is `1` (left-click).
- **`get_active_window_title()`**: This uses `xdotool getactivewindow getwindowname` to get the title of the focused window.
- **`take_screenshot()`**: This tool uses `scrot` to take a screenshot, which is then base64 encoded and returned. The screenshot is saved to a temporary file on the VM which is deleted after being read.
## Authentication
Authentication is handled via SSH key-based authentication. The server expects the following environment variables and secrets:
- `UBUNTU_HOST`: The hostname or IP address of the Ubuntu VM.
- `UBUNTU_USER`: The username to connect with.
- `UBUNTU_SSH_KEY`: A Docker secret containing the content of the SSH private key.
## Error Handling
Each tool includes error handling to catch issues like missing parameters, SSH connection problems, and command execution errors on the remote VM. The errors are returned as formatted strings to the user.
## Dependencies on VM
The server assumes that the target Ubuntu VM has the following packages installed:
- `openssh-server`
- `xdotool`
- `scrot`
You can install them on a Debian-based system using:
`sudo apt-get update && sudo apt-get install -y openssh-server xdotool scrot`