Bash MCP (Master Control Program)

by yannbam
Verified

local-only server

The server can only run on the client’s local machine because it depends on local resources.

Integrations

  • Built as a TypeScript application that provides a secure interface for bash command execution with comprehensive session management for interactive command sessions.

Bash MCP(マスターコントロールプログラム)

Claude がセキュリティ保護機能を使用して bash コマンドを安全に実行できるようにする TypeScript アプリケーション。

特徴

  • 制御された環境でbashコマンドを実行する
  • ステートレスとステートフル(対話型)の両方のコマンド実行をサポート
  • セキュリティ対策:
    • ホワイトリストに登録されたコマンド
    • ホワイトリストに登録されたディレクトリ
    • コマンド検証
    • 出力のサニタイズ
  • 対話型コマンドのセッション管理
  • 包括的なログ記録

インストール

npm install npm run build

構成

設定は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 build

リンティングとフォーマット

リンティングの問題を確認するには:

npm run lint

リンティングとフォーマットの問題を自動的に修正するには:

./fix-lint.sh

または手動で:

npm run lint:fix # Fix linting issues npm run format # Format code

テスト

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

ホワイトリスト化されたコマンド、ディレクトリ、包括的なログ記録などのセキュリティ保護機能を使用して、Claude が bash コマンドを安全に実行できるようにする TypeScript アプリケーション。

  1. Features
    1. Installation
      1. Configuration
        1. Usage
          1. Simple Command Execution
          2. Interactive Sessions
        2. Security Considerations
          1. Development
            1. Building
            2. Linting and Formatting
            3. Testing
          ID: d8uq01zv9p