SafeShell MCP Server
A safety-first shell command executor for the Model Context Protocol. Built in Rust with the rmcp SDK.
Power your agent
การติดตั้งจากผู้เผยแพร่ ไม่ใช่เอนด์พอยต์ของ PlugMCP
URL แบบรีโมตหรือคำสั่งบนเครื่องของคุณ? การติดตั้งสองแบบต่างกันอย่างไร
รันบน PlugMCP
A new server you create. It is not this listing's official endpoint. Use the publisher install when you want their URL and their credentials.
เปิดจากผู้เผยแพร่
A safety-first shell command executor for the Model Context Protocol. Built in Rust with the rmcp SDK.
A safety-first shell command executor MCP server. Supports both stdio and HTTP (SSE/Streamable HTTP) transports, with built-in permission gating, sensitive-location protection, activity logging, and cross-platform support.
SafeShell lets AI assistants run shell commands while enforcing safety guardrails: commands are classified, protected paths are hard-blocked, dangerous operations require human approval, and sensitive environment variables are automatically redacted from output.
/etc, /boot, C:\Windows, etc.)[REDACTED] in output ┌──────────────────────────────────────────────┐
│ MCP Client │
│ (Claude Desktop, Cursor, VS Code, etc.) │
└────────────────┬─────────────────────────────┘
│
stdio or HTTP/SSE
│
┌────────────────▼─────────────────────────────┐
│ SafeShell MCP Server │
│ │
│ Tools: │
│ • execute_command │
│ • get_system_path │
│ • list_safe_commands │
│ • list_protected_paths │
│ │
│ ┌────────────────────────────────────────┐ │
│ │ Safety Pipeline │ │
│ │ │ │
│ │ 1. Parse ─► Tokenize, resolve paths │ │
│ │ │ │ │
│ │ 2. Classify ─► Safe or Dangerous │ │
│ │ │ │ │
│ │ 3. Location Guard ─► Protected paths │ │
│ │ │ (hard block) │ │
│ │ │ │ │
│ │ 4. Permission Gate ─► User approval │ │
│ │ │ (elicitation) │ │
│ │ │ │ │
│ │ 5. Execute ─► Run, sanitize output │ │
│ │ │ │
│ └────────────────────────────────────────┘ │
│ │
│ Platform Layer (macOS / Linux / Windows) │
│ • Safe command allowlists │
│ • Protected path definitions │
└──────────────────────────────────────────────┘
Download from GitHub Releases:
Requires Rust 1.85+ (edition 2024).
cargo install --path .
Or build a release binary (optimized for size):
cargo build --release
# Binary at target/release/safeshell-mcp
safeshell-mcp
The server reads MCP messages from stdin and writes to stdout. This is the standard transport for MCP client integrations.
safeshell-mcp --transport http
By default, listens on 127.0.0.1:3456. Override with --bind:
safeshell-mcp --transport http --bind 0.0.0.0:8080
See MCP Client Integration below for Claude Desktop, Claude Code, Cursor, and VS Code configuration.
SafeShell exposes four MCP tools:
execute_commandRun a shell command through the safety pipeline.
Parameters:
Example:
{
"command": "ls",
"args": ["-la", "/tmp"],
"working_directory": "/home/user",
"timeout_seconds": 60
}
Pipeline: the command passes through five stages before execution:
&&, ||, |, ;), resolve ~ and relative paths to absolute paths> /etc/shadow) against protected directories; canonicalize symlinks before checking; hard-block violationsmax_output_bytes, redact sensitive env var valuesget_system_pathList all directories in the PATH environment variable.
Returns: path_entries (array of directory paths), os, arch.
list_safe_commandsShow all commands pre-approved as safe for the current OS, plus any additional_safe_commands from config.
Returns: commands (array with name and description), additional_safe_commands, os, count.
list_protected_pathsShow all directories protected from command execution on the current OS, plus any additional_protected_paths from config.
Returns: paths (array with path, read_allowed, reason), additional_protected_paths, os, count.
SafeShell implements defense-in-depth with multiple independent layers:
Every command is classified against a built-in allowlist. Commands explicitly listed as safe execute immediately. Everything else — including unknown commands — is classified as dangerous and requires user approval.
Dangerous commands are further divided into two tiers:
These commands are too destructive to ever be auto-approved. Even if added to additional_safe_commands, they are ignored and a warning is logged.
These are dangerous but legitimate developer tools. They can be pre-approved via additional_safe_commands in config or SAFESHELL_SAFE_COMMANDS env var. This is useful when your MCP client does not support elicitation.
When a whitelisted Tier 2 command executes, the tool response includes an annotation:
⚠️ Pre-approved via additional_safe_commands configuration. No interactive approval was requested.
When a non-whitelisted dangerous command is denied because elicitation is unavailable, the denial message includes instructions on how to pre-approve it.
For chained commands (ls | grep foo && rm file), each sub-command is classified independently. If any sub-command is dangerous, the entire chain requires approval. The approval prompt shows per-sub-command classification details.
The location guard checks all resolved path arguments (including redirection targets like > /etc/shadow) against OS-specific protected directories.
read_allowed: true (e.g., cat /etc/hosts is allowed)read_allowedfs::canonicalize() before checking, preventing symlink bypass attacks (e.g., /tmp/link → /etc/shadow)\0 are rejected/proc/self/root traversal (Linux): paths through /proc/self/root or /proc/<pid>/root are blocked to prevent chroot escapesProtected path violations are hard-blocked — they cannot be overridden by user approval.
Dangerous commands that pass the location guard are presented to the user via MCP elicitation. The user sees the full command and the reason it was flagged, and must explicitly approve execution.
If the MCP client does not support elicitation, the command is denied by default.
After execution, stdout and stderr are:
max_output_bytes per stream (default: 100 KB), with a [OUTPUT TRUNCATED] marker[REDACTED]Built-in sensitive patterns match: SECRET, PASSWORD, PASSWD, TOKEN, API_KEY, PRIVATE_KEY, ACCESS_KEY, AUTH, CREDENTIAL, DATABASE_URL, CONNECTION_STRING, SMTP. Values shorter than 4 characters are skipped to avoid false positives. Additional patterns can be added via redact_env_patterns in config.
A semaphore limits simultaneous command executions to max_concurrency (default: 1). Excess requests receive an immediate error rather than queueing.
Signal handlers (SIGINT/SIGTERM on Unix, CTRL_C on Windows) trigger graceful shutdown. All tracked child processes are terminated before the server exits.
SafeShell is configured via a TOML file. All fields are optional — sensible defaults apply.
If no config file is found, all defaults are used.
# Command timeout (seconds)
default_timeout_seconds = 30
# Max output per stream in bytes (stdout/stderr each)
max_output_bytes = 102400
# Max concurrent command executions
max_concurrency = 1
# Additional commands treated as safe (beyond built-in list)
additional_safe_commands = ["make", "just", "nx"]
# Additional regex patterns for env var names to redact
redact_env_patterns = ["(?i)MY_COMPANY_.*"]
# Override shell (auto-detected if unset)
# shell = "/bin/bash"
# HTTP bind address (used with --transport http when --bind is not set)
# http_bind = "127.0.0.1:3456"
# Log level filter (e.g. "debug", "info", "warn", "safeshell_mcp=debug")
# log_level = "info"
# Path to an additional log file (logs always go to stderr too)
# log_file = "/var/log/safeshell.log"
# Additional protected paths
[[additional_protected_paths]]
path = "/data/production"
read_allowed = true
[[additional_protected_paths]]
path = "/secrets"
read_allowed = false
Individual config fields can be overridden via SAFESHELL_* environment variables. These take precedence over config file values.
Precedence: environment variables > config file > defaults.
Invalid numeric values (for SAFESHELL_TIMEOUT, SAFESHELL_MAX_OUTPUT, SAFESHELL_MAX_CONCURRENCY) are logged as warnings and ignored.
Example — configure via environment in an MCP client:
{
"mcpServers": {
"safeshell": {
"command": "/path/to/safeshell-mcp",
"env": {
"SAFESHELL_TIMEOUT": "120",
"SAFESHELL_SAFE_COMMANDS": "make,just,nx",
"SAFESHELL_LOG_LEVEL": "debug"
}
}
}
}
Pre-defined SAFESHELL_SAFE_COMMANDS values for common use cases. These whitelist Tier 2 dangerous commands appropriate for each role — Tier 1 catastrophic commands (sudo, dd, mkfs, shutdown, etc.) are always blocked regardless of configuration.
Developer — build tools, package managers, interpreters:
SAFESHELL_SAFE_COMMANDS="cargo,npm,pip,python3,node,bash,sh,curl,wget,rm,chmod,kill"
# safeshell.toml
additional_safe_commands = ["cargo", "npm", "pip", "python3", "node", "bash", "sh", "curl", "wget", "rm", "chmod", "kill"]
DevOps / SRE — developer commands plus system management:
SAFESHELL_SAFE_COMMANDS="cargo,npm,pip,python3,node,bash,sh,curl,wget,rm,chmod,chown,kill,killall,pkill,systemctl,launchctl,mount,umount,apt,apt-get,brew,rsync,ssh,scp"
# safeshell.toml
additional_safe_commands = [
"cargo", "npm", "pip", "python3", "node", "bash", "sh",
"curl", "wget", "rm", "chmod", "chown",
"kill", "killall", "pkill", "systemctl", "launchctl",
"mount", "umount", "apt", "apt-get", "brew",
"rsync", "ssh", "scp",
]
Restrictive — minimal whitelist for untrusted environments:
SAFESHELL_SAFE_COMMANDS="npm,cargo,pip"
# safeshell.toml
additional_safe_commands = ["npm", "cargo", "pip"]
The built-in redaction patterns cover common sensitive variable names (SECRET, PASSWORD, TOKEN, API_KEY, AUTH, etc.). Add custom patterns via SAFESHELL_REDACT_PATTERNS or redact_env_patterns for your organization's naming conventions.
Common additions:
SAFESHELL_REDACT_PATTERNS="(?i).*KEY.*,(?i).*TOKEN.*,(?i).*AUTH.*,(?i).*CERT.*,(?i).*SIGNING.*"
# safeshell.toml
redact_env_patterns = [
"(?i).*KEY.*", # Matches: AWS_KEY, SIGNING_KEY, MY_API_KEY_V2, etc.
"(?i).*TOKEN.*", # Matches: GITHUB_TOKEN, REFRESH_TOKEN, etc.
"(?i).*AUTH.*", # Matches: OAUTH_SECRET, AUTH_HEADER, etc.
"(?i).*CERT.*", # Matches: TLS_CERT, CLIENT_CERT_PATH, etc.
"(?i).*SIGNING.*", # Matches: SIGNING_SECRET, JWT_SIGNING_KEY, etc.
]
Enterprise / compliance-heavy environments:
SAFESHELL_REDACT_PATTERNS="(?i).*KEY.*,(?i).*TOKEN.*,(?i).*AUTH.*,(?i).*CERT.*,(?i).*SIGNING.*,(?i).*ENCRYPT.*,(?i).*PRIVATE.*,(?i).*WEBHOOK.*,(?i).*DSN.*,(?i).*SENTRY.*"
When shell is not set in config:
Shell flags are auto-detected: -c for POSIX shells and fish, -Command for PowerShell/pwsh, /C for cmd.exe.
Ready-to-copy configuration files for all supported MCP hosts are available in the examples/ directory.
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"safeshell": {
"command": "/path/to/safeshell-mcp"
}
}
}
Add to your project's .mcp.json:
{
"mcpServers": {
"safeshell": {
"command": "/path/to/safeshell-mcp"
}
}
}
Or use HTTP transport:
{
"mcpServers": {
"safeshell": {
"type": "http",
"url": "http://127.0.0.1:3456/mcp"
}
}
}
Add to .cursor/mcp.json in your project:
{
"mcpServers": {
"safeshell": {
"command": "/path/to/safeshell-mcp"
}
}
}
Add to .vscode/mcp.json:
{
"servers": {
"safeshell": {
"command": "/path/to/safeshell-mcp"
}
}
}
Point to a config file via environment variable:
{
"mcpServers": {
"safeshell": {
"command": "/path/to/safeshell-mcp",
"env": {
"SAFESHELL_CONFIG": "/path/to/safeshell.toml"
}
}
}
}
Built-in safe commands vary by OS. Use the list_safe_commands tool to see the full list for your platform.
Common safe commands (all platforms): echo, date, whoami, hostname
Unix (macOS + Linux): cat, ls, head, tail, wc, pwd, uname, which, printenv, df, uptime
Windows: dir, type, where, ver, set, cd
Commands not on the safe allowlist are classified as dangerous by default and require user approval.
MIT
A safety-first shell command executor MCP server. Supports both stdio and HTTP (SSE/Streamable HTTP) transports, with built-in permission gating, sensitive-location protection, activity logging, and c
ภาพรวม
A safety-first shell command executor MCP server. Supports both stdio and HTTP (SSE/Streamable HTTP) transports, with built-in permission gating, sensitive-location protection, activity logging, and cross-platform support.
เครื่องมือ
ยังไม่มีรายการเครื่องมือ เซิร์ฟเวอร์แบบรีโมตจะได้รายการหลังการตรวจสอบสถานะครั้งแรก
FAQ
คัดลอกคอนฟิก stdio สำหรับ Cursor, Claude Desktop, Claude Code หรือ VS Code ได้ในหน้านี้ คอนฟิกนี้ใช้การติดตั้งของผู้เผยแพร่ ไม่ใช่พร็อกซีของ PlugMCP
ระเบียนนี้ไม่ได้ระบุตัวแปรสภาพแวดล้อมที่จำเป็น
MCP Safeshell ทำงานแบบโลคัลผ่าน stdio
ตรวจสอบล่าสุดเมื่อ 2026-11-05 A safety-first shell command executor MCP server. Supports both stdio and HTTP (SSE/Streamable HTTP) transports, with built-in permission gating, sensitive-location protection, activity logging, and cross-platform support.