cmdshellmcp MCP server
2026년 10월 17일 커밋AI 에이전트가 샌드박스 내에서 파일 작업, 셸 실행 및 패치 적용을 수행할 수 있도록 제한된 명령 셸 환경을 제공합니다.
다른 이름 ag88/cmdshellmcp
- 스타
- 3
- Tools
- 9
- 다운로드, 30일
- —
- 최신 버전
- —
- 마지막 커밋
- 2026년 10월 17일
- 라이선스
- MIT
cmdshellmcp MCP란?
cmdshellmcp은(는) MCP server입니다. AI 에이전트가 샌드박스 내에서 파일 작업, 셸 실행 및 패치 적용을 수행할 수 있도록 제한된 명령 셸 환경을 제공합니다. 9개 도구를 제공합니다. 예: command, args, file.
프로젝트 README에서 생성된 요약
cmdshellmcp MCP server 정보
cmdshellmcp의 주요 기능은 AI 에이전트가 로컬 시스템과 상호 작용할 수 있는 제어된 환경을 제공하는 것입니다. 이를 통해 MCP 클라이언트는 허용된 특정 Unix 명령 세트를 실행하고, 읽기, 쓰기, 이동, 삭제와 같은 작업을 통해 파일을 관리하며, unified diff를 사용하여 패치를 적용할 수 있습니다. 이 서버는 LLM에 제한된 범위 내에서 코딩 작업이나 시스템 운영을 수행할 수 있는 능력을 부여하려는 개발자를 위해 설계되었습니다.
서버는 Python과 fastmcp 패키지를 사용하여 로컬에서 실행되며, 일반적으로 streamable HTTP 또는 SSE 전송 방식을 통해 127.0.0.1:8003에서 대기합니다. 작업 디렉토리와 허용된 명령을 정의하려면 JSON 설정 파일이 필요합니다. 서버가 원격 명령 실행 기능을 제공하므로 보안이 핵심 요소입니다. 위험을 완화하기 위해 기본적으로 bearer token 인증, 디렉토리 탈출을 방지하기 위한 경로 제한 휴리스틱, 감사 로그 기능을 포함하고 있습니다. 보안을 극대화하려면 에이전트가 권한이 없는 사용자로 동작하는 일회성 Docker Debian 기반 샌드박스 컨테이너 내부에서 서버를 실행하는 것을 권장합니다.
활용 사례
- 1특정 셸 명령 실행AI 에이전트는 정의된 작업 디렉토리 내에서 ls, grep 또는 awk와 같이 선별된 Unix 명령 목록을 실행할 수 있습니다.
- 2트랜잭션 방식의 파일 편집개발자는 안전을 위해 번호가 매겨진 백업을 유지하면서 sed를 사용하여 텍스트 파일을 수정하도록 에이전트에게 작업을 맡길 수 있습니다.
- 3코드 패치 적용AI 클라이언트는 파일 시스템에 unified diff 패치를 직접 적용하여 소스 코드를 업데이트할 수 있습니다.
- 4웹 콘텐츠 가져오기 및 처리에이전트는 인터넷에서 정보를 가져오고 정렬된(prettified) HTML을 수신할 수 있습니다.
프로젝트의 README를 바탕으로 작성되었습니다. 모든 활용 사례는 해당 내용의 인용문과 대조하여 확인합니다.
cmdshellmcp MCP 도구 9
README에서 감지됨commandargsfiletextappendnewlinescriptdiffpnum
| command | — | |
| args | — | |
| file | — | |
| text | — | |
| append | — | |
| newline | — | |
| script | — | |
| diff | — | |
| pnum | — |
자동 검사
2026년 11월 14일에 실행됨전체 보고서 →아직 인증되지 않았습니다. 서버는 80점 이상의 점수, 심각한 결함 없음, 그리고 검사에 충분한 데이터를 갖추어야 합니다. 검사 방식 · 점수를 높이기 위해 수정할 항목
- 소스 저장소 연결 및 접근 가능ag88/cmdshellmcp is public and reachablegithub.com/ag88/cmdshellmcp ↗통과
- 패키지가 이 저장소를 소스로 명시검사되지 않음
- 빌드 출처(Sigstore 증명)검사되지 않음
- 오픈 소스 라이선스 (OSI)MITspdx.org/licenses/MIT.html ↗통과
- 최근 1년 내 커밋 또는 릴리스Last commit or release 2026-10-17github.com/ag88/cmdshellmcp ↗통과
- OpenSSF Scorecard검사되지 않음
- 패키지 이름이 인기 패키지와 유사하지 않음검사되지 않음
- 패키지 및 해당 종속성에 중요한 보안 권고 없음검사되지 않음
- 모델에 대한 숨겨진 지침 없음9 tool descriptions and the README read; no override phrases, credential paths or hidden characters통과
- 파괴적인 도구에 라벨 표시됨No tool named like delete, drop or exec통과
- 원격 엔드포인트가 MCP 핸드셰이크에 응답검사되지 않음
README
GitHub에서 보기cmdshellmcp
cmdshellmcp is a constrained command-shell MCP server for AI agents. It exposes a small allowlisted Unix command set, somewhat safe file operations, patch application, and URL fetching so an MCP client can perform limited local tasks without unrestricted shell access.
The server is implemented in Python and runs as an MCP server using the fastmcp package. By default it listens on 127.0.0.1:8003 using the streamable HTTP transport unless --sse is selected.
Added setup files for a full featured Docker Debian based sandbox system container with cmdshellmcp (setup scripts, guides DOCKER.md, Dockerfile, cmdshellmcp.service unit file that runs cmdshellmcp in the container).
[!CAUTION]
This server provides remote command execution (RCE), which is normally considered a critical security vulnerability. Allow-listing powerful commands—such as bash, sh, python, perl, sudo, docker, or commands capable of writing files—may allow an attacker or untrusted LLM to bypass intended restrictions and take control of the system. For example, allowing python or bash can effectively permit arbitrary code execution and file access. If the server lacks strong authentication, is reachable by untrusted clients, or is controlled by an untrusted or prompt-injected LLM, it may cause severe damage, including data loss, credential theft, malware installation, or compromise of other systems. Run cmdshellmcp (cmdshellmcp2.py) only in a protected, disposable sandbox with carefully scoped privileges limited to those required for its intended task and limited access to files, credentials, devices, and networks—for example, disposable Docker container or virtual machine that can be safely destroyed after use.
Warning
This is a scratch / experimental app that evolved out of using an MCP server (tools) that allow running shell commands for coding purpose. Unfortunately, for such a purpose, one often needs to provide the LLM (model) client with rather powerful shell commands to "do its job" for a particular scope / context / intent.
The default allowed commands are not necessarily safe, i.e. LLM agents or practically clients calling
the MCP api can 'escape' and do things outside a context e.g. the working directory defined with --cwd
option. It validates the arguments in a limited way, i.e. looking for string path patterns if they seem to escape the current
directory. This is a heuristic check, i.e. this check is pattern matching, it does not know if that argument is intended to be a file
or directory. Nor does it know the argument's context for a particular command, or if they are after all safe.
e.g. it may prevent a ls / (listing a root directory), but sometimes that is what you need. But it may prevent by sheer pattern
matching e.g. rm /PreciousFile.txt i.e. remove a file in the root directory. This is not an always secure check, but added
as it is better than no checks at all.
There are also tools (MCP functions exposed) that expose write and file modification ops, including executing shell commands.
- Authentication is enabled by default. Keep the randomly generated token, or set
a fixed auth_token using the auth field in the config file or
--auth. Using--noauthpractically means you are giving remote command execution (RCE) to any (including possibly malicious or rogue) clients that can reach the server. - Run this as an unprivileged user. Running as
rootis at best foolish - Do not use this with untrusted clients or untrusted LLMs
- Use it in a disposable sandbox e.g. a standalone docker container or virtual machine that you can afford to throw away including the contents
- Review the allow list in
cmdshellmcp.jsonand the hardcoded defaults, revise them before using.
Features
- Allowlisted shell execution for a curated set of commands
- File read/write/list/copy/move/rename/delete operations and basic directory creation/removal under a configured working directory
- Transactional text-file editing with
sed, numbered backups, and unified diffs - Unified diff patch application via
patch - HTTP fetch support with optional HTML prettification
- Bearer token authentication with a secure, randomly generated token by default
- Audit logging to stdout and/or a file
- Path restrictions to prevent escaping the current working directory
- Setup files for a delightful, full featured Docker Debian based sandbox system container with
cmdshellmcp(setup scripts, guides DOCKER.md, Dockerfile,cmdshellmcp.serviceunit file that runscmdshellmcpin the container).
AI use in this repo
This app and its contents e.g. this page, is created with the aid of LLM (large language models) such as
- ChatGPT 5.6 sol (light), Codex
- Github Co-pilot MAI-Code-1.1-Flash
Initial codes is written by the author and refactored with aid of the LLMs and updates is also done partly manually. After features are added or changed, additional tests is often done by manually running them e.g. in llama.cpp's llama-server Web UI
Installation
- Clone the repository.
- Create and activate a virtual environment if desired.
- Install dependencies:
python -m venv .venv
source .venv/bin/activate
pip install fastmcp requests beautifulsoup4
If your environment uses a requirements.txt, you can also install from there:
pip install -r requirements.txt
The editFile tool also requires GNU sed (including its --sandbox option)
and diff to be installed on the server. These programs are invoked directly by
the dedicated tool and do not need to appear in allowed_commands.
Configuration
A configuration file is mandatory. The server selects one JSON file in this order (files are not merged):
- The file specified by
--conf, when given (no automatic search). /etc/cmdshellmcp.d/cmdshellmcp.json./usr/local/python/cmdshellmcp/cmdshellmcp.json.
The current directory is never searched automatically. If no config is found,
startup exits with an error suggesting --conf FILE. A missing explicit file,
unreadable file, or invalid selected JSON file also fails startup. Command-line
options override their configuration keys; omitted optional settings retain
internal defaults within the required configuration.
Example:
{
"host": "127.0.0.1",
"port": 8003,
"cwd": "/path/to/project",
"shellnopathchk": false,
"editdelbk": false,
"quiet": false,
"auditlog": null,
"disableTools": ["writeFile", "editFile", "applyPatch", "copyFile", "moveRenameFile", "deleteFile", "mkdir", "rmdir"],
"allowed_commands": [
"ls", "pwd", "date", "cat", "grep", "egrep",
"whoami", "head", "tail", "sed", "wc", "file", "du", "df",
"free", "ps", "uname", "hostname", "uptime", "w", "last",
"mkdir", "cp", "mv", "awk"
],
"auth": "_my_secret_auth_token_"
}
Supported configuration keys:
host: bind host; default127.0.0.1port: bind port; default8003cwd: working directory path; required unless--cwdis suppliedshellnopathchk: boolean; bypasses shell argument path checks whentrue; defaultfalseeditdelbk: boolean; deletes successful edit backups after composing the diff whentrue; defaultfalsequiet: suppresses audit output to stdout whentrueauditlog: optional path to an audit log fileallowed_commands: list of commands permitted for executiondisableTools: list of MCP tool names to omit from the server, case sensitive and exact name match is requiredauth: optional fixed bearer token string; when omitted, a random token is generated at startup
Running the server
Start with an explicit configuration and working directory:
python cmdshellmcp2.py --conf /path/to/cmdshellmcp.json --cwd /path/to/project
If the config is installed in a default search location and supplies cwd,
python cmdshellmcp2.py is sufficient. Startup fails when neither --cwd nor
config cwd supplies a directory. There is no prompt or automatic working
directory fallback. The selected directory is logged before the server starts.
By default, the server listens on 127.0.0.1:8003 using streamable HTTP.
The following examples assume a config is installed in a default search location;
otherwise add --conf FILE. Supply --cwd PATH if the config leaves cwd unset.
SSE mode
python cmdshellmcp2.py --sse
This runs the server on the SSE transport instead of streamable HTTP.
Browser clients and CORS
Both HTTP transports include CORS middleware for browser-based MCP clients. The
server accepts requests from any origin, supports the MCP GET, POST, and
DELETE methods and browser preflight OPTIONS requests, and exposes the
mcp-session-id response header to browser JavaScript.
Because all origins are allowed, do not expose the server to an untrusted
network without authentication and appropriate network controls. To restrict
browser access, replace allow_origins=["*"] in CORS_MIDDLEWARE with the
specific trusted origins.
Custom working directory
python cmdshellmcp2.py --cwd /path/to/project
This overrides config cwd for file and shell tools. A configuration file is still required.
The path must exist and must be a directory; ~ is expanded and the selected
path is normalized to an absolute path.
Custom host and port
python cmdshellmcp2.py --host 0.0.0.0 --port 9000
Authentication
Authentication is enabled by default. If neither --auth nor an auth value in
the configuration file supplies a fixed token, the server generates a
cryptographically secure, base64-encoded token and displays it in the startup
log. The generated token is shown in bold when stdout supports ANSI styling.
Configure the MCP client to send that value as its bearer token.
To use a fixed token instead:
python cmdshellmcp2.py --auth my-secret-token
To explicitly run without authentication:
python cmdshellmcp2.py --noauth
--auth and --noauth are mutually exclusive. --noauth also overrides an
auth value in the configuration file. Disabling authentication is unsafe on
any network that is not completely trusted.
Audit logging
python cmdshellmcp2.py --quiet --auditlog /tmp/cmdshellmcp.log
--quietdisables audit logging to stdout.--auditlogappends audit events to the specified file.
A full featured Docker Debian based sandbox system container with cmdshellmcp
This project provides setup files for a delightful, full featured Docker Debian based sandbox system container with cmdshellmcp (setup scripts, guides DOCKER.md, Dockerfile, cmdshellmcp.service unit file that runs cmdshellmcp in the container).
Using the docker sandbox container gives you a "system in a system" experience, e.g. that Debian boots up within the container just like a full Unix / Linux system. It gives you 3 userids within the container:
root: (superuser)admin(this is for you / human user),adminhassudoaccess, i.e. practically can do anythingrootdoes, install files, change system configs, permissions etccodeagent:cmdshellmcpruns under this user, in the user's/home/codeagenthome directory.codeagenthas no sudo access.
For more details review DOCKER.md
Command-line options
python cmdshellmcp2.py [--cwd PATH] [--host HOST] [--port PORT] \
[--allow COMMAND [COMMAND ...]] [--conf FILE] [--auth TOKEN | --noauth] \
[--disableTools TOOL[,TOOL...]] [--editdelbk] [--shellnopathchk] [--sse] [--quiet] \
[--auditlog FILE] [--stdio]
Options:
--cwd: working directory used for file and shell operations; when omitted, use configcwd, otherwise exit with a missing working directory error--host: server bind host--port: server bind port--allow: override the allowlist for the current process; may be repeated--disableTools: comma-separated MCP tool names to omit; overrides thedisableToolslist from the config file; case sensitive and exact name match is required--editdelbk: delete the numbered backup aftereditFilehas completed successfully and composed its unified diff response; overrides configeditdelbk--shellnopathchk: bypass_local_path_errorchecks oncmdshellarguments for this server process; overrides configshellnopathchk; file tools continue to check their paths--conf: explicit JSON config file path; when omitted, search the locations listed in Configuration--auth: use a fixed bearer token instead of generating one--noauth: explicitly disable bearer authentication; mutually exclusive with--authand unsafe on untrusted networks--sse: use SSE transport instead of streamable HTTP--quiet: suppress audit output on stdout--auditlog: write audit logs to a given file--stdio: start the server in stdio mode, i.e. listen for clients/ tool calls on stdio.
warning: this implies--noauth, stdio clients connect without auth and runs with the authorizations of the userid running it, including shell commands. This server is not intended to be used with--stdioas it compromise the security posture as documented in the RCE (remote command execution) warning section, this is provided for specific use cases e.g. such as with amcp-proxyin which the mcp proxy handles authentication and that it is run in its own sandbox container etc.
Allowlist override
python cmdshellmcp2.py --allow ls pwd date whoami cat grep
This overrides allowed_commands from the config file for that process.
Disabling tools
python cmdshellmcp2.py --disableTools writeFile,editFile,applyPatch,fetch
This prevents matching tools from being registered by the server. Tool names
are case-sensitive and must match the function names in the MCP tools exposed to AI agents section below.
The command-line option overrides the disableTools list from the config file.
Security model
This server is intentionally restricted. It is designed to be somewhat safe in a controlled environment rather than as a general unrestricted shell.
Security features include:
- Shell commands must be explicitly present in the allowlist
- Command names are checked before execution
- The
cmdshelltool expects a command name and argument array, not a raw shell string - Piping is not supported by design
cmdshellchecks every argument with_local_path_errorafter escape decoding and removal of surrounding double quotes, before expanding globs. Expanded filenames are also checked before execution. Empty arguments are allowed; absolute paths and paths containing a..component are rejected by default.- Start the server with
--shellnopathchkor set configshellnopathchktotruewhen shell commands need access to shared resources such as/usr/shareor/usr/include. This bypass applies only tocmdshell; the command allowlist remains enforced. - File tools require non-empty paths and perform basic
_local_path_errorchecks intended to keep file paths within--cwd: absolute paths and paths containing..are rejected - These are basic lexical path checks rather than a complete filesystem sandbox.
They do not resolve symlinks or interpret command-specific options such as
--file=/absolute/path, scripts, or expressions. Choose the command allowlist carefully for your intended usage. editFileaccepts only a small allowlist of non-file-selectingsedoptions, runs GNUsedin sandbox mode, and does not invoke a shelleditFilewrites successful output to a temporary file before atomically replacing the source; failedsedruns leave the source unchanged- Patch application blocks dangerous path-changing options
In short: the shell is a narrow sandbox for controlled read/write operations, not a full-host terminal.
Configuration file resolution and placement
The server requires a configuration file. --conf FILE selects it explicitly;
otherwise only /etc/cmdshellmcp.d/cmdshellmcp.json and then
/usr/local/python/cmdshellmcp/cmdshellmcp.json are checked. A config in the
process's current directory is never loaded automatically. Missing or invalid
configuration fails startup, preventing an unintended policy from being loaded
from the client's working files.
Keep the configuration outside the tool working directory and protect it with filesystem ownership and permissions that prevent the server account from modifying it. At startup, after logging the working directory, the server checks both the selected config path and its resolved symlink target. If either lies within the working directory, it logs a warning naming the config and working directory: the MCP client may read or modify the config and compromise the sandbox's security posture. This check warns and allows startup; it does not block access or enforce isolation. Placing the config outside the working directory helps prevent access through local file tools, but lexical path checks, symlinks, and powerful allowlisted commands still require careful permissions and sandboxing.
Working directory resolution
The directory used by shell and file tools is selected in this order:
--cwd PATH, when given.cwdfrom the selected configuration file.
If neither supplies a path, startup exits with a missing working directory
error. There is no interactive prompt and no fallback to the process's current
directory. Paths must exist and be directories; ~ is expanded and paths are
resolved to absolute paths. Relative paths are resolved against the process's
current directory, including paths from config (not against the config file's
location). Invalid paths fail startup. The selected absolute directory is logged.
Set an absolute --cwd or config cwd for services so the tool directory is
independent of the launch directory. This directory scopes local operations
but does not provide a complete filesystem sandbox.
MCP tools exposed to AI agents
The server registers the following tools:
1. cmdshell(command, args)
Runs one configured Unix command with arguments.
Parameters:
command: the command name, which must appear in the allowlistargs: list of arguments/flags to pass to the command
Example:
cmdshell("ls", ["-la"])
cmdshell("grep", ["-R", "needle", "."])
Notes:
-
The command name must be in the allowlist.
-
Arguments are passed as a list, reducing shell injection risk.
-
Arguments are checked with
_local_path_errorby default, including decoded arguments and expanded glob matches. This also checks arguments used as flags or text; empty arguments are allowed, while absolute paths and..path components are rejected. -
Glob patterns may be expanded automatically relative to
--cwd. -
Quoted globs can be passed literally to prevent expansion.
-
Pipes and redirects are not allowed
-
To bypass only the shell argument path checks, start the server with:
python cmdshellmcp2.py --cwd /path/to/project --shellnopathchkThe MCP tool's parameters remain
commandandargs; the bypass is configured at server startup, and file tools still enforce their path checks.
2. writeFile(file, text, append=False, newline=True)
Writes text to a file beneath the current working directory.
Parameters:
file: a relative path undercwdtext: content to writeappend: iftrue, append instead of overwritenewline: append a trailing newline whentrue
Example:
writeFile("notes.txt", "hello from the agent")
This is restricted to relative paths below the configured working directory.
3. readFile(file)
Reads a UTF-8 text file beneath the current working directory.
Example:
readFile("README.md")
4. listFiles(path=".")
Lists the entries in a directory beneath the configured working directory.
Example:
listFiles(".")
listFiles("src")
Returns a newline-separated list of entries, with / appended for directories.
5. copyFile(source, destination)
Copies a regular file beneath the configured working directory using Python's
standard-library file operations. Both source and destination are checked with
_local_path_error.
Example:
copyFile("src/example.py", "src/example.py.copy")
6. moveRenameFile(source, destination)
Moves or renames a regular file using os.rename. Both source and destination
are checked with _local_path_error.
Example:
moveRenameFile("draft.txt", "archive/draft.txt")
7. deleteFile(file)
Deletes a regular file using os.remove after checking the path with
_local_path_error.
Example:
deleteFile("obsolete.txt")
8. mkdir(path)
Creates one directory using os.mkdir after checking the path with
_local_path_error.
Example:
mkdir("build")
The parent directory must already exist.
9. rmdir(path)
Removes one empty directory using os.rmdir after checking the path with
_local_path_error.
Example:
rmdir("build")
The directory must be empty; this tool does not recursively delete directory contents.
cmdshellmcp MCP 질문
cmdshellmcp MCP는 어떤 도구를 제공하나요?
9개 도구를 제공합니다. 예: command, args, file, text, append.
이 서버는 안전한가요?
아니요, 원격 명령 실행(RCE) 기능을 제공하므로 Docker 컨테이너나 가상 머신과 같이 보호된 일회성 샌드박스에서만 실행해야 합니다.
인증은 어떻게 처리되나요?
기본적으로 bearer token을 사용하여 인증이 활성화됩니다. 이 토큰은 시작 시 무작위로 생성되거나 설정을 통해 수동으로 지정할 수 있습니다.
AI가 실행할 수 있는 명령을 제한할 수 있나요?
네, 설정 파일에서 허용된 명령의 allowlist를 정의할 수 있습니다.
Docker를 지원하나요?
네, 이 프로젝트에는 기능이 완전한 Debian 기반 Docker 샌드박스 시스템 컨테이너를 위한 설정 파일이 포함되어 있습니다.