Skip to main content

MCP server for executing terminal commands on the host machine with configurable permissions

Project description

Host Terminal MCP

PyPI License

Run terminal commands on your computer through Claude.

Two transports:

  • Stdio — for Claude Desktop and MCP Inspector (default)
  • HTTP — for external services calling in over the network (e.g. a chatbot running in Docker)

Quick Start

MCP Server (Claude Desktop / Cowork)

# Install
uv tool install host-terminal-mcp

# Add to Claude Desktop config and restart

Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json on Mac):

{
  "mcpServers": {
    "host-terminal": {
      "command": "host-terminal-mcp"
    }
  }
}

HTTP Server (External Services)

For services running in Docker or on other machines that need to execute host commands via REST API:

# Install with HTTP extras
uv tool install 'host-terminal-mcp[http]'

# Start in background
nohup host-terminal-mcp --http --port 8099 > /tmp/host-terminal-mcp.log 2>&1 &

# With a specific permission mode
nohup host-terminal-mcp --http --port 8099 --mode ask > /tmp/host-terminal-mcp.log 2>&1 &

# Verify
curl http://localhost:8099/health

Services call POST http://localhost:8099/execute with a JSON body.

From Source

git clone https://github.com/ankitag-in/host-terminal-mcp.git
cd host-terminal-mcp
make install

# MCP stdio server (foreground, for Claude Desktop)
make run

# HTTP server (background daemon)
make start                        # port 8099, allowlist mode
make start HTTP_PORT=9000         # custom port
make start MODE=ask               # ask permission mode
make stop                         # stop
make status                       # status + recent logs
make restart                      # stop + start

HTTP 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

# Health check
curl http://localhost:8099/health

# Execute a command
curl -X POST http://localhost:8099/execute \
  -H "Content-Type: application/json" \
  -d '{"command": "docker compose ps", "working_directory": "/path/to/project"}'

# Response
{
  "status": "success",
  "stdout": "NAME    IMAGE    ...",
  "stderr": "",
  "exit_code": 0,
  "return_code": 0,
  "timed_out": false,
  "truncated": false,
  "working_directory": "/path/to/project"
}

Use

Ask Claude:

  • "List files in my home directory"
  • "Show git status"
  • "What's running on port 3000?"

Permission Modes

Mode Description Safety
allowlist Only pre-approved commands run (default) Recommended
ask Prompts for unknown commands, can be approved per-session Use with caution
allow_all Allows everything except blocked commands Dangerous

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, env, printenv, echo $

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 / Recursive delete root
rm -rf ~ Recursive delete home
rm -rf * Recursive delete all
mkfs Format filesystem
dd if= Disk destroyer
:(){ Fork bomb
> /dev/sd Overwrite disk
chmod -R 777 / Dangerous permissions
chown -R Recursive ownership change
sudo, su, doas Privilege escalation
nc -l Netcat listener
nmap Port scanner
cat /etc/shadow Password file
cat /etc/passwd User file
history -c Clear history
shred Secure delete

Config

Config file: ~/.config/host-terminal-mcp/config.yaml

# Generate default config
host-terminal-mcp --init-config

Add custom allowed commands:

allowed_commands:
  # Append your own patterns to the defaults
  - pattern: "docker compose logs"
    description: "Docker Compose service logs"
  - pattern: "docker compose ps"
    description: "Docker Compose service status"
  - pattern: "docker stats --no-stream"
    description: "Docker container resource usage"
  - pattern: "redis-cli"
    description: "Redis CLI commands"

  # Use regex for more flexible matching
  - pattern: "^kubectl get "
    description: "Kubernetes get resources"
    is_regex: true

Other config 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

Development

make install        # Install all deps (venv auto-created)
make test           # Run tests
make lint           # Run linters
make format         # Format code
make help           # Show all targets

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

host_terminal_mcp-0.2.0.tar.gz (20.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

host_terminal_mcp-0.2.0-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

Details for the file host_terminal_mcp-0.2.0.tar.gz.

File metadata

  • Download URL: host_terminal_mcp-0.2.0.tar.gz
  • Upload date:
  • Size: 20.0 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":null}

File hashes

Hashes for host_terminal_mcp-0.2.0.tar.gz
Algorithm Hash digest
SHA256 21cd140ec77a0ead6c9323bb821cc9bdcd080e5b0eda1bcba7329962a531128d
MD5 fb5dca56bf528f1211aaf32b98967b05
BLAKE2b-256 9b1050973673a665c63d520906868d6835b20650d5183181119d7396a4088fef

See more details on using hashes here.

File details

Details for the file host_terminal_mcp-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: host_terminal_mcp-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 20.3 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":null}

File hashes

Hashes for host_terminal_mcp-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e6e40138f0904fdafbec2306613a27608b8ba5a1375bd88f1dbca54b34b31f4a
MD5 81d30aab94dc1b9d6c04b9e79cd2f8dd
BLAKE2b-256 f5ce3c6b37da11ed79411626c38e1f8bfa610661e5c361674515602d7ce41211

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page