Skip to main content
Glama

MCP Terminal Server

by RinardNick

MCP ターミナルサーバー

モデルコンテキストプロトコル(MCP)を実装した安全なターミナル実行サーバー。このサーバーは、セキュリティ機能とリソース制限を備えた制御されたコマンド実行機能を提供します。

特徴

  • コマンド実行: 出力キャプチャとエラー処理を備えたシェルコマンドを実行します。
  • セキュリティ制御: 許可されたコマンドを制限し、コマンドインジェクションを防止する
  • リソース制御:
    • コマンドタイムアウト
    • 最大出力サイズの制限
  • MCP プロトコルサポート:
    • 標準MCPメッセージ形式
    • 機能広告
    • ストリーミング出力のサポート

発達

ローカルセットアップ

# Clone the repository git clone https://github.com/RinardNick/mcp-terminal.git cd mcp-terminal # Create and activate virtual environment using uv uv venv source .venv/bin/activate # or .venv\Scripts\activate on Windows # Install development dependencies uv pip install -e ".[dev]"

PyPIへの公開

# Build the package uv pip install build python -m build # Upload to PyPI uv pip install twine python -m twine upload dist/*

MCP Inspectorによるテスト

MCP Inspector ツールを使用して、サーバーの実装をテストできます。

# Install inspector npm install -g @modelcontextprotocol/inspector # Test server npx @modelcontextprotocol/inspector python3 src/mcp_terminal/server.py --allowed-commands "python,pip,git,ls,cd"

テストの実行

# Run all tests pytest tests/ # Run specific test file pytest tests/test_terminal.py # Run with coverage pytest --cov=mcp_terminal tests/

Claude Desktopでの使用

パッケージが PyPI に公開されたら:

  1. UV をインストールします(まだインストールされていない場合)。
    pip install uv
  2. UV を使用してパッケージをインストールします
    uv pip install mcp-terminal
  3. Claude Desktop を構成する: Claude Desktop 構成ファイルを編集します (通常、macOS では~/Library/Application Support/Claude/claude_desktop_config.jsonにあります)。
    { "mcpServers": { "terminal": { "command": "uv", "args": [ "pip", "run", "mcp-terminal", "--allowed-commands", "python,pip,git,ls,cd", "--timeout-ms", "30000", "--max-output-size", "1048576" ] } } }

プロトコルの実装

サーバーは、次の機能を備えたモデル コンテキスト プロトコル (MCP) を実装します。

機能広告

{ "protocol": "1.0.0", "name": "terminal", "version": "1.1.0", "capabilities": { "execute": { "description": "Execute a terminal command", "parameters": { "command": { "type": "string", "description": "The command to execute" } }, "returns": { "type": "object", "properties": { "exitCode": { "type": "number" }, "stdout": { "type": "string" }, "stderr": { "type": "string" }, "startTime": { "type": "string" }, "endTime": { "type": "string" } } } } } }

メッセージ形式

リクエスト

{ "type": "execute", "data": { "command": "echo 'hello world'" } }

応答

{ "type": "result", "data": { "command": "echo 'hello world'", "exitCode": 0, "stdout": "hello world\n", "stderr": "", "startTime": "2024-01-20T12:34:56.789Z", "endTime": "2024-01-20T12:34:56.790Z" } }

エラー

{ "type": "error", "data": { "message": "command not allowed" } }

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

  1. コマンド検証:
    • 許可されたコマンドのみ実行できます
    • シェル演算子はブロックされています
    • コマンドインジェクションの試みは阻止される
  2. 資源保護
    • コマンドタイムアウトによりハングアップを防止
    • 出力サイズの制限によりメモリ不足を防止
    • すべての失敗ケースに対するエラー処理
  3. ベストプラクティス:
    • 本番環境では常にallowed-commandsを設定する
    • 控えめなタイムアウトとサイズ制限を使用する
    • コマンド実行ログを監視する

貢献

  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ファイルを参照してください。

You must be authenticated.

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

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

モデル コンテキスト プロトコル (MCP) を介してセキュリティ機能とリソース制限を備えた制御されたコマンド実行を可能にする安全なターミナル実行サーバー。

  1. 特徴
    1. 発達
      1. ローカルセットアップ
      2. PyPIへの公開
      3. MCP Inspectorによるテスト
      4. テストの実行
    2. Claude Desktopでの使用
      1. プロトコルの実装
        1. 機能広告
        2. メッセージ形式
      2. セキュリティに関する考慮事項
        1. 貢献
          1. ライセンス

            Related MCP Servers

            • A
              security
              A
              license
              A
              quality
              A secure shell command execution server implementing the Model Context Protocol (MCP). This server allows remote execution of whitelisted shell commands with support for stdin input.
              Last updated -
              1
              74
              Python
              MIT License
              • Apple
            • A
              security
              A
              license
              A
              quality
              A secure server for executing terminal commands within predefined paths, allowing safe interaction by Large Language Models with operating system environments.
              Last updated -
              1
              11
              3
              JavaScript
              MIT License
              • Apple
              • Linux
            • A
              security
              A
              license
              A
              quality
              A Model Context Protocol server that provides secure command-line access to Windows systems, allowing MCP clients like Claude Desktop to safely execute commands in PowerShell, CMD, and Git Bash shells with configurable security controls.
              Last updated -
              9
              350
              105
              JavaScript
              MIT License
            • -
              security
              F
              license
              -
              quality
              An MCP server that allows secure execution of macOS terminal commands through Claude or Roo Code with built-in security whitelisting and approval mechanisms.
              Last updated -
              1
              JavaScript
              • Apple

            View all related MCP servers

            MCP directory API

            We provide all the information about MCP servers via our MCP API.

            curl -X GET 'https://glama.ai/api/mcp/v1/servers/RinardNick/mcp-terminal'

            If you have feedback or need assistance with the MCP directory API, please join our Discord server