Secure macOS terminal command execution with whitelisting and approval features for safety
The Mac Shell MCP Server enables secure and controlled execution of macOS terminal commands via the Model Context Protocol (MCP). Designed for integration with AI applications like Claude Desktop, Continue, and Cursor, this server provides a seamless way to run shell commands while maintaining security through robust whitelisting and approval mechanisms. By leveraging the standards set by MCP, it ensures that AI workflows remain both flexible and secure.
The Mac Shell MCP Server offers a range of advanced features designed to enhance the security and utility of the Model Context Protocol:
ls
, pwd
, and echo
.ls
, pwd
, echo
, cat
, grep
, find
, etc. These are commonly used commands that don't pose a significant security risk.mv
, cp
, mkdir
, touch
, and chmod
. These commands allow for more powerful actions, but they require explicit approval to prevent misuse.sudo
are explicitly blocked. These commands pose significant security risks if misused.The Mac Shell MCP Server is built on the Model Context Protocol (MCP), providing a robust framework for secure command execution and management:
graph TD
A[AI Application] -->|MCP Client| B[MCP Protocol]
B --> C[MCP Server]
C --> D[Data Source/Tool]
style A fill:#e1f5fe
style C fill:#f3e5f5
style D fill:#e8f5e8
graph LR
subgraph AI Environment
aiApp1[AI Application 1]
mcpClient[Model Context Protocol Client]
end
subgraph MCP Ecosystem
mcpServer[MCP Server] --> tools[Tools & Data Sources]
end
subgraph Security Layers
acl[AUTHENTICATION Layer]
wlist[WHITELIST Management]
end
aiApp1 -> mcpClient
mcpClient -> acl
acl -> mcpServer
mcpServer -> tools
acl -> wlist
To get started, follow these steps for a seamless integration of the Mac Shell MCP Server into your environment:
Clone the Repository:
git clone https://github.com/cfdude/mac-shell-mcp.git
cd mac-shell-mcp
Install Necessary Dependencies:
npm install
Build the Project:
npm run build
Start the Server:
node build/index.js
npm start
The Mac Shell MCP Server is particularly useful for AI developers looking to integrate macOS terminal commands in a secure and controlled manner. Here are two realistic use cases:
cat
and grep
commands for reading log files, while other potentially risky operations like file deletion are restricted.cat /var/log/syslog
, grep error
) are executed with approval mechanisms in place.execute_command
tool to run test scripts using commands like python3 path/to/test_script.py
.add_to_whitelist
) and removed as needed during development.The Mac Shell MCP Server is compatible with several MCP clients, including:
MCP Client | Resources | Tools | Prompts | Status |
---|---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ | Full Support |
Continue | ✅ | ✅ | ✅ | Full Support |
Cursor | ❌ | ✅ | ❌ | Tools Only |
For detailed configuration, add the server to your MCP settings:
"mac-shell": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-macshell"],
"env": {
"API_KEY": "your-api-key"
}
}
{
"mcpServers": {
"macshell": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-macshell"],
"env": {
"API_KEY": "your-api-key"
},
"tools": [
{ "name": "macshell-cli" }
]
}
}
}
Advanced users can fine-tune their setup with additional configurations:
API_KEY
: Required for secure API access.LOG_LEVEL
: Configurable logging level (e.g., debug, info).export API_KEY=your-secret-api-key
node build/index.js
Q: Can I use the Mac Shell MCP Server with Continue?
Q: What happens if a command is not on the whitelist?
add_to_whitelist
tool.Q: How do I update the security level of an existing command in the whitelist?
update_security_level
tool to adjust permissions as necessary.Q: Is there any way to troubleshoot network issues with MCP servers?
traceroute
or ping
to diagnose connectivity problems.Q: Can I integrate additional tools beyond the shell commands provided by default?
Contributors are encouraged to:
For more information on the Model Context Protocol and related projects, visit:
Join the community by participating in forums or contributing to open-source projects.
By integrating the Mac Shell MCP Server with your AI applications, you can ensure secure and efficient execution of macOS commands while maintaining control over critical operations. This setup not only secures your environment but also enhances the capabilities and flexibility of your AI workflows.
RuinedFooocus is a local AI image generator and chatbot image server for seamless creative control
Simplify MySQL queries with Java-based MysqlMcpServer for easy standard input-output communication
Learn to set up MCP Airflow Database server for efficient database interactions and querying airflow data
Build stunning one-page websites track engagement create QR codes monetize content easily with Acalytica
Explore CoRT MCP server for advanced self-arguing AI with multi-LLM inference and enhanced evaluation methods
Access NASA APIs for space data, images, asteroids, weather, and exoplanets via MCP integration