Home / MCP / Shell Command MCP Server
Executes restricted shell commands via MCP with a configurable allowed list.
Configuration
View docs{
"mcpServers": {
"shell_command": {
"command": "npx",
"args": [
"-y",
"shell-command-mcp"
],
"env": {
"ALLOWED_COMMANDS": "cat,ls,echo"
}
}
}
}This MCP server lets you execute shell commands from an MCP client, enabling controlled automation and scripting through a safe, centralized interface. It is useful when you want to run lightweight shell actions from a chatbot or automation flow without exposing a full shell to end users.
You can start the shell command MCP server locally and then connect to it from your MCP client to run permitted shell commands. Before you begin, configure which commands are allowed to be executed. Use the client to send a request that asks the server to run a command like listing a directory or printing a message, and the server will execute it if it’s in the allowed list.
Prerequisites: you need Node.js installed on your machine. You also need npm or npx to run the MCP server.
Start the server manually with the standard inline command.
npx -y shell-command-mcpThe server accepts an explicit configuration that controls which shell commands are allowed to run. You can specify a list of allowed commands as a comma-separated string in the environment variable ALLOWED_COMMANDS.
{
"mcpServers": {
"shell-command": {
"command": "npx",
"args": ["-y", "shell-command-mcp"],
"env": {
"ALLOWED_COMMANDS": "cat,ls,echo"
}
}
}
}Only enable the commands you truly need. The ALLOWED_COMMANDS environment variable controls what the server is permitted to run. Use a minimal set like cat, ls, and echo for safer operation, and avoid using * to allow all commands unless you fully understand the risks.