MCP Shell Server

MIT License
59
1
  • Linux
  • Apple

Integrations

  • Enables execution of Git commands through the shell interface, allowing AI agents to perform version control operations like commits, pulls, pushes, and branch management.

  • Supports running npm commands through the shell interface, enabling package management operations like installing, updating, and removing JavaScript packages.

  • Facilitates running pnpm commands through the shell interface, offering fast, disk-space efficient package management for JavaScript projects.

MCP シェル サーバー

モデルコンテキストプロトコル(MCP)を使用してシェルコマンドを実行するサーバー。AIエージェントが安全にシェルコマンドを実行できるようにするブリッジとして機能します。

特徴

  • シェルコマンドを実行する(単一行および複数行のサポート)
  • さまざまなシェル (bash、zsh、fish、powershell、cmd など) のサポート
  • 詳細なエラー処理とログ記録
  • MCP Inspector対応

インストール

npmから(ユーザーとして)

# Using npm npm install -g @mkusaka/mcp-shell-server # Using yarn yarn global add @mkusaka/mcp-shell-server # Using pnpm pnpm add -g @mkusaka/mcp-shell-server

ソースから(開発用)

# Clone the repository git clone https://github.com/mkusaka/mcp-shell-server.git cd mcp-shell-server # Install dependencies pnpm install # Build the project pnpm build

MCP構成

カーソルの設定

カーソル構成ファイル ( ~/.cursor/config.json ) に次のコードを追加します。

{ "mcpServers": { "shell": { "command": "npx", "args": ["-y", "@mkusaka/mcp-shell-server"] } } }

ルール設定

カーソル ルール ファイルに次のコードを追加します。

You have tools at your disposal to solve the coding task. Follow these rules regarding tool calls: 1. ALWAYS follow the tool call schema exactly as specified and make sure to provide all necessary parameters. 2. The conversation may reference tools that are no longer available. NEVER call tools that are not explicitly provided. 3. **NEVER refer to tool names when speaking to the USER.** For example, instead of saying 'I need to use the shell_exec tool to execute your command', just say 'I will execute your command'. 4. Only calls tools when they are necessary. If the USER's task is general or you already know the answer, just respond without calling tools. 5. Before calling each tool, first explain to the USER why you are calling it.

使用法

直接実行

node dist/index.js # or as an executable ./dist/index.js

開発モード

pnpm dev

MCP Inspectorによるテスト

pnpm inspect

コマンドライン引数

-s, --shell <shell> Specify the path to the shell to use -h, --help Display help message -V, --version Display version information

ツールリファレンス

シェル実行

指定されたシェルでコマンドを実行します。

パラメータ:

  • command (文字列、必須): 実行するシェルコマンド

リソースリファレンス

サーバーは、リソースとして次のシステム情報を提供します。

ホスト名

システムのホスト名を返します。

URI: hostname://

プラットフォーム

オペレーティング システム プラットフォームを返します。

URI: platform://

シェル

サーバーで使用されているシェル パスを返します。

URI: shell://

ユーザー名

現在のユーザー名を返します。

URI: username://

システム情報

以下の情報を含む包括的なシステム情報を JSON 形式で返します。

  • ホスト名
  • プラットフォーム
  • シェル
  • ユーザー名
  • CPU数
  • 合計メモリ
  • 空きメモリ
  • システム稼働時間

使用例

基本的なコマンド実行

{ "name": "shell_exec", "parameters": { "command": "echo Hello, World!" } }

複数行コマンド(ヒアドキュメント)の実行

{ "name": "shell_exec", "parameters": { "command": "cat << EOF | grep 'example'\nThis is an example text.\nAnother line without the keyword.\nEOF" } }

発達

プロジェクト構造

src/ ├── index.ts # Main entry point └── shell-server/ ├── index.ts # Shell server implementation └── lib/ └── logger.ts # Logging configuration

ログ記録

ログはmcp-shell.logファイルに書き込まれます。

ライセンス

マサチューセッツ工科大学

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

モデル コンテキスト プロトコル (MCP) を使用して AI エージェントがホスト システム上でシェル コマンドを安全に実行できるようにするサーバー。

  1. Features
    1. Installation
      1. From npm (as a user)
      2. From source (for development)
    2. MCP Configuration
      1. Cursor Configuration
      2. Rule Configuration
    3. Usage
      1. Direct Execution
      2. Development Mode
      3. Testing with MCP Inspector
    4. Command Line Arguments
      1. Tool Reference
        1. shell_exec
      2. Resource Reference
        1. hostname
        2. platform
        3. shell
        4. username
        5. system-info
        6. Usage Examples
      3. Development
        1. Project Structure
        2. Logging
      4. License
        ID: t1x2r819sf