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.
execute_command
- Execute a shell command and return its output
command
(string): Shell command to executecommand
: The executed commandoutput
: Combined stdout and stderr outputreturn_code
: Command execution return codeWhen using uv
, no specific installation is needed. You can use uvx
to directly run mcp-server-shell:
# No installation required when using uvx
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
Add to your Claude settings:
"mcpServers": {
"shell": {
"command": "uvx",
"args": ["mcp-server-shell"]
}
}
"mcpServers": {
"shell": {
"command": "python",
"args": ["-m", "mcp_server_shell"]
}
}
Add to your Zed settings.json:
"context_servers": {
"mcp-server-shell": {
"command": "uvx",
"args": ["mcp-server-shell"]
}
},
"context_servers": {
"mcp-server-shell": {
"command": "python",
"args": ["-m", "mcp_server_shell"]
}
},
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
}
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
You can ask Claude to perform various shell operations, such as:
⚠️ 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.
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.
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": "uvx",
"args": [
"mcp-server-shell"
]
}
}
}
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": "uvx",
"args": [
"mcp-server-shell"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect