The Mac Shell MCP server provides a secure interface for executing macOS terminal commands through the Model Context Protocol. It includes security features like command whitelisting and approval workflows to protect your system while allowing Claude or other MCP clients to run shell commands on your behalf.
To install the Mac Shell MCP server:
# 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
Start the server using either of these methods:
npm start
Or directly:
node build/index.js
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:
"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
}
Note: For security reasons, it's recommended to use
alwaysAllow: []
(Roo Code) oralwaysAllow: false
(Claude Desktop) to require approval for commands.
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 userYou can extend the whitelist using the add_to_whitelist
tool:
{
"command": "npm",
"securityLevel": "requires_approval",
"description": "Node.js package manager"
}
execFile
instead of exec
to prevent shell injectionThere 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 > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.