MCP Python Interpreter

Integrations

  • Allows interaction with Python environments, execution of Python code, management of packages, and Python-related file operations including reading, writing, and debugging Python files.

MCP Pythonインタープリタ

LLM が Python 環境と対話し、ファイルを読み書きし、Python コードを実行し、開発ワークフローを管理できるようにするモデル コンテキスト プロトコル (MCP) サーバー。

特徴

  • 環境管理: さまざまな Python 環境 (システムと conda) を一覧表示して使用する
  • コード実行: 利用可能な環境で Python コードまたはスクリプトを実行します。
  • パッケージ管理: インストール済みのパッケージを一覧表示し、新しいパッケージをインストールする
  • ファイル操作:
    • あらゆるタイプのファイル(テキスト、ソースコード、バイナリ)を読み取る
    • テキストファイルとバイナリファイルの書き込み
  • Python プロンプト: 関数の作成やデバッグなどの一般的な Python タスクのテンプレート

インストール

pip を使用して MCP Python インタープリターをインストールできます。

pip install mcp-python-interpreter

またはUVの場合:

uv install mcp-python-interpreter

Claude Desktopでの使用

  1. Claude Desktopをインストールする
  2. Claude Desktopを開き、メニューをクリックして設定をクリックします
  3. 開発タブに移動し、「構成の編集」をクリックします。
  4. claude_desktop_config.jsonに以下を追加します。
{ "mcpServers": { "mcp-python-interpreter": { "command": "uvx", "args": [ "mcp-python-interpreter", "--dir", "/path/to/your/work/dir", "--python-path", "/path/to/your/python" ], "env": { "MCP_ALLOW_SYSTEM_ACCESS": 0 }, } } }

Windowsの場合:

{ "mcpServers": { "python-interpreter": { "command": "uvx", "args": [ "mcp-python-interpreter", "--dir", "C:\\path\\to\\your\\working\\directory", "--python-path", "/path/to/your/python" ], "env": { "MCP_ALLOW_SYSTEM_ACCESS": 0 }, } } }
  1. Claudeデスクトップを再起動します
  2. チャットインターフェースにMCPツールアイコンが表示されるはずです。

--dirパラメータは必須で、すべてのファイルの保存場所と実行場所を指定します。これにより、MCP サーバーを特定のディレクトリに分離し、セキュリティを維持できます。

前提条件

  • uvがインストールされていることを確認してください。インストールされていない場合は、以下のコマンドでインストールしてください。
    curl -LsSf https://astral.sh/uv/install.sh | sh
  • Windowsの場合:
    powershell -ExecutionPolicy Bypass -Command "iwr -useb https://astral.sh/uv/install.ps1 | iex"

利用可能なツール

Python インタープリタは次のツールを提供します。

環境とパッケージ管理

  • list_python_environments : 利用可能なすべての Python 環境 (システムと conda) を一覧表示します。
  • list_installed_packages : 特定の環境にインストールされているパッケージを一覧表示する
  • install_package : 特定の環境に Python パッケージをインストールする

コード実行

  • run_python_code : 特定の環境でPythonコードを実行する
  • run_python_file : 特定の環境でPythonファイルを実行する

ファイル操作

  • read_file : サイズと安全制限付きで、あらゆるファイルタイプの内容を読み取ります
    • 構文強調表示付きのテキストファイルをサポート
    • バイナリファイルの16進表現を表示します
  • write_file : テキストまたはバイナリコンテンツでファイルを作成または上書きします
  • write_python_file : Pythonファイルを作成または上書きする
  • list_directory : ディレクトリ内の Python ファイルを一覧表示する

利用可能なリソース

  • python://environments : 利用可能なすべての Python 環境を一覧表示します
  • python://packages/{env_name} : 特定の環境にインストールされているパッケージを一覧表示します
  • python://file/{file_path} : Pythonファイルの内容を取得する
  • python://directory/{directory_path} : ディレクトリ内のすべての Python ファイルを一覧表示します。

プロンプト

  • python_function_template : Python関数のテンプレートを生成する
  • refactor_python_code : Python コードのリファクタリングを支援
  • debug_python_error : Pythonエラーのデバッグを支援する

使用例

この MCP サーバーで Claude に依頼できる操作の例をいくつか示します。

  • 「システム上で利用可能なすべての Python 環境を表示」
  • 「この Python コードを conda-base 環境で実行します: print('Hello, world!')」
  • 「hello.py」という新しいPythonファイルを作成し、helloという関数を追加します。
  • 「data.jsonファイルの内容を読み取ります」
  • 「これらの設定で新しい構成ファイルを作成します...」
  • 「システムの Python 環境にインストールされているすべてのパッケージを一覧表示する」
  • 「システムの Python 環境にリクエスト パッケージをインストールする」
  • 「次の引数を指定して data_analysis.py を実行します: --input=data.csv --output=results.csv」

ファイル処理機能

MCP Python インタープリタは包括的なファイル操作をサポートするようになりました。

  • 最大1MBのテキストファイルとバイナリファイルを読み取る
  • テキストファイルとバイナリファイルの書き込み
  • ソースコードファイルの構文強調表示
  • バイナリファイルの16進表現
  • 厳密なファイルパスセキュリティ(作業ディレクトリ内のみ)

セキュリティに関する考慮事項

このMCPサーバーは、Python環境とファイルシステムにアクセスできます。主なセキュリティ機能は次のとおりです。

  • 分離された作業ディレクトリ
  • ファイルサイズの制限
  • 作業ディレクトリ外への書き込みを防止
  • 明示的な上書き保護

完全に理解していないコードやファイル操作を実行するときは常に注意してください。

ライセンス

マサチューセッツ工科大学

You must be authenticated.

A
security – no known vulnerabilities
F
license - not found
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.

LLM が Python 環境と対話し、コードを実行し、指定された作業ディレクトリ内のファイルを管理できるようにするモデル コンテキスト プロトコル サーバー。

  1. Features
    1. Installation
      1. Usage with Claude Desktop
        1. Prerequisites
      2. Available Tools
        1. Environment and Package Management
        2. Code Execution
        3. File Operations
      3. Available Resources
        1. Prompts
          1. Example Usage
            1. File Handling Capabilities
              1. Security Considerations
                1. License

                  Related MCP Servers

                  • -
                    security
                    F
                    license
                    -
                    quality
                    A Model Context Protocol server that allows LLMs to execute shell commands and receive their output in a controlled manner.
                    Last updated -
                    Python
                  • A
                    security
                    A
                    license
                    A
                    quality
                    A Model Context Protocol server that gives LLMs the ability to interact with Ethereum networks, manage wallets, query blockchain data, and execute smart contract operations through a standardized interface.
                    Last updated -
                    31
                    323
                    2
                    TypeScript
                    MIT License
                  • -
                    security
                    A
                    license
                    -
                    quality
                    A Model Context Protocol server that extracts and analyzes Python code structures, focusing on import/export relationships between files to help LLMs understand code context.
                    Last updated -
                    2
                    Python
                    MIT License
                  • -
                    security
                    F
                    license
                    -
                    quality
                    A Model Context Protocol server that connects LLMs to the Compiler Explorer API, enabling them to compile code, explore compiler features, and analyze optimizations across different compilers and languages.
                    Last updated -
                    Python

                  View all related MCP servers

                  ID: asvhgbf6de