mcp-shell-sudo
mcp-shell-sudo
Linux 向けの MCP サーバーで、Python で書かれており、argv を使用してローカルコマンドを実行します。PASSWORD_SUDO による非対話型の sudo をサポートし、ALLOW_COMMANDS によるオプションのコマンド許可リストを提供し、Bubblewrap を使用してファイルシステムへの書き込みを WORK_DIR に限定できます。
要件
Linux。
Python 3.11+。
uv推奨。MCP Python SDK 2.0.0。
昇格したコマンドを実行する場合は
sudo。WORK_DIRを設定する場合はbubblewrap。
Debian/Ubuntu の場合:
sudo apt update
sudo apt install -y bubblewrapRelated MCP server: mcp-shell
環境変数
PASSWORD_SUDO
MCP サーバーを実行するユーザーのパスワード。
空または未設定: サーバーはパスワードを発明したり、対話的に要求したりすることはありません。
sudoで始まるコマンドはsudo -nを使用して実行され、有効なキャッシュされた資格情報がすでに存在するか、NOPASSWDルールが設定されている場合にのみ機能します。設定:
sudoは-S付きで実行され、パスワードは stdin を介して提供されます。argv やログには決して含まれません。
例:
"PASSWORD_SUDO": "my-password"サポートされる形式は次のとおりです:
["sudo", "id"]sudo -u postgres ... などのカスタム sudo フラグは受け付けられません。これにより、ポリシーレイヤーが完全な sudo コマンド文法を解釈する必要がなくなります。
WORK_DIR
オプションの作業ディレクトリ。
空または未設定: MCP サーバーは、ツール呼び出しで指定された既存の任意のディレクトリから作業できます。
設定: サーバーは厳格モードに入ります。
directoryはWORK_DIR内に解決される必要があり、すべてのプロセスは Bubblewrap マウント名前空間内で実行され、/は読み取り専用、WORK_DIRは読み書き可能でマウントされ、/tmpと/runは一時的です。
cwd だけを使用しても、この分離を保証するには不十分です。プロセスは /etc や /home/... に書き込んだり、プロジェクト外のシンボリックリンクをたどったりする可能性があります。このため、WORK_DIR が設定されているが bwrap が利用できない場合、サーバーは起動時に失敗します。
このモードでは、sudo は拒否されます。ホストレベルの権限昇格は、ファイルシステムへの書き込みがワークスペース内に限定されるという保証と互換性がないためです。
ALLOW_COMMANDS
カンマ区切りの実行可能ファイル名のリスト。
"ALLOW_COMMANDS": "git,ls,cat,grep,python,node,pnpm"空または未設定: すべての実行可能ファイルが許可されます。
設定: リスト内の正確な実行可能ファイル名のみが許可され、
/usr/bin/gitなどのパスではなく名前で呼び出す必要があります。コマンドが
sudoで始まる場合、sudoに続く実際の実行可能ファイルが検証されます。
許可リストは実行可能ファイルに適用され、引数には適用されません。bash、python、node、env、またはプロセスを実行できる別のツールを許可すると、MCP クライアントが実行できることが大幅に拡大します。
インストール
uv sync開発用:
uv sync --extra dev手動実行
uv run mcp-shell-sudoトランスポートは stdio です。JSON-RPC メッセージを破損しないように、ログは stdout に書き込まれることはありません。ログは stderr に書き込まれます。
MCP 設定
制限なしのコマンドと sudo を有効にした例:
{
"mcpServers": {
"shell": {
"command": "uv",
"args": [
"--directory",
"/ABSOLUTE/PATH/mcp-shell-sudo",
"run",
"mcp-shell-sudo"
],
"env": {
"PASSWORD_SUDO": "YOUR_PASSWORD",
"WORK_DIR": "",
"ALLOW_COMMANDS": ""
}
}
}
}特定のプロジェクトに限定した例:
{
"mcpServers": {
"shell-project": {
"command": "uv",
"args": [
"--directory",
"/ABSOLUTE/PATH/mcp-shell-sudo",
"run",
"mcp-shell-sudo"
],
"env": {
"PASSWORD_SUDO": "",
"WORK_DIR": "/home/user/projects/app",
"ALLOW_COMMANDS": "git,ls,cat,grep,find,python,node,pnpm"
}
}
}
}shell_execute ツール
基本的な入力:
{
"command": ["ls", "-la"]
}作業ディレクトリを指定:
{
"command": ["git", "status"],
"directory": "backend"
}stdin を指定:
{
"command": ["cat"],
"stdin": "hello\n"
}sudo を使用:
{
"command": ["sudo", "id"]
}応答:
{
"stdout": "uid=0(root) gid=0(root) groups=0(root)\n",
"stderr": "",
"status": 0,
"execution_time": 0.031,
"timed_out": false,
"output_limited": false
}shell_config ツール
有効な非秘密設定を返します。
PASSWORD_SUDO を返すことは決してありません。sudo パスワードが設定されているかどうかのみを示します。
実装されたセキュリティ対策
create_subprocess_execを使用します。shell=Trueは使用しません。commandは明示的な argv 配列として渡されます。sudo パスワードは argv、応答、ログ、子プロセス環境に決して表示されません。
PASSWORD_SUDOが設定されていない場合、sudo -nにより、対話的なパスワードプロンプトを待ってプロセスがハングするのを防ぎます。ALLOW_COMMANDSは、単純なsudo呼び出しに続く実際の実行可能ファイルを検証します。固定された縮小された
PATHを使用して、.や任意の継承されたパスから実行可能ファイルを解決しないようにします。MCP サーバー環境全体を継承する代わりに、縮小された子環境を使用します。
呼び出しごとのタイムアウト: デフォルト 60 秒、最大 600 秒。
出力制限: ストリームあたり 2 MiB。制限を超えると、プロセスグループ全体が終了されます。
プロセスは新しいセッションで実行され、タイムアウト時にプロセスグループ全体が終了されます。
WORK_DIRは Bubblewrap を使用し、分離を提供できない場合はフェイルクローズします。
重要な制限事項
ALLOW_COMMANDS=""は、MCP サーバーを実行しているユーザーの権限での任意のコマンド実行を意味します。PASSWORD_SUDOも設定されている場合、MCP クライアントは root としてのアクションを要求できます。この設定は、制御しているクライアントとモデルでのみ使用してください。実行可能ファイルの許可リストは、コマンド引数を意味的に検証しません。
python、node、bash、sh、perlなどのツールは、事実上、任意のコード実行を許可することと同じです。WORK_DIRは書き込み可能なファイルシステムの場所を限定しますが、VM やネットワークサンドボックスとして動作することを意図したものではありません。ネットワークアクセスを持つコマンドは、有効な資格情報を持つリモートリソースを変更する可能性があります。MCP クライアント設定に保存された
PASSWORD_SUDOは、そのファイルに保存された秘密情報のままです。chmod 600でファイルの権限を制限し、バージョン管理にコミットしないでください。
テスト
uv run --extra dev pytest
uv run --extra dev ruff check .Available Tools
2 toolsshell_configA
Return the effective non-secret shell policy configuration.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description serves as the only behavioral disclosure. It implies a read-only operation ('Return') but does not explicitly state that it has no side effects or that it is safe. It does clarify that secrets are excluded, which is a useful constraint. However, it does not mention any authentication or permission requirements, which could be relevant.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, concise sentence that front-loads the action ('Return') and specifies the resource. There is no wasted verbiage.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given that there are no parameters, the description sufficiently conveys the tool's function. The existence of an output schema covers return details, so the description need not elaborate. It does not mention usage context, but that is already addressed in usage_guidelines; for a simple config retrieval, this is complete enough.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
There are zero parameters, so the description is not required to explain parameter syntax. The phrase 'non-secret' adds context about the output scope but does not relate to parameters. For a parameterless tool, this is adequate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb ('Return') and a clear resource ('effective non-secret shell policy configuration'). It distinguishes itself from the sibling tool by nature (configuration retrieval vs. execution), though it does not explicitly name the alternative. The purpose is unambiguous.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is given for when to use this tool versus the sibling shell_execute. An agent must infer that this is for reading configuration, not executing commands. The description does not mention any prerequisites, alternatives, or context for selection.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
shell_executeA
Execute one command as an argv array.
Args: command: Executable and arguments, for example ["ls", "-la"] or ["sudo", "systemctl", "status", "ssh"]. Shell syntax is not interpreted. stdin: Optional text sent to the command's standard input. directory: Optional working directory. With WORK_DIR configured, this path must resolve inside WORK_DIR. Without WORK_DIR, any existing directory may be used. timeout: Execution timeout in seconds. Values above 600 seconds are capped at 600.
Returns: stdout, stderr, exit status, execution time, timeout flag, and output-limit flag.
| Name | Required | Description | Default |
|---|---|---|---|
| stdin | No | ||
| command | Yes | ||
| timeout | No | ||
| directory | No |
Output Schema
| Name | Required | Description |
|---|---|---|
No output parameters | ||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of disclosing behavioral traits. It mentions that shell syntax is not interpreted, that the timeout is capped at 600 seconds, and that directory paths must resolve inside WORK_DIR if configured. However, it does not warn about the potentially destructive nature of executing arbitrary commands or the side effects of the executed process, which is a notable omission for a command execution tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is structured with a clear one-line summary, a detailed 'Args' section, and a 'Returns' section. It is appropriately detailed for a tool with multiple parameters but remains readable. The example for the command parameter adds clarity without bloat.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The description covers the essential invocation details: command format, directory constraints, timeout cap, and the return fields (stdout, stderr, exit status, etc.). It does not explain prerequisites such as the meaning of WORK_DIR, but this is likely a global configuration rather than tool-specific. Given the presence of an output schema (though not shown), the return-field listing is sufficient. Overall, it provides enough for an agent to call the tool correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema provides no descriptions for any of the four parameters (schema coverage 0%), so the description must fully compensate. It does so thoroughly by explaining each parameter: the command array with examples, optional stdin, directory restrictions relative to WORK_DIR, and timeout cap. This adds substantial meaning beyond the schema's type definitions.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description opens with a specific verb and resource: 'Execute one command as an argv array.' It clearly distinguishes from the sibling tool 'shell_config' by implying execution vs. configuration, and provides a concrete example to clarify the argv format.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
It provides clear guidance on how to invoke the tool, including the requirement to pass an argv array rather than shell syntax, and clarifies timeout and directory constraints. However, it does not explicitly state when to prefer this tool over shell_config, though the purpose difference is evident from the name and description.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
2 tool updates
v0.1.0- First observed
shell_config - First observed
shell_execute
TDQS
Scored across 2 tools
The two tools have completely distinct purposes: one executes commands and the other returns configuration. There is no overlap or potential for misselection between them.
Both tools follow the same snake_case verb_noun pattern (shell_execute, shell_config). The naming is clear, predictable, and consistent.
With only two tools, this server feels thin, but the narrow scope (shell execution and configuration) justifies the limited surface. It is at the lower edge of what is reasonable, as stated in the calibration.
The tool surface covers the core functionality of executing shell commands and retrieving configuration. There is no obvious missing operation for the stated purpose; the only minor gap might be a way to list allowed commands or test, but that is not essential.
Maintenance
Related MCP Connectors
Start, pause, resume, and run commands and file operations in Linux sandboxes.
Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.
Securely control computers you explicitly pair through files, terminals, processes, screenshots, desktop UI/input, clipboard, browser automation, diagnostics, and document tools.
Use a person's computer after they approve it there: files, Terminal, browser, local MCP.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables secure execution of shell commands through a dynamic approval system that prompts for user authorization on first use, with persistent command storage and comprehensive audit logging.Apache 2.0
- AlicenseNot gradedqualityDmaintenanceProvides a secure, token-authenticated command execution tool over MCP Streamable HTTP, with a default-deny allowlist and shell metacharacter rejection.11 npm1Apache 2.0
- AlicenseNot gradedqualityBmaintenanceEnables controlled delegation of tasks to local coding-agent CLIs and the Manus API, with strict sandboxing, approval tracking, and remote-egress safeguards.4 npmMIT

sudo-proxyofficial
AlicenseAqualityAmaintenanceExecutes privileged commands with mandatory human approval via a TUI prompt, supporting local and remote execution through sudo.5MIT