Exec Sandbox

io.github.inhuman由 GitHub 账号 inhuman 发布v0.5.4更新于 Oct 24, 2026

Single exec tool running caller Python in a network-isolated locked-down sandbox.

已验证STDIO仅桌面开发者工具安全与监控

概览

AI 生成的概览

一个 MCP 服务器,只提供一个 exec 工具,在隔离网络、受限的沙箱中运行助手提供的 Python 代码,并返回标准输出、标准错误和退出码。

可以做什么
在沙箱中运行 Python 代码,返回 stdout、stderr、退出码、耗时以及截断或超时标记,可传入 stdin 并指定单次超时。使用内置的 PyYAML、Jinja2、Pillow、numpy、pandas、matplotlib 在运行中做数据处理、模板渲染和绘图。非零退出码和超时属于正常结果,而不是工具错误。
适用场景
适合让助手通过编写代码来完成计算、数据转换或生成文件,而不是调用大量细碎工具,并且希望这些代码被限制在一次性沙箱中。如果需要 shell 访问、Python 以外的语言,或让执行的代码访问网络,则不太适用。
运行要求
以本地进程方式运行,通常使用已发布的 Docker 镜像,需要可写的 /tmp tmpfs 和只读根文件系统。通过环境变量配置,例如 MCP_EXEC_TRANSPORT(stdio、http 或 sse)、MCP_EXEC_DEFAULT_TIMEOUT_S、MCP_EXEC_MAX_TIMEOUT_S、MCP_EXEC_MAX_OUTPUT_BYTES 和 MCP_EXEC_MAX_STDIN_BYTES。stdio 模式无需账号或 API 密钥。
安装前请注意
exec 是权限最大的接口,应通过助手的工具策略仅对受信任角色开放。网络隔离仅在 stdio 下成立:使用 HTTP 或 SSE 时容器需要监听端口,除非在编排层禁止出站流量,否则沙箱代码可能访问网络。每个实例内的运行是串行执行的。设置 MCP_EXEC_AUTH_TOKEN 后,HTTP/SSE 请求必须携带匹配的 X-MCP-AUTH 头;留空则关闭该校验。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Exec Sandbox,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

mcp-exec

English | Русский

[Version] [MCP Registry] [Docker Pulls] [Docker Image Version] [Build] [Go Version] [Go Report Card] [License: MIT] [Issues] [Last Commit]

Public OSS MCP server (Go, MIT) exposing a single powerful tool — exec — that runs caller-supplied Python code in a network-isolated, locked-down sandbox and returns stdout / stderr / exit_code. It is the "code-execution mode" building block: instead of flooding an agent's context with hundreds of tool schemas, the agent writes code that orchestrates the work.

Works over three transports — stdio / HTTP / SSE — with an identical tool set everywhere (official modelcontextprotocol/go-sdk).

The exec tool

Input: { code: string (required), timeout_s?: int, stdin?: string } Output: { stdout, stderr, exit_code, duration_ms, truncated, timed_out }

  • A non-zero exit_code or timed_out=true is a normal result, not a tool error. Only invalid input (empty code, oversized stdin) is a tool-call error.
  • Sandbox v1: Python 3 with stdlib + PyYAML, Jinja2, Pillow, numpy, pandas, matplotlib.

Security model (invariants)

Per execution: no network, non-root, cap-drop=ALL, no-new-privileges, read-only rootfs, no CAP_SYS_ADMIN, ephemeral tmpdir (cleaned up), wall-clock timeout (kills the whole process-group), memory/PID/CPU limits, capped output (1 MiB → truncated). Runs are serialized within an instance; scale out with replicas. Caller data (code/stdin/output) is never persisted and never logged in full — only metadata.

exec is the most powerful surface there is. When embedding it in an agent, gate it behind that agent's tool-policy (trusted roles only).

Network note: --network none only applies to stdio. In HTTP/SSE the container needs networking to serve its port, so sandboxed code would inherit egress — deny it at the orchestrator. In k8s, a NetworkPolicy that allows ingress to the port and denies all egress:

yaml
apiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata: { name: mcp-exec-lockdown }spec:  podSelector: { matchLabels: { app: mcp-exec } }  policyTypes: [Ingress, Egress]  ingress: [{ ports: [{ port: 8080 }] }]  egress: []   # deny all egress → sandbox has no network

Run

bash
go build -o mcp-exec ./cmd/mcp-execMCP_EXEC_TRANSPORT=stdio ./mcp-exec

Docker (recommended production posture):

bash
docker run --rm -i --network none --read-only --cap-drop ALL \  --security-opt no-new-privileges --user 65532:65532 \  --tmpfs /tmp:rw,noexec,nosuid,size=64m \  --memory 256m --pids-limit 128 --cpus 1 \  idconstruct/mcp-exec

--tmpfs /tmp is required: the rootfs is read-only, and each run needs a writable ephemeral workspace (cleaned up after).

Optional auth (HTTP/SSE)

Set MCP_EXEC_AUTH_TOKEN to require every HTTP/SSE request to carry a matching X-MCP-AUTH header (constant-time compare; 401 otherwise). Empty token disables it. Not applicable to stdio.

Configuration

Env varPurposeDefault
MCP_EXEC_TRANSPORTstdio | http | ssestdio
MCP_EXEC_ADDRlisten address for http/sse:8080
MCP_EXEC_DEFAULT_TIMEOUT_Sdefault wall-clock timeout30
MCP_EXEC_MAX_TIMEOUT_Stimeout ceiling300
MCP_EXEC_MAX_OUTPUT_BYTEScombined stdout+stderr cap1048576
MCP_EXEC_MAX_STDIN_BYTESstdin size cap1048576
MCP_EXEC_PYTHONinterpreter pathpython3
MCP_EXEC_AUTH_TOKENif set, http/sse require X-MCP-AUTH header (constant-time); empty = off``

Not in v1

bash / multi-language, network from the sandbox, proxying other MCP servers into the sandbox.

License

MIT.

来源:README.md,提交 ae987e0

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.5.4最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分