连接器指南阅读约 4 分钟13 个 MCP 工具7 种语言

如何通过 MCP 将 E2B 连接到 Cursor

用 AI 管理团队的 E2B 云沙箱:列出、启动、查看、暂停、恢复和延长沙箱,读取它们的日志以及 CPU、内存和磁盘指标,并浏览团队的模板、构建和快照。

HC作者:HelpCode 团队更新于 4 分钟阅读 在 GitHub 开源

无需信用卡 · 7 天试用 · 提供自托管方案

E2B

E2B

Manage E2B cloud sandboxes for AI agents: list, start, inspect, pause, resume and extend sandboxes, read their logs and CPU, memory and disk metrics, and browse the team's templates, builds and snapshots.

个工具

13

区域

INTL

类别

基础设施

身份验证

API Key

所需环境变量

E2B_API_KEY
在 Cloud 上一键安装

7 天免费试用 · 无需信用卡

  • 7 天免费试用
    无需信用卡
  • 符合 GDPR,SOC 2 就绪
    数据驻留欧盟,审计日志
  • 在 GitHub 开源
    开源 · AGPL-3.0
  • 支持 ChatGPT、Claude、Gemini
    任何兼容 MCP 的客户端

跳过安装。2 分钟内即可运行。

在 cloud.anythingmcp.com 开始免费试用,一键添加 E2B,然后将你的 AI 客户端(Claude、ChatGPT、Copilot 或 Cursor)指向生成的 MCP 端点。无需 Docker,无需 git clone,无需任何工程经验。

开始免费试用

摘要

用 AI 管理团队的 E2B 云沙箱:列出、启动、查看、暂停、恢复和延长沙箱,读取它们的日志以及 CPU、内存和磁盘指标,并浏览团队的模板、构建和快照。

试试这样问

E2B 的示例提示

点击任意提示即可复制,然后粘贴到 Claude、ChatGPT、Cursor、Gemini、Copilot 或 OpenClaw 中,在该连接器上运行。

E2B · 通过 MCP 实时
分享
Opus 4.7

Claude 是 AI,可能会出错。请核对回答。

💡 无需安装? 直接使用 cloud.anythingmcp.com。 登录、点击 Connectors → E2B、粘贴凭证、生成 MCP API key,即可完成。无 Docker、无 git clone、无本地服务器。

E2B + Cursor

用 AI 管理团队的 E2B 云沙箱:列出、启动、查看、暂停、恢复和延长沙箱,读取它们的日志以及 CPU、内存和磁盘指标,并浏览团队的模板、构建和快照。

前提条件

完整的设置说明已内置在连接器中 (在 store 中选择连接器时可见)。所需环境变量:

E2B_API_KEY

步骤 1 — 获取凭证

设置大约需要 2 分钟。你需要一个 E2B 账户;运行中的沙箱按秒向团队计费(Hobby 套餐附带免费额度)。

  1. 登录 https://e2b.dev/dashboard,打开 Keys(https://e2b.dev/dashboard?tab=keys)。
  2. 复制一个团队 API 密钥。它以 e2b_ 开头;个人访问令牌(sk_e2b_...)在这里无效。
  3. 把它粘贴到 E2B_API_KEY。连接器通过 X-API-Key 请求头发送它,该密钥代表整个团队。
  4. 安装连接器并运行 e2b_list_sandboxes 检查密钥。

哪些工具会产生费用:e2b_create_sandbox 启动沙箱,e2b_resume_sandbox 恢复已暂停的沙箱。运行中的沙箱按秒对 CPU 和内存计费,直到超时、被暂停或被终止;e2b_set_sandbox_timeout 把结束时间往后推时,计费也会相应延长。AI 会在启动、恢复或延长沙箱之前征求你的确认,保持较短的 timeout,并在工作完成后暂停沙箱或让它们到期。读取类工具免费,已暂停的沙箱不收取计算费用。

模板:e2b_list_default_templates 显示 E2B 的现成模板,例如 base、code-interpreter-v1 和 desktop,以及 CPU、内存、磁盘和 envd 版本;e2b_list_templates 列出团队自己的模板及其别名、构建状态和启动次数;e2b_list_template_builds 列出某个模板的构建。

启动沙箱:e2b_create_sandbox 接收 template_id(ID 或别名,默认 base)、以秒为单位的 timeout(默认 300),以及可选的 metadata(用于之后查找的字符串键值对)、env_vars、auto_pause(超时时暂停而不是结束)和 allow_internet_access。响应包含 sandboxID 和 domain。AI 不会把你未批准的密钥信息放进 env_vars。

查看:e2b_list_sandboxes 可按 state(running 或 paused)、template、metadata(如 user=abc&app=prod)和 started_after 过滤;e2b_get_sandbox 显示模板、资源、开始和结束时间、状态及网络设置;e2b_get_sandbox_logs 读取系统和进程日志,可按最低级别或搜索文本(区分大小写)过滤;e2b_get_sandbox_metrics 显示 CPU、内存和磁盘使用量随时间的变化。

生命周期:e2b_set_sandbox_timeout 从现在起设置新的结束时间并替换原来的时间,因此设置较短的值会让沙箱更早结束。e2b_pause_sandbox 冻结沙箱及其文件,默认也包括内存(memory: false 只保留文件系统,恢复时沙箱会重新启动);e2b_resume_sandbox 恢复沙箱,或延长正在运行的沙箱;e2b_list_snapshots 列出已保存的快照。

安装时关闭的工具:e2b_kill_sandbox。它无法撤销(进程、内存和文件都会丢失),因此由工作区管理员在团队需要时开启。

运行代码不属于本连接器:命令、文件和代码解释器由每个沙箱自身提供(其 envd 代理位于 https://<port>-<sandboxID>.e2b.app),并使用各自的访问令牌;团队 API 密钥不能发送到运行生成代码的沙箱中。如需运行代码,请使用 E2B SDK(e2b、@e2b/code-interpreter)或封装了它们的工具。沙箱访问令牌会从响应中移除。

数据格式:时间为 UTC 的 ISO 8601 格式;指标的 start 和 end 为 Unix 秒,日志的 cursor 值为 Unix 毫秒。cpuCount 是 vCPU 数,memoryMB 和 diskSizeMB 以兆字节计。

分页:e2b_list_sandboxes、e2b_list_templates、e2b_list_template_builds 和 e2b_list_snapshots 接收 limit(默认 50,最多 100),在 _headers.x-next-token 中返回下一页令牌,列表本身位于 data 中;AI 会把令牌作为 next_token 传回,直到它不再出现。e2b_list_sandboxes 还返回 _headers.x-total-running。e2b_get_sandbox_logs 从某个 cursor 起按 forward 或 backward 返回最多 1,000 行(默认 100 行)。

限制:团队有同时运行的沙箱数量上限。timeout 受套餐限制:Hobby 为 1 小时,Pro 为 24 小时。

常见错误:400 表示参数错误(例如超时超过套餐上限);401 表示密钥错误,或使用了访问令牌而不是团队 API 密钥;403 表示团队无权使用该模板;404 表示沙箱或模板不存在(超时的沙箱已被移除);409 表示沙箱已暂停或正在暂停;429 表示同时运行的沙箱或请求过多(AI 会等待,而不是循环重试);500 和 503 是 E2B 端的问题。

该连接器不在沙箱内运行代码、命令或文件操作,也不构建模板。

步骤 2 — 安装 adapter

curl -fsSL https://raw.githubusercontent.com/HelpCode-ai/anythingmcp/main/docker-compose.quickstart.yml -o docker-compose.yml
printf 'JWT_SECRET=%s\nENCRYPTION_KEY=%s\n' "$(openssl rand -hex 32)" "$(openssl rand -hex 32)" > .env
docker compose up -d

步骤 3 — 在 Cursor 中添加连接器

你的服务器 URL: 在 AnythingMCP 中打开 MCP Servers → 此连接器所在的服务器,复制它的 URL(https://cloud.anythingmcp.com/mcp/…)。本指南中出现 YOUR_SERVER_ID 的地方都用它替换。

Cursor 从 ~/.cursor/mcp.json 读取 MCP 服务器。添加以下条目:

{
  "mcpServers": {
    "anythingmcp": {
      "url": "https://cloud.anythingmcp.com/mcp/YOUR_SERVER_ID",
      "headers": { "X-API-Key": "YOUR_MCP_API_KEY" }
    }
  }
}
  1. 在 AnythingMCP 的 MCP Servers → 你的服务器 → API keys 中创建 MCP API 密钥,并用它替换 YOUR_MCP_API_KEY。
  2. 保存文件并重启 Cursor。
  3. 打开 Cursor → Settings → MCP,确认 anythingmcp 已列出并处于已连接状态。
  4. 开始对话,智能体现在可以调用 E2B 的工具。

可用工具

ToolWhat it does
e2b_list_sandboxesList the E2B sandboxes of the team, newest first: sandbox id, template, alias, state (running or paused), start and end time, CPU, memory…
e2b_get_sandboxRead one E2B sandbox: template and alias, state, start and end time, CPU, memory and disk, envd version, domain, internet access, network…
e2b_create_sandboxStart a new E2B sandbox from a template
e2b_set_sandbox_timeoutSet when an E2B sandbox ends: timeout seconds counted from now, replacing the previous end time (a shorter value ends it sooner)
e2b_pause_sandboxPause a running E2B sandbox, saving its files and, by default, its memory, so it can be resumed later with e2b_resume_sandbox
e2b_resume_sandboxResume a paused E2B sandbox (or extend a running one) and return its details
e2b_kill_sandboxKill an E2B sandbox immediately
e2b_get_sandbox_logsRead the logs of one E2B sandbox (system and process output) with timestamp, level and message; filter by minimum level or a search string
e2b_get_sandbox_metricsRead the resource use of one E2B sandbox over time: CPU count and usage percent, memory and disk used and total, per timestamp
e2b_list_templatesList the team's E2B templates: template id, aliases and names, build id and status, CPU, memory and disk, public flag, spawn count, last…
e2b_list_template_buildsList the builds of one E2B template with build id, status, CPU, memory, disk, envd version and dates
e2b_list_default_templatesList E2B's ready-made default templates (such as base, code-interpreter-v1 and desktop) with their aliases, CPU, memory, disk and envd…
e2b_list_snapshotsList the team's E2B sandbox snapshots with id, name, the sandbox they came from and dates; filter by sandbox or name

示例提示

  • “现在有哪些 E2B 沙箱在运行?每个用的是什么模板,什么时候结束?”
  • “用元数据 user=demo 启动一个 code-interpreter-v1 沙箱,运行 10 分钟,并告诉我它的 sandbox id。”
  • “显示沙箱 ixk2b9z0 的错误日志。”
  • “沙箱 ixk2b9z0 自启动以来用了多少 CPU 和内存?”
  • “暂停所有带有元数据 app=staging 且正在运行的沙箱。”

FAQ

Cursor 免费套餐支持自定义 MCP 服务器吗? 支持,Hobby、Pro 和 Business 套餐均可使用 MCP。

下一步

这份指南对你有帮助吗?

你的 E2B 智能体只差一次点击。

安装连接器,粘贴密钥,向 Cursor 提问。免费试用 7 天,无需信用卡。

相关指南

连接器

如何通过 MCP 将 E2B 连接到 ChatGPT

用 AI 管理团队的 E2B 云沙箱:列出、启动、查看、暂停、恢复和延长沙箱,读取它们的日志以及 CPU、内存和磁盘指标,并浏览团队的模板、构建和快照。

连接器

如何通过 MCP 将 E2B 连接到 Claude

用 AI 管理团队的 E2B 云沙箱:列出、启动、查看、暂停、恢复和延长沙箱,读取它们的日志以及 CPU、内存和磁盘指标,并浏览团队的模板、构建和快照。

连接器

如何通过 MCP 将 E2B 连接到 Gemini

用 AI 管理团队的 E2B 云沙箱:列出、启动、查看、暂停、恢复和延长沙箱,读取它们的日志以及 CPU、内存和磁盘指标,并浏览团队的模板、构建和快照。

连接器

如何通过 MCP 将 E2B 连接到 Meta Muse

用 AI 管理团队的 E2B 云沙箱:列出、启动、查看、暂停、恢复和延长沙箱,读取它们的日志以及 CPU、内存和磁盘指标,并浏览团队的模板、构建和快照。

连接器

E2B 接入 MCP:在任意 AI 智能体中管理云沙箱、日志、指标、模板和快照

用 AI 管理团队的 E2B 云沙箱:列出、启动、查看、暂停、恢复和延长沙箱,读取它们的日志以及 CPU、内存和磁盘指标,并浏览团队的模板、构建和快照。

连接器

如何通过 MCP 将 E2B 连接到 Microsoft Copilot

用 AI 管理团队的 E2B 云沙箱:列出、启动、查看、暂停、恢复和延长沙箱,读取它们的日志以及 CPU、内存和磁盘指标,并浏览团队的模板、构建和快照。