About Shell Execution MCP Server
Shell Execution MCP Server gives Claude and other MCP-compatible AI assistants persistent shell command execution. It supports background processes, timeouts, and session resets.
Key features
- 01Persistent state across commands
- 02Run commands in background
- 03Configure command timeouts
- 04Reset the shell session
Use cases
- 01Run successive commands in one shell session
- 02Keep long-running commands in the background
- 03Set an execution limit for commands
- 04Clear state and restart a session
MCP support
The MCP server exposes execute-command and reset-shell tools to compatible clients for running shell commands and resetting sessions.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMEShell Execution MCP Server
A Model Context Protocol (MCP) server that provides persistent shell command execution capabilities for Claude and other MCP-compatible AI assistants.
Features
- Persistent Shell Session: Maintains state between commands in the same session
- Background Execution: Run commands in the background with proper process management
- Cross-Platform: Works on macOS, Linux, and Windows with the appropriate shell
- Timeout Control: Configure command execution timeouts to prevent hanging
- Session Reset: Ability to reset the shell session if needed
Installation
# Clone the repository
git clone https://github.com/samihalawa/mcp-server-shell-exec.git
cd mcp-server-shell-exec
# Install dependencies
npm install
# Make the server executable
chmod +x server.js
Usage
Starting the Server
npm start
Configuration
Add the server to your MCP configuration:
macOS/Linux
{
"mcpServers": {
"shell-exec-server": {
"command": "/path/to/node",
"args": [
"/absolute/path/to/mcp-server-shell-exec/server.js"
]
}
}
}
Windows
{
"mcpServers": {
"shell-exec-server": {
"command": "node",
"args": [
"C:\\path\\to\\mcp-server-shell-exec\\server.js"
]
}
}
}
Available Tools
execute-command
Execute a shell command in the persistent shell session.
Parameters:
command(string, required): The shell command to executerunInBackground(boolean, optional): Whether to run the command in the background. Default: falsetimeoutMs(number, optional): Timeout in milliseconds for the command. Default: 30000
Returns:
success(boolean): Whether the command executed successfullyoutput(string): Output from the command execution
reset-shell
Reset the shell session. This will kill the current session and start a new one.
Parameters: None
Returns:
success(boolean): Whether the shell was reset successfullymessage(string): Status message
Example Usage
-
Execute a simple command:
execute-command(command: "ls -la") -
Run a long-running command in the background:
execute-command(command: "sleep 60 && echo 'Done'", runInBackground: true) -
Execute a command with a custom timeout:
execute-command(command: "find / -name '*.js'", timeoutMs: 60000) -
Reset the shell session:
reset-shell()
How It Works
The server uses Node.js to create a shell process that maintains state between commands. This allows for:
- Environment variables to persist between commands
- Working directory to remain consistent
- Background processes to continue running
- Interactive commands that require stdin/stdout
Requirements
- Node.js 14+
- Compatible with Claude Desktop, Cursor, and other MCP-compatible applications
Troubleshooting
If you encounter issues with the MCP server, check the following:
Common Error: Tool Execution Failed
If you see "Tool execution failed" errors, check:
- That the server is running correctly
- That your configuration file uses absolute paths
- That you have restarted your client application after changing the configuration
Testing the Server
You can test the server directly by sending a command:
echo '{"id":"test1","jsonrpc":"2.0","method":"execute-command","params":{"command":"echo \"Hello World\""}}' | node server.js
This should return a properly formatted JSON response with the output.
Configuration Path Issues
Double-check the paths in your configuration:
- Use absolute paths instead of relative paths
- For Windows users, use forward slashes (/) or escaped backslashes (\) in the path
- Verify the server file path is correct
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.