MCP server for executing terminal commands on the host machine with configurable permissions
Project description
Host Terminal MCP
An MCP server that lets AI assistants run terminal commands on your machine with permission controls. Built for Claude Desktop / Co-work and any MCP-compatible client.
How It Works
You (in Co-work) Your Mac
───────────────── ─────────
"run git status"
│
▼
Claude (cloud)
│ MCP tool call:
│ execute_command("git status")
▼
Claude Desktop (local)
│ forwards via stdio pipe
▼
host-terminal-mcp ◄── this project
│ 1. permission check ✅
│ 2. /bin/bash -c "git status"
▼
Terminal output flows back up the chain
Claude Desktop spawns host-terminal-mcp as a child process and communicates over stdin/stdout using the MCP protocol. There is no network server involved — it's a local pipe.
Setup for Co-work
1. Install
uv tool install host-terminal-mcp
Or with pip:
pip install host-terminal-mcp
2. Configure Claude Desktop
Add the MCP server to your Claude Desktop config file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Important: Claude Desktop runs with a minimal PATH (
/usr/local/bin,/usr/bin,/bin,/usr/sbin,/sbin,/opt/homebrew/bin). If you installed withuv tool installorpip install --user, the binary is likely in~/.local/bin/which is not in Claude Desktop's PATH. Use the full absolute path to the binary to avoid "No such file or directory" errors.
Find your binary path:
which host-terminal-mcp
# Example output: /Users/you/.local/bin/host-terminal-mcp
Then use that path in the config:
{
"mcpServers": {
"host-terminal": {
"command": "/Users/you/.local/bin/host-terminal-mcp"
}
}
}
To start in ask mode (recommended — prompts you before running unlisted commands):
{
"mcpServers": {
"host-terminal": {
"command": "/Users/you/.local/bin/host-terminal-mcp",
"args": ["--mode", "ask"]
}
}
}
Tip: If you installed globally to a system path (e.g.
/usr/local/bin/host-terminal-mcp), you can use just"command": "host-terminal-mcp"without the full path.
3. Restart Claude Desktop
Quit and reopen Claude Desktop. It will automatically spawn the host-terminal-mcp process. You can verify it's running:
ps aux | grep host-terminal-mcp
4. Use it
Open a Co-work session in Claude.ai (or use Claude Desktop directly) and ask:
- "List files in my home directory"
- "Show git status in ~/projects/myapp"
- "What's running on port 3000?"
- "Run the tests for this project"
Permission Modes
| Mode | Behavior | Safety |
|---|---|---|
allowlist (default) |
Only pre-approved read-only commands run | Safest |
ask |
Prompts you for approval on unlisted commands | Recommended for power users |
allow_all |
Everything runs except blocked commands | Dangerous |
How ask Mode Works
When Claude tries to run a command not in the allow list, the server uses MCP elicitation to prompt you (the human) directly in the Claude Desktop UI:
┌─────────────────────────────────────────────┐
│ The AI wants to run a command that is not │
│ in the allow list: │
│ │
│ npm install │
│ │
│ Do you approve? │
│ │
│ [✓] Approve this command? │
│ [✓] Add to allowed list permanently? │
│ │
│ [ Cancel ] [ Submit ] │
└─────────────────────────────────────────────┘
- Approve — runs the command for this session
- Add to allowed list permanently — saves the command to your config file so you're never asked again
- Cancel/Decline — command is blocked
This is a real human-in-the-loop: Claude cannot approve commands on its own.
Note: Elicitation requires MCP client support. If your client doesn't support it, unlisted commands are rejected with a message telling you to add them to the config file.
Permission check order: blocked (always wins) > allowed > session-approved > mode decision
Default Allowed Commands
These commands (and their arguments) are allowed out of the box:
File listing & navigation:
ls, ll, la, pwd, tree, find, locate, which, whereis, file
File viewing:
cat, head, tail, less, more, bat, wc
Search:
grep, rg, ag, ack, fzf
Git (read-only):
git status, git log, git diff, git show, git branch, git remote, git tag, git stash list, git rev-parse, git config --get, git config --list, git blame, git shortlog, git describe
System info:
uname, hostname, whoami, id, date, uptime, df, du, free, top -l 1, ps
Network (read-only):
ping -c, curl -I, curl --head, dig, nslookup, host, ifconfig, ip addr, netstat, ss
Package managers (info only):
npm list, npm ls, npm view, npm show, npm outdated, pip list, pip show, pip freeze, brew list, brew info, apt list, dpkg -l
Dev tool versions:
python --version, python3 --version, node --version, npm --version, cargo --version, rustc --version, go version, java --version, javac --version, ruby --version, docker --version
Docker (read-only):
docker ps, docker images, docker logs
Data processing:
jq, yq
Misc:
man, help, type, stat, md5sum, sha256sum, shasum
Always Blocked Commands
These are blocked regardless of permission mode:
| Pattern | Reason |
|---|---|
rm -rf /, rm -rf ~, rm -rf * |
Recursive delete |
mkfs, dd |
Format/overwrite disk |
find ... -exec |
Arbitrary command execution |
:(){ |
Fork bomb |
> /dev/sd* |
Overwrite disk device |
chmod -R 777 /, chown -R |
Dangerous permission changes |
sudo, su, doas |
Privilege escalation |
reboot, shutdown, halt, poweroff |
System control |
kill, killall, pkill |
Process control |
nc -l, nmap |
Network attacks |
*/.ssh/, */.aws/, */.gnupg/ |
Sensitive credential access |
/etc/shadow, /etc/passwd |
System file access |
history -c, shred |
History/credential wiping |
Configuration
Config file: ~/.config/host-terminal-mcp/config.yaml
# Generate a default config file
host-terminal-mcp --init-config
Add custom allowed commands
allowed_commands:
- pattern: "docker compose logs"
description: "Docker Compose service logs"
- pattern: "docker compose ps"
description: "Docker Compose service status"
- pattern: "npm install"
description: "Install npm packages"
# Use regex for flexible matching
- pattern: "^kubectl get "
description: "Kubernetes get resources"
is_regex: true
Other options
permission_mode: allowlist # allowlist | ask | allow_all
timeout_seconds: 300 # Max command execution time
max_output_size: 100000 # Max output chars (truncated beyond this)
shell: /bin/bash # Shell to use
allowed_directories: # Commands restricted to these dirs
- /Users/me
environment_passthrough: # Env vars passed to commands
- PATH
- HOME
- USER
- LANG
- LC_ALL
HTTP Transport
For external services (e.g. a chatbot in Docker) that need to call your machine over the network:
# Install with HTTP extras
uv tool install 'host-terminal-mcp[http]'
# Start
host-terminal-mcp --http --port 8099
# Or in background
nohup host-terminal-mcp --http --port 8099 --mode ask > /tmp/host-terminal-mcp.log 2>&1 &
Endpoints
| Endpoint | Method | Purpose |
|---|---|---|
/health |
GET | Health check |
/execute |
POST | Run a command |
/cd |
POST | Change working directory |
/cwd |
GET | Get current directory |
/permissions |
GET | Get permission config |
Example
curl -X POST http://localhost:8099/execute \
-H "Content-Type: application/json" \
-d '{"command": "docker compose ps", "working_directory": "/path/to/project"}'
Architecture
src/host_terminal_mcp/
├── server.py ← MCP stdio server, tool handlers, elicitation
├── http_server.py ← Alternative HTTP/REST transport (FastAPI)
├── config.py ← Permission rules, allowlist/blocklist, YAML config
└── executor.py ← Runs commands via asyncio subprocess
Tools exposed to the AI:
| Tool | Description |
|---|---|
execute_command |
Run a shell command (main tool) |
change_directory |
Change working directory |
get_current_directory |
Get current working directory |
get_permission_status |
Inspect current permissions |
set_permission_mode |
Change permission mode |
Development
git clone https://github.com/ankitag-in/host-terminal-mcp.git
cd host-terminal-mcp
make install # Install all deps (venv auto-created)
make test # Run tests
make lint # Run linters
make format # Format code
make run # Run stdio server (foreground)
make run MODE=ask # Run in ask mode
make inspect # Test with MCP Inspector
make help # Show all targets
From source with Claude Desktop
{
"mcpServers": {
"host-terminal": {
"command": "uv",
"args": ["run", "--directory", "/path/to/host-terminal-mcp", "host-terminal-mcp"]
}
}
}
License
Apache-2.0
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file host_terminal_mcp-0.2.2.tar.gz.
File metadata
- Download URL: host_terminal_mcp-0.2.2.tar.gz
- Upload date:
- Size: 21.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59df7018e3400b320613ecb417c8bf052a874d02c5439d6fa922651fbbb54e14
|
|
| MD5 |
8676a6125e46bbef108e669c7c9f2857
|
|
| BLAKE2b-256 |
84f4569e80eccd038e5b2b82e2958d59be1d344a0836898504f71ea20e175258
|
File details
Details for the file host_terminal_mcp-0.2.2-py3-none-any.whl.
File metadata
- Download URL: host_terminal_mcp-0.2.2-py3-none-any.whl
- Upload date:
- Size: 21.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d51c997b83fd16c711aec5a3ccdaf5c2ef69ca248e8ac57231eebf1804c9bb6c
|
|
| MD5 |
c20722fcd8da4ec58b6ee1726df9dfc3
|
|
| BLAKE2b-256 |
7a0290809085317fede7cb9493294f2fc32fbbc1dc5c0dee015b3a358504b1e1
|