Skip to main content
Glama
Mac Shell MCP Server

Mac Shell MCP Server

by cfdude

Mac Shell MCP サーバー

ZSHシェルでmacOSターミナルコマンドを実行するためのMCP(Model Context Protocol)サーバー。このサーバーは、ホワイトリストと承認メカニズムを内蔵しており、シェルコマンドを安全に実行できます。

特徴

  • 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 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への公開
  1. 詳細を記載したpackage.jsonを更新します

  2. npm に公開:

    npm publish
Rooコード構成
"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 クライアントによって MCP サーバーが自動的に起動されます。

注記:

  • Roo Codeの場合:セキュリティ上の理由から、 alwaysAllow空の配列[]に設定することを推奨します。これにより、コマンド実行前に承認を求めるプロンプトが表示されます。特定のコマンドをプロンプトなしで許可したい場合は、そのコマンドの名前を配列に追加します。例: "alwaysAllow": ["execute_command", "get_whitelist"] 。

  • Claude Desktopの場合:セキュリティ上の理由から、 alwaysAllowをfalseに設定することをお勧めします。Claude Desktopでは、配列ではなくブール値を使用します。false falseすべてのコマンドに承認が必要であり、 trueはすべてのコマンドがプロンプトなしで許可されることを意味します。

重要: alwaysAllowパラメータは、Mac Shell MCPサーバー自体ではなく、MCPクライアント(Roo CodeまたはClaude Desktop)によって処理されます。クライアントはサーバーにリクエストを送信する前に承認プロセスを処理するため、サーバーはどちらの形式でも正常に動作します。

利用可能なツール

サーバーは次の MCP ツールを公開します。

execute_command

macOS でシェル コマンドを実行します。

{
  "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サーバーを実行しているユーザーの権限で実行されます。

  • 承認を必要とするコマンドは、明示的に承認されるまでキューに保持されます。

  • 禁止されたコマンドは決して実行されない

  • サーバーはシェルインジェクションを防ぐためにexecの代わりにNode.jsのexecFileを使用します。

  • 引数は、指定された場合に許可されたパターンに対して検証されます。

ホワイトリストの拡張

ホワイトリストを拡張するには、 add_to_whitelistツールを使用します。例:

{
  "command": "npm",
  "securityLevel": "requires_approval",
  "description": "Node.js package manager"
}

npmパッケージとして使用する

Brave Search などの他の MCP サーバーと同様に、 npxで Mac Shell 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 に公開する場合:

  1. 詳細を記載したpackage.jsonを更新します

  2. package.json に「bin」フィールドを追加します。

    "bin": {
      "mac-shell-mcp": "./build/index.js"
    }
  3. 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ファイルをご覧ください。

Available Tools

8 tools
add_to_whitelistC

Add a command to the whitelist

Inputs: command (required), securityLevel (required), description.

approve_commandC

Approve a pending command

Inputs: commandId (required).

deny_commandC

Deny a pending command

Inputs: commandId (required), reason.

execute_commandC

Execute a shell command on macOS

Inputs: command (required), args.

get_pending_commandsB

Get the list of commands pending approval

Inputs: no named parameters.

get_whitelistB

Get the list of whitelisted commands

Inputs: no named parameters.

remove_from_whitelistC

Remove a command from the whitelist

Inputs: command (required).

update_security_levelC

Update the security level of a whitelisted command

Inputs: command (required), securityLevel (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 8 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose with no ambiguity. The tools cover separate aspects of command management: whitelist operations (add/remove/get), approval workflow (approve/deny/get_pending), execution (execute_command), and security configuration (update_security_level). There is no overlap in functionality.

    Naming Consistency5/5

    All tools follow a consistent verb_noun pattern with snake_case throughout. The naming is predictable and readable, using clear action verbs like 'add_to', 'remove_from', 'get', 'execute', 'approve', 'deny', and 'update' paired with appropriate nouns.

    Tool Count5/5

    With 8 tools, this server is well-scoped for its macOS shell security management purpose. Each tool earns its place by covering essential operations for command whitelisting, approval workflows, execution, and security configuration without being excessive or insufficient.

    Completeness5/5

    The tool set provides complete coverage for the macOS shell security domain. It includes full CRUD operations for the whitelist (add, remove, get), comprehensive approval workflow management (approve, deny, get_pending), command execution, and security level updates, leaving no obvious gaps for agents to work with.

    Maintenance

    ActivityMaintained
    ResponsivenessLimited data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      F
      maintenance
      A 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.
      9
      372 npm
      265
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      An MCP server that enables secure execution of shell commands across Windows, macOS, and Linux with built-in whitelisting and approval mechanisms for enhanced security.
      9
      114 npm
      23
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      An 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.
      2
      MIT