mcp-bash
Click on "Install 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-bashlist 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.
| Name | Required | Description | Default |
|---|---|---|---|
| cmd | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden of disclosing behavior. It does add value by noting the execution directory and the return format (stdout, stderr), but it omits critical details such as side effects, environment dependencies, error handling, or potential timeouts. For a command-execution tool, more transparency is needed.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is very concise, using a standard docstring format with Args and Returns sections. Every sentence serves a purpose, and there is no fluff. It is appropriately sized for the tool's simplicity.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The description covers the basics: what it runs, where it runs, and the return type. However, given the tool executes arbitrary shell commands in a shared working directory, more context is needed about the relationship with 'set_cwd', potential side effects, and how command failures manifest. The lack of annotations and output schema increases the burden, but the description provides just enough for basic use.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema has no description for 'cmd', so the description's 'The shell command to execute' provides some semantic clarification. However, this is minimal and largely restates the parameter name, adding little beyond what one might infer from 'cmd'. With 0% schema coverage, the description only partially compensates.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool runs a bash command and specifies the scope ('global working directory'), which gives a specific verb and resource. However, it does not explicitly differentiate from the sibling tool 'set_cwd', though the focus on execution vs. setting the directory is implicit.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage (run bash commands in the global working directory) but provides no explicit guidance on when to use this tool versus alternatives like 'set_cwd'. There is no mention of prerequisites, exclusions, or when not to use it, leaving the agent to infer context.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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.
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden. It states that it sets the global working directory and returns a confirmation message, but it does not disclose potential errors, validation behavior, or whether the change is session-wide. This is minimal but adequate for such a simple state-changing tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is concise: a one-sentence purpose, a clear Args section, and a Returns section. Every line serves a purpose with no unnecessary fluff. The structure is front-loaded with the primary action.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple tool with one parameter and no output schema, the description covers the essential aspects: what it does, the parameter requirement (absolute path), and the return type. It is complete for the tool's complexity.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema provides only the parameter name and type (string), with 0% coverage. The description compensates by explicitly stating 'path: The absolute path to use as the new working directory', adding the important constraint that the path must be absolute. This adds meaningful semantic value beyond the schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states 'Set the global working directory for bash commands', which clearly identifies the verb (set), resource (global working directory), and scope (for bash commands). This effectively distinguishes it from the sibling tool execute_bash, which runs commands rather than changing the working directory.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies that this tool should be used to change the working directory for subsequent bash commands, but it does not explicitly state when to use it versus execute_bash or any exclusions. The usage context is clear but not formally articulated.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
TDQS
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
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Run commands and read/write files on your servers over Termalin's keyless tunnels (hosted MCP).
MCP server to assist with JxBrowser development.
Remote MCP gateway for ScriptMasterLabs x402-paid tools and agent-native API access.
Related MCP Servers
- AlicenseAqualityCmaintenanceAn 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.22MIT

terminal-toolkit-mcpofficial
AlicenseNot gradedqualityCmaintenanceEnables 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 gradedqualityBmaintenanceExposes an interactive terminal over MCP, enabling remote shell command execution, file operations, and directory management via ChatGPT or Claude Desktop.2MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/patrickomatik/mcp-bash'
If you have feedback or need assistance with the MCP directory API, please join our Discord server