shell-mcp
shell-mcp
로컬 LLM 클라이언트와 함께 셸 명령을 안전하게 실행하기 위한 초보안 MCP(Model Context Protocol) 서버입니다.
보안 모델
명령어는 8개의 독립적인 보안 계층을 통과하며, 모든 계층을 통과해야 합니다:
계층 | 기능 |
1 | Zod 스키마 검증 — 처리 전 엄격한 타입 검사 |
2 | 셸 미사용(No-shell spawn) — |
3 | 하드코딩된 차단 목록 — |
4 | 인자 검사 — 메타 문자, 널 바이트, 의심스러운 패턴, 명령어별 위험 플래그 거부 |
5 | 디렉토리 허용 목록 — 모든 경로는 |
6 | 심볼릭 링크 해석 — 경로 확인 전 심볼릭 링크 해석 (심볼릭 링크를 통한 탈출 방지) |
7 | 리소스 제한 — 타임아웃, 출력 크기 제한, 동시성 제한 |
8 | 환경 변수 정제 — |
Related MCP server: MCP Shell Server
빠른 시작
# Clone and build
git clone https://github.com/your-username/shell-mcp.git
cd shell-mcp
npm install
npm run build
# Run (must specify at least one --allow-dir)
node dist/index.js --allow-dir ~/projects --allow-dir ~/dataLLM 클라이언트 설정
{
"shell-mcp": {
"command": "node",
"args": [
"/path/to/shell-mcp/dist/index.js",
"--allow-dir", "/home/user/projects",
"--allow-dir", "/home/user/data",
"--allow-cmd", "ls",
"--allow-cmd", "cat",
"--allow-cmd", "grep",
"--allow-cmd", "find",
"--allow-cmd", "python3",
"--timeout", "30",
"--log-file", "/home/user/.shell-mcp/audit.log"
]
}
}플래그
플래그 | 설명 | 기본값 |
| 허용된 디렉토리 (필수, 반복 가능) | 없음 — 서버 시작 불가 |
| 특정 명령어 화이트리스트 (반복 가능) | 차단되지 않은 모든 명령어 |
| 추가 차단 명령어 | — |
| 최대 실행 시간 (1–300) | 30 |
| 최대 출력 크기 | 1048576 (1MB) |
| 최대 병렬 명령어 수 (1–10) | 3 |
| 감사 로그 파일 경로 | stderr 전용 |
|
| off |
| 파일 덮어쓰기 허용 | off |
| 모든 쓰기 작업 비활성화 ( | off |
| curl, wget, nc 차단 해제 | off |
| 자식 프로세스로 전체 환경 변수 전달 | off (정제됨) |
LLM에 노출된 도구
run_command
명시적인 인자 배열로 명령어를 실행합니다. 셸을 사용하지 않으므로 파이프와 리다이렉션은 작동하지 않습니다.
{
"command": "grep",
"args": ["-r", "TODO", "/home/user/projects/myapp"],
"cwd": "/home/user/projects/myapp",
"timeout": 10
}read_file
파일 내용을 읽습니다. 줄 범위 및 바이너리(base64) 출력을 지원합니다.
{
"path": "/home/user/projects/myapp/src/main.py",
"startLine": 1,
"endLine": 50
}list_directory
트리 뷰, 크기 및 권한과 함께 디렉토리 목록을 표시합니다.
{
"path": "/home/user/projects/myapp",
"recursive": true
}write_file (--enable-write 필요)
파일을 씁니다. --allow-overwrite 없이는 덮어쓰지 않습니다.
{
"path": "/home/user/projects/myapp/notes.txt",
"content": "Hello world"
}get_server_info
현재 서버 설정 및 제한 사항을 반환합니다. LLM이 작업을 수행하기 전에 샌드박스 환경을 이해하는 데 유용합니다.
영구 차단된 명령어
다음 명령어는 어떤 플래그로도 활성화할 수 없습니다:
rm, rmdir, shred, dd, mkfs, fdisk, diskutil, sudo, su, doas,
osascript, defaults, open, launchctl, crontab,
curl, wget, nc, ssh, scp, rsync,
brew, npm, yarn, pip, gem, cargo, docker,
gcc, clang, kill, killall, shutdown, reboot,
gpg, security (macOS keychain), ...and more감사 로그
모든 명령어 시도(허용 또는 거부됨)는 JSON 형식으로 기록됩니다:
{"timestamp":"2024-01-01T12:00:00.000Z","sessionId":"A3F9B2C1","event":"COMMAND_DENY","command":"rm","args":["-rf","/"],"denyLayer":3,"denyReason":"Command \"rm\" is on the hardcoded blocklist"}
{"timestamp":"2024-01-01T12:00:01.000Z","sessionId":"A3F9B2C1","event":"COMMAND_ALLOW","command":"ls","args":["-la"],"cwd":"/home/user/projects","exitCode":0,"durationMs":12,"outputBytes":1024}MCP Inspector로 검사
npx @modelcontextprotocol/inspector node dist/index.js --allow-dir /tmp/testThis server cannot be deployed
Maintenance
Related MCP Connectors
- gatewayOAuthai.sealgate
MCP gateway with runtime security policy, tool-call-level control, and audit of agent actions.
Paid remote MCP for LLM security scans, jailbreak checks, analytics, checkout, and readiness.
Security & DLP proxy for MCP: tool-poisoning scans, PII redaction on tool args/results. Beta.
Remote MCP for Android CLI agent build gate, structured receipts, audit logs, and reviewer-ready evi
Related MCP Servers
- AlicenseAqualityFmaintenanceAn MCP server that enables secure execution of shell commands across Windows, macOS, and Linux with built-in whitelisting and approval mechanisms for enhanced security.971 npm21MIT
- AlicenseBqualityDmaintenanceEnables secure execution of whitelisted shell commands through MCP, with support for stdin input, timeout control, and comprehensive output including stdout, stderr, and execution time.1MIT

terminal-toolkit-mcpofficial
AlicenseNot gradedqualityCmaintenanceEnables LLM clients to execute shell commands safely through the MCP protocol, with features like session management, safe mode, and process control.1Apache 2.0- AlicenseNot gradedqualityDmaintenanceEnables executing shell commands on the host system via an MCP tool, with JWT/OAuth authentication and audit logging for secure remote access.1MIT