Manage GNU Screen from Python with MCP server support.
pip install screen_managerfrom screen_manager import ScreenSessionManager
manager = ScreenSessionManager()
# Create session and send commands
manager.create_session("work")
manager.send_command("work", "python script.py")
output = manager.capture("work")# Create and manage sessions
python -m screen_manager create work
python -m screen_manager send work "echo hello"
python -m screen_manager capture work
# Send multiple commands
python -m screen_manager send-commands work -c "echo 1" -c "echo 2"
# Execute files
python -m screen_manager send-file work script.py
# List and attach
python -m screen_manager list --all
python -m screen_manager attach work
# Smart create/attach
python -m screen_manager create-or-attach work
# Cleanup
python -m screen_manager cleanup work# Run as MCP server
python -m screen_manager serve
# Or from Python
from screen_manager.mcp_server import main
main()Add to your MCP client configuration:
{
"mcpServers": {
"screen-manager": {
"command": "python",
"args": ["-m", "screen_manager.mcp_server"],
"description": "Manage screen sessions, send commands, and capture output"
}
}
}create_session(name)- Create new sessionsend_command(name, cmd)- Send single commandsend_commands(name, cmds)- Send command listsend_command_from_file(name, file)- Execute filecapture(name, lines=-1)- Get outputlist_sessions(all_sessions=False)- List sessionsattach_session(name)- Get attach instructionscreate_or_attach_session(name)- Smart create/attachcleanup_session(name)- Remove session
The MCP server provides 10 tools:
create_sessionsend_commandsend_commandssend_command_from_filecapture_outputlist_sessionslist_all_sessionsattach_sessioncreate_or_attach_sessioncleanup_session
# pip install cipdb # See https://github.com/ywatanabe1989/cipdb
manager.send_commands("debug", [
"export CIPDB_IDS=validate,transform",
"python script_with_cipdb.py"
])- Python 3.8+
screencommand (install withapt install screenorbrew install screen)