XL

xkiranj/linux-command-mcp

Developer tools

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

25 stars 8 forks 品質 70 トレンド 0MIT

Linux コマンドを実行する MCP サーバーとクライアント

概要

Linux コマンド MCP は、モデルコンテキストプロトコル (MCP) を使用して構築されたリモートコマンド実行システムで、Linux コマンドの安全で標準化された実行を可能にします。 MCP サーバーは claude desktop config.json ファイルに構成されます。通常は ~/.config/Claude/claude desktop config.json にあります。 - "command": executor (node, npx, uvx) - "args" を指定します。 サーバの実行可能へのフルパス - パスがあなたのindex.jsへの絶対パスであることを確認してください - 常に、絶対パス - ファイルの権限を検証 - 指定されたファイルが実行可能であることを確認してください - Node.js (v18.x 以降) - npm - PM2 (プロセス管理用) 利用可能なコマンド: 1. exec - Linux コマンドの実行 2. リスト [ディレクトリ] - リスト ディレクトリのコンテンツ 3 - このヘルプを表示 4. 終了 - クライアントを終了します : Linux コマンド MCP サーバーが stdin 経由でインタラクティブなスクリプトをサポートしています! stdin パラメーターを使用して、インタラクティブなスクリプトに入力できるようになりました

概要(AI 翻訳)

概要

Linux コマンド MCP は、モデルコンテキストプロトコル (MCP) を使用して構築されたリモートコマンド実行システムで、Linux コマンドの安全で標準化された実行を可能にします。

ClaudeデスクトップMCPサーバーの#構成

設定の理解

MCP サーバーは、[[claude_desktop_config.json]] ファイルに構成されます。通常、[~/.config/Claude/claude_desktop_config.json] にあります。

構成構造

##LinuxコマンドMCPサーバーの設定

構成 説明

  • ["command": 行使者 ([node]]), [npx], [[uvx]])を指定します。
  • ["args": サーバの実行可能パス
  • パスが [[T7] の絶対パスであることを確認してください。

重要な構成のヒント

  • 常にフルで絶対的なパスを使用する
  • ファイル権限の確認
  • 指定されたファイルが実行可能であることを確認してください

前提条件

  • Node.js(v18.x以降)
  • 午後
  • PM2(プロセス管理用)

インストール

  1. リポジトリのクローン化

  2. サーバ依存関係のインストール

  3. クライアントの依存関係をインストールする

使用法

サーバーの起動

  1. サーバーディレクトリに移動

  2. PM2から始めて下さい

クライアントの使用

利用可能なコマンド:

  1. exec - Linux コマンドを実行する

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。

README

以下は原文 README の抜粋です。原文を見る。

Linux Command MCP (Model Context Protocol)

Overview

Linux Command MCP is a remote command execution system built using the Model Context Protocol (MCP), allowing secure and standardized execution of Linux commands.

Configuration for Claude Desktop MCP Servers

Understanding the Configuration

The MCP servers are configured in the claude_desktop_config.json file, typically located at ~/.config/Claude/claude_desktop_config.json.

Configuration Structure

"mcpServers": {
  "server-name": {
    "command": "node|npx|uvx",
    "args": ["server-specific-arguments"],
    "env": {
      "OPTIONAL_ENVIRONMENT_VARIABLES": "value"
    }
  }
}

Linux Command MCP Server Configuration

"linux-command": {
  "command": "node",
  "args": [
    "/full/path/to/linux-command-mcp/server/dist/index.js"
  ]
}

Configuration Explained

  • "command": Specifies the executor (node, npx, uvx)
  • "args": Full path to the server’s executable
  • Ensure the path is an absolute path to your index.js

Important Configuration Tips

  • Always use full, absolute paths
  • Verify file permissions
  • Ensure the specified file is executable

Prerequisites

  • Node.js (v18.x or later)
  • npm
  • PM2 (for process management)

Installation

  1. Clone the repository
git clone 
cd linux-command-mcp
  1. Install server dependencies
cd server
npm install
npm run build
  1. Install client dependencies
cd ../client
npm install
npm run build

Usage

Starting the Server

  1. Navigate to the server directory
cd server
  1. Start with PM2
npm run pm2:start

Using the Client

Available Commands:

  1. exec - Execute a Linux command
  2. list [directory] - List directory contents
  3. help - Show this help
  4. exit - Exit the client

Execute commands directly:

# In the client directory
npm start 
exec "ls -l"
exec "list /home"
exec "uname -a"

Interactive Commands & Stdin Support

✨ NEW: The Linux Command MCP server now supports interactive scripts via stdin!

Using stdin Parameter

You can now provide input to interactive scripts using the stdin parameter:

// Example: Run an interactive Python game
await callTool('execute-command', {
  command: 'python3 /path/to/interactive_script.py',
  stdin: '15\n2\n1\n2\n1\n'  // Automated responses
});

How it works:

  • The stdin parameter sends input to the script before execution
  • Input is sent line-by-line (use \n for newlines)
  • Script runs to completion with automated responses
  • All output is captured and returned

Interactive Script Examples

Python game with input:

# Game expects: number of sticks, then player moves
stdin: "15\n2\n1\n2\n1\n"

Setup wizard:

# Wizard expects: username, email, confirm
stdin: "johndoe\[email protected]\ny\n"

Multiple choice prompt:

GitHub で README 全文を見る

インストール

This server does not publish a one-line install command.

Open the repository installation guide MCP 初心者?mcpskill.org のガイドから始めましょう →

設定

"mcpServers": { "server-name": { "command": "node|npx|uvx", "args": ["server-specific-arguments"], "env": { "OPTIONAL_ENVIRONMENT_VARIABLES": "value" } } }