Shell MCP server

Enables secure execution of shell commands on host systems for tasks like system diagnostics, file manipulation, and automation.
Back to servers
Setup instructions
Provider
odysseus0
Release date
Dec 11, 2024
Language
Python
Package
Stats
3.3K downloads
3 stars

The Shell MCP Server provides shell command execution capabilities for Large Language Models (LLMs), allowing them to execute commands and receive their output in a controlled manner. This server implements the Model Context Protocol (MCP) to facilitate seamless interaction between LLMs and your local shell.

Available Tools

  • execute_command - Execute a shell command and return its output
    • Required arguments:
      • command (string): Shell command to execute
    • Returns:
      • Command result containing:
        • command: The executed command
        • output: Combined stdout and stderr output
        • return_code: Command execution return code

Installation

Using uv (recommended)

When using uv, no specific installation is needed. You can use uvx to directly run mcp-server-shell:

# No installation required when using uvx

Using PIP

Alternatively, install mcp-server-shell via pip:

pip install mcp-server-shell

After installation, run it as a script using:

python -m mcp_server_shell

Configuration

Configure for Claude.app

Add to your Claude settings:

For uvx users:

"mcpServers": {
  "shell": {
    "command": "uvx",
    "args": ["mcp-server-shell"]
  }
}

For pip installation:

"mcpServers": {
  "shell": {
    "command": "python",
    "args": ["-m", "mcp_server_shell"]
  }
}

Configure for Zed

Add to your Zed settings.json:

For uvx users:

"context_servers": {
  "mcp-server-shell": {
    "command": "uvx",
    "args": ["mcp-server-shell"]
  }
},

For pip installation:

"context_servers": {
  "mcp-server-shell": {
    "command": "python",
    "args": ["-m", "mcp_server_shell"]
  }
},

Usage Examples

Executing Shell Commands

To execute a shell command, the LLM will call the execute_command tool with the following format:

{
  "name": "execute_command",
  "arguments": {
    "command": "ls -la"
  }
}

The server will respond with:

{
  "command": "ls -la",
  "output": "total 24\ndrwxr-xr-x  5 user  group   160 Jan  1 12:00 .\ndrwxr-xr-x  3 user  group    96 Jan  1 12:00 ..",
  "return_code": 0
}

Debugging

You can use the MCP inspector to debug the server:

# For uvx installations
npx @modelcontextprotocol/inspector uvx mcp-server-shell

# For specific directory or development
cd path/to/servers/src/shell
npx @modelcontextprotocol/inspector uv run mcp-server-shell

Example Questions for Claude

You can ask Claude to perform various shell operations, such as:

  • "What files are in the current directory?"
  • "Show me the contents of the README.md file"
  • "What's the current system date?"
  • "Check if Python is installed and show its version"

Security Warning

⚠️ Warning: This server executes shell commands directly on your system. Use with caution and implement appropriate security measures to prevent unauthorized or dangerous command execution.

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":"uvx","args":["mcp-server-shell"]}'

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": "uvx",
            "args": [
                "mcp-server-shell"
            ]
        }
    }
}

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": "uvx",
            "args": [
                "mcp-server-shell"
            ]
        }
    }
}

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