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내부에 있어야 하며, 모든 프로세스는/가 읽기 전용이고WORK_DIR이 읽기-쓰기로 마운트되며/tmp와/run이 임시인 Bubblewrap 마운트 네임스페이스 내에서 실행됩니다.
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초.
출력 제한: 스트림당 2MiB. 제한을 초과하면 전체 프로세스 그룹이 종료됩니다.
프로세스는 새 세션에서 실행되며, 타임아웃 시 전체 프로세스 그룹이 종료됩니다.
WORK_DIR는 Bubblewrap을 사용하며 격리를 제공할 수 없으면 실패 시 닫힙니다(fail closed).
중요한 제한 사항
ALLOW_COMMANDS=""는 MCP 서버를 실행하는 사용자의 권한으로 임의의 명령 실행을 의미합니다.PASSWORD_SUDO도 구성된 경우 MCP 클라이언트는 루트로 작업을 요청할 수 있습니다. 이 구성은 제어하는 클라이언트와 모델에서만 사용하십시오.실행 파일 허용 목록은 명령 인수를 의미적으로 검증하지 않습니다.
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