Skip to main content
Glama

Bash MCP

by yannbam

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

Claude がセキュリティ対策を講じた上で安全に bash コマンドを実行できるようにする TypeScript アプリケーションです。このプロジェクトは、Model Context Protocol (MCP) を実装し、Claude のような AI アシスタントから bash コマンドを実行するための安全なインターフェースを提供します。

特徴

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

インストール

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サーバーとして

このプロジェクトには、Claude Desktop またはその他の MCP クライアントで使用できる MCP サーバー実装が含まれています。

# Start the TypeScript MCP server npm run mcp # Start the JavaScript MCP server npm run mcp-js # Start with MCP Inspector npm run inspector

MCP サーバーの実装に関する詳細なドキュメントについては、 MCP.md参照してください。

セキュリティに関する考慮事項

この 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

MCP SDKバージョン

このプロジェクトでは、MCP SDK バージョン 1.0.1 を使用します。

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

local-only server

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

モデル コンテキスト プロトコルを通じて安全なインターフェースを提供し、Claude がセキュリティ保護機能を使用して bash コマンドを安全に実行できるようにする TypeScript アプリケーションです。

  1. 特徴
    1. インストール
      1. 構成
        1. 使用法
          1. 図書館として
          2. MCPサーバーとして
        2. セキュリティに関する考慮事項
          1. 発達
            1. 建物
            2. リンティングとフォーマット
            3. テスト
          2. MCP SDKバージョン

            Related MCP Servers

            • A
              security
              A
              license
              A
              quality
              A secure shell command execution server implementing the Model Context Protocol (MCP). This server allows remote execution of whitelisted shell commands with support for stdin input.
              Last updated -
              1
              74
              Python
              MIT License
              • Apple
            • A
              security
              A
              license
              A
              quality
              A Model Context Protocol server that provides secure command-line access to Windows systems, allowing MCP clients like Claude Desktop to safely execute commands in PowerShell, CMD, and Git Bash shells with configurable security controls.
              Last updated -
              9
              350
              105
              JavaScript
              MIT License
            • A
              security
              A
              license
              A
              quality
              A Node.js implementation of the Model Context Protocol that provides secure shell command execution capabilities, allowing AI models like Claude to run shell commands in a controlled environment with built-in security measures.
              Last updated -
              1
              110
              25
              JavaScript
              MIT License
              • Apple
            • -
              security
              F
              license
              -
              quality
              A TypeScript application that allows Claude to safely execute bash commands with security safeguards including whitelisted commands, directories, and comprehensive logging.
              Last updated -
              TypeScript
              • Linux

            View all related MCP servers

            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/yannbam/fresh-bash-mcp'

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