Skip to main content

shell-mcp

MCP server for shell command execution. Allows LLMs to run shell commands with security controls, background task management, and output handling.

Features

  • Dual transport: stdio (local) and streamable-http (remote)
  • Foreground/background execution: LLM controls execution mode per command
  • Background task management: query status, stop, list -- state is kept in memory with configurable TTL cleanup for completed tasks
  • Security: blacklist/whitelist with recursive parsing (pipes, &&, ||, ;, $(), backticks, bash -c)
  • Non-interactive: stdin=DEVNULL + env vars prevent interactive prompts (git, apt, etc.)
  • Output control: configurable max length, truncation direction, and truncation flag
  • Timeout: per-command timeout, auto-kill on expiry
  • Keepalive: periodic progress notifications for long-running commands over HTTP
  • YAML config: file-based configuration with CLI override support

Installation

Requires Python >= 3.11 and uv.

uv sync

Usage

stdio (local, e.g. Claude Desktop)

uvx tab-shell-mcp

streamable-http (remote)

uvx tab-shell-mcp --transport streamable-http --port 8000

With config file

cp config.yaml.example config.yaml
# Edit config.yaml as needed
uvx tab-shell-mcp --config config.yaml

CLI flags (override config file)

uvx tab-shell-mcp \
  --transport stdio \
  --shell /bin/bash \
  --timeout 60 \
  --max-output-length 100000 \
  --output-truncation-mode tail \
  --completed-task-ttl 3600 \
  --blacklist "rm,mkfs,dd,format" \
  --whitelist ""

Configuration priority: CLI args > YAML config file > defaults.

Claude Desktop integration

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "shell": {
      "command": "uvx",
      "args": ["tab-shell-mcp"],
      "env": {}
    }
  }
}

MCP Tools

execute_shell_command

Execute a shell command in foreground or background.

Parameter Type Default Description
command str required Shell command to execute
background bool false Run in background, return task_id immediately
timeout float | null config default (30s) Timeout in seconds
shell str "" (auto-detect) Shell to use (e.g. /bin/bash)
cwd str | null null Working directory
output_truncation_mode "head" | "tail" | null config default (tail) tail keeps the end of oversized output, head keeps the beginning

Foreground result:

{
  "status": "success",
  "exit_code": 0,
  "stdout": "...",
  "stderr": "",
  "execution_time": 1.23,
  "truncated": false,
  "command": "ls -la"
}

Status values: success, error, timeout, rejected (blocked by blacklist/whitelist).

Background result:

{
  "task_id": "a1b2c3d4e5f6",
  "status": "running",
  "message": "Command started in background"
}

Background task status values reported by get_task_status: running, completed, error, timeout, killed. If a task has a result, then result.status uses foreground-style values such as success, error, or timeout. Completed background task records are retained for completed_task_ttl seconds (default: 3600). Set it to 0 to keep them until the server exits.

get_task_status

Query a background task by ID.

Parameter Type Description
task_id str Task ID from execute_shell_command

stop_background_task

Stop a running background task.

Parameter Type Description
task_id str Task ID to stop

list_background_tasks

List all background tasks (running and completed). No parameters.

Configuration

See config.yaml.example for all options:

Option Default Description
shell "" (auto-detect) Shell executable. Auto-detect: $SHELL -> /bin/sh
default_timeout 30.0 Default command timeout in seconds
max_output_length 50000 Max total chars for stdout + stderr
output_truncation_mode "tail" Default truncation direction for oversized output (tail keeps the end, head keeps the beginning)
keepalive_interval 5.0 Progress ping interval (seconds) for HTTP keepalive
completed_task_ttl 3600.0 Seconds to retain completed background task records in memory (0 disables expiry)
blacklist [] Commands to block
whitelist [] If non-empty, ONLY these commands are allowed
transport "stdio" "stdio" or "streamable-http"
host "127.0.0.1" HTTP transport bind host
port 8000 HTTP transport bind port
non_interactive_env see example Env vars injected to prevent interactive prompts

Security

The command parser extracts all command names from a shell string, including:

  • Piped commands: cat file | grep pattern -> [cat, grep]
  • Chained commands: cmd1 && cmd2 || cmd3; cmd4 -> [cmd1, cmd2, cmd3, cmd4]
  • Subshells: echo $(whoami) -> [echo, whoami]
  • Shell wrappers: bash -c "rm -rf /" -> [bash, rm]

Each extracted command is checked against the whitelist (if set) or blacklist.

Interactive prompts are prevented by:

  • Redirecting stdin from /dev/null
  • Setting GIT_TERMINAL_PROMPT=0
  • Setting CI=true
  • Setting DEBIAN_FRONTEND=noninteractive

Development

# Run tests
uv run pytest -v

# Run specific test module
uv run pytest tests/test_command_parser.py -v

# Run the local server during development
uv run tab-shell-mcp

License

MIT

Metadata

Release files for tab-shell-mcp 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tab-shell-mcp 0.1.2
File Size Uploaded Provenance
tab_shell_mcp-0.1.2.tar.gz 74.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for tab-shell-mcp 0.1.2
File Interpreter ABI Platform
tab_shell_mcp-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 91.5 kB

Release files / tab_shell_mcp-0.1.2.tar.gz

Download URL tab_shell_mcp-0.1.2.tar.gz
Size 74.8 kB
Tags Source
SHA-256 checksum
How to use checksums
cb960f6de6cd4917faa577b1214b0e8b354c25bfb5fd1225b9c8e4955fd33919
BLAKE2b-256 checksum
How to use checksums
8b4f0644fa6c362164261e5db94abb6011058b06720a9e8db29f996977c4d56b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / tab_shell_mcp-0.1.2-py3-none-any.whl

Download URL tab_shell_mcp-0.1.2-py3-none-any.whl
Size 16.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
58590d8729c6565cebac52a4a815ef6eebda651a1fc23be6501cbda822a4fb17
BLAKE2b-256 checksum
How to use checksums
911c2e9d17a3d84e5e8ba5fdbcd5ad208b6860f55d94c52a147782b534881002
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for tab-shell-mcp 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page