Mac Shell MCP Server
Mac Shell MCP 服务器
一个 MCP(模型上下文协议)服务器,用于使用 ZSH shell 执行 macOS 终端命令。该服务器通过内置的白名单和审批机制,提供了一种安全执行 shell 命令的方法。
特征
通过 MCP 执行 macOS 终端命令
具有安全级别的命令白名单:
安全:无需批准即可执行的命令
需要批准:执行前需要明确批准的命令
禁止:明确阻止的命令
预先配置白名单,包含常用安全命令
潜在危险命令的审批工作流程
全面的命令管理工具
Related MCP server: Terminal 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用法
启动服务器
npm start或者直接:
node build/index.js在 Roo Code 和 Claude Desktop 中配置
Roo Code 和 Claude Desktop 的 MCP 服务器配置格式类似。以下是设置 Mac Shell MCP 服务器的方法:
使用本地安装
Roo 代码配置
将以下内容添加到您的 Roo Code MCP 设置配置文件(位于~/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
}Claude桌面配置
将以下内容添加到您的 Claude Desktop 配置文件(位于~/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
}将/path/to/mac-shell-mcp替换为您克隆存储库的实际路径。
使用 NPX(推荐)
为了更方便的设置,不需要保持终端窗口打开,您可以将包发布到 npm 并与 npx 一起使用:
发布到 npm
使用您的详细信息更新 package.json
发布到 npm:
npm publish
Roo 代码配置
"mac-shell": {
"command": "npx",
"args": [
"-y",
"mac-shell-mcp"
],
"alwaysAllow": [],
"disabled": false
}Claude桌面配置
"mac-shell": {
"command": "npx",
"args": [
"-y",
"mac-shell-mcp"
],
"alwaysAllow": false,
"disabled": false
}这种方法允许 MCP 客户端自动启动 MCP 服务器,而无需单独的终端窗口或手动干预。
笔记:
对于 Roo 代码:出于安全考虑,建议将
alwaysAllow设置为空数组[],因为它会在执行任何命令之前提示您批准。如果您想允许特定命令而不提示,可以将这些命令的名称添加到数组中,例如:"alwaysAllow": ["execute_command", "get_whitelist"]。对于 Claude Desktop:出于安全考虑,建议
alwaysAllow设置为falseDesktop 使用布尔值而不是数组,其中false表示所有命令都需要批准,true表示所有命令均允许,无需提示。重要提示:
alwaysAllow参数由 MCP 客户端(Roo Code 或 Claude Desktop)处理,而非由 Mac Shell MCP 服务器本身处理。服务器无论使用哪种格式都能正常工作,因为客户端会在向服务器发送请求之前处理审批流程。
可用工具
该服务器公开以下 MCP 工具:
execute_command
在 macOS 上执行 shell 命令。
{
"command": "ls",
"args": ["-la"]
}get_whitelist
获取白名单命令列表。
{}add_to_whitelist
将命令添加到白名单。
{
"command": "python3",
"securityLevel": "safe",
"description": "Run Python 3 scripts"
}update_security_level
更新白名单命令的安全级别。
{
"command": "python3",
"securityLevel": "requires_approval"
}remove_from_whitelist
从白名单中删除命令。
{
"command": "python3"
}get_pending_commands
获取待批准的命令列表。
{}approve_command
批准待处理的命令。
{
"commandId": "command-uuid-here"
}deny_command
拒绝待处理的命令。
{
"commandId": "command-uuid-here",
"reason": "This command is potentially dangerous"
}默认白名单命令
安全命令(无需批准)
ls列出目录内容pwd打印工作目录echo将文本打印到标准输出cat连接并打印文件grep在文件中搜索模式find在目录层次结构中查找文件cd更改目录head输出文件的第一部分tail输出文件的最后部分wc打印换行符、字数和字节数
需要批准的命令
mv移动(重命名)文件cp复制文件和目录mkdir创建目录touch更改文件时间戳或创建空文件chmod更改文件模式位chown更改文件所有者和组
禁止的命令
rm删除文件或目录sudo以另一个用户身份执行命令
安全注意事项
所有命令均以运行 MCP 服务器的用户权限执行
需要批准的命令将被保留在队列中,直到明确批准
禁止的命令永远不会执行
服务器使用 Node.js 的
execFile而不是exec来防止 shell 注入指定时,根据允许的模式验证参数
扩展白名单
您可以使用add_to_whitelist工具扩展白名单。例如:
{
"command": "npm",
"securityLevel": "requires_approval",
"description": "Node.js package manager"
}用作 npm 包
要将 Mac Shell MCP 服务器与npx一起使用,类似于 Brave Search 等其他 MCP 服务器,您可以将其发布到 npm 或直接从 GitHub 使用它。
使用 npx 配置
将以下内容添加到您的 MCP 设置配置中:
罗奥代码
"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
}这将自动下载并运行服务器,而无需手动克隆和构建过程。
发布到 npm
如果你想将自己的版本发布到 npm:
使用您的详细信息更新 package.json
在 package.json 中添加“bin”字段:
"bin": { "mac-shell-mcp": "./build/index.js" }发布到 npm:
npm publish
然后您可以在 MCP 配置中使用它:
罗奥代码
"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
}执照
此 MCP 服务器采用 MIT 许可证。这意味着您可以自由使用、修改和分发该软件,但须遵守 MIT 许可证的条款和条件。更多详情,请参阅项目仓库中的 LICENSE 文件。
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseBqualityFmaintenanceA Model Context Protocol server that provides secure command-line access to Windows systems, allowing MCP clients like Claude Desktop to safely execute commands in PowerShell, CMD, and Git Bash shells with configurable security controls.9715268MIT
- FlicenseNot gradedqualityDmaintenanceAn MCP server that allows AI assistants like Claude to execute terminal commands on the user's computer and return the output, functioning like a terminal through AI.88
- AlicenseAqualityDmaintenanceAn MCP server that enables secure execution of shell commands across Windows, macOS, and Linux with built-in whitelisting and approval mechanisms for enhanced security.99420MIT
- AlicenseNot gradedqualityDmaintenanceAn enhanced MCP server that grants AI assistants the ability to execute terminal commands on a user's system with improved security controls, designed for use in controlled environments.2MIT
Related MCP Connectors
Hosted MCP server connecting claude.ai, ChatGPT and other AI apps to your own computer
A paid remote MCP for CLI tool MCP, built to return verdicts, receipts, usage logs, and audit-ready
An MCP server for Arcjet - the runtime security platform that ships with your AI code.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/cfdude/mac-shell-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server