
maxim-saplin/mcp_safe_local_python_executor
Developer toolsЭта страница переведена автоматически. Технические детали смотрите в оригинале. Открыть оригинал
Студия MCP Server wrapping custom Python runtime (LocalPythonExecutor) из фреймворка Hugging Faces `smolagents`.
Обзор
Сервер MCP (stdio transport), который обертывает Hugging Face’s LocalPythonExecutor (из фреймворка smolagents). Это пользовательская среда выполнения Python, которая обеспечивает базовую изоляцию / безопасность при запуске кода Python, генерируемого локально LLM. Не требуется Docker или VM. Этот пакет позволяет представить исполнителя Python через MCP (Model Context Protocol) в качестве инструмента для приложений LLM, таких как Claude Desktop, Cursor или любой другой MCP-совместимый клиент. В случае Claude Desktop этот инструмент является простым способом добавить отсутствующий интерпретатор кода (доступен в качестве плагина в ChatGPT уже довольно давно).
Обзор (машинный перевод)
Сервер MCP (stdio transport), который обертывает Hugging Face’s [[Т1]][править править код]] Это пользовательский Python Runtime, который обеспечивает базовую изоляцию/безопасность при запуске кода Python, генерируемого локально LLM. Не требуется Docker или VM. Этот пакет позволяет представить исполнителя Python через MCP (Model Context Protocol) в качестве инструмента для приложений LLM, таких как Claude Desktop, Cursor или любой другой MCP-совместимый клиент. В случае Claude Desktop этот инструмент является простым способом добавить отсутствующий интерпретатор кода (доступен в качестве плагина в ChatGPT уже довольно давно).
Особенности
- Инструмент для экспозиций
run_pythonБолее безопасное выполнение кода Python по сравнению с прямым использованием Pythoneva()lRan via uv в Python venv - Файлы I/O не допускаются Ограниченный список импорта
- коллекции
- дата
- итертулы математика
- очередь случайный
- Ре
- Статус
- статистика время
- unicodata
Безопасность
Будьте осторожны с выполнением кода, созданного LLM на вашем компьютере, держитесь подальше от MCP-серверов, которые запускают Python через командную строку или используют T4. Наиболее безопасным вариантом является использование VM или докер-контейнера, хотя он требует некоторых усилий для настройки, потребляет ресурсы / медленнее.
Эта страница переведена автоматически. Технические детали смотрите в оригинале.
README
Показан фрагмент оригинального README. Открыть оригинал.
Safe Local Python Executor
An MCP server (stdio transport) that wraps Hugging Face’s LocalPythonExecutor
(from the smolagents framework). It is a custom Python runtime that
provides basic isolation/security when running Python code generated by LLMs locally. It does not require Docker or VM.
This package allows to expose the Python executor via MCP (Model Context Protocol) as a tool for LLM apps like Claude Desktop, Cursor or any other MCP compatible client.
In case of Claude Desktop this tool is an easy way to add a missing Code Interpreter (available as a plugin in ChatGPT for quite a while already).
Features
- Exposes
run_pythontool - Safer execution of Python code compared to direct use of Python
eva()l - Ran via uv in Python venv
- No file I/O ops are allowed
- Restricted list of imports
- collections
- datetime
- itertools
- math
- queue
- random
- re
- stat
- statistics
- time
- unicodedata
Security
Be careful with execution of code produced by LLM on your machine, stay away from MCP servers that run Python via command line or using eval(). The safest option is using a VM or a docker container, though it requires some effort to set-up, consumes resources/slower. There’re 3rd party servcices providing Python runtime, though they require registration, API keys etc.
LocalPythonExecutor provides a good balance between direct use of local Python environment (which is easier to set-up) AND remote execution in Dokcer container or a VM/3rd party service (which is safe). Hugginng Face team has invested time into creating a quick and safe option to run LLM generated code used by their code agents. This MCP server builds upon it:
To add a first layer of security, code execution in smolagents is not performed by the vanilla Python interpreter. We have re-built a more secure LocalPythonExecutor from the ground up.
Read more here.
Installation and Execution
Installing via Smithery
To install Safe Local Python Executor for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @maxim-saplin/mcp_safe_local_python_executor --client claude
Installing Manually
- Install
uv(e.h.brew install uvon macOS or use official docs) - Clone the repo, change the directory
cd mcp_safe_local_python_executor
Установка
npx -y @smithery/cli install @maxim-saplin/mcp_safe_local_python_executor --client claudeКонфигурация
{
"mcpServers": {
"safe-local-python-executor": {
"command": "uv",
"args": [
"--directory",
"/path/to/mcp_local_python_executor/",
"run",
"mcp_server.py"
]
}
}
}