安全本地 Python 执行器
通过 MCP 协议提供安全的本地 Python 代码执行环境,适用于 LLM 应用。
快速入门
- 安装
uv
工具(例如 macOS 上运行brew install uv
)。 - 克隆仓库并进入目录:
git clone https://github.com/maxim-saplin/mcp_safe_local_python_executor.git cd mcp_safe_local_python_executor
- 启动服务器:
uv run mcp_server.py
- 配置 Claude Desktop:
- 编辑配置文件(macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
)。 - 添加以下内容:
{ "mcpServers": { "safe-local-python-executor": { "command": "uv", "args": [ "--directory", "/path/to/mcp_local_python_executor/", "run", "mcp_server.py" ] } } }
- 编辑配置文件(macOS:
- 重启 Claude Desktop,即可使用 Python 执行工具。
示例指令
- 计算 5 的阶乘
- 创建 100 以内的质数列表
- 使用 Python 解方程:x^2 + 5x + 6 = 0