Skip to main content
Glama
simon-ami

Windows CLI MCP Server

Windows CLI MCP サーバー

NPMダウンロード NPMバージョン 鍛冶屋のバッジ

Windowsシステム上で安全なコマンドラインインタラクションを実現するMCPサーバー。PowerShell、CMD、Git Bashシェル、そしてSSH経由のリモートシステムへの制御されたアクセスを可能にします。MCPクライアント( Claude Desktopなど)が、 Open Interpreterと同様にシステム上で操作を実行できるようになります。

[!重要] このMCPサーバーは、SSH経由でシステムのコマンドラインインターフェースとリモートシステムへの直接アクセスを提供します。有効にすると、ファイル、環境変数、コマンド実行機能、およびリモートサーバー管理へのアクセスが許可されます。

  • 許可されたパスとSSH接続を確認して制限する

  • ディレクトリ制限を有効にする

  • コマンドブロックを構成する

  • セキュリティへの影響を考慮する

詳細については、構成を参照してください。

特徴

  • マルチシェルのサポート: PowerShell、コマンドプロンプト (CMD)、Git Bash でコマンドを実行します。

  • SSHサポート: SSH経由でリモートシステム上でコマンドを実行する

  • リソースの公開: SSH 接続、現在のディレクトリ、および構成を MCP リソースとして表示します。

  • セキュリティ管理:

    • コマンドと SSH コマンドのブロック (フルパス、大文字と小文字の区別)

    • 作業ディレクトリの検証

    • 最大コマンド長制限

    • コマンドのログ記録と履歴の追跡

    • スマートな引数検証

  • 設定可能:

    • カスタムセキュリティルール

    • シェル固有の設定

    • SSH接続プロファイル

    • パス制限

    • ブロックされたコマンドリスト

サーバーが MCP クライアントに提供するツールとリソースの詳細については、 APIセクションを参照してください。

: サーバーは、設定されたディレクトリ内、許可されたコマンド、および設定された SSH 接続での操作のみを許可します。

Related MCP server: Calculator MCP Server

Claude Desktopでの使用

これをclaude_desktop_config.jsonに追加します:

{
  "mcpServers": {
    "windows-cli": {
      "command": "npx",
      "args": ["-y", "@simonb97/server-win-cli"]
    }
  }
}

特定の設定ファイルで使用する場合は、 --configフラグを追加します。

{
  "mcpServers": {
    "windows-cli": {
      "command": "npx",
      "args": [
        "-y",
        "@simonb97/server-win-cli",
        "--config",
        "path/to/your/config.json"
      ]
    }
  }
}

設定後、次のことが可能になります。

  • 利用可能なツールを使用して直接コマンドを実行する

  • リソースセクションで構成されたSSH接続とサーバー構成を表示します。

  • 提供されたツールを使用してSSH接続を管理する

構成

サーバーはJSON構成ファイルを使用して動作をカスタマイズします。セキュリティ制御、シェル構成、SSH接続の設定を指定できます。

  1. デフォルトの設定ファイルを作成するには、次のいずれかを実行します。

a) config.json.exampleconfig.jsonにコピーするか、

**b)**実行:

npx @simonb97/server-win-cli --init-config ./config.json
  1. 次に、 「Claude Desktop での使用」セクションで説明されているように、 --configフラグを設定して構成ファイルを指定します。

構成場所

サーバーは、次の場所 (順番に) で構成を検索します。

  1. --configフラグで指定されたパス

  2. 現在のディレクトリの./config.json

  3. ユーザーのホームディレクトリ内の ~/.win-cli-mcp/config.json

設定ファイルが見つからない場合、サーバーはデフォルトの(制限された)設定を使用します。

デフォルト設定

:デフォルト設定は制限を厳しくし、セキュリティを強化するように設計されています。各設定の詳細については、「構成設定」セクションをご覧ください。

{
  "security": {
    "maxCommandLength": 2000,
    "blockedCommands": [
      "rm",
      "del",
      "rmdir",
      "format",
      "shutdown",
      "restart",
      "reg",
      "regedit",
      "net",
      "netsh",
      "takeown",
      "icacls"
    ],
    "blockedArguments": [
      "--exec",
      "-e",
      "/c",
      "-enc",
      "-encodedcommand",
      "-command",
      "--interactive",
      "-i",
      "--login",
      "--system"
    ],
    "allowedPaths": ["User's home directory", "Current working directory"],
    "restrictWorkingDirectory": true,
    "logCommands": true,
    "maxHistorySize": 1000,
    "commandTimeout": 30,
    "enableInjectionProtection": true
  },
  "shells": {
    "powershell": {
      "enabled": true,
      "command": "powershell.exe",
      "args": ["-NoProfile", "-NonInteractive", "-Command"],
      "blockedOperators": ["&", "|", ";", "`"]
    },
    "cmd": {
      "enabled": true,
      "command": "cmd.exe",
      "args": ["/c"],
      "blockedOperators": ["&", "|", ";", "`"]
    },
    "gitbash": {
      "enabled": true,
      "command": "C:\\Program Files\\Git\\bin\\bash.exe",
      "args": ["-c"],
      "blockedOperators": ["&", "|", ";", "`"]
    }
  },
  "ssh": {
    "enabled": false,
    "defaultTimeout": 30,
    "maxConcurrentSessions": 5,
    "keepaliveInterval": 10000,
    "keepaliveCountMax": 3,
    "readyTimeout": 20000,
    "connections": {}
  }
}

構成設定

設定ファイルは、 securityshellsssh 3 つの主要なセクションに分かれています。

セキュリティ設定

{
  "security": {
    // Maximum allowed length for any command
    "maxCommandLength": 1000,

    // Commands to block - blocks both direct use and full paths
    // Example: "rm" blocks both "rm" and "C:\\Windows\\System32\\rm.exe"
    // Case-insensitive: "del" blocks "DEL.EXE", "del.cmd", etc.
    "blockedCommands": [
      "rm", // Delete files
      "del", // Delete files
      "rmdir", // Delete directories
      "format", // Format disks
      "shutdown", // Shutdown system
      "restart", // Restart system
      "reg", // Registry editor
      "regedit", // Registry editor
      "net", // Network commands
      "netsh", // Network commands
      "takeown", // Take ownership of files
      "icacls" // Change file permissions
    ],

    // Arguments that will be blocked when used with any command
    // Note: Checks each argument independently - "cd warm_dir" won't be blocked just because "rm" is in blockedCommands
    "blockedArguments": [
      "--exec", // Execution flags
      "-e", // Short execution flags
      "/c", // Command execution in some shells
      "-enc", // PowerShell encoded commands
      "-encodedcommand", // PowerShell encoded commands
      "-command", // Direct PowerShell command execution
      "--interactive", // Interactive mode which might bypass restrictions
      "-i", // Short form of interactive
      "--login", // Login shells might have different permissions
      "--system" // System level operations
    ],

    // List of directories where commands can be executed
    "allowedPaths": ["C:\\Users\\YourUsername", "C:\\Projects"],

    // If true, commands can only run in allowedPaths
    "restrictWorkingDirectory": true,

    // If true, saves command history
    "logCommands": true,

    // Maximum number of commands to keep in history
    "maxHistorySize": 1000,

    // Timeout for command execution in seconds (default: 30)
    "commandTimeout": 30,

    // Enable or disable protection against command injection (covers ;, &, |, \`)
    "enableInjectionProtection": true
  }
}

シェルの構成

{
  "shells": {
    "powershell": {
      // Enable/disable this shell
      "enabled": true,
      // Path to shell executable
      "command": "powershell.exe",
      // Default arguments for the shell
      "args": ["-NoProfile", "-NonInteractive", "-Command"],
      // Optional: Specify which command operators to block
      "blockedOperators": ["&", "|", ";", "`"]  // Block all command chaining
    },
    "cmd": {
      "enabled": true,
      "command": "cmd.exe",
      "args": ["/c"],
      "blockedOperators": ["&", "|", ";", "`"]  // Block all command chaining
    },
    "gitbash": {
      "enabled": true,
      "command": "C:\\Program Files\\Git\\bin\\bash.exe",
      "args": ["-c"],
      "blockedOperators": ["&", "|", ";", "`"]  // Block all command chaining
    }
  }
}

SSH設定

{
  "ssh": {
    // Enable/disable SSH functionality
    "enabled": false,

    // Default timeout for SSH commands in seconds
    "defaultTimeout": 30,

    // Maximum number of concurrent SSH sessions
    "maxConcurrentSessions": 5,

    // Interval for sending keepalive packets (in milliseconds)
    "keepaliveInterval": 10000,

    // Maximum number of failed keepalive attempts before disconnecting
    "keepaliveCountMax": 3,

    // Timeout for establishing SSH connections (in milliseconds)
    "readyTimeout": 20000,

    // SSH connection profiles
    "connections": {
      // NOTE: these examples are not set in the default config!
      // Example: Local Raspberry Pi
      "raspberry-pi": {
        "host": "raspberrypi.local", // Hostname or IP address
        "port": 22, // SSH port
        "username": "pi", // SSH username
        "password": "raspberry", // Password authentication (if not using key)
        "keepaliveInterval": 10000, // Override global keepaliveInterval
        "keepaliveCountMax": 3, // Override global keepaliveCountMax
        "readyTimeout": 20000 // Override global readyTimeout
      },
      // Example: Remote server with key authentication
      "dev-server": {
        "host": "dev.example.com",
        "port": 22,
        "username": "admin",
        "privateKeyPath": "C:\\Users\\YourUsername\\.ssh\\id_rsa", // Path to private key
        "keepaliveInterval": 10000,
        "keepaliveCountMax": 3,
        "readyTimeout": 20000
      }
    }
  }
}

API

ツール

  • 実行コマンド

    • 指定されたシェルでコマンドを実行する

    • 入力:

      • shell (文字列): 使用するシェル ("powershell", "cmd", または "gitbash")

      • command (文字列): 実行するコマンド

      • workingDir (オプションの文字列): 作業ディレクトリ

    • コマンド出力をテキストとして返すか、実行が失敗した場合はエラーメッセージを返します。

  • コマンド履歴を取得する

    • 実行されたコマンドの履歴を取得する

    • 入力: limit (オプションの数値)

    • タイムスタンプ付きのコマンド履歴を出力とともに返します

  • ssh_execute

    • SSH経由でリモートシステムでコマンドを実行する

    • 入力:

      • connectionId (文字列): 使用するSSH接続のID

      • command (文字列): 実行するコマンド

    • コマンド出力をテキストとして返すか、実行が失敗した場合はエラーメッセージを返します。

  • ssh_切断

    • SSHサーバーから切断する

    • 入力:

      • connectionId (文字列): 切断するSSH接続のID

    • 確認メッセージを返す

  • SSH接続を作成する

    • 新しいSSH接続を作成する

    • 入力:

      • connectionId (文字列): 新しいSSH接続のID

      • connectionConfig (オブジェクト): ホスト、ポート、ユーザー名、パスワードまたは privateKeyPath を含む接続構成の詳細

    • 確認メッセージを返す

  • read_ssh_connections

    • 設定されたすべてのSSH接続を読み取る

    • 設定からすべてのSSH接続のリストを返します

  • アップデート_ssh_接続

    • 既存のSSH接続を更新する

    • 入力:

      • connectionId (文字列): 更新するSSH接続のID

      • connectionConfig (オブジェクト): 新しい接続構成の詳細

    • 確認メッセージを返します

  • SSH接続の削除

    • SSH接続を削除する

    • 入力:

      • connectionId (文字列): 削除するSSH接続のID

    • 確認メッセージを返す

  • 現在のディレクトリを取得する

    • サーバーの現在の作業ディレクトリを取得する

    • 現在の作業ディレクトリのパスを返します

リソース

  • SSH接続

    • URI 形式: ssh://{connectionId}

    • 機密情報がマスクされた接続の詳細が含まれています

    • 構成されたSSH接続ごとに1つのリソース

    • 例: ssh://raspberry-pi 「raspberry-pi」接続の設定を表示します

  • SSH設定

    • URI: ssh://config

    • 全体的な SSH 構成とすべての接続 (パスワードはマスクされています) が含まれます

    • defaultTimeout、maxConcurrentSessions、接続リストなどの設定を表示します

  • 現在のディレクトリ

    • URI: cli://currentdir

    • CLIサーバーの現在の作業ディレクトリが含まれます

    • デフォルトでコマンドが実行されるパスを表示します

  • CLI設定

    • URI: cli://config

    • CLI サーバー構成が含まれます (機密データは除く)

    • セキュリティ設定、シェル構成、SSH設定を表示します

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

組み込みのセキュリティ機能(常時有効)

次のセキュリティ機能はサーバーにハードコードされており、無効にすることはできません。

  • 大文字と小文字を区別しないコマンド ブロッキング: すべてのコマンド ブロッキングは大文字と小文字を区別しません (例: 「DEL.EXE」、「del.cmd」などは、blockedCommands に「del」が含まれている場合すべてブロックされます)

  • スマート パス解析: サーバーは完全なコマンド パスを解析してバイパスの試みを防止します (「rm」がブロックされている場合は「C:\Windows\System32\rm.exe」もブロックします)

  • コマンド解析インテリジェンス: 誤検知を回避します (例: 「warm_dir」は「rm」が blockedCommands にあるからといってブロックされるわけではありません)

  • 入力検証: すべてのユーザー入力は実行前に検証されます

  • シェルプロセス管理: プロセスは実行後またはタイムアウト後に適切に終了されます

  • 機密データのマスキング: リソース内のパスワードは自動的にマスクされます (******** に置き換えられます)

設定可能なセキュリティ機能(デフォルトで有効)

これらのセキュリティ機能は、config.json ファイルを通じて構成できます。

  • コマンドブロッキング: blockedCommands配列で指定されたコマンドがブロックされます (デフォルトでは、rm、del、format などの危険なコマンドが含まれます)

  • 引数のブロック: blockedArguments配列で指定された引数はブロックされます (デフォルトでは潜在的に危険なフラグが含まれます)

  • コマンドインジェクション保護: コマンドチェーンを防止します ( enableInjectionProtection: trueによりデフォルトで有効)

  • 作業ディレクトリの制限: コマンドの実行を指定されたディレクトリに制限します ( restrictWorkingDirectory: trueによりデフォルトで有効)

  • コマンドの長さ制限: コマンドの最大長を制限します (デフォルト: 2000 文字)

  • コマンドタイムアウト: 実行時間が長すぎるコマンドを終了します (デフォルト: 30 秒)

  • コマンドログ: コマンド履歴を記録します ( logCommands: trueによりデフォルトで有効)

重要なセキュリティ警告

これらは機能ではありませんが、知っておくべき重要なセキュリティ上の考慮事項です。

  • 環境アクセス: コマンドは環境変数にアクセスする可能性があり、そこには機密情報が含まれている可能性があります。

  • ファイルシステムアクセス: コマンドは許可されたパス内のファイルの読み取り/書き込みが可能です。機密データへのアクセスを防ぐため、 allowedPathsを慎重に構成してください。

ライセンス

このプロジェクトは MIT ライセンスに基づいてライセンスされています - 詳細についてはLICENSEファイルを参照してください。

Latest Blog Posts

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/simon-ami/win-cli-mcp-server'

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