bash-mcp is a local stdio MCP server that gives an MCP client unrestricted access to execute local Bash commands with your user account.
Every bash_exec call explicitly sources ~/.profile and ~/.bashrc before running the requested command. The server also exposes list_bash_executables so a client can discover and select from the Bash binaries available on the machine.
This project is intentionally unsandboxed. If you attach it to an LLM client, that client can run arbitrary local commands as you.
- Runs as a stdio MCP server using the official MCP Node SDK
- Enumerates discoverable Bash binaries on macOS and Linux
- Executes commands with optional
cwd,env,timeout_seconds, andbash_executable - Sources
~/.profileand~/.bashrcon every command - Installs into multiple MCP clients with one script
- Codex
- Claude Code
- Claude Desktop
- Cursor
- Augment
- GitHub Copilot CLI
- GitHub Copilot in VS Code
- macOS or Linux
node18+npm
There is no allowlist, approval gate, or runtime sandbox in this server.
If a client can call bash_exec, it can:
- read and modify files your user can access
- start processes
- use networked tools already available on your machine
- inherit environment set by
~/.profileand~/.bashrc
Do not install this into clients or environments you do not trust.
Interactive install:
./install.shInstall into selected clients:
./install.sh --tool codex,claude,claude-desktopInstall everywhere the script detects a supported client:
./install.sh --all-foundDry run:
./install.sh --tool cursor,copilot-cli --dry-runThe installer stages the runtime under:
~/.local/share/bash-mcp/~/.local/bin/bash-mcp-server
codexUsescodex mcp add.claudeUsesclaude mcp add --scope user.claude-desktopWritesclaude_desktop_config.json. On macOS this is~/Library/Application Support/Claude/claude_desktop_config.json.cursorWrites~/.cursor/mcp.json.augmentWrites~/.augment/settings.json.copilot-cliWrites~/.copilot/mcp-config.json.copilot-vscodeWrites the default user MCP config for VS Code.
Claude Desktop requires a full quit and relaunch after config changes.
Arguments: none.
Returns executables, where each entry contains:
pathrealpathversionis_default
Discovery covers Bash binaries visible on PATH plus common system bin directories. Results are deduplicated by resolved realpath, and only executables that identify as Bash are returned.
Arguments:
commandrequiredbash_executableoptionalcwdoptionalenvoptionaltimeout_secondsoptional, default120
Returns:
stdoutstderrexit_codetimed_outduration_msbash_executablebash_realpathcwdloaded_init_filesstdout_truncatedstderr_truncated
For each bash_exec call, the server:
- selects the requested Bash binary, or the first discovered Bash
- starts Bash with
--noprofile --norc - sources
~/.profileif readable - sources
~/.bashrcif readable - applies the provided environment overrides
- changes into
cwdif provided - evaluates the command string
This keeps behavior consistent across clients, even when they launch the MCP server from a GUI process with a minimal environment.
Install dependencies:
npm installRun tests:
npm testSmoke-check the installer:
./install.sh --all-found --dry-runLaunch the server directly:
./bash_mcp.shRemove the client config entries that reference bash-mcp, then remove the staged files:
rm -rf ~/.local/share/bash-mcp
rm -f ~/.local/bin/bash-mcp-server