Shell Command Executor
STDIOA server that allows AI agents to safely execute shell commands.
A server that allows AI agents to safely execute shell commands.
A server that uses the Model Context Protocol (MCP) to execute shell commands. It functions as a bridge that allows AI agents to safely execute shell commands.
# Using npm npm install -g @mkusaka/mcp-shell-server # Using yarn yarn global add @mkusaka/mcp-shell-server # Using pnpm pnpm add -g @mkusaka/mcp-shell-server
# Clone the repository git clone https://github.com/mkusaka/mcp-shell-server.git cd mcp-shell-server # Install dependencies pnpm install # Build the project pnpm build
Add the following to your Cursor configuration file (~/.cursor/config.json
):
{ "mcpServers": { "shell": { "command": "npx", "args": ["-y", "@mkusaka/mcp-shell-server"] } } }
Cline is a VS Code extension that allows you to use MCP servers with Claude AI. To set up this MCP shell server with Cline:
Open your Cline MCP settings file:
~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
%APPDATA%/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
Add the shell server MCP configuration:
{ "mcpServers": { "shell": { "command": "npx", "args": ["-y", "@mkusaka/mcp-shell-server"], "disabled": false, "autoApprove": [] } } }
Alternatively, if you want to use a locally installed package:
{ "mcpServers": { "shell": { "command": "node", "args": ["/path/to/mcp-shell-server/dist/index.js"], "disabled": false, "autoApprove": [] } } }
Add the following to your AI assistant's rules or prompt:
You have MCP Shell tools at your disposal. Follow these rules regarding Shell tool usage:
1. ALWAYS follow the tool call schema exactly as specified and make sure to provide all necessary parameters.
2. **NEVER refer to tool names when speaking to me.** For example, instead of saying 'I need to use the shell_exec tool to run this command', just say 'I'll run that command for you'.
3. Only use Shell tools when they are necessary. If my task is general or you already know the answer, just respond without calling tools.
4. When I ask you to execute shell commands, use the appropriate tool to:
- Run single-line commands
- Run multi-line commands (using heredoc syntax when appropriate)
- Execute file operations, git commands, or system utilities
- Provide system information when relevant
5. Always be careful with shell commands that might modify the system, and explain what the command will do before executing it.
6. If a shell command produces an error, explain what went wrong in simple terms and suggest ways to fix it.
node dist/index.js # or as an executable ./dist/index.js
pnpm dev
pnpm inspect
-s, --shell <shell> Specify the path to the shell to use
-w, --working-dir <directory> Specify the working directory for command execution
-h, --help Display help message
-V, --version Display version information
Executes commands in the specified shell.
Parameters:
command
(string, required): The shell command to executeworkingDir
(string, optional): The working directory to execute the command in. Must be under $HOME.The server provides the following system information as resources:
Returns the hostname of the system.
URI: hostname://
Returns the operating system platform.
URI: platform://
Returns the shell path being used by the server.
URI: shell://
Returns the current username.
URI: username://
Returns comprehensive system information in JSON format, including:
{ "name": "shell_exec", "parameters": { "command": "echo Hello, World!" } }
{ "name": "shell_exec", "parameters": { "command": "cat << EOF | grep 'example'\nThis is an example text.\nAnother line without the keyword.\nEOF" } }
src/
├── index.ts # Main entry point
└── shell-server/
├── index.ts # Shell server implementation
└── lib/
└── logger.ts # Logging configuration
Logs are written to the mcp-shell.log
file.
MIT