Shell Command Executor MCP server

Provides a secure bridge for executing shell commands on the host system with automatic environment detection, supporting multiple shells across different operating systems.
Back to servers
Setup instructions
Provider
mkusaka
Release date
Mar 21, 2025
Language
TypeScript
Stats
3 stars

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.

Installation

Using Package Managers

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

Configuration

Cursor Configuration

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"]
    }
  }
}

Cline Integration (VS Code)

To set up MCP Shell Server with Cline for VS Code:

  1. Open your Cline MCP settings file (location varies by operating system):

    • macOS: ~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
    • Windows: %APPDATA%/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
    • Linux: ~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
  2. 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": []
    }
  }
}

AI Assistant Rules

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.

Usage

Running the Server

You can run the server directly:

node dist/index.js
# or as an executable
./dist/index.js

Command Line Arguments

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

Tool Reference

shell_exec

This tool executes commands in the specified shell.

Parameters:

  • command (string, required): The shell command to execute
  • workingDir (string, optional): The working directory to execute the command in. Must be under $HOME.

Usage Examples

Basic Command Execution

{
  "name": "shell_exec",
  "parameters": {
    "command": "echo Hello, World!"
  }
}

Multi-line Command (Heredoc) Execution

{
  "name": "shell_exec",
  "parameters": {
    "command": "cat << EOF | grep 'example'\nThis is an example text.\nAnother line without the keyword.\nEOF"
  }
}

Resource Reference

The server provides the following system information as resources:

hostname

Returns the hostname of the system (URI: hostname://).

platform

Returns the operating system platform (URI: platform://).

shell

Returns the shell path being used by the server (URI: shell://).

username

Returns the current username (URI: username://).

system-info

Returns comprehensive system information in JSON format, including hostname, platform, shell, username, CPU count, total memory, free memory, and system uptime.

How to install this MCP server

For Claude Code

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.

For Cursor

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.

Adding an MCP server to Cursor globally

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"
            ]
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.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

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later