Skip to main content
Glama
Shell MCP Server

Shell MCP Server

by blazickjp

🖥️ シェル MCP サーバー

PyPIバージョン ライセンス: MIT パイソン コードスタイル: 黒

🚀 Shell MCP サーバーを使用して、AI アプリケーションに安全なシェル コマンド実行機能を追加します。モデル コンテキスト プロトコル用に構築されています。

✨ 特徴

  • 🔒セキュア実行- コマンドは指定されたディレクトリ内でのみ実行されます

  • 🐚複数のシェル- bash、sh、cmd、powershell をサポート

  • ⏱️タイムアウト制御- 長時間実行されるコマンドの自動終了

  • 🌍クロスプラットフォーム- Unix と Windows の両方のシステムで動作します

  • 🛡️デフォルトで安全- ディレクトリとシェルの検証が組み込まれています

Related MCP server: Terminal MCP Server

🚀 クイックスタート

インストール

# Using pip
pip install shell-mcp-server

# Using uv (recommended)
uv pip install shell-mcp-server

🔌 クロード デスクトップ統合

シェル コマンドの実行を有効にするには、Claude Desktop 構成にこれを追加します。

{
    "mcpServers": {
        "shell-mcp-server": {
            "command": "uv",
            "args": [
                "--directory",
                "/path/to/shell-mcp-server",
                "run",
                "shell-mcp-server",
                "/path/to/allowed/dir1",
                "/path/to/allowed/dir2",
                "--shell", "bash", "/bin/bash",
                "--shell", "zsh", "/bin/zsh"
            ]
        }
    }
}

🎮 使用例

基本的なファイル操作

# List directory contents
result = execute_command(
    command="ls -la",
    shell="bash",
    cwd="/path/to/project"
)

# Find files by pattern
result = execute_command(
    command="find . -name '*.py'",
    shell="bash",
    cwd="/path/to/project"
)

プロジェクト管理

# Git operations
result = execute_command(
    command="git status && git diff",
    shell="bash",
    cwd="/path/to/repo"
)

# Package management
result = execute_command(
    command="pip list --outdated",
    shell="bash",
    cwd="/path/to/python/project"
)

システム情報

# Resource usage
result = execute_command(
    command="df -h && free -h",
    shell="bash",
    cwd="/path/to/dir"
)

# Process monitoring
result = execute_command(
    command="ps aux | grep python",
    shell="bash",
    cwd="/path/to/dir"
)

ファイル処理

# Search file content
result = execute_command(
    command="grep -r 'TODO' .",
    shell="bash",
    cwd="/path/to/project"
)

# File manipulation
result = execute_command(
    command="awk '{print $1}' data.csv | sort | uniq -c",
    shell="bash",
    cwd="/path/to/data"
)

Windows固有の例

# List processes
result = execute_command(
    command="Get-Process | Where-Object {$_.CPU -gt 10}",
    shell="powershell",
    cwd="C:\\path\\to\\dir"
)

# System information
result = execute_command(
    command="systeminfo | findstr /B /C:'OS'",
    shell="cmd",
    cwd="C:\\path\\to\\dir"
)

⚙️ 構成

コマンドライン引数を使用して動作を構成します。

口論

説明

directories

📁 許可されたディレクトリのリスト

--shell name path

🐚 シェルの仕様(名前とパス)

環境変数:

  • COMMAND_TIMEOUT : ⏱️ 最大実行時間(秒)(デフォルト: 30)

🛡️ セキュリティ機能

  • 🔐ディレクトリ分離: コマンドは指定されたディレクトリ内でのみ実行できます

  • 🔒シェル制御: 設定されたシェルのみが許可されます

  • ⏰タイムアウト保護: すべてのコマンドには設定可能なタイムアウトがあります

  • 🛑パス検証: 作業ディレクトリの検証によりトラバーサル攻撃を防止

  • 👤権限分離: コマンドはサーバープロセスと同じ権限で実行されます

🛠️ 開発

開発環境をセットアップします。

# Create and activate virtual environment
uv venv
source .venv/bin/activate

# Install development dependencies
uv pip install -e ".[test]"

# Run tests
python -m pytest

# Run tests with coverage
python -m pytest --cov=shell_mcp_server

🤝 貢献する

貢献大歓迎!お気軽にどうぞ:

  • 🐛 バグを報告する

  • 💡 機能を提案する

  • 🔧 プルリクエストを送信する

  • 📚 ドキュメントの改善

📜 ライセンス

MIT ライセンス - 詳細についてはライセンスを参照してください。


🌟 セキュア シェル アクセスで AI を強化しましょう! 🌟

モデルコンテキストプロトコル向けに構築 | MCPコミュニティによって愛を込めて作成

Available Tools

1 tool
execute_commandB

Execute a shell command in a specified directory using a specified shell

Inputs: command (required), shell (required), cwd (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.3/5.0

    Scored across 1 tool

    Disambiguation5/5

    With only one tool, there is no possibility of ambiguity or overlap between tools. The single tool has a clear and distinct purpose.

    Naming Consistency5/5

    A single tool inherently has perfect naming consistency, as there are no other tools to compare it against for patterns or conventions.

    Tool Count2/5

    A single tool is generally too few for a server's purpose, as it limits functionality and scope. For a shell server, this feels thin and may not cover common use cases effectively.

    Completeness2/5

    The tool surface is severely incomplete for a shell domain. It lacks operations for file management, process control, environment variables, or other common shell tasks, leading to significant gaps that will cause agent failures.

    Maintenance

    ActivityInactive
    ResponsivenessLimited data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      A secure server for executing terminal commands within predefined paths, allowing safe interaction by Large Language Models with operating system environments.
      1
      41 npm
      18
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables safe execution of terminal commands across different shells (bash, cmd, PowerShell) with configurable timeouts, working directories, and resource limits for command-line operations through AI assistants.
      -
    • A
      license
      A
      quality
      D
      maintenance
      Enables AI assistants to execute terminal commands on a host machine with configurable, granular permission controls and safety protections. It features multiple security modes, including allowlists and manual approval, to ensure safe command execution within specified directories.
      6
      Apache 2.0
    • A
      license
      Not graded
      quality
      C
      maintenance
      Provides a secure environment for executing shell commands with restricted directory access and timeout enforcement. It includes tools for running commands, managing execution history, and isolating environment variables.
      24 npm
      MIT