Bash MCP(마스터 제어 프로그램)
Claude가 보안 보호 기능을 통해 bash 명령을 안전하게 실행할 수 있게 해주는 TypeScript 애플리케이션입니다.
특징
- 제어된 환경에서 bash 명령 실행
- 상태 비저장 및 상태 저장(대화형) 명령 실행 모두 지원
- 보안 보호 장치:
- 허용 목록에 있는 명령
- 허용 목록에 있는 디렉토리
- 명령 검증
- 출력 정리
- 대화형 명령에 대한 세션 관리
- 종합 로깅
설치
지엑스피1
구성
구성은 config/default.json
에 저장됩니다. 다음을 사용자 지정할 수 있습니다.
- 허용된 명령
- 허용된 디렉토리
- 세션 설정
- 보안 설정
- 로깅 설정
구성 예:
{
"allowedCommands": ["ls", "cat", "echo", "pwd"],
"allowedDirectories": ["/tmp", "/home"],
"session": {
"timeout": 300,
"maxActiveSessions": 5,
"defaultMode": "stateless"
},
"security": {
"validateCommandsStrictly": true,
"sanitizeOutput": true,
"maxOutputSize": 1048576,
"commandTimeout": 30
},
"logging": {
"level": "info",
"file": "logs/bash-mcp.log",
"maxSize": 10485760,
"maxFiles": 5
}
}
용법
간단한 명령 실행
import { executeCommand } from 'bash-mcp';
const result = await executeCommand('ls -la', { cwd: '/home/user' });
console.log(result.output);
대화형 세션
import { initBashMCP } from 'bash-mcp';
const mcp = await initBashMCP();
// Create a session
const session = mcp.createSession('/home/user');
const sessionId = session.sessionId;
// Execute a command in the session
const result1 = await mcp.executeCommand('ls -la', { sessionId });
console.log(result1.output);
// Send input to the session
const result2 = await mcp.sendInput({ sessionId, input: 'echo "Hello, world!"' });
console.log(result2.output);
// Close the session when done
mcp.closeSession(sessionId);
보안 고려 사항
이 MCP는 보안을 염두에 두고 설계되었지만 다음 사항이 중요합니다.
- 허용되는 명령 및 디렉토리 목록을 최대한 제한적으로 유지하세요.
- 구성을 정기적으로 검토하고 업데이트하세요
- 의심스러운 활동에 대한 로그를 모니터링합니다.
- MCP와 해당 종속성을 최신 상태로 유지하세요.
개발
건물
린팅 및 포맷팅
린팅 문제를 확인하려면:
린팅 및 서식 문제를 자동으로 해결하려면 다음을 수행합니다.
또는 수동으로:
npm run lint:fix # Fix linting issues
npm run format # Format code
테스트