MCP Shell Server
MCP シェル サーバー
モデル コンテキスト プロトコル (MCP) を実装するシェル コマンドを実行するための安全なサーバー。このサーバーは、stdin 経由の入力をサポートし、承認されたシェル コマンドのリモート実行を可能にします。
特徴
安全なコマンド実行: 許可されたコマンドのみ実行可能
標準入力サポート: stdin経由でコマンドに入力を渡します
包括的な出力: stdout、stderr、終了コード、実行時間を返します
シェル演算子によるセキュリティ: シェル演算子 (;、&&、||、|) の後のコマンドを検証します。
タイムアウト制御: コマンドの最大実行時間を設定します
Related MCP server: Shell MCP Server
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-serverALLOW_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
}安全
サーバーはいくつかのセキュリティ対策を実装しています。
コマンドホワイトリスト: 明示的に許可されたコマンドのみ実行できます
シェル演算子の検証: シェル演算子 (;、&&、||、|) の後のコマンドもホワイトリストに対して検証されます。
シェルインジェクションなし: コマンドはシェル解釈なしで直接実行されます
発達
開発環境のセットアップ
リポジトリをクローンする
git clone https://github.com/yourusername/mcp-shell-server.git
cd mcp-shell-serverテスト要件を含む依存関係をインストールする
pip install -e ".[test]"テストの実行
pytestAPIリファレンス
リクエスト引数
分野 | タイプ | 必須 | 説明 |
指示 | 弦[] | はい | コマンドとその引数を配列要素として |
標準入力 | 弦 | いいえ | コマンドに渡される入力 |
ディレクトリ | 弦 | いいえ | コマンドを実行するための作業ディレクトリ |
タイムアウト | 全体 | いいえ | 最大実行時間(秒) |
応答フィールド
分野 | タイプ | 説明 |
標準出力 | 弦 | コマンドの標準出力 |
標準エラー出力 | 弦 | コマンドエラー出力 |
状態 | 全体 | 終了ステータスコード |
実行時間 | フロート | 実行にかかった時間(秒) |
エラー | 弦 | エラー メッセージ (失敗した場合のみ表示) |
要件
Python 3.11以上
mcp>=1.1.0
ライセンス
MITライセンス - 詳細はLICENSEファイルを参照
Available Tools
1 toolshell_executeC
Execute um comando shell Comandos permitidos:
Inputs: command (required), directory (required), stdin, timeout.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 1 tool
With only one tool, there is no possibility for confusion or overlap between tools. The tool 'shell_execute' has a single, clearly defined purpose of executing shell commands, so disambiguation is perfect.
Since there is only one tool, naming consistency is inherently perfect. The tool name 'shell_execute' follows a clear verb_noun pattern, but with no other tools to compare, it sets no pattern to deviate from.
A single tool is too few for a server named 'MCP Shell Server', which implies broader shell-related functionality. While the tool covers basic command execution, the scope feels thin, lacking tools for tasks like listing files, checking processes, or managing environment variables that are typical in shell operations.
The tool set is severely incomplete for a shell server. It only provides execution, missing essential operations like file manipulation (e.g., read, write, delete), directory navigation, process management, or system information retrieval. This will likely cause agent failures when trying to perform common shell tasks beyond simple command execution.
Related MCP Connectors
Remote MCP server exposing your Node Command fleet (files, shell, processes, browser) to AI hosts.
Enable secure connectivity between Sentry issues and debugging data, and LLM clients, using a Model Context Protocol (MCP) server.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
MCP server for mandates, delegation, policy-gated execution, credential grants, and audit.
Related MCP Servers
- AlicenseAqualityAmaintenanceA 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.1202MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that allows LLMs to execute shell commands and receive their output in a controlled manner.7MIT
- AlicenseBqualityDmaintenanceA secure terminal execution server that enables controlled command execution with security features and resource limits via the Model Context Protocol (MCP).14 npm11MIT
- AlicenseBqualityFmaintenanceA server that uses the Model Context Protocol (MCP) to allow AI agents to safely execute shell commands on a host system.180 npm9MIT