MCP Shell Server is a tool that enables AI agents to safely execute shell commands using the Model Context Protocol (MCP). It serves as a bridge between AI systems and your computer's command line, allowing controlled execution of shell commands in various environments.
You can install the MCP Shell Server globally using your preferred package manager:
# 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
To use MCP Shell Server with Cursor, add the following to your Cursor configuration file (~/.cursor/config.json
):
{
"mcpServers": {
"shell": {
"command": "npx",
"args": ["-y", "@mkusaka/mcp-shell-server"]
}
}
}
To set up MCP Shell Server with Cline for VS Code:
Open your Cline MCP settings file (location varies by operating system):
~/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 configuration:
{
"mcpServers": {
"shell": {
"command": "npx",
"args": ["-y", "@mkusaka/mcp-shell-server"],
"disabled": false,
"autoApprove": []
}
}
}
For a locally installed package, use:
{
"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 for proper shell tool usage:
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.
You can run the server directly:
node dist/index.js
# or as an executable
./dist/index.js
The server accepts several command line arguments:
-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
This tool 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.{
"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"
}
}
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 hostname, platform, shell, username, CPU count, total memory, free memory, and system uptime.
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "shell" '{"command":"npx","args":["-y","@mkusaka/mcp-shell-server"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"shell": {
"command": "npx",
"args": [
"-y",
"@mkusaka/mcp-shell-server"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"shell": {
"command": "npx",
"args": [
"-y",
"@mkusaka/mcp-shell-server"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect