bash-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@bash-mcp Run 'df -h' to check disk space"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Bash MCP Server (bash-mcp)
A Model Context Protocol (MCP) server that provides robust Bash execution capabilities across Windows, macOS, and Linux. Built with Python 3.12+ and managed with uv.
Key Features
Cross-Platform Multi-Runtime Support:
Windows: Automatically detects and supports Git Bash (
C:\Program Files\Git\bin\bash.exe), WSL (Windows Subsystem for Linux), and MSYS2.macOS / Linux: Native POSIX
bash.Custom Override: Override runtime with the
BASH_PATHenvironment variable across all platforms. The target executable is expected to implement Bash semantics and accept standard-c <command>arguments.
Process Lifecycle Management & Containment Model:
Windows (Git Bash / MSYS2): Windows Job assignment is best-effort and occurs immediately after process creation; a short pre-assignment execution window exists. Processes assigned to the dedicated Windows Job Object (
JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE) have termination attempts performed on their entire process tree on timeout, cancellation, or error.WSL (Linux VM): Employs PID-marker-based process-group signaling and clean group termination (
SIGTERM->SIGKILL) to terminate background Linux processes inside the VM on timeout or cancellation. (Note: commands that detach into independent sessions viasetsidor modify supervisor markers require container-level isolation such as Docker/cgroups for full sandbox containment).POSIX (macOS / Linux): Creates isolated process groups (
start_new_session=True) and performs phased shutdown (SIGTERM-> 0.2s grace interval ->SIGKILL).Cancellation-Safe: Shielded cleanup performs bounded reader-drain and process-reap attempts, and closes pipe transports even under repeated task cancellation.
Exact Bash Semantics:
WSL commands are passed directly as raw positional parameters without outer shell interpolation, preserving exact variable scoping, literal single-quotes, and quoted heredocs.
PE Binary Screening:
Checks expected DOS/PE signatures (
MZ,PE\0\0) for Windows binary executables, rejecting plain-text or corrupt files.
Bounded Stream Capture & Truncation Metadata:
Streams are drained concurrently with per-stream byte limits (default 1 MB) to prevent unbounded memory consumption from noisy commands.
Output truncation is clearly indicated in results with byte-accurate counts.
Partial output emitted prior to timeouts is preserved.
Modern Transport Protocols:
stdio(default, recommended for local clients like Antigravity, Claude Desktop, Cursor).streamable-http(recommended modern network transport).sse(legacy network transport).Strict loopback protection: only canonical loopback addresses (
127.0.0.1,localhost,::1) are permitted without explicit--allow-remoteopt-in.
Related MCP server: Bash MCP Server
Exposed Tools
1. execute_bash
Executes a Bash command, pipeline, or multi-line script.
Parameter | Type | Default | Description |
|
| (required) | The Bash command or multi-line script to run. |
|
|
| Working directory. Accepts Windows paths or native POSIX paths (e.g. |
|
|
| Execution timeout in seconds (must be between 1 and 3600). |
|
|
| Execution environment ( |
Tool Annotations:
destructive_hint=Trueopen_world_hint=Trueread_only_hint=False
2. get_bash_environments
Returns diagnostic details about all detected Bash runtimes, executable paths, and the active default environment.
Installation & Setup
Ensure uv is installed.
# Clone or navigate to the repository
cd bash-mcp
# Install dependencies and sync the virtual environment
uv syncRunning the Server
Stdio Transport (Default)
uv run bash-mcpStreamable HTTP Transport (Recommended for Network)
uv run bash-mcp --transport streamable-http --host 127.0.0.1 --port 8000Legacy SSE Transport
uv run bash-mcp --transport sse --host 127.0.0.1 --port 8000Security Note: Binding to non-loopback interfaces requires passing
--allow-remote. Because command execution runs with host user privileges, network deployments should be secured with TLS, authentication proxies, or container isolation.
Integrating with Antigravity / MCP Clients
Antigravity Global Configuration (~/.gemini/config/mcp_config.json)
{
"mcpServers": {
"bash": {
"command": "uv",
"args": [
"--directory",
"C:\\Users\\User\\stuff\\bash-mcp",
"run",
"bash-mcp"
]
}
}
}Running Tests
Run the test suite with pytest:
uv run pytestAvailable Tools
2 toolsexecute_bashBDestructive
Execute a Bash command or script with robust process lifecycle management. Automatically detects and uses Git Bash or WSL on Windows, and native Bash on POSIX.
Inputs: command (required), cwd, env_type, timeout_seconds. Returns: result
get_bash_environmentsARead-only
Inspect detected Bash runtime environments and paths on the current system.
Inputs: no named parameters. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 2 tools
The two tools have clearly distinct purposes: one executes commands, the other inspects the environment. There is no overlap or ambiguity between them.
Both tool names follow a consistent verb_noun pattern: execute_bash and get_bash_environments. The naming style is uniform and predictable.
Two tools is minimal but appropriate for a narrowly scoped bash execution server. The environment inspection tool supplements the primary execution capability without unnecessary bloat.
The core domain of executing bash commands is fully covered by execute_bash, and environment introspection adds useful context. While more convenience tools could exist, most operations can be accomplished through command execution.
Related MCP Connectors
Connect ChatGPT and Claude to your Mac, Windows or Linux with secure MCP remote access.
I run shell commands on your private cloud environment (bash, sh, zsh)
Remote MCP for 1,500+ APIs. Vault-managed credentials; OAuth or API key. Search, load, and execute.
Build and run AI workflows, agents, data tables and 1000+ API integrations from any MCP client.
Related MCP Servers
- AlicenseAqualityBmaintenanceEnables execution of bash commands with support for timeouts and background jobs, allowing file operations, build commands, system inspection, and long-running tasks.362275 npm9MIT
- AlicenseBqualityBmaintenanceAn MCP server that enables the execution of arbitrary bash commands and returns detailed output including stdout, stderr, and exit codes. It supports customizable working directories, execution timeouts, and environment variable configurations.1MIT
- AlicenseAqualityNot gradedmaintenanceEnables execution of bash commands via MCP, allowing clients to run shell commands and set a working directory.237MIT
- AlicenseNot gradedqualityDmaintenanceEnables running shell commands on the local machine via MCP, using bash.MIT