MCP stdio ShellGuard — Claude Code MCP server: shell-injection defence
Adds an allowlist, sandbox limits and replay detection around shell calls in MCP servers, plus a CLI that audits source files for risky patterns.
claude mcp add stdio-shellguard -- npx -y mcp-stdio-shellguardWhat MCP stdio ShellGuard does
MCP stdio ShellGuard targets the attack class where an MCP server passes raw user input into a shell command. It ships as three layers you can adopt one at a time.
The library layer gives you guardExec and guardSpawn as replacements for child_process calls. Nothing runs until you register a tool with AllowlistRegistry, naming the executable and the argument patterns it accepts. Sandbox profiles cap runtime, output size and file descriptors; a replay window flags the same invocation twice. You can tighten limits per call, never loosen them past the profile.
The audit CLI mcp-shellguard-audit scan <path> parses the AST and reports 12 rule hits, from a missing timeout to input interpolated straight into exec. Exit code 1 means findings, which makes it usable as a CI gate. Node.js 20 or newer and @modelcontextprotocol/sdk ^1.29.0 are required, so an older runtime won't start the server at all.
What it helps with
- find template literals that pipe user input into
exec - block commands outside a registered tool list
- cap runtime and output size of spawned processes
- spot the same command invoked twice
- gate a CI pipeline on shell-call audit findings
Example prompts for the agent
- Scan
./srcfor shell-injection patterns and return the report as markdown - Register a
git-logtool for/usr/bin/gitthat only acceptslog --oneline -n - Check whether this command with this hash already ran in the replay window
How to install MCP stdio ShellGuard
Platform CLI
claude mcp add stdio-shellguard -- npx -y mcp-stdio-shellguardPlatform CLI
codex mcp add mcp-stdio-shellguard -- npx -y mcp-stdio-shellguardConfig file
{
"mcpServers": {
"mcp-stdio-shellguard": {
"command": "npx",
"args": [
"-y",
"mcp-stdio-shellguard"
]
}
}
}Config file
{
"servers": {
"mcp-stdio-shellguard": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"mcp-stdio-shellguard"
]
}
}
}Platform CLI
gemini mcp add mcp-stdio-shellguard npx -y mcp-stdio-shellguardStep by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about MCP stdio ShellGuard
How to install MCP stdio ShellGuard in Claude Code?
Run claude mcp add stdio-shellguard -- npx -y mcp-stdio-shellguard.
What does MCP stdio ShellGuard do?
It wraps shell calls with an allowlist, sandbox profiles and replay tracking, and provides a CLI that audits MCP server sources for injection risks.
Which Node.js version does it need?
Node.js 20 or newer, along with @modelcontextprotocol/sdk ^1.29.0.