- Explore MCP Servers
- sandbox-fusion-mcp
Sandbox Fusion Mcp
What is Sandbox Fusion Mcp
sandbox-fusion-mcp is an implementation of a Machine Code Protocol (MCP) server that interfaces with Sandbox Fusion, providing a code interpreter functionality for large language models.
Use cases
Use cases include executing code snippets in various programming languages, running Jupyter notebooks for data analysis, and integrating with large language models for enhanced code understanding and execution.
How to use
To use sandbox-fusion-mcp, clone the repository, create and activate a Conda environment, configure the server using environment variables, and run the server using the provided launch script or Python script.
Key features
Key features include support for multiple programming languages, execution of Jupyter notebooks, interaction with clients via stdio, and provision of resources and tools APIs for large language models.
Where to use
sandbox-fusion-mcp can be used in fields such as machine learning, data analysis, educational tools, and any application requiring code execution and interpretation.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Overview
What is Sandbox Fusion Mcp
sandbox-fusion-mcp is an implementation of a Machine Code Protocol (MCP) server that interfaces with Sandbox Fusion, providing a code interpreter functionality for large language models.
Use cases
Use cases include executing code snippets in various programming languages, running Jupyter notebooks for data analysis, and integrating with large language models for enhanced code understanding and execution.
How to use
To use sandbox-fusion-mcp, clone the repository, create and activate a Conda environment, configure the server using environment variables, and run the server using the provided launch script or Python script.
Key features
Key features include support for multiple programming languages, execution of Jupyter notebooks, interaction with clients via stdio, and provision of resources and tools APIs for large language models.
Where to use
sandbox-fusion-mcp can be used in fields such as machine learning, data analysis, educational tools, and any application requiring code execution and interpretation.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Content
Sandbox Fusion MCP 服务器
这是一个对接 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
Dev Tools Supporting MCP
The following are the main code editors that support the Model Context Protocol. Click the link to visit the official website for more information.










