Fire in da houseTop Tip:Paying $100+ per month for Perplexity, MidJourney, Runway, ChatGPT and other tools is crazy - get all your AI tools in one site starting at $15 per month with Galaxy AI Fire in da houseCheck it out free

mcp-server-shell

MCP.Pizza Chef: odysseus0

The mcp-server-shell is an MCP server that provides controlled shell command execution capabilities to language models. It allows LLMs to run arbitrary shell commands and receive their combined stdout and stderr output along with the command's return code. This server facilitates real-time interaction with the underlying system shell, enabling advanced automation, diagnostics, and environment inspection within the MCP ecosystem. Installation is straightforward via pip or using the uv tool for seamless integration. The server exposes a single tool, `execute_command`, which accepts a shell command string and returns detailed execution results, ensuring safe and observable command execution.

Use This MCP server To

Run shell commands from LLMs for automation Retrieve system diagnostics via shell output Execute scripts and commands in real time Integrate shell access into AI workflows Debug environments through command execution

README

Shell MCP Server

A Model Context Protocol server that provides shell command execution capabilities. This server enables LLMs to execute shell commands and receive their output in a controlled manner.

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. We will use uvx to directly run mcp-server-shell.

Using PIP

Alternatively you can install mcp-server-shell via pip:

pip install mcp-server-shell

After installation, you can run it as a script using:

python -m mcp_server_shell

Configuration

Configure for Claude.app

Add to your Claude settings:

Using uvx
"mcpServers": {
  "shell": {
    "command": "uvx",
    "args": ["mcp-server-shell"]
  }
}
Using pip installation
"mcpServers": {
  "shell": {
    "command": "python",
    "args": ["-m", "mcp_server_shell"]
  }
}

Configure for Zed

Add to your Zed settings.json:

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

Example Interactions

Execute a shell command:

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

Response:

{
  "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

Or if you've installed the package in a specific directory or are developing on it:

cd path/to/servers/src/shell
npx @modelcontextprotocol/inspector uv run mcp-server-shell

Examples of Questions for Claude

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

Security Considerations

⚠️ 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.

Contributing

We encourage contributions to help expand and improve mcp-server-shell. Whether you want to add new features, enhance security, or improve documentation, your input is valuable.

For examples of other MCP servers and implementation patterns, see: https://github.com/modelcontextprotocol/servers

Pull requests are welcome! Feel free to contribute new ideas, bug fixes, or enhancements to make mcp-server-shell even more powerful and useful.

License

mcp-server-shell is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.

mcp-server-shell FAQ

How do I install mcp-server-shell?
You can install it via pip using 'pip install mcp-server-shell' or run it directly with uvx without installation.
What command execution details does mcp-server-shell return?
It returns the executed command, combined stdout and stderr output, and the command's return code.
Is it safe to execute arbitrary shell commands with mcp-server-shell?
The server provides controlled execution, but users should ensure commands are safe as it runs with the server's permissions.
Can mcp-server-shell be integrated with different LLM providers?
Yes, it works with any MCP-compatible LLM host, including OpenAI, Anthropic Claude, and Google Gemini.
How do I run mcp-server-shell after installation?
Run it as a script using 'python -m mcp_server_shell' or use uvx for direct execution.
Does mcp-server-shell support asynchronous command execution?
The current implementation executes commands synchronously and returns output once complete.
Can I customize the shell environment for command execution?
Customization depends on the server environment; you can configure the shell context before starting the server.
What happens if a command fails or returns an error?
The output includes both stdout and stderr, and the return code indicates success or failure.