by GongRzhe
A Model Context Protocol (MCP) server that enables secure terminal command execution, directory navigation, and file system operations through a standardized interface.
Terminal Controller for MCP is a server that allows secure execution of terminal commands, navigation of directories, and file system operations through a standardized Model Context Protocol (MCP) interface. It acts as a bridge between an MCP-compatible client (like Claude Desktop) and your terminal, enabling natural language interaction with your command line.
To use Terminal Controller, you first need to install it. The recommended method is via PyPI using pip install terminal-controller
or uv pip install terminal-controller
. Alternatively, you can install from source by cloning the repository and running python setup_mcp.py
.
After installation, you need to configure your MCP client. For Claude Desktop, you can add a configuration entry in claude_desktop_config.json
to either use uvx
or directly execute the Python module. Once configured, you can interact with your terminal using natural language commands through your MCP client, such as "Run the command ls -la
" or "Navigate to my Documents folder."
execute_command
, get_command_history
, change_directory
, list_directory
, write_file
, read_file
, insert_file_content
, delete_file_content
, and update_file_content
for programmatic interaction.Terminal Controller is ideal for:
Q: What are the prerequisites for Terminal Controller? A: You need Python 3.11+ and an MCP-compatible client like Claude Desktop. UV/UVX is optional but recommended for installation.
Q: What security measures are in place?
A: The project includes timeout controls, blacklisting of dangerous commands (e.g., rm -rf /
), proper error handling, and isolation of command execution.
Q: Are there any limitations? A: Commands must complete within the timeout period to return results. The server has the same file system permissions as the user running it, and some interactive commands may not work as expected due to the non-interactive nature of the interface.
Q: How can I troubleshoot issues? A: Check your Python version (3.11+), verify your Claude Desktop configuration, try running the terminal controller directly, or review your MCP client's logs for connection errors.
A Model Context Protocol (MCP) server that enables secure terminal command execution, directory navigation, and file system operations through a standardized interface.
To install Terminal Controller for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @GongRzhe/terminal-controller-mcp --client claude
Install the package directly from PyPI:
pip install terminal-controller
Or if you prefer to use UV:
uv pip install terminal-controller
If you prefer to install from source:
Clone this repository:
git clone https://github.com/GongRzhe/terminal-controller-mcp.git
cd terminal-controller-mcp
Run the setup script:
python setup_mcp.py
There are two ways to configure Claude Desktop to use Terminal Controller:
Add this to your Claude Desktop configuration file:
"terminal-controller": {
"command": "uvx",
"args": ["terminal_controller"]
}
"terminal-controller": {
"command": "python",
"args": ["-m", "terminal_controller"]
}
The configuration path varies by operating system:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
For Cursor, use similar configuration settings as Claude Desktop.
For other clients, refer to their documentation on how to configure external MCP servers.
Once configured, you can use natural language to interact with your terminal through your MCP client:
ls -la
in the current directory"Terminal Controller exposes the following MCP tools:
execute_command
Execute a terminal command and return its results.
Parameters:
command
: The command line command to executetimeout
: Command timeout in seconds (default: 30)Returns:
get_command_history
Get recent command execution history.
Parameters:
count
: Number of recent commands to return (default: 10)Returns:
get_current_directory
Get the current working directory.
Returns:
change_directory
Change the current working directory.
Parameters:
path
: Directory path to switch toReturns:
list_directory
List files and subdirectories in the specified directory.
Parameters:
path
: Directory path to list contents (default: current directory)Returns:
write_file
Write content to a file with overwrite or append options.
Parameters:
path
: Path to the filecontent
: Content to writemode
: Write mode ('overwrite' or 'append', default: 'overwrite')Returns:
read_file
Read content from a file with optional row selection.
Parameters:
path
: Path to the filestart_row
: Starting row to read from (0-based, optional)end_row
: Ending row to read to (0-based, inclusive, optional)Returns:
insert_file_content
Insert content at specific row(s) in a file.
Parameters:
path
: Path to the filecontent
: Content to insertrow
: Row number to insert at (0-based, optional)rows
: List of row numbers to insert at (0-based, optional)Returns:
delete_file_content
Delete content at specific row(s) from a file.
Parameters:
path
: Path to the filerow
: Row number to delete (0-based, optional)rows
: List of row numbers to delete (0-based, optional)Returns:
update_file_content
Update content at specific row(s) in a file.
Parameters:
path
: Path to the filecontent
: New content to place at the specified row(s)row
: Row number to update (0-based, optional)rows
: List of row numbers to update (0-based, optional)Returns:
Terminal Controller implements several security measures:
If you encounter issues:
python -m terminal_controller
uvx terminal_controller
Contributions are welcome! Please feel free to submit a Pull Request.
MIT
Please log in to share your review and rating for this MCP.