The MCP Shell Server is a server that uses the Model Context Protocol (MCP) to execute shell commands. It acts as a bridge, allowing AI agents to safely execute shell commands with support for various shells, detailed error handling, and logging.
# 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
# Clone the repository
git clone https://github.com/mkusaka/mcp-shell-server.git
cd mcp-shell-server
# Install dependencies
pnpm install
# Build the project
pnpm build
Add the following to your Cursor configuration file (~/.cursor/config.json
):
{
"mcpServers": {
"shell": {
"command": "npx",
"args": ["-y", "@mkusaka/mcp-shell-server"]
}
}
}
Add the following to your Cursor rules file:
You have tools at your disposal to solve the coding task. Follow these rules regarding tool calls:
1. ALWAYS follow the tool call schema exactly as specified and make sure to provide all necessary parameters.
2. The conversation may reference tools that are no longer available. NEVER call tools that are not explicitly provided.
3. **NEVER refer to tool names when speaking to the USER.** For example, instead of saying 'I need to use the shell_exec tool to execute your command', just say 'I will execute your command'.
4. Only calls tools when they are necessary. If the USER's task is general or you already know the answer, just respond without calling tools.
5. Before calling each tool, first explain to the USER why you are calling it.
node dist/index.js
# or as an executable
./dist/index.js
pnpm dev
pnpm inspect
-s, --shell <shell> Specify the path to the shell to use
-h, --help Display help message
-V, --version Display version information
Executes commands in the specified shell.
Parameters:
- command
(string, required): The shell command to execute
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
- System uptime
{
"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"
}
}
src/
├── index.ts # Main entry point
└── shell-server/
├── index.ts # Shell server implementation
└── lib/
└── logger.ts # Logging configuration
Logs are written to the mcp-shell.log
file.
MIT