MLX Assistant is an AI-powered typing assistant that leverages MLX language models to correct text in real-time. Designed to run in the background, it listens for specific hotkeys to fix typos, casing, and punctuation in the selected text or the current line you're typing. This script is optimized for macOS, taking advantage of MLX's performance on Apple devices.
First, ensure you have Python installed on your system. Then, install the required Python packages:
pip install pynput pyperclip httpx mlx-lm
For the script to work correctly on macOS, you need to grant accessibility and input monitoring permissions to the terminal or IDE you are using to run the script. This is necessary for the script to simulate keyboard inputs and listen for hotkeys.
System Preferences > Security & Privacy.Privacy tab.Accessibility on the left pane.+ button and add your Terminal or IDE application.Repeat the above steps for Input Monitoring.
Download the Script
Download mlx-assistant.py to your preferred directory.
mlx-assistant.py.python mlx-assistant.py
With the script running in the background, you can use the following hotkeys in any text editor:
F9: Fixes the current line you're on.
Alt+F10: Fixes the selected text.The script will automatically replace the text with the corrected version provided by the MLX model. Feel free to change to your preferred keys in the script.
You can customize the hotkeys and the MLX model used by editing the mlx-assistant.py script. Look for the MLX_MODEL variable to change the model and the keyboard.GlobalHotKeys configuration to modify hotkeys.
This script is designed for macOS users and has been optimized for performance on Apple devices using the MLX platform. Ensure you have the necessary permissions enabled for your terminal or IDE to allow the script to function correctly.
$ claude mcp add mlx-assistant \
-- python -m otcore.mcp_server <graph>