Skip to main content
Glama

MCP Shell Server

by mkusaka

MCP シェル サーバー

モデルコンテキストプロトコル(MCP)を使用してシェルコマンドを実行するサーバー。AIエージェントが安全にシェルコマンドを実行できるようにするブリッジとして機能します。

特徴

  • シェルコマンドを実行する(単一行および複数行のサポート)
  • さまざまなシェル (bash、zsh、fish、powershell、cmd など) のサポート
  • 詳細なエラー処理とログ記録
  • MCP Inspector対応

インストール

npmから(ユーザーとして)

# Using npm npm install -g @mkusaka/mcp-shell-server # Using yarn yarn global add @mkusaka/mcp-shell-server # Using pnpm pnpm add -g @mkusaka/mcp-shell-server

ソースから(開発用)

# Clone the repository git clone https://github.com/mkusaka/mcp-shell-server.git cd mcp-shell-server # Install dependencies pnpm install # Build the project pnpm build

MCP構成

カーソルの設定

カーソル構成ファイル ( ~/.cursor/config.json ) に次のコードを追加します。

{ "mcpServers": { "shell": { "command": "npx", "args": ["-y", "@mkusaka/mcp-shell-server"] } } }

クライン統合

Clineは、Claude AIでMCPサーバーを利用できるようにするVS Code拡張機能です。ClineでMCPシェルサーバーを設定するには、以下の手順に従います。

  1. Cline MCP 設定ファイルを開きます。
    • macOS: ~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
    • Windows: %APPDATA%/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
    • Linux: ~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
  2. シェル サーバーの MCP 構成を追加します。
    { "mcpServers": { "shell": { "command": "npx", "args": ["-y", "@mkusaka/mcp-shell-server"], "disabled": false, "autoApprove": [] } } }
    あるいは、ローカルにインストールされたパッケージを使用する場合は、次のようにします。
    { "mcpServers": { "shell": { "command": "node", "args": ["/path/to/mcp-shell-server/dist/index.js"], "disabled": false, "autoApprove": [] } } }

ルール設定

AI アシスタントのルールまたはプロンプトに次の内容を追加します。

You have MCP Shell tools at your disposal. Follow these rules regarding Shell tool usage: 1. ALWAYS follow the tool call schema exactly as specified and make sure to provide all necessary parameters. 2. **NEVER refer to tool names when speaking to me.** For example, instead of saying 'I need to use the shell_exec tool to run this command', just say 'I'll run that command for you'. 3. Only use Shell tools when they are necessary. If my task is general or you already know the answer, just respond without calling tools. 4. When I ask you to execute shell commands, use the appropriate tool to: - Run single-line commands - Run multi-line commands (using heredoc syntax when appropriate) - Execute file operations, git commands, or system utilities - Provide system information when relevant 5. Always be careful with shell commands that might modify the system, and explain what the command will do before executing it. 6. If a shell command produces an error, explain what went wrong in simple terms and suggest ways to fix it.

使用法

直接実行

node dist/index.js # or as an executable ./dist/index.js

開発モード

pnpm dev

MCP Inspectorによるテスト

pnpm inspect

コマンドライン引数

-s, --shell <shell> Specify the path to the shell to use -w, --working-dir <directory> Specify the working directory for command execution -h, --help Display help message -V, --version Display version information

ツールリファレンス

シェル実行

指定されたシェルでコマンドを実行します。

パラメータ:

  • command (文字列、必須): 実行するシェルコマンド
  • workingDir (文字列、オプション): コマンドを実行する作業ディレクトリ。$HOME の下にある必要があります。

リソースリファレンス

サーバーは、リソースとして次のシステム情報を提供します。

ホスト名

システムのホスト名を返します。

URI: hostname://

プラットフォーム

オペレーティング システム プラットフォームを返します。

URI: platform://

シェル

サーバーで使用されているシェル パスを返します。

URI: shell://

ユーザー名

現在のユーザー名を返します。

URI: username://

システム情報

以下の情報を含む包括的なシステム情報を JSON 形式で返します。

  • ホスト名
  • プラットフォーム
  • シェル
  • ユーザー名
  • CPU数
  • 合計メモリ
  • 空きメモリ
  • システム稼働時間

使用例

基本的なコマンド実行
{ "name": "shell_exec", "parameters": { "command": "echo Hello, World!" } }
複数行コマンド(ヒアドキュメント)の実行
{ "name": "shell_exec", "parameters": { "command": "cat << EOF | grep 'example'\nThis is an example text.\nAnother line without the keyword.\nEOF" } }

発達

プロジェクト構造

src/ ├── index.ts # Main entry point └── shell-server/ ├── index.ts # Shell server implementation └── lib/ └── logger.ts # Logging configuration

ログ記録

ログはmcp-shell.logファイルに書き込まれます。

ライセンス

マサチューセッツ工科大学

Install Server
A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

local-only server

The server can only run on the client's local machine because it depends on local resources.

モデル コンテキスト プロトコル (MCP) を使用して AI エージェントがホスト システム上でシェル コマンドを安全に実行できるようにするサーバー。

  1. 特徴
    1. インストール
      1. npmから(ユーザーとして)
      2. ソースから(開発用)
    2. MCP構成
      1. カーソルの設定
      2. クライン統合
      3. ルール設定
    3. 使用法
      1. 直接実行
      2. 開発モード
      3. MCP Inspectorによるテスト
    4. コマンドライン引数
      1. ツールリファレンス
        1. シェル実行
      2. リソースリファレンス
        1. ホスト名
        2. プラットフォーム
        3. シェル
        4. ユーザー名
        5. システム情報
        6. 使用例
      3. 発達
        1. プロジェクト構造
        2. ログ記録
      4. ライセンス

        Related MCP Servers

        • A
          security
          A
          license
          A
          quality
          A secure shell command execution server implementing the Model Context Protocol (MCP). This server allows remote execution of whitelisted shell commands with support for stdin input.
          Last updated -
          1
          74
          Python
          MIT License
          • Apple
        • -
          security
          A
          license
          -
          quality
          A Model Context Protocol (MCP) server that allows AI models to safely access and interact with local file systems, enabling reading file contents, listing directories, and retrieving file metadata.
          Last updated -
          47
          1
          JavaScript
          MIT License
          • Linux
        • -
          security
          A
          license
          -
          quality
          A secure, container-based implementation of the Model Context Protocol (MCP) that provides sandboxed environments for AI systems to safely execute code, run commands, access files, and perform web operations.
          Last updated -
          9
          Python
          Apache 2.0
          • Linux
        • A
          security
          A
          license
          A
          quality
          A server that enables AI assistants to execute terminal commands and retrieve outputs via the Model Context Protocol (MCP).
          Last updated -
          3
          6
          Python
          MIT License
          • Apple
          • Linux

        View all related MCP servers

        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/mkusaka/mcp-shell-server'

        If you have feedback or need assistance with the MCP directory API, please join our Discord server