mcp-bash
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., "@mcp-bash list files in the current directory"
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.
MCP Bash
A simple Model-Context-Protocol (MCP) server for executing bash commands. This project allows you to execute bash commands via an MCP server interface, with all the potential security risks that entails! I couldn't find anything else like this in the public domain at the time of writing, so I wrote my own. It's a boon when getting Claude Desktop to write code (it can run the tests, assess the results and fix the issues is finds in one pass.)
Description
MCP Bash provides a simple way to execute bash commands from client applications. It wraps command execution in a controlled environment and returns both stdout and stderr from the executed commands.
Key features:
Execute arbitrary bash commands
Set and maintain a working directory across command executions
Clean interface through the Model-Context-Protocol (MCP)
Simple to deploy and extend
Related MCP server: shell-mcp
Installation
Prerequisites
Python 3.10 or higher
pip or another package manager
Setup
Clone the repository
git clone https://github.com/yourusername/mcp-bash.git cd mcp-bashCreate and activate a virtual environment
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activateInstall dependencies
pip install -e .
Usage
Starting the server
python -m mcp.cli.server --module serverClaude Desktop Configuration
To use this with Claude Desktop, add this to your configuration (usually /Users//Library/Application Support/Claude/claude_desktop_config.json, or see 'Settings -> Developer' in Claude Desktop UI):
{
"mcpServers": {
"Bash": {
"command": "/Users/<username>/.local/bin/uv",
"args": [
"run",
"--with",
"mcp[cli]",
"mcp",
"run",
"/path/to/server.py"
]
}
}
}Then ask Claude: "List the files in my current directory using the Bash MCP tool"
Using the API
The server exposes two main functions:
set_cwd(path): Set the working directory for bash commandsexecute_bash(cmd): Execute a bash command and return stdout/stderr
Example client code
from mcp.client import MCPClient
async def main():
# Connect to the MCP server
client = MCPClient("http://localhost:8000")
# Set working directory
await client.set_cwd("/path/to/your/directory")
# Execute a command
stdout, stderr = await client.execute_bash("ls -la")
print(f"Command output: {stdout}")
if stderr:
print(f"Error output: {stderr}")
if __name__ == "__main__":
import asyncio
asyncio.run(main())Security Considerations
This server executes bash commands directly, which can be a lethal security risk if not properly restricted. There's nothing stopping the LLM from running dangerous commands like rm -rf /. For personal use, the usefulness may outweigh the risks, but take care when deploying.
Consider:
Running in a container or restricted environment
Adding command validation or allowlists
Limiting filesystem access with appropriate user permissions
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Available Tools
2 toolsexecute_bashA
Run a bash command in the global working directory.
Args:
cmd: The shell command to execute.
Returns:
A tuple (stdout, stderr) from the command execution.
Inputs: cmd (required).
set_cwdA
Set the global working directory for bash commands.
Args:
path: The absolute path to use as the new working directory.
Returns:
A confirmation message.
Inputs: path (required).
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 sets the working directory, the other executes commands. There is no overlap or ambiguity between them.
Both tools follow the same verb_noun pattern: set_cwd and execute_bash. The naming is predictable and consistent.
With only two tools, the set is minimal yet sufficient for its scope. Each tool serves a necessary function without unnecessary bloat.
The core functionality of a bash server is covered: setting the working directory and executing commands. Minor gaps like environment variable management exist but are not critical for basic operations.
Maintenance
Related MCP Connectors
Remote MCP server exposing your Node Command fleet (files, shell, processes, browser) to AI hosts.
Remote MCP access to user-authorized Linux, Windows and Intel Mac devices for AI assistants.
Connect ChatGPT and Claude to your Mac, Windows or Linux with secure MCP remote access.
Secure and manage MCP servers through the Speakeasy AI Control Plane from your agent.
Related MCP Servers
- 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
- AlicenseNot gradedqualityDmaintenanceEnables secure execution of shell commands via MCP with multiple security layers including command whitelisting and directory restrictions.MIT

terminal-toolkit-mcpofficial
AlicenseNot gradedqualityDmaintenanceEnables LLM clients to execute shell commands safely through the MCP protocol, with features like session management, safe mode, and process control.1Apache 2.0- AlicenseNot gradedqualityDmaintenanceEnables running shell commands on the local machine via MCP, using bash.MIT