MCP-ShellJS

by erniebrodeur
Verified

local-only server

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

Integrations

  • Provides controlled access to ShellJS commands for filesystem operations, including read-only functions (ls, grep, find) and optional read-write capabilities (mkdir, touch, cp, mv, rm, sed).

  • Built with TypeScript for strong typing, enabling integration with TypeScript applications through a programmatic API.

  • Implements schema-based validation for command inputs and responses, ensuring that all operations conform to defined security constraints.

MCP-ShellJS

Claude のような LLM に安全で制御された ShellJS アクセスを提供する MCP サーバー。

概要

MCP-ShellJSは、モデルコンテキストプロトコル(MCP)とShellJSを橋渡しし、AIシステムが安全なサンドボックス内でシェルコマンドを実行できるようにします。また、複数のセキュリティレイヤーによる制御されたファイルシステムアクセスを提供します。

特徴

  • 簡素化されたセキュリティ
    • デフォルトでは読み取り専用モード
    • コマンドラインフラグによるオプションの読み取り/書き込みモード
    • コマンドラインフラグによるオプションの実行権限
  • Zodによるスキーマベースの検証
  • 完全な ShellJS 機能 ( lsgrepsedfindなど)
  • 強い型付けによるTypeScript実装
  • LLM統合のためのシンプルなAPI

インストール

# Clone the repository git clone https://github.com/yourusername/mcp-shelljs.git cd mcp-shelljs # Install dependencies npm install # Build the project npm run build

使用法

コマンドライン

# Default mode (read-only) node dist/index.js # Enable read-write operations node dist/index.js --enable-rw # Enable exec command (careful!) node dist/index.js --enable-exec # Enable both node dist/index.js --enable-rw --enable-exec

TypeScript統合

// Import and initialize the MCP server import { startMCPServer } from 'mcp-shelljs'; // Start the server with default configuration (read-only) startMCPServer(); // Or with custom security configuration startMCPServer({ enableRw: true, // Enable read-write operations enableExec: false // Keep exec disabled });

セキュリティ設計

MCP-ShellJS はシンプルなセキュリティ モデルを実装します。

  1. 読み取り専用モード(デフォルト):ファイルシステムを変更しないコマンドのみが使用可能
  2. 読み書きモード( --enable-rw ): ファイルを作成、変更、または削除できるコマンドを有効にします
  3. 実行モード( --enable-exec ): 潜在的に危険なexecコマンドを有効にして、任意のシェル コマンドを実行します。

サーバーは stdio トランスポートのみで実行されるため、デスクトップ LLM アプリケーションとの統合に適しています。

MCP-ShellJS を使用する理由

AI 開発者にとって、MCP-ShellJS は、リスクを制御しながら強力なファイルシステム機能を実現します。

  • 効率的な探索: grepによる高速検索とコードベース全体のfind
  • テキスト処理: ファイル全体をロードせずにsedで変換する
  • 安全な自動化:AIがファイルの整理と管理を支援
  • 強力なパイプライン: Unix スタイルのパイプによるチェーン操作

リソース

ディレクトリリソース

directory://{path}?include={glob}&exclude={glob}&honor_gitignore={boolean}

強力なフィルタリング機能を備えたディレクトリ リストを提供します。

パラメータ説明
include含める glob パターン (例: *.js,*.ts )
exclude除外する glob パターン (例: node_modules,dist )
honor_gitignoretrueの場合、.gitignore のパターンに一致するファイルを除外します。
recursivetrueの場合、サブディレクトリを再帰的に含めます

例:

directory:///project/src?include=*.ts&exclude=*.test.ts&honor_gitignore=true

ファイルリソース

file://{path}?lines={boolean}&start={number}&end={number}

特定の部分を表示するためのオプションを含むファイルの内容を提供します。

パラメータ説明
linestrueの場合、出力に行番号が含まれます
start含める最初の行(1から始まるインデックス)
end最後に含める行
highlight一致するテキストを強調表示するグロブパターン

例:

file:///project/src/index.ts?lines=true&start=10&end=50

ツール

MCP-ShellJS は、セキュリティ リスク レベル別にグループ化された ShellJS コマンドをツールとして公開します。

読み取り専用ツール

道具説明議論
cat出力ファイルの内容files : 文字列/配列、 options : -n付きオブジェクト (行数)
grepファイル内のパターンを検索するregexfilesoptions : -v (反転)、 -l (ファイル名のみ)、 -i (大文字と小文字を区別しない) を指定したオブジェクト
find再帰的にファイルを検索するpaths : 文字列/配列 (ベースディレクトリを含むファイルパスを返します)
lsディレクトリの内容を一覧表示するpaths : 文字列/配列、 options : -R (再帰)、 -A (すべて)、 -L (シンボリックリンクをたどる)、 -d (ディレクトリのみ) を使用したオブジェクト
whichコマンドを見つけるcommand : 文字列(コマンドへのパスを返す)
pwd作業ディレクトリを印刷(議論なし)
testテストファイルの条件expression : 文字列 (例: -d pathディレクトリが存在する、 -f pathファイルが存在する)
head最初の行を表示files : 文字列/配列、 options : -n <num>付きのオブジェクト (表示する行数)
tail最後の行を表示files : 文字列/配列、 options : -n <num>付きのオブジェクト (表示する行数)
sortソートラインfiles : 文字列/配列、 options : -r (逆順)、 -n (数値) 付きのオブジェクト
uniq重複行をフィルタリングinput : 文字列、 output : 文字列、 options : -i (大文字と小文字を区別しない)、 -c (カウント)、 -d (重複のみ) 付きのオブジェクト

読み書きツール

道具説明議論
mkdirディレクトリを作成するdir : 文字列/配列、 options : -p付きのオブジェクト(中間ディレクトリを作成)
touchファイルの作成/更新files : 文字列/配列、 options : -c (作成なし)、 -a (アクセス時間のみ)、 -m (変更時間のみ) を指定したオブジェクト
cpファイル/ディレクトリをコピーするsource : 文字列/配列、 dest : 文字列、 options : -R (再帰)、 -n (上書きなし)、 -f (強制) 付きのオブジェクト
mvファイル/ディレクトリを移動するsource : 文字列/配列、 dest : 文字列、 options : -f (強制)、 -n (上書きなし) 付きのオブジェクト
rmファイル/ディレクトリを削除するfiles : 文字列/配列、 options : -r/-R (再帰)、 -f (強制) 付きのオブジェクト
sedファイルのストリームエディターsearch_regex : 正規表現、 replacement : 文字列、 files : 文字列/配列、 options : -i付きオブジェクト (インプレース)

特別な権限ツール

道具説明議論
execコマンドを実行command : 文字列、 options : asyncsilentallowExec: true構成が必要なオブジェクト

ライセンス

GPL-3.0以降

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

LLM に制御された ShellJS アクセスを提供する安全な MCP サーバー。これにより、AI システムはシェル コマンドを安全に実行し、構成可能なセキュリティ サンドボックス内でファイルシステムと対話できるようになります。

  1. Overview
    1. Features
      1. Installation
        1. Usage
          1. Command Line
          2. TypeScript Integration
        2. Security Design
          1. Why Use MCP-ShellJS?
            1. Resources
              1. Directory Resource
              2. File Resource
            2. Tools
              1. Read-Only Tools
              2. Read-Write Tools
              3. Special Permission Tools
            3. License
              ID: lyxa7v4e53