An MCP tool that allows the Gemini CLI to send commands to itself via tmux.
This extension enables the Gemini agent to execute CLI commands "on itself" by injecting them into its own input stream. This is useful for self-correction, navigation, or triggering other CLI features programmatically.
- Immediate Return: The tool acknowledges the request and returns immediately to avoid blocking the agent.
- Delay: It waits for approximately 3 seconds to ensure the previous operation clears.
- Tmux Injection: It uses
tmux send-keysto simulate user input in thegemini-clisession. - Monitoring & Resume: A background worker monitors the terminal output. Once it detects the command has finished (by observing screen stability), it sends a "Resume" signal to the agent, ensuring the agent knows when it can proceed.
Sends a command to the Gemini CLI. It waits for the session to stabilize after the command is sent and then notifies the agent to resume.
Explicitly ends the agent's current turn and prepares the CLI for subsequent input.
Why it exists:
The Gemini agent is not naturally "aware" of background processes or tmux-style key injections. When a command is scheduled (e.g., via the run-long-command extension or similar mechanisms), the agent may need to stop generating and wait for that specific task to complete. yield_turn sends a Ctrl-C followed by two Enter keys to the tmux session, clearing the input line and ensuring the CLI prompt is fresh and ready for the next event. This helps it to avoid loops and polling that might cause it to become "stuck."
- Tmux: You must run the Gemini CLI inside a tmux session named
gemini-cli. - Node.js: Required to run the MCP server.
You can install this extension directly via the Gemini CLI:
gemini extensions install https://github.com/stevenAthompson/self-command- Clone this repository.
- Install dependencies:
npm install
- Build the project:
npm run build
- Start the tmux session using the helper script:
./gemini_tmux.sh
- Inside the session, start Gemini (if not already started).
- Load this MCP server into Gemini.
- Ask Gemini to run a command on itself, e.g., "Run the 'help' command on yourself".
- Test:
npm test - Build:
npm run build
This project is licensed under the MIT License - see the LICENSE file for details.