just-bash-mcp

just-bash-mcp

Sandboxed bash execution MCP server for AI agents, using an in-memory virtual filesystem overlay to prevent real filesystem damage, with configurable network access, timeouts, and optional Python/JS runtimes.

Category
访问服务器

README

just-bash-mcp

Sandboxed bash execution for AI agents via Model Context Protocol, powered by Vercel Labs' just-bash.

Every agent in your fleet — OpenCode, Codex, Claude, Droid, Cline, Kiro, Gemini, etc. — currently runs its bash tool with full user privileges against your real filesystem. This MCP server replaces that with a sandboxed alternative: agents operate on a virtual filesystem backed by an in-memory overlay, so writes evaporate unless you explicitly commit them.

What you get

  • 100+ unix commands (cat, awk, sed, jq, sqlite3, xan, yq, tar, grep, sort, find, tee, ...)
  • Optional python3 (CPython compiled to WASM) and js-exec (QuickJS) — opt-in
  • Pipes, redirections, variables, if/while/for, functions, all the bash you know
  • A real bash, not a shell-out to PowerShell — works the same on every OS
  • Path translation: /home/user/project/* ↔ your real <project-root>/*
  • Network off by default; allow-list via env var
  • 30s timeout, 1MB output cap, configurable
  • Process kills cleanly on SIGINT/SIGTERM

What you don't get (intentional)

  • No VM isolation. This is a TypeScript sandbox, not OS-level. It stops accidental damage — a slipped rm -rf won't kill your real project — but not a determined attacker.
  • No modification of the real filesystem. The overlay is in-memory; committing is a separate step the user does explicitly.
  • No PowerShell compatibility. This is bash. For your day-to-day shell on Windows, keep using PowerShell.

Install

cd "C:\tools\03-Projects\lains Tools\just-bash-mcp"
npm install
npm run build

Run standalone (for testing)

# Pipe JSON-RPC requests
$req | node dist/index.js

The server uses stdio transport. It speaks the MCP protocol.

Wire to OpenCode

Add to C:\Users\badanalysis\.config\opencode\mcp_servers.json:

"just-bash": {
  "command": "node",
  "args": ["C:\\tools\\03-Projects\\lains Tools\\just-bash-mcp\\dist\\index.js"],
  "env": {
    "JUST_BASH_PROJECT_ROOT": "C:\\path\\to\\your\\project"
  }
}

The JUST_BASH_PROJECT_ROOT should point at the project you want the agent to operate on. Each project will need its own MCP instance OR you set it to a neutral root and let the agent cd around.

Tools

bash_exec(script, timeout?)

Run a bash script in the sandbox. Returns stdout, stderr, and exit code.

// Example: agent wants to look at the project structure
await bash_exec({ script: "ls -la src/ && wc -l src/*.ts | tail -5" });
// Example: agent wants to create a new file
await bash_exec({
  script: "mkdir -p src/components && cat > src/components/Button.tsx <<'EOF\nexport function Button() { return <button>Click</button>; }\nEOF"
});
// The file lives in the overlay until committed

sandbox_status

await sandbox_status();
// {
//   project_root: "C:\\path\\to\\project",
//   age_seconds: 42,
//   executions: 7,
//   network_policy: "DISABLED" | "https://api.github.com/, ..."
// }

sandbox_reset(confirm)

Drop the in-memory overlay and start fresh. Useful when an agent has gone off-track and you want to restart from the real FS state.

await sandbox_reset({ confirm: true });

realpath(sandboxPath)

await realpath({ sandboxPath: "/home/user/project/src/index.ts" });
// "C:\\path\\to\\project\\src\\index.ts"

path_exists(sandboxPath)

await path_exists({ sandboxPath: "/home/user/project/README.md" });
// "true" | "false"

Configuration

Env var Default Description
JUST_BASH_PROJECT_ROOT cwd Project dir to mount in the overlay
JUST_BASH_NETWORK_ALLOW (empty) Comma-separated URL prefixes (e.g. https://api.github.com/,https://registry.npmjs.org/)
JUST_BASH_MAX_DURATION_MS 30000 Max script duration
JUST_BASH_MAX_OUTPUT_BYTES 1048576 Max stdout bytes

Limits

Built into just-bash itself:

  • maxCallDepth: 100 (function recursion)
  • maxCommandCount: 10000 (total commands in a session)
  • maxLoopIterations: 10000 (per loop)
  • maxAwkIterations: 10000, maxSedIterations: 10000

Security model

Layer Protection
TypeScript sandbox Stops prototype-pollution attacks and accidental escape to host JS engine
Filesystem isolation Writes go to in-memory overlay; reads from real FS only at the configured project root
Path translation All sandbox paths must start with /home/user/project; traversal blocked
Network isolation Off by default; allow-list with URL prefix + HTTP method (GET/HEAD)
Optional runtimes off python3 and js-exec are opt-in — they don't exist unless you set python: true / javascript: true
Execution limits Prevent infinite loops, runaway computation
No VM If you need a full VM with arbitrary binary execution, use Vercel Sandbox instead — same API, different backend

License

Apache-2.0 (inherited from just-bash)

Related projects

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选