sandbox-mcp-server/SKILL.md
Sandbox MCP Server 是一个隔离的代码执行环境,提供完整的文件系统操作、命令执行、 代码分析、测试运行和远程桌面能力。当你需要执行代码、操作文件、运行测试、 分析代码结构、或需要图形界面操作时使用此技能。支持 Python、Node.js、Java 等多语言环境。
npx skillsauth add s1366560/agi-demos sandboxInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Sandbox 是一个功能完备的隔离执行环境,通过 MCP (Model Context Protocol) 提供以下核心能力:
所有操作默认在 /workspace 目录下进行。路径可以是:
/workspace,如 src/main.py/workspace 内部,如 /workspace/src/main.py⚠️ 安全限制: 不允许访问 /workspace 外部的文件
read - 读取文件读取文件内容,返回带行号的文本。
{
"tool": "read",
"arguments": {
"file_path": "src/main.py",
"offset": 0, // 起始行 (0-based)
"limit": 2000 // 最大行数
}
}
使用场景:
返回格式:
1 import os
2 from pathlib import Path
3
4 def main():
5 pass
write - 写入文件创建或覆盖文件。自动创建父目录。
{
"tool": "write",
"arguments": {
"file_path": "src/new_module.py",
"content": "# New module\n\ndef hello():\n return 'world'"
}
}
使用场景:
edit - 编辑文件通过查找替换修改文件内容。
{
"tool": "edit",
"arguments": {
"file_path": "src/main.py",
"old_text": "def old_function():\n pass",
"new_text": "def new_function():\n return True"
}
}
使用场景:
注意事项:
old_text 必须精确匹配(包括空格和换行)patch - 应用补丁使用 unified diff 格式应用补丁。
{
"tool": "patch",
"arguments": {
"file_path": "src/main.py",
"patch": "--- a/src/main.py\n+++ b/src/main.py\n@@ -1,3 +1,4 @@\n import os\n+import sys\n from pathlib import Path"
}
}
glob - 查找文件通过 glob 模式查找文件。
{
"tool": "glob",
"arguments": {
"pattern": "**/*.py", // Glob 模式
"include_hidden": false, // 是否包含隐藏文件
"max_results": 100 // 最大结果数
}
}
常用模式:
**/*.py - 所有 Python 文件src/**/*.ts - src 目录下所有 TypeScript 文件*.json - 当前目录的 JSON 文件**/test_*.py - 所有测试文件grep - 搜索内容在文件中搜索文本或正则表达式。
{
"tool": "grep",
"arguments": {
"pattern": "def\\s+\\w+\\(", // 搜索模式
"path": "src/", // 搜索路径
"file_pattern": "*.py", // 文件过滤
"is_regex": true, // 是否正则表达式
"context_lines": 2 // 上下文行数
}
}
使用场景:
list - 列出目录列出目录内容。
{
"tool": "list",
"arguments": {
"path": "src/",
"recursive": false,
"include_hidden": false
}
}
bash - 执行命令在 sandbox 中执行 bash 命令。
{
"tool": "bash",
"arguments": {
"command": "python -m pytest tests/ -v",
"timeout": 300, // 超时秒数 (最大 600)
"working_dir": "project/" // 工作目录
}
}
使用场景:
python script.pypip install -r requirements.txtnpm run buildpytest tests/git status安全限制:
rm -rf /, mkfs, fork bomb 等)预装环境:
Python 3.13 (及 /opt/skills-venv 虚拟环境)
Node.js 22 (npm, pnpm, yarn, bun)
Java 21 (maven, gradle)
Git, ffmpeg, pandoc, LibreOffice
中文支持:
Locale: zh_CN.UTF-8
时区: Asia/Shanghai
预装中文字体:
- Noto Sans CJK (思源黑体) - /usr/share/fonts/opentype/noto/
- Noto Serif CJK (思源宋体)
- 文泉驿微米黑 (WenQuanYi Micro Hei)
- 文泉驿正黑 (WenQuanYi Zen Hei)
- 文鼎楷体 (AR PL UKai)
- 文鼎明体 (AR PL UMing)
桌面输入法: IBus 拼音 (仅完整版)
Python 中文字体使用示例:
# Pillow 绘制中文
from PIL import ImageFont
font = ImageFont.truetype('/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc', 24)
# Matplotlib 中文
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['Noto Sans CJK SC', 'WenQuanYi Micro Hei']
plt.rcParams['axes.unicode_minus'] = False
# ReportLab PDF 中文
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
pdfmetrics.registerFont(TTFont('NotoSansCJK', '/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc'))
预装 Python 包:
# 文档处理
pypdf, pdfplumber, reportlab, pdf2image
python-docx, openpyxl, pandas
# 图像处理
pillow, imageio, numpy, matplotlib
# Web 自动化
playwright (已安装 chromium)
# 开发工具
pytest, black, ruff, mypy
预装 Node.js 包:
pptxgenjs, docx, typescript, vite, parcel
remotion, puppeteer, sharp, tailwindcss
ast_parse - AST 解析解析 Python 文件的 AST 结构。
{
"tool": "ast_parse",
"arguments": {
"file_path": "src/main.py",
"include_docstrings": true
}
}
返回信息:
ast_find_symbols - 查找符号在 AST 中查找特定符号。
{
"tool": "ast_find_symbols",
"arguments": {
"file_path": "src/main.py",
"symbol_name": "MyClass",
"symbol_type": "class" // class, function, method
}
}
ast_extract_function - 提取函数提取函数的完整代码。
{
"tool": "ast_extract_function",
"arguments": {
"file_path": "src/main.py",
"function_name": "process_data"
}
}
ast_get_imports - 获取导入获取文件的所有导入语句。
{
"tool": "ast_get_imports",
"arguments": {
"file_path": "src/main.py"
}
}
code_index_build - 构建索引为项目构建代码索引。
{
"tool": "code_index_build",
"arguments": {
"project_path": "src/",
"pattern": "**/*.py",
"exclude_dirs": ["__pycache__", ".venv"]
}
}
find_definition - 查找定义查找符号的定义位置。
{
"tool": "find_definition",
"arguments": {
"symbol_name": "MyClass"
}
}
find_references - 查找引用查找符号的所有引用。
{
"tool": "find_references",
"arguments": {
"symbol_name": "process_data"
}
}
call_graph - 调用图生成函数调用关系图。
{
"tool": "call_graph",
"arguments": {
"function_name": "main",
"max_depth": 3
}
}
dependency_graph - 依赖图生成模块依赖关系图。
{
"tool": "dependency_graph",
"arguments": {
"module_name": "src.main"
}
}
edit_by_ast - AST 编辑基于 AST 进行精确编辑。
{
"tool": "edit_by_ast",
"arguments": {
"file_path": "src/main.py",
"target_type": "function", // class, function, method
"target_name": "old_name",
"operation": "rename", // rename, delete
"new_value": "new_name"
}
}
使用场景:
batch_edit - 批量编辑一次执行多个编辑操作。
{
"tool": "batch_edit",
"arguments": {
"edits": [
{"file_path": "a.py", "old_text": "foo", "new_text": "bar"},
{"file_path": "b.py", "old_text": "baz", "new_text": "qux"}
],
"dry_run": false,
"stop_on_error": true
}
}
preview_edit - 预览编辑预览编辑效果(不实际修改)。
{
"tool": "preview_edit",
"arguments": {
"file_path": "src/main.py",
"old_text": "old_code",
"new_text": "new_code"
}
}
generate_tests - 生成测试为 Python 代码生成测试用例。
{
"tool": "generate_tests",
"arguments": {
"file_path": "src/calculator.py",
"function_name": "add", // 可选
"class_name": "Calculator", // 可选
"test_framework": "pytest",
"output_path": "tests/test_calculator.py"
}
}
run_tests - 运行测试执行测试并返回结果。
{
"tool": "run_tests",
"arguments": {
"path": "tests/",
"pattern": "test_*.py",
"verbose": true,
"coverage": true
}
}
analyze_coverage - 覆盖率分析分析测试覆盖率。
{
"tool": "analyze_coverage",
"arguments": {
"source_dir": "src/",
"test_dir": "tests/"
}
}
git_diff - 查看差异显示代码变更。
{
"tool": "git_diff",
"arguments": {
"file_path": "src/main.py", // 可选,不填则显示所有
"cached": false, // true 显示暂存区
"context_lines": 3
}
}
git_log - 提交历史查看 Git 提交历史。
{
"tool": "git_log",
"arguments": {
"max_count": 10,
"file_path": "src/main.py", // 可选
"since": "1 week ago" // 可选
}
}
generate_commit - 生成提交信息基于变更生成提交信息。
{
"tool": "generate_commit",
"arguments": {
"style": "conventional" // conventional, simple
}
}
start_terminal - 启动终端启动 Web 终端 (ttyd)。
{
"tool": "start_terminal",
"arguments": {
"port": 7681
}
}
访问: http://localhost:7681
stop_terminal - 停止终端{"tool": "stop_terminal", "arguments": {}}
get_terminal_status - 终端状态{"tool": "get_terminal_status", "arguments": {}}
start_desktop - 启动桌面启动 XFCE 远程桌面。
{
"tool": "start_desktop",
"arguments": {
"display": ":1",
"resolution": "1920x1080",
"port": 6080
}
}
访问: http://localhost:6080/vnc.html
支持分辨率: 1280x720, 1920x1080, 1600x900
stop_desktop - 停止桌面{"tool": "stop_desktop", "arguments": {}}
get_desktop_status - 桌面状态{"tool": "get_desktop_status", "arguments": {}}
restart_desktop - 重启桌面{
"tool": "restart_desktop",
"arguments": {
"resolution": "1920x1080"
}
}
1. glob pattern="**/*.py" → 找到所有 Python 文件
2. read file_path="README.md" → 了解项目
3. code_index_build project_path="src/" → 建立索引
4. ast_parse file_path="src/main.py" → 分析代码结构
1. read file_path="src/module.py" → 查看当前代码
2. preview_edit old_text="..." new_text="..." → 预览修改
3. edit file_path="src/module.py" old_text="..." new_text="..." → 执行修改
4. run_tests path="tests/" → 验证修改
1. grep pattern="ERROR" path="logs/" → 查找错误
2. read file_path="logs/app.log" offset=100 → 查看日志
3. bash command="python -c 'import module; print(module.debug())'" → 测试
1. start_desktop resolution="1920x1080" → 启动桌面
2. bash command="firefox https://example.com" → 打开浏览器
3. get_desktop_status → 获取 VNC URL
4. [用户通过浏览器访问 noVNC 进行图形操作]
# PDF 处理
bash command="python -c \"
from pypdf import PdfReader
reader = PdfReader('/workspace/doc.pdf')
print(len(reader.pages))
\""
# Excel 处理
bash command="python -c \"
import pandas as pd
df = pd.read_excel('/workspace/data.xlsx')
print(df.head())
\""
# Word 文档
bash command="pandoc input.docx -o output.md"
read 确认当前内容edit 时 old_text 要包含足够上下文batch_editpreview_edit 确认timeoutexit_code/opt/skills-venv 或创建新虚拟环境code_index_buildedit_by_astcall_graph 了解影响generate_tests 生成骨架analyze_coverage所有工具返回统一格式:
{
"content": [{"type": "text", "text": "结果或错误信息"}],
"isError": true/false,
"metadata": { ... }
}
常见错误:
File not found: 文件不存在Path is outside workspace: 路径越界Command blocked for security: 危险命令被阻止Command timed out: 命令超时| 服务 | 端口 | URL |
|------|------|-----|
| MCP Server | 8765 | ws://localhost:8765 |
| Web Terminal | 7681 | http://localhost:7681 |
| Remote Desktop | 6080 | http://localhost:6080/vnc.html |
tools
Replace with description of the skill and when Claude should use it.
development
Generate high-quality images using ModelScope's Z-Image API. Use this skill when the user wants to generate images using the specific Z-Image model or ModelScope API they provided. Trigger words: 'Zimage', 'ModelScope', 'generate zimage'.
tools
No-code automation democratizes workflow building. Zapier and Make (formerly Integromat) let non-developers automate business processes without writing code. But no-code doesn't mean no-complexity ...
content-media
Download YouTube video transcripts when user provides a YouTube URL or asks to download/get/fetch a transcript from YouTube. Also use when user wants to transcribe or get captions/subtitles from a YouTube video.