Advanced MCP Bash Server
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Advanced MCP Bash Server
A production-grade Model Context Protocol (MCP) server that provides advanced bash execution capabilities for AI assistants.
Built for developers who need powerful, isolated bash environments with multi-session management, background process control, and comprehensive error handling.
š Quick Start
One-Line Installation
curl -fsSL https://raw.githubusercontent.com/stat-guy/bash/main/install.sh | bashThis will:
ā Check prerequisites (Node.js 14+, Python 3.10+, git)
ā Clone the repository
ā Install all dependencies
ā Verify the installation
ā Optionally configure Claude Desktop
Manual Installation
# Clone the repository
git clone https://github.com/stat-guy/bash.git
cd bash
# Install dependencies
npm install
pip3 install -e . # Recommended: installs package in development mode
# OR
pip3 install mcp pydantic # Alternative: install dependencies manually
# Verify installation
./verify.shRelated MCP server: E2B MCP Server
š Table of Contents
š” Why This Server?
Beyond Basic Bash Execution
While Claude and other AI assistants have built-in bash capabilities, this MCP server provides enterprise-grade features for complex development workflows:
Feature | Built-in Bash | This MCP Server |
Session Management | Single session | Multiple isolated sessions |
Background Jobs | Limited | Full background process support |
Process Control | Basic timeout | Advanced timeout & monitoring |
Session Analytics | None | Creation time, usage stats, job tracking |
File Operations | None | Upload/download with encoding |
Error Handling | Basic | Comprehensive with detailed output |
Multi-Project | Limited | Full isolation between projects |
Perfect For
Complex development workflows: Multiple projects, different environments
Long-running processes: Builds, tests, servers running in background
Session isolation: Separate environments for different tasks
Production deployments: Reliable process management and error handling
AI agent development: Full MCP protocol support
š§ Installation
Prerequisites
Installation Methods
Option 1: Quick Install (Recommended)
curl -fsSL https://raw.githubusercontent.com/stat-guy/bash/main/install.sh | bashOption 2: Development Install
git clone https://github.com/stat-guy/bash.git
cd bash
npm install
pip3 install -e . # Installs in editable mode for developmentOption 3: Standard Install
git clone https://github.com/stat-guy/bash.git
cd bash
npm install
pip3 install mcp pydanticVerify Installation
Run the verification script to ensure everything is set up correctly:
./verify.shThis checks:
ā Required binaries (git, node, python3, npm, pip3)
ā Project files
ā Dependencies installed
ā Server can start
ā Configuration (if applicable)
ā File permissions
āļø Configuration
Claude Desktop
macOS/Linux: Edit ~/.config/claude_desktop_config.json
Add the following configuration:
{
"mcpServers": {
"bash": {
"command": "node",
"args": ["/absolute/path/to/bash/mcp-bash-wrapper.js"]
}
}
}Getting the absolute path:
cd bash
echo "$(pwd)/mcp-bash-wrapper.js"Then copy the output into your config file.
After configuration:
Save the config file
Completely quit and restart Claude Desktop
The bash server tools will now be available
Claude Code
cd bash
claude mcp add bash node "$(pwd)/mcp-bash-wrapper.js"Other MCP Clients
Point your MCP client to run:
node /absolute/path/to/bash/mcp-bash-wrapper.jsš Usage
Basic Command Execution
# Simple commands
execute_command("ls -la")
execute_command("pwd")
# Commands persist state
execute_command("cd /tmp && export VAR=value")
execute_command("echo $VAR") # Outputs: valueMulti-Session Management
# Create isolated sessions for different projects
create_session("frontend", "/path/to/frontend")
create_session("backend", "/path/to/backend")
# Execute commands in specific sessions
execute_command("npm install", session_id="frontend")
execute_command("pip install -r requirements.txt", session_id="backend")
# Each session maintains its own state
execute_command("export NODE_ENV=development", session_id="frontend")
execute_command("export FLASK_ENV=development", session_id="backend")
# Clean up when done
kill_session("frontend")
kill_session("backend")Background Execution
# Start long-running processes
execute_command("npm run dev", session_id="frontend", background=True)
execute_command("python manage.py runserver", session_id="backend", background=True)
# Heavy builds with custom timeout
execute_command("docker build -t myapp .", timeout=600, background=True)
# Monitor sessions
list_sessions() # Shows all active sessions and their statusFile Operations
# Upload configuration files
upload_file("config.json", file_content, encoding="text")
# Download build outputs
build_log = download_file("/var/log/build.log", encoding="text")
# Upload and execute scripts
upload_file("deploy.sh", script_content, encoding="text")
execute_command("chmod +x deploy.sh && ./deploy.sh")š Available Tools
Core Execution
execute_command(command, session_id="default", timeout=30, background=False)
Execute bash commands with full shell support.
Parameters:
command(str): The bash command to executesession_id(str): Session identifier (default: "default")timeout(int): Command timeout in seconds (default: 30)background(bool): Run in background (default: False)
Returns:
{
"stdout": "command output",
"stderr": "error output (if any)",
"exit_code": 0,
"completed": true,
"timeout": false,
"session_id": "default"
}Recommended Timeouts:
Simple commands (ls, pwd, etc.): 30s (default)
Package installs (npm, pip): 300s (5 min)
Builds (webpack, docker): 600-900s (10-15 min)
Long processes: Use
background=True
Session Management
create_session(session_id, working_directory=None)
Create a new isolated bash session.
list_sessions()
View all active sessions with detailed analytics:
Session ID
Working directory
Creation time
Last activity
Command count
Background jobs
kill_session(session_id)
Cleanly terminate a session and all its processes.
File Operations
upload_file(file_path, content, encoding="base64", session_id="default", mode="w")
Upload files to the server filesystem.
download_file(file_path, encoding="base64", session_id="default", max_size=10485760)
Download files from the server (default max: 10MB).
Server Info
get_server_info()
Get server version and capabilities.
šÆ Advanced Features
Session Isolation Strategy
Use separate sessions for:
Different projects:
frontend,backend,mobileDifferent environments:
dev,staging,prodLong-running processes:
server,build,testsDifferent contexts: Isolate experimental or risky commands
Error Handling
result = execute_command("risky_command", timeout=60)
if result["timeout"]:
# Handle timeout
kill_session(session_id)
create_session(session_id) # Start fresh
if result["exit_code"] != 0:
# Command failed
print(f"Error: {result['stderr']}")
if not result["completed"]:
# Command didn't complete properly
handle_incomplete_command()Development Workflow Example
# Setup isolated development environment
session = create_session("myproject", "/home/user/projects/myproject")
# Install dependencies
execute_command("npm install", session_id="myproject", timeout=300)
# Run tests
test_result = execute_command(
"npm test -- --coverage",
session_id="myproject",
timeout=600
)
# Start dev server in background
execute_command(
"npm run dev",
session_id="myproject",
background=True
)
# Monitor all sessions
sessions = list_sessions()
# Clean up when done
kill_session("myproject")Production Deployment Example
# Create deployment session
deploy = create_session("deploy", "/var/www/myapp")
# Build application
build = execute_command(
"docker build -t myapp:latest .",
session_id="deploy",
timeout=900
)
if build["exit_code"] == 0:
# Deploy to production
deploy_result = execute_command(
"kubectl apply -f k8s/production/",
session_id="deploy",
timeout=300
)
# Clean up
kill_session("deploy")š Troubleshooting
Installation Issues
Server not starting:
# Check Python dependencies
python3 -c "import mcp, pydantic"
# Check Node.js version
node --version # Should be 14+
# Run verification script
./verify.shImport errors:
# Reinstall dependencies
pip3 install -e .
# OR
pip3 install --force-reinstall mcp pydanticConfiguration Issues
Claude Desktop not finding server:
Verify absolute path in config:
cat ~/.config/claude_desktop_config.jsonEnsure path is absolute (starts with
/)Test server manually:
node /absolute/path/to/mcp-bash-wrapper.jsCompletely quit and restart Claude Desktop (not just close window)
Permission errors:
# Make scripts executable
chmod +x mcp-bash-wrapper.js verify.sh install.shRuntime Issues
Commands timing out:
Increase timeout parameter for long commands
Use
background=Truefor indefinite processesSplit complex operations into smaller steps
Session management:
# List all active sessions
list_sessions()
# Kill unresponsive sessions
kill_session("session_id")
# Create fresh session
create_session("session_id")Memory issues:
Sessions auto-cleanup after 1 hour of inactivity
Manually kill sessions when done:
kill_session()Monitor with:
list_sessions()
Getting Help
Issues: GitHub Issues
Verification: Run
./verify.shfor diagnosticsLogs: Check stderr output when running the server
š„ Development
Project Structure
bash/
āāā src/
ā āāā mcp_bash_server/
ā āāā __init__.py
ā āāā server.py # Main MCP server
ā āāā session_manager.py # Session management
āāā mcp-bash-wrapper.js # Node.js wrapper
āāā install.sh # Installation script
āāā verify.sh # Verification script
āāā package.json # Node.js config
āāā pyproject.toml # Python package config
āāā README.mdRunning Tests
# Run Python import test
npm test
# Full verification
./verify.sh
# Manual server test
node mcp-bash-wrapper.jsDevelopment Install
# Clone for development
git clone https://github.com/stat-guy/bash.git
cd bash
# Install in editable mode
pip3 install -e .
npm install
# Make changes and test
./verify.shContributing
Fork the repository
Create a feature branch:
git checkout -b feature/your-featureMake your changes
Test thoroughly:
./verify.shCommit:
git commit -am 'Add new feature'Push:
git push origin feature/your-featureCreate a Pull Request
š Performance
Execution time: 0.02-0.05s for basic commands
Large output: Tested with 1000+ line outputs
Session isolation: Complete process group separation
Memory: Automatic cleanup of stale sessions
Reliability: Comprehensive timeout and error recovery
š Security
Process isolation: Separate process groups per session
Resource limits: Configurable timeouts and size limits
Clean termination: Proper SIGTERM/SIGKILL handling
Environment isolation: Separate environment variables per session
No privilege escalation: Runs with user permissions
š License
MIT License - see LICENSE file for details.
š Acknowledgments
Built on:
Model Context Protocol (MCP) by Anthropic
Ready to supercharge your AI assistant's bash capabilities?
ā Star this repo | š Report issues | š Read the docs
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogā¦
This server cannot be deployed
Maintenance
Related MCP Connectors
Build Apps and run code in 30 languages ā sandboxed, with persistent sessions for agent loops.
Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.
Linux cloud desktop your AI can use by the hour: run commands, read and write files, see the screen.
Execution platform for AI agents on Firecracker microVMs in the EU. Interactive Linux sandboxes with root, templates for Python, Node.js, Go, Rust and a headless browser, public HTTPS URLs. Background jobs that outlive the connection, batches of up to 1,000 jobs with dependencies, hard cost caps reserved up front, execution receipts with SHA-256, log digests that fit the context. IPv4, dual-stack or IPv6-only with its own public address, allowlists or no network. WASI runtime for small tasks. Idle sandboxes sleep and keep their files. Also REST API, Python SDK and LangChain.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables safe execution of terminal commands across different shells (bash, cmd, PowerShell) with configurable timeouts, working directories, and resource limits for command-line operations through AI assistants.-
- AlicenseAqualityDmaintenanceEnables AI assistants to securely execute Python and JavaScript code in sandboxed environments, with file management and package installation.7MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to create isolated Kubernetes Pod sessions for real-time shell command execution, file management, and Node.js code execution, with automatic TTL-based cleanup.MIT
- AlicenseBqualityCmaintenanceEnables LLMs to execute shell commands with configurable security controls, foreground/background task management, timeouts, and output truncation over local or HTTP transports.4MIT