mcpField
M
Mcp Await

Mcp Await

ローカル
github.com/ricardo-hdrn開発ツール234 週間前に更新

Mcp Await について

Mcp Await は、AI アシスタント向けの MCP サーバー兼コマンドラインツールです。ポート、ファイル、URL、プロセス、コマンドなどの条件を待機でき、ブロッキング待機とバックグラウンド監視に対応しています。

主な機能

  1. 01ポート、ファイル、URL、プロセスの待機
  2. 02Docker と GitHub Actions の実行待機
  3. 03成功するまでコマンドを再実行
  4. 04ブロッキングまたはバックグラウンド監視
  5. 05MCP リソースで監視結果を取得

活用シーン

  1. 01ローカルサービスの接続受付を待機
  2. 02ファイルの作成、変更、削除を検知
  3. 03ヘルスチェック URL やコマンドの成功を待機
  4. 04Docker コンテナや GitHub Actions の実行を監視

MCP 対応

wait_for_port、wait_for_file、wait_for_url、wait_for_command などの条件待機ツールを提供します。バックグラウンド監視は MCP リソースとして公開され、キャンセルできます。

設定

ローカルサーバーの設定はどのクライアントでも共通です。コピーしてクライアントの MCP 設定ファイルに貼り付けてください。

mcp.json · 共通設定
{
"mcpServers": {
"await": {
"command": "npx",
"args": [
"-y",
"mcp-await"
]
}
}
}
起動コマンドnpx -y mcp-await

ローカルサーバーにはマシン上の実行環境(Node.js 18 以上など)が必要です。設定ファイルの場所はクライアントごとに異なります。

パッケージ
npmmcp-await0.1.3

ツール

8

掲載時のツール一覧 · 2 週間前に更新

パラメーター型必須説明
watch_idstringはいキャンセルする watch_id

詳細

mcp-await

crates.io CI license

AI コマンドラインアシスタント(Claude Code、Codex、Cursor など)向けの条件監視 MCP サーバーと CLI です。

API のラウンドトリップを無駄にする sleep ループや curl --retry でポーリングする代わりに、待機ツールを一度呼び出すだけで、条件が満たされるまで処理がブロックされ、結果が返されます。

デモ

インストール

# Prebuilt binary (Linux, macOS, Windows) — download from GitHub Releases
# https://github.com/ricardo-hdrn/mcp-await/releases/latest

# From crates.io
cargo install mcp-await

# From source
git clone https://github.com/ricardo-hdrn/mcp-await.git
cd mcp-await
cargo build --release

クイックスタート

# Wait for a service to be ready
mcp-await port localhost 8080 --timeout 30

# Wait for a file to appear
mcp-await file /tmp/deploy.lock --event create --timeout 60

# Wait for a command to succeed
mcp-await cmd "curl -sf http://localhost:8080/health" --interval 2 --timeout 30

ツール

ツール主なパラメーター監視方法
wait_for_porthost、portTCP 接続のループ、500ms 間隔
wait_for_filepath、event(create/modify/delete)notify クレート経由の inotify、ポーリングなし
wait_for_urlurl、expected_status(デフォルトは 200)curl ループ、2s 間隔(curl が必要)
wait_for_pidpid/proc/{pid} を確認、500ms 間隔
wait_for_dockercontainerdocker wait(docker が必要)
wait_for_gh_runrun_id、repo(任意)gh run watch(gh が必要)
wait_for_commandcommand、interval_seconds(デフォルトは 5)終了コードが 0 になるまで sh -c で再実行
cancel_watchwatch_idノンブロッキング監視をキャンセル

すべてのツールは timeout_seconds(デフォルト:300)と blocking(デフォルト:true)を受け付けます。

CLI の使用方法

バイナリはスタンドアロンの CLI ツールとしても使用できます。

# TCP port
mcp-await port localhost 5432 --timeout 30

# File events
mcp-await file /var/log/app.log --event modify --timeout 120
mcp-await file /tmp/flag --event create --timeout 60
mcp-await file /tmp/old.pid --event delete --timeout 30

# HTTP status
mcp-await url https://api.example.com/health --status 200 --timeout 120

# Process exit
mcp-await pid 12345 --timeout 300

# Docker container exit
mcp-await docker my-container --timeout 600

# GitHub Actions run
mcp-await gh-run 12345678 --repo owner/repo --timeout 1800

# Arbitrary shell command (exit 0 = success)
mcp-await cmd "test -f /tmp/ready" --interval 2 --timeout 30
終了コード
コード意味
0条件を満たしました(成功)
1タイムアウト
2エラー
出力形式

すべてのコマンドは JSON を出力します。

{
  "status": "success",
  "elapsed_seconds": 1.23,
  "detail": "localhost:8080 is accepting connections"
}

MCP サーバーのセットアップ

Claude Code

~/.claude.json に追加します。

{
  "mcpServers": {
    "await": {
      "command": "/path/to/mcp-await"
    }
  }
}

サブコマンドなしで(または mcp-await serve を指定して)実行すると、バイナリは stdio MCP サーバーとして動作します。

MCP Inspector
npx @modelcontextprotocol/inspector ./target/release/mcp-await

ブロッキングモードとノンブロッキングモード

ブロッキング(デフォルト)

条件が満たされるか、タイムアウトするか、キャンセルされるまで、ツール呼び出しは保留されます。最もシンプルなモードで、AI アシスタントは結果を待ちます。

ノンブロッキング

blocking: false を設定すると、watch_id とリソース URI がすぐに返されます。サーバーはバックグラウンドで監視し、完了すると通知を送信します。

フロー:

  1. blocking: false を指定して wait_for_port を呼び出す
  2. すぐに次の応答を受け取ります:
    {"watch_id": "port-1", "resource": "watch://port-1", "status": "watching"}
    
  3. 待機中に別の作業を行う
  4. 条件が満たされると notifications/resources/updated を受け取る
  5. watch://port-1 を読み込み、結果全体を取得する
キャンセル

cancel_watch を使って、ノンブロッキング監視をキャンセルできます。

{"watch_id": "port-1"}

リソース

ノンブロッキング監視は、watch://{watch_id} の MCP リソースとして公開されます。

  • list_resources — アクティブな監視と完了した監視をすべて返します
  • read_resource("watch://port-1") — 監視のステータスと結果を含む JSON を返します

エージェントでの使用を徹底する

エージェントは、mcp-await を使用せず、シェルによる回避策を使うことがあります。動作を徹底するには、プロジェクトのエージェント指示ファイルにスニペットを追加してください。

エージェント指示ファイル
Claude CodeCLAUDE.md
CodexAGENTS.md
Gemini CLIGEMINI.md
Cursor.cursor/rules/
Windsurf.windsurfrules
## Waiting for conditions

Use mcp-await tools instead of shell workarounds:
- `wait_for_port` instead of `while ! nc ...; do sleep 1; done`
- `wait_for_url` instead of `curl --retry`
- `wait_for_file` instead of polling loops
- `wait_for_command` instead of `while ! cmd; do sleep N; done`

Prefer `blocking: false` when there is independent work to do in parallel.

ロードマップ

  • すべてのエージェントで mcp-await の使用を徹底するためのエージェントレベルの指示(システムプロンプト、ツールのメタデータヒント)
  • より幅広いエージェント互換性テスト(Codex、Gemini CLI、Cursor、Windsurf)

開発

cargo build           # debug build
cargo build --release # release build
cargo test            # run tests
cargo clippy          # lint
cargo fmt             # format

ライセンス

MIT

コメント

MCP は初めてですか?

プロトコルの概要から最初のサーバーの導入まで、よくある疑問にまとめて答えます。

AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。