An MCP server that allows secure execution of macOS terminal commands through Claude or Roo Code with built-in security whitelisting and approval mechanisms.
An MCP (Model Context Protocol) server for executing macOS terminal commands with ZSH shell. This server provides a secure way to execute shell commands with built-in whitelisting and approval mechanisms.
# Clone the repository git clone https://github.com/cfdude/mac-shell-mcp.git cd mac-shell-mcp # Install dependencies npm install # Build the project npm run build
npm start
Or directly:
node build/index.js
Both Roo Code and Claude Desktop use a similar configuration format for MCP servers. Here's how to set up the Mac Shell MCP server:
Add the following to your Roo Code MCP settings configuration file (located at ~/Library/Application Support/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json
):
"mac-shell": { "command": "node", "args": [ "/path/to/mac-shell-mcp/build/index.js" ], "alwaysAllow": [], "disabled": false }
Add the following to your Claude Desktop configuration file (located at ~/Library/Application Support/Claude/claude_desktop_config.json
):
"mac-shell": { "command": "node", "args": [ "/path/to/mac-shell-mcp/build/index.js" ], "alwaysAllow": false, "disabled": false }
Replace /path/to/mac-shell-mcp
with the actual path where you cloned the repository.
For a more convenient setup that doesn't require keeping a terminal window open, you can publish the package to npm and use it with npx:
npm publish
"mac-shell": { "command": "npx", "args": [ "-y", "mac-shell-mcp" ], "alwaysAllow": [], "disabled": false }
"mac-shell": { "command": "npx", "args": [ "-y", "mac-shell-mcp" ], "alwaysAllow": false, "disabled": false }
This approach allows the MCP server to be started automatically by the MCP client without requiring a separate terminal window or manual intervention.
Note:
- For Roo Code: Setting
alwaysAllow
to an empty array[]
is recommended for security reasons, as it will prompt for approval before executing any commands. If you want to allow specific commands without prompting, you can add their names to the array, for example:"alwaysAllow": ["execute_command", "get_whitelist"]
.- For Claude Desktop: Setting
alwaysAllow
tofalse
is recommended for security reasons. Claude Desktop uses a boolean value instead of an array, wherefalse
means all commands require approval andtrue
means all commands are allowed without prompting.Important: The
alwaysAllow
parameter is processed by the MCP client (Roo Code or Claude Desktop), not by the Mac Shell MCP server itself. The server will work correctly with either format, as the client handles the approval process before sending requests to the server.
The server exposes the following MCP tools:
execute_command
Execute a shell command on macOS.
{ "command": "ls", "args": ["-la"] }
get_whitelist
Get the list of whitelisted commands.
{}
add_to_whitelist
Add a command to the whitelist.
{ "command": "python3", "securityLevel": "safe", "description": "Run Python 3 scripts" }
update_security_level
Update the security level of a whitelisted command.
{ "command": "python3", "securityLevel": "requires_approval" }
remove_from_whitelist
Remove a command from the whitelist.
{ "command": "python3" }
get_pending_commands
Get the list of commands pending approval.
{}
approve_command
Approve a pending command.
{ "commandId": "command-uuid-here" }
deny_command
Deny a pending command.
{ "commandId": "command-uuid-here", "reason": "This command is potentially dangerous" }
ls
- List directory contentspwd
- Print working directoryecho
- Print text to standard outputcat
- Concatenate and print filesgrep
- Search for patterns in filesfind
- Find files in a directory hierarchycd
- Change directoryhead
- Output the first part of filestail
- Output the last part of fileswc
- Print newline, word, and byte countsmv
- Move (rename) filescp
- Copy files and directoriesmkdir
- Create directoriestouch
- Change file timestamps or create empty fileschmod
- Change file mode bitschown
- Change file owner and grouprm
- Remove files or directoriessudo
- Execute a command as another userexecFile
instead of exec
to prevent shell injectionYou can extend the whitelist by using the add_to_whitelist
tool. For example:
{ "command": "npm", "securityLevel": "requires_approval", "description": "Node.js package manager" }
To use the Mac Shell MCP server with npx
similar to other MCP servers like Brave Search, you can publish it to npm or use it directly from GitHub.
Add the following to your MCP settings configuration:
"mac-shell": { "command": "npx", "args": [ "-y", "github:cfdude/mac-shell-mcp" ], "alwaysAllow": [], "disabled": false }
"mac-shell": { "command": "npx", "args": [ "-y", "github:cfdude/mac-shell-mcp" ], "alwaysAllow": false, "disabled": false }
This will automatically download and run the server without requiring a manual clone and build process.
If you want to publish your own version to npm:
"bin": { "mac-shell-mcp": "./build/index.js" }
npm publish
Then you can use it in your MCP configuration:
"mac-shell": { "command": "npx", "args": [ "-y", "mac-shell-mcp" ], "alwaysAllow": [], "disabled": false }
"mac-shell": { "command": "npx", "args": [ "-y", "mac-shell-mcp" ], "alwaysAllow": false, "disabled": false }
This MCP server 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.
Discover shared experiences
Shared threads will appear here, showcasing real-world applications and insights from the community. Check back soon for updates!