Skip to main content
Glama

Safe Local Python Executor/Interpreter

安全なローカル Python エグゼキュータ

Hugging FaceのLocalPythonExecutorsmolagentsフレームワークより)をラップするMCPサーバー(stdioトランスポート)です。これは、LLMによって生成されたPythonコードをローカルで実行する際に基本的な分離性とセキュリティを提供するカスタムPythonランタイムです。DockerやVMは必要ありません。このパッケージは、Claude Desktop、Cursor、その他のMCP対応クライアントなどのLLMアプリ用のツールとして、MCP(Model Context Protocol)経由でPythonエグゼキューターを公開することを可能にします。Claude Desktopの場合、このツールは不足しているコードインタープリター(ChatGPTのプラグインとして既にかなり以前から利用可能)を簡単に追加する方法です。

特徴

  • run_pythonツールを公開する
  • Python eva()lを直接使用するよりも安全に Python コードを実行できます
  • Python venvでuv経由で実行
  • ファイルI/O操作は許可されません
  • 輸入制限リスト
    • コレクション
    • 日時
    • イターツール
    • 数学
    • ランダム
    • 統計
    • 統計
    • 時間
    • ユニコードデータ

安全

LLM によって生成されたコードを自分のマシンで実行する際は注意してください。コマンドラインやeval()を使って Python を実行する MCP サーバーは使用しないでください。最も安全な選択肢は VM または Docker コンテナを使用することですが、セットアップに多少の手間がかかり、リソースを消費し、速度も低下します。Python ランタイムを提供するサードパーティのサービスもありますが、登録や API キーなどが必要になります。

LocalPythonExecutor 、ローカルPython環境の直接利用(セットアップが容易)と、DokcerコンテナまたはVM/サードパーティサービスでのリモート実行(安全)のバランスに優れています。Hugginng Faceチームは、コードエージェントで使用されるLLM生成コードを迅速かつ安全に実行するためのオプションの開発に時間を費やしました。このMCPサーバーは、このソリューションを基盤としています。

セキュリティの第一層として、smolagents でのコード実行は標準の Python インタープリターでは実行されません。より安全な LocalPythonExecutor をゼロから再構築しました。

詳細はこちらをご覧ください。

インストールと実行

  1. uvをインストールします (macOS ではbrew install uv実行するか、公式ドキュメントを使用してください)
  2. リポジトリをクローンし、ディレクトリを変更しますcd mcp_safe_local_python_executor
  3. サーバーはコマンドラインuv run mcp_server.pyで起動できます。venv が自動的に作成され、依存関係 (smollagents、mcp) がインストールされます。

Claudeデスクトップの設定

  1. Claude for Desktop がインストールされていることを確認してください ( claude.aiからダウンロード)
  2. Claude for Desktop 構成ファイルを編集します。
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
    • または、Claude Desktop -> 設定 -> 開発者 -> 「設定の編集」ボタンをクリックします。
  3. 次の構成を追加します。
{ "mcpServers": { "safe-local-python-executor": { "command": "uv", "args": [ "--directory", "/path/to/mcp_local_python_executor/", "run", "mcp_server.py" ] } } }
  1. デスクトップ版のClaudeを再起動する
  2. Python 実行ツールが Claude で利用できるようになります (メッセージ入力フィールドにハンマーアイコンが表示されます)

プロンプトの例

設定が完了すると、次のようなプロンプトが使用できるようになります。

  • 「Python を使って 5 の階乗を計算する」
  • 「100までの素数のリストを作成してください」
  • 「この方程式を解いてください(Python を使用):x^2 + 5x + 6 = 0」

発達

リポジトリをクローンします。uv uv使用して venv を作成し、開発依存関係をインストールし、テストを実行します。

uv venv .venv uv sync --group dev python -m pytest tests/

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

local-only server

The server can only run on the client's local machine because it depends on local resources.

Hugging FacesのsmolagentsフレームワークからカスタムPythonランタイム(LocalPythonExecutor)をラップしたstdio MCPサーバー。このランタイムは、Docker、VM、クラウドランタイムと比較してセットアップが容易でありながら、安全対策を提供し、ランタイム内で許可される操作/インポートを制限します。

  1. 特徴
    1. 安全
      1. インストールと実行
        1. Claudeデスクトップの設定
          1. プロンプトの例
            1. 発達

              Related MCP Servers

              • A
                security
                A
                license
                A
                quality
                An MCP server to run commands.
                Last updated -
                2
                265
                150
                TypeScript
                MIT License
                • Apple
              • -
                security
                A
                license
                -
                quality
                A Python-based MCP server that integrates OpenAPI-described REST APIs into MCP workflows, enabling dynamic exposure of API endpoints as MCP tools.
                Last updated -
                2
                39
                Python
                MIT License
                • Linux
                • Apple
              • A
                security
                A
                license
                A
                quality
                A server that provides a persistent Python REPL environment through the MCP protocol, allowing execution of Python code, variable management, and package installation.
                Last updated -
                3
                3
                Python
                MIT License
              • -
                security
                A
                license
                -
                quality
                An MCP server that allows managing Docker containers through natural language, enabling users to compose, introspect, and debug containers without running commands themselves.
                Last updated -
                468
                Python
                GPL 3.0
                • Apple

              View all related MCP servers

              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