Skip to main content
Glama
MCP Python Interpreter

MCP Python Interpreter

by yzfly

MCP 파이썬 인터프리터

LLM이 Python 환경과 상호 작용하고, 파일을 읽고 쓰고, Python 코드를 실행하고, 개발 워크플로를 관리할 수 있게 해주는 MCP(Model Context Protocol) 서버입니다.

특징

  • 환경 관리 : 다양한 Python 환경(시스템 및 conda)을 나열하고 사용합니다.

  • 코드 실행 : 사용 가능한 모든 환경에서 Python 코드나 스크립트를 실행합니다.

  • 패키지 관리 : 설치된 패키지를 나열하고 새 패키지를 설치합니다.

  • 파일 작업 :

    • 모든 유형의 파일 읽기(텍스트, 소스 코드, 바이너리)

    • 텍스트 및 바이너리 파일 쓰기

  • Python 프롬프트 : 함수 생성 및 디버깅과 같은 일반적인 Python 작업을 위한 템플릿

Related MCP server: MCP Python Toolbox

설치

pip를 사용하여 MCP Python 인터프리터를 설치할 수 있습니다.

지엑스피1

또는 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 Desktop을 다시 시작하세요

  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 오류 디버깅을 도와줍니다.

사용 예

다음은 Claude에게 MCP 서버를 사용하여 수행할 수 있는 작업의 몇 가지 예입니다.

  • "내 시스템에서 사용 가능한 모든 Python 환경을 보여주세요"

  • "conda-base 환경에서 이 Python 코드를 실행하세요: print('Hello, world!')"

  • "hello라는 함수를 포함하는 'hello.py'라는 새로운 Python 파일을 만듭니다."

  • "내 'data.json' 파일의 내용을 읽어보세요"

  • "이 설정으로 새로운 구성 파일을 작성하세요..."

  • "내 시스템 Python 환경에 설치된 모든 패키지 나열"

  • "내 시스템 Python 환경에 requests 패키지를 설치하세요"

  • "다음 인수를 사용하여 data_analysis.py를 실행하세요: --input=data.csv --output=results.csv"

파일 처리 기능

MCP Python 인터프리터는 이제 포괄적인 파일 작업을 지원합니다.

  • 최대 1MB의 텍스트 및 바이너리 파일을 읽습니다.

  • 텍스트 및 바이너리 파일 쓰기

  • 소스 코드 파일에 대한 구문 강조 표시

  • 이진 파일의 16진수 표현

  • 엄격한 파일 경로 보안(작업 디렉토리 내에서만)

보안 고려 사항

이 MCP 서버는 Python 환경 및 파일 시스템에 접근할 수 있습니다. 주요 보안 기능은 다음과 같습니다.

  • 격리된 작업 디렉토리

  • 파일 크기 제한

  • 작업 디렉토리 외부에서 쓰기가 방지되었습니다.

  • 명시적 덮어쓰기 보호

자신이 완전히 이해하지 못하는 코드나 파일 작업을 실행할 때는 항상 주의하세요.

특허

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
      -