YM

yzfly/mcp-python-interpreter

Developer tools

Эта страница переведена автоматически. Технические детали смотрите в оригинале. Открыть оригинал

104 stars 35 forks Качество 78 Тренд 35NOASSERTION

yzfly/mcp-python-interpreter — это кандидат на MCP-сервер, импортированный из https://github.com/yzfly/mcp-python-interpreter.

Обзор

yzfly/mcp-python-interpreter — это кандидат на MCP-сервер, импортированный из https://github.com/yzfly/mcp-python-interpreter.

Обзор (машинный перевод)

Сервер Model Context Protocol (MCP), который позволяет LLM взаимодействовать с Python-средами, читать и записывать файлы, выполнять код на Python и управлять рабочими процессами разработки.

Особенности

  • Управление окружением: Перечисление и использование различных Python-сред (системных и conda)
  • Выполнение кода: Запуск Python-кода или скриптов в любой доступной среде
  • Управление пакетами: Список установленных пакетов и установка новых
  • Операции с файлами:
  • Чтение файлов любого типа (текст, исходный код, бинарный)
  • Запись текстовых и двоичных файлов
  • Python prompts: шаблоны для распространённых задач на Python, таких как создание функций и отладка

Установка

Вы можете установить интерпретатор MCP Python с помощью pip:

Или с УФ:

Использование с Claude Desktop

  1. Установите Claude Desktop
  2. Откройте Claude Desktop, выберите меню, затем Настройки
  3. Перейдите на вкладку «Разработчик» и нажмите «Редактировать конфигурацию»
  4. Добавьте следующее в ваш claude_desktop_config.json:

Для Windows:

  1. Перезапустить Claude Desktop
  2. Теперь вы должны увидеть значок MCP tools в чате

Параметр --dir — required и указывает, где будут сохранены и выполнены все файлы.

Эта страница переведена автоматически. Технические детали смотрите в оригинале.

README

Показан фрагмент оригинального README. Открыть оригинал.

MCP Python Interpreter

A Model Context Protocol (MCP) server that allows LLMs to interact with Python environments, read and write files, execute Python code, and manage development workflows.

Features

  • Environment Management: List and use different Python environments (system and conda)
  • Code Execution: Run Python code or scripts in any available environment
  • Package Management: List installed packages and install new ones
  • File Operations:
    • Read files of any type (text, source code, binary)
    • Write text and binary files
  • Python Prompts: Templates for common Python tasks like function creation and debugging

Installation

You can install the MCP Python Interpreter using pip:

pip install mcp-python-interpreter

Or with uv:

uv tool install mcp-python-interpreter

Usage with Claude Desktop

  1. Install Claude Desktop
  2. Open Claude Desktop, click on menu, then Settings
  3. Go to Developer tab and click “Edit Config”
  4. Add the following to your 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"
        }
    }
  }
}

For 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. Restart Claude Desktop
  2. You should now see the MCP tools icon in the chat interface

The --dir parameter sets the working directory (default: the directory where the server starts). File tools and run_python_code(save_as=...) restrict paths to this directory unless MCP_ALLOW_SYSTEM_ACCESS=1 is set. It is not a sandbox for executed Python code.

Prerequisites

  • Make sure you have uv installed. If not, install it using:
    curl -LsSf https://astral.sh/uv/install.sh | sh
    
  • For Windows:
    powershell -ExecutionPolicy Bypass -Command "iwr -useb https://astral.sh/uv/install.ps1 | iex"
    

Available Tools

The Python Interpreter provides the following tools:

Environment and Package Management

  • list_python_environments: List all available Python environments (system and conda)
  • list_installed_packages: List packages installed in a specific environment
  • install_package: Install a Python package in a specific environment

Code Execution

Открыть полный README на GitHub

Установка

uvx mcp-python-interpreter --dir /path/to/your/work/dir --python-path /path/to/your/python
Новичок в MCP? Начните с руководства на mcpskill.org →

Конфигурация

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