MCP Python Interpreter
MCP Pythonインタープリタ
LLM が Python 環境と対話し、ファイルを読み書きし、Python コードを実行し、開発ワークフローを管理できるようにするモデル コンテキスト プロトコル (MCP) サーバー。
特徴
環境管理: さまざまな Python 環境 (システムと conda) を一覧表示して使用する
コード実行: 利用可能な環境で Python コードまたはスクリプトを実行します。
パッケージ管理: インストール済みのパッケージを一覧表示し、新しいパッケージをインストールする
ファイル操作:
あらゆるタイプのファイル(テキスト、ソースコード、バイナリ)を読み取る
テキストファイルとバイナリファイルの書き込み
Python プロンプト: 関数の作成やデバッグなどの一般的な Python タスクのテンプレート
Related MCP server: MCP Python Toolbox
インストール
pip を使用して MCP Python インタープリターをインストールできます。
pip install mcp-python-interpreterまたはUVの場合:
uv install mcp-python-interpreterClaude Desktopでの使用
Claude Desktopをインストールする
Claude Desktopを開き、メニューをクリックして設定をクリックします
開発タブに移動し、「構成の編集」をクリックします。
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
},
}
}
}Claudeデスクトップを再起動します
チャットインターフェースにMCPツールアイコンが表示されるはずです。
--dirパラメータは必須で、すべてのファイルの保存場所と実行場所を指定します。これにより、MCP サーバーを特定のディレクトリに分離し、セキュリティを維持できます。
前提条件
uvがインストールされていることを確認してください。インストールされていない場合は、以下のコマンドでインストールしてください。curl -LsSf https://astral.sh/uv/install.sh | shWindowsの場合:
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環境とファイルシステムにアクセスできます。主なセキュリティ機能は次のとおりです。
分離された作業ディレクトリ
ファイルサイズの制限
作業ディレクトリ外への書き込みを防止
明示的な上書き保護
完全に理解していないコードやファイル操作を実行するときは常に注意してください。
ライセンス
マサチューセッツ工科大学
Available Tools
10 toolsclear_sessionC
Clear a REPL session's state and history.
Args:
session_id: Session ID to clear
Inputs: session_id. Returns: result
install_packageB
Install a Python package in the specified environment.
Args:
package_name: Name of the package to install
environment: Name of the Python environment
upgrade: Whether to upgrade if already installed
timeout: Maximum execution time in seconds
Inputs: package_name (required), timeout, upgrade, environment. Returns: result
list_directoryB
List all Python files in a directory.
Args:
directory_path: Path to directory (empty for working directory)
Inputs: directory_path. Returns: result
list_installed_packagesC
List installed packages for a specific Python environment.
Args:
environment: Name of the Python environment
Inputs: environment. Returns: result
list_python_environmentsB
List all available Python environments (system Python and conda environments).
Inputs: no named parameters. Returns: result
list_sessionsB
List all active REPL sessions.
Inputs: no named parameters. Returns: result
read_fileA
Read the content of any file, with size limits for safety.
Args:
file_path: Path to the file
max_size_kb: Maximum file size to read in KB
Inputs: file_path (required), max_size_kb. Returns: result
run_python_codeA
Execute Python code with flexible execution modes.
Args:
code: Python code to execute
execution_mode: Execution mode - "inline" (default, fast, in-process) or "subprocess" (isolated)
session_id: Session ID for inline mode to maintain state across executions
environment: Python environment name (only for subprocess mode)
save_as: Optional filename to save the code before execution (within --dir by default)
timeout: Maximum execution time in seconds (only enforced for subprocess mode)
overwrite: Allow replacing an existing save_as file (default: False)
Returns:
Execution result with output
Execution modes:
- "inline" (default): Executes code in the current process. Fast and reliable,
maintains session state. Use for most code execution tasks.
- "subprocess": Executes code in a separate Python process. Use when you need
environment isolation or a different Python environment.
Inputs: code (required), save_as, timeout, overwrite, +3 more. Returns: result
run_python_fileB
Execute a Python file (always uses subprocess for file execution).
Args:
file_path: Path to the Python file to execute
environment: Name of the Python environment to use
arguments: List of command-line arguments to pass to the script
timeout: Maximum execution time in seconds (default: 300)
Inputs: file_path (required), timeout, arguments, environment. Returns: result
write_fileB
Write content to a file.
Args:
file_path: Path to the file to write
content: Content to write
overwrite: Whether to overwrite if exists
Inputs: content (required), file_path (required), overwrite. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 10 tools
Most tools target clearly distinct resources or actions (execution, files, environments, packages, sessions). The main potential confusion is between run_python_code and run_python_file, but the descriptions make the inline-code vs file-execution split explicit, so an agent can select correctly.
All ten tools follow a consistent snake_case verb_noun pattern: list_*, run_*, install_*, clear_*, read_*, write_*. No mixed conventions or vague single-word names.
Ten tools is a well-scoped surface for a Python interpreter server, covering execution, file I/O, environments, packages, and sessions without redundancy. Each tool earns its place.
Core lifecycle is covered: execute code/files, read/write files, list/install packages, list environments and sessions, and clear sessions. Minor gaps exist (no uninstall_package, no file delete, no environment creation), but agents can work around these via run_python_code.
Maintenance
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
A Model Context Protocol server for Wix AI tools
Model Context Protocol server for the Apideck Unified API. Connect any MCP-compatible agent framework to 100+ accounting systems, HRIS platforms, file storage providers, and more through one integration. More information https://www.apideck.com/mcp-server
Enable secure connectivity between Sentry issues and debugging data, and LLM clients, using a Model Context Protocol (MCP) server.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that allows LLMs to execute shell commands and receive their output in a controlled manner.7MIT
- AlicenseNot gradedqualityFmaintenanceA Model Context Protocol server that enables AI assistants like Claude to perform Python development tasks through file operations, code analysis, project management, and safe code execution.9MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol (MCP) server that allows AI models to safely access and interact with local file systems, enabling reading file contents, listing directories, and retrieving file metadata.10MIT
- FlicenseAqualityNot gradedmaintenanceA Model Context Protocol server that allows LLMs to interact with Python environments, enabling code execution, file operations, package management, and development workflows.9-