Skip to content

shell

Run shell commands restricted to a strict basename allowlist. No shell expansion: arguments are passed directly to exec(), never through /bin/sh. There is no glob, pipe, redirect, or variable substitution.

Usage

bash
native-mcp shell --allow CMD,CMD,... [--cwd DIR] [--timeout DUR]

--allow is required: the server refuses to start without it. There is no "open mode".

Flags

FlagDefaultDescription
--allow(required)Comma-separated list of allowed command basenames (e.g. ls,grep,find,git,cat).
--cwd(none)If set, all commands run in this directory. The tool's cwd argument is then rejected.
--timeout30sPer-command timeout (Go duration).

Tools

run

FieldTypeRequiredDescription
commandstringyesBasename of the command (must be in --allow). Paths are rejected.
argsarray<string>noArgument list, passed verbatim to exec().
stdinstringnoOptional stdin content.
cwdstringnoWorking directory. Rejected if --cwd was set on the server.

Returns:

text
exit: 0
cwd: /tmp                    (only if a cwd was used)
---- stdout ----
<command stdout, capped at 1 MiB>
---- stderr ----
<command stderr, capped at 1 MiB>

list_allowed_commands

Returns the configured allowlist, one per line.

Why this design

  • No /bin/sh — every byte of args reaches the binary unchanged. Quoting is a non-issue.
  • Basename-only command — paths like /bin/sh or ../bin/sh are rejected. The actual binary is resolved via PATH server-side.
  • Allowlist required — there is no "yolo mode" that exposes every command on disk.
  • Output capped — runaway commands cannot blow up the agent's context.
  • Timeout — runaway commands cannot hang the session.

Register in Claude Code

bash
# Read-only tools for code exploration
claude mcp add native-shell native-mcp shell --allow ls,find,grep,cat,head,tail,wc

# Locked to one project, with longer timeout for builds
claude mcp add native-shell-build native-mcp shell \
  --allow make,cargo,go,npm \
  --cwd /home/you/project \
  --timeout 5m

Released under the MIT License.