MCP-코드사반트
CodeSavant는 현재 진행 중인 프로젝트입니다.
CodeSavant는 코드 조작, 실행 및 버전 제어 기능을 제공하는 모델 컨텍스트 프로토콜(MCP) 서버입니다. 이를 통해 AI 비서가 변경 내역을 유지하면서 코드를 읽고, 쓰고, 실행할 수 있습니다.
특징
- 라인별 작업으로 코드 파일을 읽고 씁니다.
- 여러 프로그래밍 언어(Python, Node.js)로 코드 실행
- 제어된 환경에서 셸 명령 실행
- 버전 제어를 통해 코드 변경 사항을 추적하고 관리하세요
- 코드 파일 내에서 검색
- 이전 버전의 코드로 되돌리기
설치
- 저장소를 복제합니다.
지엑스피1
- 필요한 종속성을 설치하세요:
pip install -r requirements.txt
- Claude Desktop config.json에 서버 구성을 추가합니다.
{
"mcpServers": {
"codesavant": {
"command": "python",
"args": ["path/to/codesavant.py"]
}
}
}
디렉토리 구조
서버는 다음과 같은 디렉토리 구조를 생성하고 관리합니다.
workspaces/
├── project1/
│ ├── .code_history.json
│ └── [code files]
├── project2/
│ ├── .code_history.json
│ └── [code files]
└── ...
도구 참조
자세한 사용법
1. 코드 파일 읽기
코드 파일의 내용을 읽고, 선택적으로 특정 섹션을 검색합니다.
{
"project": "string", // Project name
"path": "string", // Path to file relative to project workspace
"search": "string" // (Optional) Text/pattern to search for in file
}
응답:
{
"success": true,
"timestamp": 1234567890,
"data": {
"content": "string", // File content
"start_line": number, // (Only if search used) Starting line of found section
"end_line": number // (Only if search used) Ending line of found section
}
}
2. 코드 파일 쓰기
코드 파일의 특정 줄을 작성하거나 업데이트합니다.
{
"project": "string", // Project name
"path": "string", // Path to file relative to workspace
"content": "string", // Content to write (just the lines being changed)
"start_line": number, // Starting line number for the change
"end_line": number // (Optional) Ending line number for the change
}
응답:
{
"success": true,
"timestamp": 1234567890,
"data": {
"diff": {
"changes": [ // List of changes made
[string, number, number, number, number] // (type, old_start, old_end, new_start, new_end)
],
"timestamp": number // When the change was made
}
}
}
3. 코드 기록을 가져오세요
코드 파일의 변경 내역을 가져옵니다.
{
"path": "string" // Path to file relative to workspace
}
응답:
{
"success": true,
"timestamp": 1234567890,
"data": {
"history": [
{
"changes": [ // List of changes made
[string, number, number, number, number]
],
"timestamp": number
}
]
}
}
4. 실행_코드_명령
코드 관련 셸 명령을 실행합니다.
{
"command": "string", // Shell command to execute
"timeout": number // (Optional) Command timeout in seconds (default: 30)
}
응답:
{
"success": true,
"timestamp": 1234567890,
"data": {
"state": "success|error|timeout|cancelled",
"output": "string", // Command output
"error": "string", // Error message if any
"runtime": number, // Execution time in seconds
"exit_code": number // Command exit code
}
}
5. 실행 코드
지정된 언어로 코드를 실행합니다.
{
"code": "string", // Code to execute
"language": "string", // Programming language ("python" or "node")
"timeout": number // (Optional) Execution timeout in seconds (default: 30)
}
응답:
{
"success": true,
"timestamp": 1234567890,
"data": {
"state": "success|error|timeout|cancelled",
"output": "string", // Code execution output
"error": "string", // Error message if any
"runtime": number, // Execution time in seconds
"exit_code": number // Execution exit code
}
}
6. 버전으로 되돌리기
코드 파일을 특정 버전으로 되돌립니다.
{
"path": "string", // Path to file relative to workspace
"timestamp": number // Timestamp of version to revert to
}
응답:
{
"success": true,
"timestamp": 1234567890,
"data": {
"diff": {
"changes": [ // List of changes made
[string, number, number, number, number]
],
"timestamp": number // When the reversion was made
}
}
}
7. 코드 파일 줄 읽기
코드 파일에서 특정 줄을 읽습니다.
{
"project": "string", // Project name
"path": "string", // Path to file relative to project workspace
"start_line": number, // Starting line number to read
"end_line": number // (Optional) Ending line number to read
}
응답:
{
"success": true,
"timestamp": 1234567890,
"data": {
"content": "string" // Content of the specified lines
}
}
오류 처리
서버는 다음 형식으로 자세한 오류 응답을 제공합니다.
{
"success": false,
"timestamp": 1234567890,
"data": null,
"error": "Error message"
}
오류 유형은 다음과 같습니다.
CodeFileError
: 파일 작업 오류CodeValidationError
: 코드 검증 오류CodeExecutionError
: 코드 실행 오류
언어 지원
현재 코드 실행에 지원되는 언어:
- Python(시스템 Python 인터프리터 사용)
- Node.js(node 명령 사용)
각 언어를 실행하면 작업 공간 디렉토리에 임시 파일이 생성되고 적절한 인터프리터로 실행됩니다.
기여하다
- 저장소를 포크하세요
- 기능 브랜치를 생성하세요
- 변경 사항을 커밋하세요
- 지점으로 밀어 넣기
- 새로운 풀 리퀘스트 만들기
특허
이 프로젝트는 MIT 라이선스에 따라 라이선스가 부여되었습니다. 자세한 내용은 라이선스 파일을 참조하세요.
작가
토드 울븐 - ( https://github.com/tolven )
감사의 말
- Anthropic의 MCP(Model Context Protocol)로 구축됨
- Anthropic의 Claude와 함께 사용하도록 개발됨