MCP 파이썬 툴박스
Claude와 같은 AI 도우미가 Python 코드와 프로젝트를 효과적으로 작업할 수 있도록 Python 개발을 위한 포괄적인 도구 세트를 제공하는 MCP(Model Context Protocol) 서버입니다.
개요
MCP Python Toolbox는 Claude가 표준화된 인터페이스를 통해 Python 개발 작업을 수행할 수 있도록 하는 모델 컨텍스트 프로토콜 서버를 구현합니다. Claude는 이를 통해 다음과 같은 작업을 수행할 수 있습니다.
Related MCP server: Hass-MCP
특징
파일 작업( FileOperations )
작업 공간 디렉토리 내에서 안전한 파일 작업
작업 공간 외부의 무단 접근을 방지하기 위한 경로 검증
줄별 작업으로 파일 읽기 및 쓰기
파일 및 디렉토리 생성 및 삭제
자세한 메타데이터(크기, 유형, 수정 시간)를 포함한 디렉토리 콘텐츠 나열
파일 쓰기 시 자동 상위 디렉토리 생성
코드 분석( CodeAnalyzer )
프로젝트 관리( ProjectManager )
코드 실행( CodeExecutor )
설치
저장소를 복제합니다.
지엑스피1
가상 환경을 만들고 활성화하세요.
python -m venv .venv
source .venv/bin/activate # Linux/Mac
# or
.venv\Scripts\activate # Windows
개발 모드에서 패키지를 설치하세요:
용법
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 서버를 자동으로 실행하고 관리할 수 있습니다. 구성 방법은 다음과 같습니다.
위에 설명된 대로 MCP Python Toolbox를 설치하고 설정하세요.
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": ""
}
}
환경에 맞게 경로를 사용자 지정하세요
Claude Desktop은 필요할 때 자동으로 MCP 서버를 시작합니다.
이제 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']}")
개발
테스트 실행
유형 검사
mypy src/mcp_python_toolbox
린팅
pylint src/mcp_python_toolbox
서식
black src/mcp_python_toolbox
기여하다
저장소를 포크하세요
기능 브랜치를 생성합니다( git checkout -b feature/amazing-feature )
변경 사항을 커밋하세요( git commit -m 'Add some amazing feature' )
브랜치에 푸시( git push origin feature/amazing-feature )
풀 리퀘스트 열기
특허
이 프로젝트는 MIT 라이선스에 따라 라이선스가 부여되었습니다. 자세한 내용은 라이선스 파일을 참조하세요.
감사의 말