Skip to main content
Glama
MCP Python Interpreter

MCP Python Interpreter

by yzfly

MCP Python Interpreter

Ein Model Context Protocol (MCP)-Server, der es LLMs ermöglicht, mit Python-Umgebungen zu interagieren, Dateien zu lesen und zu schreiben, Python-Code auszuführen und Entwicklungs-Workflows zu verwalten.

Merkmale

  • Umgebungsverwaltung : Auflisten und Verwenden verschiedener Python-Umgebungen (System und Conda)

  • Codeausführung : Führen Sie Python-Code oder -Skripte in jeder verfügbaren Umgebung aus

  • Paketverwaltung : Installierte Pakete auflisten und neue installieren

  • Dateioperationen :

    • Lesen von Dateien aller Art (Text, Quellcode, Binärdateien)

    • Schreiben Sie Text- und Binärdateien

  • Python-Eingabeaufforderungen : Vorlagen für allgemeine Python-Aufgaben wie Funktionserstellung und Debuggen

Related MCP server: MCP Python Toolbox

Installation

Sie können den MCP Python Interpreter mit pip installieren:

pip install mcp-python-interpreter

Oder mit UV:

uv install mcp-python-interpreter

Verwendung mit Claude Desktop

  1. Installieren Sie Claude Desktop

  2. Öffnen Sie Claude Desktop, klicken Sie auf Menü und dann auf Einstellungen

  3. Gehen Sie zur Registerkarte „Entwickler“ und klicken Sie auf „Konfiguration bearbeiten“.

  4. Fügen Sie Ihrer claude_desktop_config.json Folgendes hinzu:

{
  "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
        },
    }
  }
}

Für 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. Starten Sie Claude Desktop neu

  2. Sie sollten jetzt das MCP-Tools-Symbol in der Chat-Oberfläche sehen

Der Parameter --dir ist erforderlich und gibt an, wo alle Dateien gespeichert und ausgeführt werden. Dies trägt zur Aufrechterhaltung der Sicherheit bei, indem der MCP-Server auf ein bestimmtes Verzeichnis beschränkt wird.

Voraussetzungen

  • Stellen Sie sicher, dass uv installiert ist. Falls nicht, installieren Sie es mit:

    curl -LsSf https://astral.sh/uv/install.sh | sh
  • Für Windows:

    powershell -ExecutionPolicy Bypass -Command "iwr -useb https://astral.sh/uv/install.ps1 | iex"

Verfügbare Tools

Der Python-Interpreter bietet die folgenden Tools:

Umgebungs- und Paketverwaltung

  • list_python_environments : Listet alle verfügbaren Python-Umgebungen auf (System und Conda)

  • list_installed_packages : Listet die in einer bestimmten Umgebung installierten Pakete auf

  • install_package : Installieren Sie ein Python-Paket in einer bestimmten Umgebung

Codeausführung

  • run_python_code : Python-Code in einer bestimmten Umgebung ausführen

  • run_python_file : Führen Sie eine Python-Datei in einer bestimmten Umgebung aus

Dateioperationen

  • read_file : Liest Inhalte beliebiger Dateitypen, mit Größen- und Sicherheitsbeschränkungen

    • Unterstützt Textdateien mit Syntaxhervorhebung

    • Zeigt die Hex-Darstellung für Binärdateien an

  • write_file : Erstellen oder überschreiben Sie Dateien mit Text- oder Binärinhalt

  • write_python_file : Erstellen oder überschreiben Sie eine Python-Datei speziell

  • list_directory : Listet Python-Dateien in einem Verzeichnis auf

Verfügbare Ressourcen

  • python://environments : Listet alle verfügbaren Python-Umgebungen auf

  • python://packages/{env_name} : Listet installierte Pakete für eine bestimmte Umgebung auf

  • python://file/{file_path} : Ruft den Inhalt einer Python-Datei ab

  • python://directory/{directory_path} : Listet alle Python-Dateien in einem Verzeichnis auf

Eingabeaufforderungen

  • python_function_template : Erstellen Sie eine Vorlage für eine Python-Funktion

  • refactor_python_code : Helfen Sie beim Refactoring von Python-Code

  • debug_python_error : Helfen Sie beim Debuggen eines Python-Fehlers

Beispielverwendung

Hier sind einige Beispiele dafür, was Sie Claude mit diesem MCP-Server tun lassen können:

  • „Zeigen Sie mir alle verfügbaren Python-Umgebungen auf meinem System“

  • „Führen Sie diesen Python-Code in meiner Conda-Base-Umgebung aus: print(‚Hallo Welt!‘)“

  • „Erstellen Sie eine neue Python-Datei namens ‚hello.py‘ mit einer Funktion, die Hallo sagt.“

  • „Lesen Sie den Inhalt meiner Datei ‚data.json‘“

  • „Schreiben Sie eine neue Konfigurationsdatei mit diesen Einstellungen …“

  • „Listet alle in meiner System-Python-Umgebung installierten Pakete auf“

  • „Installieren Sie das Anforderungspaket in meiner System-Python-Umgebung.“

  • „Führen Sie data_analysis.py mit diesen Argumenten aus: --input=data.csv --output=results.csv“

Dateiverwaltungsfunktionen

Der MCP Python Interpreter unterstützt jetzt umfassende Dateioperationen:

  • Lesen Sie Text- und Binärdateien bis zu 1 MB

  • Schreiben Sie Text- und Binärdateien

  • Syntaxhervorhebung für Quellcodedateien

  • Hex-Darstellung für Binärdateien

  • Strikte Dateipfadsicherheit (nur innerhalb des Arbeitsverzeichnisses)

Sicherheitsüberlegungen

Dieser MCP-Server hat Zugriff auf Ihre Python-Umgebungen und Ihr Dateisystem. Zu den wichtigsten Sicherheitsfunktionen gehören:

  • Isoliertes Arbeitsverzeichnis

  • Dateigrößenbeschränkungen

  • Schreibvorgänge außerhalb des Arbeitsverzeichnisses verhindert

  • Expliziter Überschreibschutz

Seien Sie immer vorsichtig, wenn Sie Code oder Dateivorgänge ausführen, die Sie nicht vollständig verstehen.

Lizenz

MIT

Available Tools

10 tools
clear_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

    A3.5/5.0

    Scored across 10 tools

    Disambiguation4/5

    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.

    Naming Consistency5/5

    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.

    Tool Count5/5

    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.

    Completeness4/5

    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

    ActivitySlowing
    ResponsivenessLimited data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      A Model Context Protocol server that allows LLMs to execute shell commands and receive their output in a controlled manner.
      7
      MIT
    • A
      license
      Not graded
      quality
      F
      maintenance
      A 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.
      9
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      A 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.
      10
      MIT
    • F
      license
      A
      quality
      Not graded
      maintenance
      A Model Context Protocol server that allows LLMs to interact with Python environments, enabling code execution, file operations, package management, and development workflows.
      9
      -