Skip to main content
Glama

MCP Shell Server

MCP シェル サーバー

モデル コンテキスト プロトコル (MCP) を実装するシェル コマンドを実行するための安全なサーバー。このサーバーは、stdin 経由の入力をサポートし、承認されたシェル コマンドのリモート実行を可能にします。

特徴

  • 安全なコマンド実行: 許可されたコマンドのみ実行可能
  • 標準入力サポート: stdin経由でコマンドに入力を渡します
  • 包括的な出力: stdout、stderr、終了コード、実行時間を返します
  • シェル演算子によるセキュリティ: シェル演算子 (;、&&、||、|) の後のコマンドを検証します。
  • タイムアウト制御: コマンドの最大実行時間を設定します

Claude.app で MCP クライアントを構成する

公開版

code ~/Library/Application\ Support/Claude/claude_desktop_config.json
{ "mcpServers": { "shell": { "command": "uvx", "args": [ "mcp-shell-server" ], "env": { "ALLOW_COMMANDS": "ls,cat,pwd,grep,wc,touch,find" } }, } }

ローカルバージョン

設定
code ~/Library/Application\ Support/Claude/claude_desktop_config.json
{ "mcpServers": { "shell": { "command": "uv", "args": [ "--directory", ".", "run", "mcp-shell-server" ], "env": { "ALLOW_COMMANDS": "ls,cat,pwd,grep,wc,touch,find" } }, } }
インストール
pip install mcp-shell-server

使用

サーバーの起動

ALLOW_COMMANDS="ls,cat,echo" uvx mcp-shell-server # Ou usando o alias ALLOWED_COMMANDS="ls,cat,echo" uvx mcp-shell-server

ALLOW_COMMANDS環境変数 (またはそのエイリアスALLOWED_COMMANDS ) は、実行できるコマンドを指定します。コマンドはコンマで区切ることができ、その周囲にスペースを入れることもできます。

ALLOW_COMMANDS または ALLOWED_COMMANDS の有効な形式:

ALLOW_COMMANDS="ls,cat,echo" # Formato básico ALLOWED_COMMANDS="ls ,echo, cat" # Com espaços (usando alias) ALLOW_COMMANDS="ls, cat , echo" # Múltiplos espaços

リクエスト形式

# Execução básica de comando { "command": ["ls", "-l", "/tmp"] } # Comando com entrada stdin { "command": ["cat"], "stdin": "Hello, World!" } # Comando com timeout { "command": ["long-running-process"], "timeout": 30 # Tempo máximo de execução em segundos } # Comando com diretório de trabalho e timeout { "command": ["grep", "-r", "pattern"], "directory": "/path/to/search", "timeout": 60 }

応答フォーマット

成功した応答:

{ "stdout": "saída do comando", "stderr": "", "status": 0, "execution_time": 0.123 }

エラー応答:

{ "error": "Comando não permitido: rm", "status": 1, "stdout": "", "stderr": "Comando não permitido: rm", "execution_time": 0 }

安全

サーバーはいくつかのセキュリティ対策を実装しています。

  1. コマンドホワイトリスト: 明示的に許可されたコマンドのみ実行できます
  2. シェル演算子の検証: シェル演算子 (;、&&、||、|) の後のコマンドもホワイトリストに対して検証されます。
  3. シェルインジェクションなし: コマンドはシェル解釈なしで直接実行されます

発達

開発環境のセットアップ

  1. リポジトリをクローンする
git clone https://github.com/yourusername/mcp-shell-server.git cd mcp-shell-server
  1. テスト要件を含む依存関係をインストールする
pip install -e ".[test]"

テストの実行

pytest

APIリファレンス

リクエスト引数

分野タイプ必須説明
指示[]はいコマンドとその引数を配列要素として
標準入力いいえコマンドに渡される入力
ディレクトリいいえコマンドを実行するための作業ディレクトリ
タイムアウト全体いいえ最大実行時間(秒)

応答フィールド

分野タイプ説明
標準出力コマンドの標準出力
標準エラー出力コマンドエラー出力
状態全体終了ステータスコード
実行時間フロート実行にかかった時間(秒)
エラーエラー メッセージ (失敗した場合のみ表示)

要件

  • Python 3.11以上
  • mcp>=1.1.0

ライセンス

MITライセンス - 詳細はLICENSEファイルを参照

-
security - not tested
-
license - not tested
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

モデル コンテキスト プロトコル (MCP) を実装し、stdin サポートによる承認済みシェル コマンドの制御された実行を可能にする安全なサーバー。

  1. 特徴
    1. Claude.app で MCP クライアントを構成する
      1. 公開版
      2. ローカルバージョン
    2. 使用
      1. サーバーの起動
      2. リクエスト形式
      3. 応答フォーマット
    3. 安全
      1. 発達
        1. 開発環境のセットアップ
        2. テストの実行
      2. APIリファレンス
        1. リクエスト引数
        2. 応答フィールド
      3. 要件
        1. ライセンス

          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
          • A
            security
            A
            license
            A
            quality
            A secure terminal execution server that enables controlled command execution with security features and resource limits via the Model Context Protocol (MCP).
            Last updated -
            1
            12
            1
            JavaScript
            MIT License
            • Apple
          • A
            security
            F
            license
            A
            quality
            A Model Context Protocol server implementation that enables secure remote command execution via SSH, with features for managing and using SSH credentials.
            Last updated -
            5
            3
            JavaScript
          • -
            security
            A
            license
            -
            quality
            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.
            Last updated -
            13
            JavaScript
            MIT License
            • Linux
            • Apple

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

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