A Model Context Protocol (MCP) capability for executing shell commands.
npm install mcp-shell-executeAdd the shell execute capability to your MCP configuration:
{
"capabilities": {
"shell": {
"provider": "mcp-shell-execute"
}
}
}The shell execute capability provides one method:
Executes a shell command and returns its output.
Parameters:
command(string, required): The command to executetimeout(number, optional): Timeout in milliseconds (default: 60000)
Returns:
stdout(string): Standard output from the commandstderr(string): Standard error from the commandexitCode(number): Exit code from the command (0 for success)
Example:
// Request
{
"method": "execute.command",
"params": {
"command": "echo 'Hello, World!'",
"timeout": 5000
}
}
// Response
{
"stdout": "Hello, World!\n",
"stderr": "",
"exitCode": 0
}- Install dependencies:
npm install- Build:
npm run build- Run in development mode:
npm run devThis capability executes shell commands on the host system. Make sure to:
- Validate and sanitize input commands
- Run with appropriate permissions
- Consider using a restricted shell or command whitelist for production use