Skip to main content
Glama
gianlucamazza

MCP Python Toolbox

MCP 파이썬 툴박스

Claude와 같은 AI 도우미가 Python 코드와 프로젝트를 효과적으로 작업할 수 있도록 Python 개발을 위한 포괄적인 도구 세트를 제공하는 MCP(Model Context Protocol) 서버입니다.

개요

MCP Python Toolbox는 Claude가 표준화된 인터페이스를 통해 Python 개발 작업을 수행할 수 있도록 하는 모델 컨텍스트 프로토콜 서버를 구현합니다. Claude는 이를 통해 다음과 같은 작업을 수행할 수 있습니다.

  • 작업 공간 내에서 파일을 읽고, 쓰고, 관리합니다.

  • Python 코드 분석, 포맷 및 린트

  • 가상 환경 및 종속성 관리

  • Python 코드를 안전하게 실행하세요

Related MCP server: Hass-MCP

특징

파일 작업( FileOperations )

  • 작업 공간 디렉토리 내에서 안전한 파일 작업

  • 작업 공간 외부의 무단 접근을 방지하기 위한 경로 검증

  • 줄별 작업으로 파일 읽기 및 쓰기

  • 파일 및 디렉토리 생성 및 삭제

  • 자세한 메타데이터(크기, 유형, 수정 시간)를 포함한 디렉토리 콘텐츠 나열

  • 파일 쓰기 시 자동 상위 디렉토리 생성

코드 분석( CodeAnalyzer )

  • AST를 사용하여 Python 코드 구조를 구문 분석하고 분석합니다.

  • 다음에 대한 자세한 정보를 추출합니다:

    • 가져오기 명령문 및 별칭

    • 인수와 데코레이터를 사용한 함수 정의

    • 기본 클래스와 메서드를 사용한 클래스 정의

    • 전역 변수 할당

  • 다음을 사용하여 코드 형식 지정:

    • 검정색(기본)

    • PEP8(autopep8 사용)

  • Pylint를 사용한 포괄적인 코드 린팅 및 상세 보고서

프로젝트 관리( ProjectManager )

  • pip 지원을 통해 가상 환경을 만들고 관리하세요

  • 유연한 종속성 관리:

    • requirements.txt에서 설치

    • pyproject.toml에서 설치

    • 특정 패키지 버전 지원

  • 고급 종속성 처리:

    • 패키지 간 버전 충돌을 확인하세요

    • 설치된 모든 패키지와 버전을 나열합니다.

    • 패키지를 특정 버전으로 업데이트

    • 현재 환경에서 requirements.txt를 생성합니다.

코드 실행( CodeExecutor )

  • 제어된 환경에서 Python 코드 실행

  • 일관된 종속성을 위해 프로젝트의 가상 환경을 사용합니다.

  • 코드 실행을 위한 임시 파일 관리

  • stdout, stderr 및 종료 코드 캡처

  • 사용자 정의 작업 디렉토리 지원

설치

  1. 저장소를 복제합니다.

지엑스피1

  1. 가상 환경을 만들고 활성화하세요.

python -m venv .venv
source .venv/bin/activate  # Linux/Mac
# or
.venv\Scripts\activate  # Windows
  1. 개발 모드에서 패키지를 설치하세요:

pip install -e ".[dev]"

용법

CLI 도구로 실행

서버를 시작하는 가장 간단한 방법은 CLI를 사용하는 것입니다.

# Start with current directory as workspace
python -m mcp_python_toolbox

# Or specify a workspace directory
python -m mcp_python_toolbox --workspace /path/to/your/project

Claude Desktop 설정

Claude Desktop은 MCP Python Toolbox 서버를 자동으로 실행하고 관리할 수 있습니다. 구성 방법은 다음과 같습니다.

  1. 위에 설명된 대로 MCP Python Toolbox를 설치하고 설정하세요.

  2. Claude Desktop의 MCP 도구 구성에 Python 도구 상자에 대한 구성 항목을 추가합니다.

"python-toolbox": {
  "command": "/Users/username/path/to/mcp_python_toolbox/.venv/bin/python",
  "args": [
    "-m",
    "mcp_python_toolbox",
    "--workspace",
    "/Users/username/path/to/workspace"
  ],
  "env": {
    "PYTHONPATH": "/Users/username/path/to/mcp_python_toolbox/src",
    "PATH": "/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",
    "VIRTUAL_ENV": "/Users/username/path/to/mcp_python_toolbox/.venv",
    "PYTHONHOME": ""
  }
}
  1. 환경에 맞게 경로를 사용자 지정하세요

  2. Claude Desktop은 필요할 때 자동으로 MCP 서버를 시작합니다.

  3. 이제 Claude는 MCP 인터페이스를 통해 Python 개발 도구에 액세스할 수 있습니다.

프로그래밍 방식 사용

from mcp_python_toolbox import PythonToolboxServer

server = PythonToolboxServer(workspace_root="/path/to/your/project")
server.setup()
server.run()

핵심 모듈 예제

파일 작업

from mcp_python_toolbox.core import FileOperations

file_ops = FileOperations(workspace_root="/path/to/project")

# Read file contents
content = file_ops.read_file("src/example.py")
# Read specific lines
lines = file_ops.read_file("src/example.py", start_line=10, end_line=20)

# Write to file
file_ops.write_file("output.txt", "Hello, World!")
# Append to file
file_ops.write_file("log.txt", "New entry\n", mode='a')

# List directory contents
contents = file_ops.list_directory("src")
for item in contents:
    print(f"{item['name']} - {item['type']} - {item['size']} bytes")

코드 분석

from mcp_python_toolbox.core import CodeAnalyzer

analyzer = CodeAnalyzer(workspace_root="/path/to/project")

# Analyze Python file structure
analysis = analyzer.parse_python_file("src/example.py")
print(f"Found {len(analysis['functions'])} functions")
print(f"Found {len(analysis['classes'])} classes")

# Format code
formatted = analyzer.format_code(code, style='black')

# Lint code
issues = analyzer.lint_code("src/example.py")
for issue in issues:
    print(f"Line {issue['line']}: {issue['message']}")

프로젝트 관리

from mcp_python_toolbox.core import ProjectManager

pm = ProjectManager(workspace_root="/path/to/project")

# Create virtual environment
pm.create_virtual_environment()

# Install dependencies
pm.install_dependencies()  # from requirements.txt or pyproject.toml
pm.install_dependencies("requirements-dev.txt")  # from specific file

# Check for conflicts
conflicts = pm.check_dependency_conflicts()
if conflicts:
    print("Found dependency conflicts:")
    for conflict in conflicts:
        print(f"{conflict['package']} requires {conflict['requires']}")

# Update packages
pm.update_package("requests")  # to latest
pm.update_package("flask", version="2.0.0")  # to specific version

코드 실행

from mcp_python_toolbox.core import CodeExecutor

executor = CodeExecutor(workspace_root="/path/to/project")

code = '''
def greet(name):
    return f"Hello, {name}!"

print(greet("World"))
'''

result = executor.execute_code(code)
print(f"Output: {result['stdout']}")
print(f"Errors: {result['stderr']}")
print(f"Exit code: {result['exit_code']}")

개발

테스트 실행

pytest

유형 검사

mypy src/mcp_python_toolbox

린팅

pylint src/mcp_python_toolbox

서식

black src/mcp_python_toolbox

기여하다

  1. 저장소를 포크하세요

  2. 기능 브랜치를 생성합니다( git checkout -b feature/amazing-feature )

  3. 변경 사항을 커밋하세요( git commit -m 'Add some amazing feature' )

  4. 브랜치에 푸시( git push origin feature/amazing-feature )

  5. 풀 리퀘스트 열기

특허

이 프로젝트는 MIT 라이선스에 따라 라이선스가 부여되었습니다. 자세한 내용은 라이선스 파일을 참조하세요.

감사의 말

  • 모델 컨텍스트 프로토콜 사양을 구현합니다.

  • 최신 Python 개발 도구와 모범 사례를 사용하여 구축됨

  • 산업 표준 포맷팅(Black) 및 린팅(Pylint) 도구를 사용합니다.

-
security - not tested
F
license - not found
-
quality - not tested

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/gianlucamazza/mcp_python_toolbox'

If you have feedback or need assistance with the MCP directory API, please join our Discord server