Simple Subprocess MCP Server
シェルコマンドを実行するシンプルなModel Context Protocol (MCP) サーバー
概要
このMCPサーバーは、LLMアプリケーションから任意のシェルコマンドを安全に実行できるツールを提供します。FastMCPフレームワークを使用して構築されており、subprocessモジュールを通じてコマンドを実行します。
機能
- 任意のシェルコマンドの実行
- 30秒のタイムアウト設定
- エラーハンドリング
- 標準出力とエラー出力の取得
必要条件
- Python 3.11+
- uv (パッケージマネージャー)
インストール
使用方法
1. サーバーの起動
2. テストクライアントの実行
3. LLMアプリケーションとの統合
Claude Desktop等のMCP対応アプリケーションで使用する場合、設定ファイルにサーバーのパスを追加してください。
API
run_command(command: str) -> str
指定されたシェルコマンドを実行し、結果を返します。
パラメータ:
command
: 実行するシェルコマンド(文字列)
戻り値:
- 成功時: コマンドの標準出力
- エラー時: エラーメッセージ(終了コードとエラー出力を含む)
例:
セキュリティ考慮事項
⚠️ 注意: このサーバーは任意のシェルコマンドを実行できるため、信頼できる環境でのみ使用してください。
推奨される対策
- サンドボックス環境での実行
- コマンドフィルタリングの実装
- 実行権限の制限
- ログ監視の実装
ファイル構造
実装例
Webスクレイピング
ファイル操作
システム情報の取得
トラブルシューティング
タイムアウトエラー
コマンドの実行時間が30秒を超える場合、タイムアウトエラーが発生します。長時間実行されるコマンドの場合は、server.pyのtimeout
値を調整してください。
パーミッションエラー
実行権限が不足している場合は、適切な権限を付与するか、sudo を使用してください(ただし、セキュリティリスクを考慮してください)。
ライセンス
MIT License
貢献
プルリクエストやイシューの報告を歓迎します。
Tools
A Model Context Protocol server that enables LLM applications to safely execute shell commands with error handling and timeout settings.
Related MCP Servers
- -securityFlicense-qualityA Model Context Protocol server that allows LLMs to execute shell commands and receive their output in a controlled manner.Last updated -3Python
- AsecurityFlicenseAqualityA Model Context Protocol server that allows LLMs to interact with Python environments, execute code, and manage files within a specified working directory.Last updated -956Python
- AsecurityAlicenseAqualityA Model Context Protocol server that allows LLMs to execute shell commands with explicit user permission through desktop notifications.Last updated -26121TypeScriptMIT License
- -securityFlicense-qualityA secure interface that enables language models to execute shell commands on the host operating system through the Model Context Protocol.Last updated -1Python