MS

maxim-saplin/mcp_safe_local_python_executor

Developer tools

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

48 stars 12 forks 品質 66 トレンド 13MIT

ステディオ MCP Hugging Facesの[`smolagents`]フレームワークからカスタムPythonランタイム(LocalPythonExecutor)をラップするサーバー.

概要

Hugging Face の LocalpythonExecutor をラップする MCP サーバー (stdio トランスポート) (smolagents フレームワークから)。 ローカルLLMで生成されたPythonコードを実行する際の基本的な分離/セキュリティを提供するカスタムPythonランタイムです。 Docker や VM を必要としません。 このパッケージは、Claude Desktop、Ccursor、その他のMCP互換クライアントなどのLMアプリ用のツールとして、MCP(Model Context Protocol)を介してPythonの実行者を明示することができます。 Claudeデスクトップの場合、このツールは、欠落しているコード通訳を追加する簡単な方法です(すでにしばらくの間、ChatGPTのプラグインとして利用可能).

概要(AI 翻訳)

Hugging Face の [[T0] をラップする MCP サーバー (stdio トランスポート) ([smolagents]フレームワークから) それはカスタムPythonのランタイムです。 LLM がローカルで生成した Python コードを実行する際の基本的な分離/セキュリティを提供します。 Docker や VM を必要としません。 このパッケージは、Claude Desktop、Ccursor、その他のMCP互換クライアントなどのLMアプリ用のツールとして、MCP(Model Context Protocol)を介してPythonの実行者を明示することができます。 Claudeデスクトップの場合、このツールは、欠落しているコード通訳を追加する簡単な方法です(すでにしばらくの間、ChatGPTのプラグインとして利用可能)。

##特徴

  • 露出 [[T2] ツール
  • Pythonの直接使用と比較してPythonのコードのより安全な実行[eva()l]
  • Python venv の uv による Ran
  • ファイルI/O が許可されていない
  • 輸入の制限されたリスト
  • コレクション
  • 日付時刻
  • ツール
  • 数学
  • キュー
  • ランダム
  • 再
  • ステータス
  • 統計
  • 時間
  • ユニコードデータ

セキュリティ

お使いのマシンでLLMによって生成されたコードの実行に注意してください。, コマンドラインを介してPythonを実行したり、[eval()を使用してMCPサーバーから離れる. 最も安全なオプションは、VM またはドッカーコンテナを使用しますが、セットアップにいくつかの努力が必要ですが、リソース/スローアーを消費します.

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。

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_python tool
  • 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

  1. Install uv (e.h. brew install uv on macOS or use official docs)
  2. Clone the repo, change the directory cd mcp_safe_local_python_executor
GitHub で README 全文を見る

インストール

npx -y @smithery/cli install @maxim-saplin/mcp_safe_local_python_executor --client claude
MCP 初心者?mcpskill.org のガイドから始めましょう →

設定

{ "mcpServers": { "safe-local-python-executor": { "command": "uv", "args": [ "--directory", "/path/to/mcp_local_python_executor/", "run", "mcp_server.py" ] } } }