Sandbox Fusion
FreeNot checkedConnects AI models to Sandbox Fusion environments for testing, training, and demonstrating agent interactions with simulated worlds
About
Connects AI models to Sandbox Fusion environments for testing, training, and demonstrating agent interactions with simulated worlds
README
这是一个对接 Sandbox Fusion 的 MCP (Machine Code Protocol) 服务器实现,可以为大语言模型提供代码解释器功能。
功能特点
- 支持多种编程语言的代码执行
- 支持 Jupyter 笔记本执行
- 通过 stdio 交互方式与客户端通信
- 提供资源和工具 API 供大语言模型调用
支持的编程语言
- Python
- JavaScript/TypeScript
- Bash
- R
- Julia
- Go
- Java
- C++
- Rust
- PHP
安装
环境要求
- Python 3.10+
- Conda (推荐用于环境管理)
安装步骤
- 克隆仓库
git clone https://github.com/happyZYM/sandbox-fusion-mcp.git
cd sandbox-fusion-mcp
- 创建并激活 Conda 环境
conda env create -f environment.yml
conda activate mcp-sandbox-fusion
配置
服务器通过环境变量进行配置:
SANDBOX_FUSION_ENDPOINT: Sandbox Fusion API 的端点地址,默认为http://localhost:8000
运行
使用提供的启动脚本运行服务器:
./launch.sh
或者直接运行 Python 脚本:
python server.py
API 说明
资源 (Resources)
服务器提供以下资源:
sandbox://languages- 获取支持的编程语言列表sandbox://endpoint- 获取当前配置的 Sandbox Fusion 端点信息
工具 (Tools)
服务器提供以下工具:
execute_code- 执行代码片段- 参数:
code(字符串): 要执行的代码language(字符串,可选): 编程语言,默认为 "python"timeout(整数,可选): 执行超时时间(秒)
- 参数:
execute_jupyter- 执行 Jupyter 笔记本- 参数:
notebook_content(字符串): Jupyter 笔记本内容(JSON 格式)timeout(整数,可选): 执行超时时间(秒)
- 参数:
提示模板 (Prompts)
服务器提供以下提示模板:
code_execution_prompt- 代码执行提示模板- 参数:
language(字符串,可选): 编程语言,默认为 "python"description(字符串,可选): 代码任务描述
- 参数:
jupyter_execution_prompt- Jupyter 笔记本执行提示模板- 参数:
description(字符串,可选): 笔记本任务描述
- 参数:
与客户端集成
MCP 服务器使用 stdio 交互方式与客户端通信,客户端可以通过 JSON-RPC 进行通信。
示例:列出可用工具
{"jsonrpc": "2.0", "method": "list_tools", "params": {}, "id": 1}
故障排除
如果遇到问题,请检查以下日志文件:
mcp_server.log: 服务器主日志mcp_stderr.log: 标准错误输出日志
开发
项目结构
sandbox-fusion-mcp/
├── server.py - MCP 服务器实现
├── launch.sh - 启动脚本
├── environment.yml - Conda 环境配置
└── README.md - 文档
添加新功能
要添加新的工具或资源,请按照以下模式修改 server.py:
@mcp_server.tool()
def your_tool_name(param1: str, param2: int = 0) -> str:
"""
工具描述
参数:
- param1: 参数1描述
- param2: 参数2描述
"""
# 实现逻辑
return json.dumps(result)
@mcp_server.resource("sandbox://your_resource")
def your_resource_function() -> str:
"""资源描述"""
# 实现逻辑
return json.dumps(result)
注意事项
- 确保
stderr被重定向到日志文件,以免干扰 stdio 通信 - 工具函数应返回 JSON 字符串格式的结果
- 处理所有可能的异常,并在发生错误时返回有用的错误信息
许可证
MIT
Installing Sandbox Fusion
This server has no published package — it is built from source. Open the repository and follow its README.
▸ github.com/astricaelus/sandbox-fusion-mcpFAQ
Is Sandbox Fusion MCP free?
Yes, Sandbox Fusion MCP is free — one-click install via Unyly at no cost.
Does Sandbox Fusion need an API key?
No, Sandbox Fusion runs without API keys or environment variables.
Is Sandbox Fusion hosted or self-hosted?
Self-hosted: the server runs locally on your machine via the install command above.
How do I install Sandbox Fusion in Claude Desktop, Claude Code or Cursor?
Open Sandbox Fusion on unyly.org, pick your client tab (Claude Desktop, Claude Code, Cursor) and press Install — the config is generated automatically, no JSON editing.
Related MCPs
Fetch
Web content fetching and conversion for efficient LLM usage.
AWS KB Retrieval
Retrieval from AWS Knowledge Base using Bedrock Agent Runtime.
by modelcontextprotocolSpring AI MCP Server
Provides auto-configuration for setting up an MCP server in Spring Boot applications.
llm-analysis-assistant
A very streamlined mcp client that supports calling and monitoring stdio/sse/streamableHttp, and can also view request responses through the /logs page. It also
by xuzexin-hzCompare Sandbox Fusion with
Not sure what to pick?
Find your stack in 60 seconds
Author?
Embed badge for your README
Browse similar
All ai MCPs
