Andrew Baker | 01 Mar 2026 | andrewbaker.ninja
You want one script that does everything. No digging around in settings. No manually editing JSON. No clicking Developer, Edit Config. Just run it once and Claude Desktop can execute bash commands through an MCP server.
This guide gives you exactly that.
1. Why You Would Want This
Out of the box, Claude Desktop is a chat window. It can write code, explain things, and draft documents, but it cannot actually do anything on your machine. It cannot run a command. It cannot check a log file. It cannot restart a service. You are the middleman, copying and pasting between Claude and your terminal.
MCP (Model Context Protocol) changes that. It lets Claude Desktop call local tools directly. Once you wire up a bash MCP server, Claude stops being a suggestion engine and becomes something closer to a capable assistant that can act on your behalf.
Here are real situations where this matters.
1.1 Debugging Without the Copy Paste Loop
You are troubleshooting a failing deployment. Normally the conversation goes like this: you describe the error, Claude suggests a command, you copy it into terminal, you copy the output back into Claude, Claude suggests the next command, and you repeat this loop fifteen times.
With bash MCP enabled, you say:
Check the last 50 lines of /var/log/app/error.log and tell me what is going wrong
Claude runs the command, reads the output, and gives you a diagnosis. If it needs more context it runs the next command itself. A fifteen step copy paste loop becomes one prompt.
1.2 System Health Checks on Demand
You want to know if your machine is in good shape. Instead of remembering the right incantations for disk usage, memory pressure, and process counts, you ask Claude:
Give me a quick health check on this machine. Disk, memory, CPU, and any processes using more than 1GB of RAM
Claude runs df -h, free -m, uptime, and ps aux --sort=-%mem in sequence, then summarises everything into a single readable report. No tab switching. No forgetting flags.
1.3 File Operations at Scale
You have 200 log files from last month and you need to find which ones contain a specific error code, then extract the timestamps of each occurrence into a CSV. Describing this to Claude without bash access means Claude writes you a script, you save it, chmod it, run it, fix the one thing that did not work, and run it again.
With bash MCP, you say:
Search all .log files in /var/log/myapp/ from February for error code E4012, extract the timestamps, and save them to ~/Desktop/e4012-timestamps.csv
Claude writes the pipeline, executes it, checks the output, and tells you it is done. If something fails it adjusts and retries.
1.4 Git Operations and Code Exploration
You are picking up an unfamiliar codebase. Instead of manually navigating directories, you ask Claude:
Show me the directory structure of this repo, find all Python files that import redis, and tell me how many lines of code are in each one
Claude runs find, grep, and wc itself, then gives you an annotated summary. You can follow up with questions like “show me the largest one” and Claude will cat the file and walk you through it.
1.5 Environment Setup and Configuration
You are setting up a new development environment and need to install dependencies, configure services, and verify everything works. Instead of following a README step by step, you point Claude at it:
Read the SETUP.md in this repo and execute the setup steps for a macOS development environment. Stop and ask me before doing anything destructive.
Claude reads the file, runs each installation command, checks for errors, and reports back. You stay in control of anything risky, but you are not manually typing brew install forty times.
2. What the Script Does
The installation script below handles the full setup in one shot:
- Creates a local MCP launcher script at
~/mcp/run-bash-mcp.shthat runs a bash MCP server vianpx bash-mcp - Locates your Claude Desktop config file automatically (macOS and Windows paths)
- Creates a timestamped backup of the existing config
- Safely merges the required
mcpServersentry usingjqwithout overwriting your other MCP servers - Sets correct file permissions
- Validates the JSON and restores the backup if anything goes wrong
After a restart, Claude Desktop will have a tool called myLocalBashServer available in every conversation.
3. One Command Installation
I dislike wasting time following step by step guides. So just copy this entire block into your Terminal and run it. Done!
cat << 'EOF' > ~/claude-enable-bash-mcp.sh
#!/usr/bin/env bash
set -euo pipefail
SERVER_NAME="myLocalBashServer"
MCP_PACKAGE="bash-mcp"
die() { echo "ERROR: $*" >&2; exit 1; }
have() { command -v "$1" >/dev/null 2>&1; }
timestamp() { date +"%Y%m%d-%H%M%S"; }
echo "Creating MCP launcher..."
mkdir -p "$HOME/mcp"
LAUNCHER="$HOME/mcp/run-bash-mcp.sh"
cat > "$LAUNCHER" <<LAUNCH_EOF
#!/usr/bin/env bash
set -euo pipefail
export PATH="/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:\$PATH"
if ! command -v node >/dev/null 2>&1; then
echo "node is not installed or not on PATH" >&2
exit 1
fi
exec npx ${MCP_PACKAGE}
LAUNCH_EOF
chmod +x "$LAUNCHER"
echo "Locating Claude Desktop config..."
OS="$(uname -s || true)"
CONFIG=""
if [[ "$OS" == "Darwin" ]]; then
C1="$HOME/Library/Application Support/Claude/claude_desktop_config.json"
C2="$HOME/Library/Application Support/Anthropic/Claude/claude_desktop_config.json"
C3="$HOME/Library/Application Support/claude/claude_desktop_config.json"
if [[ -f "$C1" || -d "$(dirname "$C1")" ]]; then CONFIG="$C1"; fi
if [[ -z "$CONFIG" && ( -f "$C2" || -d "$(dirname "$C2")" ) ]]; then CONFIG="$C2"; fi
if [[ -z "$CONFIG" && ( -f "$C3" || -d "$(dirname "$C3")" ) ]]; then CONFIG="$C3"; fi
fi
if [[ -z "$CONFIG" && -n "${APPDATA:-}" ]]; then
W1="${APPDATA}/Claude/claude_desktop_config.json"
if [[ -f "$W1" || -d "$(dirname "$W1")" ]]; then CONFIG="$W1"; fi
fi
[[ -n "$CONFIG" ]] || die "Could not determine Claude Desktop config path. Open Claude Desktop β Settings β Developer β Edit Config once, then rerun this script."
mkdir -p "$(dirname "$CONFIG")"
if ! have jq; then
if [[ "$OS" == "Darwin" ]] && have brew; then
echo "Installing jq..."
brew install jq
else
die "jq is required. Install it and rerun."
fi
fi
if [[ ! -f "$CONFIG" ]]; then
echo '{}' > "$CONFIG"
fi
BACKUP="${CONFIG}.bak.$(timestamp)"
cp -f "$CONFIG" "$BACKUP"
echo "Updating Claude config..."
if ! jq . "$CONFIG" >/dev/null 2>&1; then
cp -f "$BACKUP" "$CONFIG"
die "Config was invalid JSON. Restored backup."
fi
TMP="$(mktemp)"
jq --arg name "$SERVER_NAME" --arg cmd "$LAUNCHER" '
.mcpServers = (.mcpServers // {}) |
.mcpServers[$name] = (
(.mcpServers[$name] // {}) |
.command = $cmd
)
' "$CONFIG" > "$TMP"
mv "$TMP" "$CONFIG"
echo ""
echo "DONE."
echo ""
echo "Launcher created at:"
echo " $LAUNCHER"
echo ""
echo "Claude config updated at:"
echo " $CONFIG"
echo ""
echo "Backup saved at:"
echo " $BACKUP"
echo ""
echo "IMPORTANT: Completely quit Claude Desktop and relaunch it."
echo "Claude only loads MCP servers on startup."
echo ""
echo "Then try:"
echo " Use the MCP tool ${SERVER_NAME} to run: pwd"
echo ""
EOF
chmod +x ~/claude-enable-bash-mcp.sh
~/claude-enable-bash-mcp.sh
4. What Happens Under the Hood
Claude Desktop runs local tools using MCP. The config file contains a key called mcpServers. Each entry defines a command Claude launches when it starts.
The script creates ~/mcp/run-bash-mcp.sh which uses npx bash-mcp to expose shell execution as a tool. The launcher explicitly sets PATH to include common binary locations like /opt/homebrew/bin because GUI launched apps on macOS do not inherit your shell profile. Without this, Node would not be found even if it is installed.
The config update uses jq to merge the new server entry into your existing config rather than replacing the whole file. If you already have other MCP servers configured they will not be touched. If the existing config is invalid JSON, the script restores the backup and exits rather than making things worse.
5. Test It
After restarting Claude Desktop, open a new chat and type:
Use your MCP myLocalBashServer to run: ls -la
If everything worked, Claude will call the MCP tool and return your directory listing. From there you can ask it to do anything your shell can do.
Some good first tests:
Use your MCP to show me disk usage on this machine
Use your MCP to determine what version of Python and Node do I have installed?
Use your MCP to find all files larger than 100MB in my home directory
6. Security Warning
You are giving Claude the ability to execute shell commands with your user permissions. That means file access, deletion, modification, everything your account can do.
Only enable this on a machine you control. Consider creating a dedicated limited permission user if you want stronger isolation. Claude will ask for confirmation before running destructive commands in most cases, but the capability is there.
That is it. One script. Full setup. No clicking through menus.