Remote Command MCP Server

MIT License
  • Linux

Integrations

  • Enables execution of Chocolatey commands for Windows package management through the remote command interface

  • Provides ability to execute Git commands remotely with support for repository operations like status checks and working directory specification

  • Supports execution of Linux-specific commands with automatic command normalization between Windows and Unix-like systems

リモートコマンドMCPサーバー

異なるオペレーティングシステム間でリモートコマンド実行を可能にするモデルコンテキストプロトコル(MCP)サーバー。このサーバーは、シェルコマンドを実行するための統一されたインターフェースを提供し、WindowsとUnix系システム間のプラットフォーム固有の違いを自動的に処理します。

特徴

  • クロスプラットフォームのコマンド実行
  • WindowsとUnix間の自動コマンド正規化
  • 組み込みのエラー処理と出力ストリーミング
  • 作業ディレクトリ指定のサポート
  • プラットフォーム固有のシェルの選択

インストール

  1. リポジトリをクローンします。
git clone https://github.com/deepsuthar496/Remote-Command-MCP cd remote-command-server
  1. 依存関係をインストールします:
npm install
  1. サーバーを構築します。
npm run build
  1. 設定ファイルで MCP サーバーを構成します。

VSCode Cline 拡張機能 ( cline_mcp_settings.json ) の場合:

{ "mcpServers": { "remote-command": { "command": "node", "args": ["path/to/remote-command-server/build/index.js"], "disabled": false, "autoApprove": [] } } }

使用法

サーバーは、ホストマシン上で有効な任意のシェルコマンドを実行できるexecute_remote_commandという単一のツールを提供します。これには以下が含まれます。

  • システムコマンド
  • パッケージ マネージャー コマンド (apt、yum、chocolatey など)
  • 開発ツール (git、npm、python など)
  • ファイル操作
  • ネットワークコマンド
  • サービス管理
  • システムで利用可能なその他のCLIコマンド

ツール: execute_remote_command

パラメータ:

  • command (必須): ホストOS上で実行できる有効なシェルコマンド
  • cwd (オプション): コマンド実行のための作業ディレクトリ

  1. システム情報:
<use_mcp_tool> <server_name>remote-command</server_name> <tool_name>execute_remote_command</tool_name> <arguments> { "command": "systeminfo" // Windows // or "uname -a" // Linux } </arguments> </use_mcp_tool>
  1. パッケージ管理:
<use_mcp_tool> <server_name>remote-command</server_name> <tool_name>execute_remote_command</tool_name> <arguments> { "command": "npm list -g --depth=0" // List global NPM packages } </arguments> </use_mcp_tool>
  1. ネットワーク操作:
<use_mcp_tool> <server_name>remote-command</server_name> <tool_name>execute_remote_command</tool_name> <arguments> { "command": "netstat -an" // Show all network connections } </arguments> </use_mcp_tool>
  1. Git 操作:
<use_mcp_tool> <server_name>remote-command</server_name> <tool_name>execute_remote_command</tool_name> <arguments> { "command": "git status", "cwd": "/path/to/repo" } </arguments> </use_mcp_tool>
  1. ファイル操作:
<use_mcp_tool> <server_name>remote-command</server_name> <tool_name>execute_remote_command</tool_name> <arguments> { "command": "ls -la", // List files with details "cwd": "/path/to/directory" } </arguments> </use_mcp_tool>
  1. プロセス管理:
<use_mcp_tool> <server_name>remote-command</server_name> <tool_name>execute_remote_command</tool_name> <arguments> { "command": "ps aux" // List all running processes (Unix) // or "tasklist" // Windows equivalent } </arguments> </use_mcp_tool>
  1. サービス制御:
<use_mcp_tool> <server_name>remote-command</server_name> <tool_name>execute_remote_command</tool_name> <arguments> { "command": "systemctl status nginx" // Check service status (Linux) // or "sc query nginx" // Windows equivalent } </arguments> </use_mcp_tool>

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

このサーバーは任意のシステム コマンドを実行できるため、次のセキュリティ プラクティスを考慮してください。

  1. アクセス制御: MCP サーバーへのアクセスを信頼できるユーザーのみに制限します
  2. コマンド検証: アプリケーションロジックで実行する前にコマンドを検証します
  3. 作業ディレクトリ: cwdパラメータを使用して、コマンドの実行を特定のディレクトリに制限します。
  4. 環境: システム設定や機密ファイルを変更するコマンドには注意してください
  5. 権限: 適切なユーザー権限でMCPサーバーを実行します

クロスプラットフォームのコマンド処理

サーバーはプラットフォーム固有の違いを自動的に処理します。

  1. コマンド翻訳:
    • lsdir (プラットフォームに応じて自動的に変換されます)
    • 各プラットフォームに適したパイプ演算子のフォーマット
  2. シェルの選択:
    • Windows: cmd.exeを使用します
    • Unix/Linux: /bin/shを使用する

エラー処理

サーバーは詳細なエラーメッセージを提供し、応答には標準出力と標準エラー出力の両方が含まれます。コマンドが失敗した場合は、問題の詳細を含むエラーメッセージが表示されます。

エラー応答の例:

{ "content": [ { "type": "text", "text": "Command execution error: Command failed with exit code 1" } ], "isError": true }

発達

プロジェクト構造

remote-command-server/ ├── src/ │ └── index.ts # Main server implementation ├── package.json ├── tsconfig.json └── README.md

建物

npm run build

これにより、TypeScript コードがコンパイルされ、 buildディレクトリに実行可能ファイルが作成されます。

貢献

  1. リポジトリをフォークする
  2. 機能ブランチを作成します( git checkout -b feature/amazing-feature
  3. 変更をコミットします ( git commit -m 'Add some amazing feature' )
  4. ブランチにプッシュする ( git push origin feature/amazing-feature )
  5. プルリクエストを開く

ライセンス

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

-
security - not tested
A
license - permissive license
-
quality - not tested

異なるオペレーティング システム間でシェル コマンドをリモート実行できるようにし、Windows と Unix 系システム間のプラットフォーム固有の違いを自動的に処理するモデル コンテキスト プロトコル サーバー。

  1. Features
    1. Installation
      1. Usage
        1. Tool: execute_remote_command
        2. Examples
        3. Security Considerations
        4. Cross-Platform Command Handling
        5. Error Handling
      2. Development
        1. Project Structure
        2. Building
      3. Contributing
        1. License
          ID: mshw9wfbs6