Safe Local Python Executor/Interpreter

Integrations

  • Integrates with Hugging Face's LocalPythonExecutor from the smolagents framework to provide secure Python code execution capabilities with basic isolation and security for running LLM-generated Python code.

안전한 로컬 Python 실행기

Hugging Face의 LocalPythonExecutor ( smolagents 프레임워크 기반)를 래핑하는 MCP 서버(stdio 전송)입니다. LLM에서 생성된 Python 코드를 로컬에서 실행할 때 기본적인 격리/보안을 제공하는 맞춤형 Python 런타임입니다. Docker나 VM이 필요하지 않습니다. 이 패키지를 사용하면 Claude Desktop, Cursor 또는 기타 MCP 호환 클라이언트와 같은 LLM 앱의 도구로 MCP(Model Context Protocol)를 통해 Python 실행기를 노출할 수 있습니다. Claude Desktop의 경우, 이 도구는 누락된 코드 인터프리터(ChatGPT에서 이미 꽤 오랫동안 플러그인으로 제공됨)를 쉽게 추가할 수 있는 방법입니다.

특징

  • run_python 도구를 노출합니다
  • Python eva()l 을 직접 사용하는 것보다 Python 코드를 더 안전하게 실행합니다.
  • Python venv에서 uv를 통해 실행
  • 파일 I/O 작업이 허용되지 않습니다.
  • 수입 제한 목록
    • 컬렉션
    • 날짜시간
    • itertools
    • 수학
    • 대기줄
    • 무작위의
    • 답장
    • 통계
    • 통계
    • 시간
    • 유니코드데이터

보안

LLM에서 생성된 코드를 컴퓨터에서 실행할 때는 주의하세요. 명령줄이나 eval() 사용하여 Python을 실행하는 MCP 서버는 사용하지 마세요. 가장 안전한 방법은 VM이나 도커 컨테이너를 사용하는 것이지만, 설정에 약간의 노력이 필요하고 리소스를 많이 소모하며 속도가 느립니다. Python 런타임을 제공하는 타사 서비스도 있지만, 등록, API 키 등이 필요합니다.

LocalPythonExecutor 로컬 Python 환경의 직접 사용(설정이 더 쉬움)과 Dokcer 컨테이너 또는 VM/서드파티 서비스에서의 원격 실행(안전함) 간의 적절한 균형을 제공합니다. Hugginng Face 팀은 코드 에이전트에서 사용하는 LLM 생성 코드를 빠르고 안전하게 실행할 수 있는 옵션을 개발하는 데 많은 시간을 투자했습니다. 이 MCP 서버는 이를 기반으로 합니다.

보안을 한층 강화하기 위해, smolagents의 코드 실행은 vanilla Python 인터프리터에서 수행되지 않습니다. 저희는 더욱 안전한 LocalPythonExecutor를 처음부터 다시 빌드했습니다.

자세한 내용은 여기에서 읽어보세요.

설치 및 실행

  1. uv 설치하세요(macOS에서는 brew install uv 사용하거나 공식 문서를 사용하세요)
  2. 저장소를 복제하고 디렉토리를 변경합니다. cd mcp_safe_local_python_executor
  3. 서버는 명령줄 uv run mcp_server.py 통해 시작할 수 있으며, venv가 자동으로 생성되고 종속성(smollagents, mcp)이 설치됩니다.

Claude Desktop 구성

  1. Claude for Desktop이 설치되어 있는지 확인하세요( claude.ai 에서 다운로드)
  2. Claude for Desktop 구성 파일을 편집하세요.
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
    • 또는 Claude Desktop을 열고 -> 설정 -> 개발자 -> "구성 편집" 버튼을 클릭하세요.
  3. 다음 구성을 추가합니다.

지엑스피1

  1. 데스크톱용 Claude 재시작
  2. Python 실행기 도구는 이제 Claude에서 사용할 수 있습니다(메시지 입력 필드에 망치 아이콘이 표시됩니다).

예시 프롬프트

구성이 완료되면 다음과 같은 프롬프트를 사용할 수 있습니다.

  • "Python을 사용하여 5의 계승을 계산하세요"
  • "100까지의 소수 목록을 만들어 보세요"
  • "이 방정식을 풀어보세요(파이썬을 사용하세요): x^2 + 5x + 6 = 0"

개발

저장소를 복제하세요. uv 사용하여 venv를 생성하고, 개발 종속성을 설치하고, 테스트를 실행하세요.

uv venv .venv uv sync --group dev python -m pytest tests/

You must be authenticated.

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

Hugging Faces의 smolagents 프레임워크에서 커스텀 Python 런타임(LocalPythonExecutor)을 래핑하는 Stdio MCP 서버입니다. 이 런타임은 Docker, VM, 클라우드 런타임에 비해 설정의 편의성을 제공하는 동시에, 보안 기능을 제공하고 런타임 내에서 허용되는 작업/가져오기를 제한합니다.

  1. Features
    1. Security
      1. Installation and Execution
        1. Configuring Claude Desktop
          1. Example Prompts
            1. Development

              Related MCP Servers

              • A
                security
                A
                license
                A
                quality
                An MCP server to run commands.
                Last updated 13 days ago
                2
                204
                104
                JavaScript
                MIT License
                • Apple
              • -
                security
                A
                license
                -
                quality
                A Python-based MCP server that integrates OpenAPI-described REST APIs into MCP workflows, enabling dynamic exposure of API endpoints as MCP tools.
                Last updated 8 days ago
                2
                39
                Python
                MIT License
                • Linux
                • Apple
              • A
                security
                A
                license
                A
                quality
                A server that provides a persistent Python REPL environment through the MCP protocol, allowing execution of Python code, variable management, and package installation.
                Last updated 4 months ago
                3
                3
                Python
                MIT License
              • -
                security
                A
                license
                -
                quality
                An MCP server that allows managing Docker containers through natural language, enabling users to compose, introspect, and debug containers without running commands themselves.
                Last updated 8 days ago
                340
                Python
                GPL 3.0
                • Apple

              View all related MCP servers

              ID: cj2uey3ghu