Safe Local Python Executor/Interpreter
安全的本地 Python 执行器
一个 MCP 服务器(stdio 传输),它封装了 Hugging Face 的LocalPythonExecutor (来自smolagents框架)。它是一个自定义的 Python 运行时,在本地运行 LLM 生成的 Python 代码时提供基本的隔离/安全性。它不需要 Docker 或虚拟机。此包允许通过 MCP(模型上下文协议)将 Python 执行器公开为 LLM 应用(例如 Claude Desktop、Cursor 或任何其他兼容 MCP 的客户端)的工具。对于 Claude Desktop,此工具可以轻松添加缺少的代码解释器(ChatGPT 中已作为插件提供一段时间了)。
特征
公开
run_python工具与直接使用 Python
eva()l相比,Python 代码的执行更安全通过 Python venv 中的 uv 运行
不允许文件 I/O 操作
限制进口商品清单
收藏品
日期时间
迭代工具
数学
队列
随机的
关于
统计
统计数据
时间
unicode数据
Related MCP server: MCP Code Mode
安全
在你的机器上执行 LLM 生成的代码时要小心,远离通过命令行或使用eval()运行 Python 的 MCP 服务器。最安全的选择是使用虚拟机或 Docker 容器,尽管这需要一些设置工作,消耗资源/速度较慢。有一些第三方服务提供 Python 运行时,但它们需要注册、API 密钥等。
LocalPythonExecutor在直接使用本地 Python 环境(更易于设置)和在 Dokcer 容器或虚拟机/第三方服务中远程执行(更安全)之间提供了良好的平衡。Hugginng Face 团队投入了大量时间,创建了一个快速安全的选项,用于运行其代码代理使用的 LLM 生成的代码。此 MCP 服务器以此为基础构建:
为了增加第一层安全性,smolagents 中的代码执行并非由原生 Python 解释器执行。我们从头开始重新构建了一个更安全的 LocalPythonExecutor。
点击此处了解更多信息。
安装和执行
安装
uv(在 macOS 上brew install uv或者使用官方文档)克隆 repo,更改目录
cd mcp_safe_local_python_executor可以通过命令行
uv run mcp_server.py启动服务器,venv 将自动创建,依赖项(smollagents、mcp)将被安装
配置 Claude 桌面
确保已安装 Claude for Desktop(从claude.ai下载)
编辑 Claude for Desktop 配置文件:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json或者打开 Claude Desktop -> 设置 -> 开发者 -> 点击“编辑配置”按钮
添加以下配置:
{
"mcpServers": {
"safe-local-python-executor": {
"command": "uv",
"args": [
"--directory",
"/path/to/mcp_local_python_executor/",
"run",
"mcp_server.py"
]
}
}
}重启 Claude 桌面版
Python 执行器工具现在将在 Claude 中可用(您将在消息输入字段中看到锤子图标)
示例提示
配置完成后,您可以使用如下提示:
“使用 Python 计算 5 的阶乘”
“创建一个 100 以内的素数列表”
“解这个方程(使用 Python):x^2 + 5x + 6 = 0”
发展
克隆仓库。使用uv创建 venv,安装开发依赖项,运行测试:
uv venv .venv
uv sync --group dev
python -m pytest tests/Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Tools
Related MCP Servers
- MIT
- AlicenseAqualityDmaintenanceUniversal Python code execution MCP server that lets LLMs write and run Python for any task, with auto-install packages, streaming output, and automatic file display.91MIT
- Alicense-qualityDmaintenanceAn MCP server that provides secure code execution capabilities using AWS Bedrock AgentCore's CodeInterpreter, supporting Python, JavaScript, TypeScript, shell commands, and file operations.8MIT
- Flicense-qualityBmaintenanceA Python MCP server that allows ChatGPT to execute commands on your local PC via a secure Cloudflare tunnel.
Related MCP Connectors
Hosted MCP server connecting claude.ai, ChatGPT and other AI apps to your own computer
Security scanner for MCP servers. Detect vulnerabilities, prompt injection, and tool poisoning.
An MCP server that gives your AI access to the source code and docs of all public github repos
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/maxim-saplin/mcp_safe_local_python_executor'
If you have feedback or need assistance with the MCP directory API, please join our Discord server