Next.js DevTools
MCPサーバー経由でNext.jsアプリケーションを調査・デバッグします。
クイックスタート
# サーバーを起動(オンデマンドで起動)
bash scripts/start-server.sh
# またはmcp-clientを使って直接呼び出し
python3 scripts/mcp-client.py call \
-s "npx next-devtools-mcp@latest" \
-t list-routes
利用可能なツール
| ツール | 説明 |
|---|---|
list-routes | すべてのアプケーションルートを取得 |
get-route-info | 特定のルートの詳細情報 |
list-components | アプリ内のReactコンポーネント一覧 |
get-build-info | ビルド設定情報 |
get-config | next.config.jsの設定内容 |
ワークフローパターン
パターン1:ルート調査
# 全ルートを一覧表示
python3 scripts/mcp-client.py call \
-s "npx next-devtools-mcp@latest" \
-t list-routes
# 特定のルートの詳細を取得
python3 scripts/mcp-client.py call \
-s "npx next-devtools-mcp@latest" \
-t get-route-info \
-p '{"route": "/api/auth"}'
パターン2:ビルド問題のデバッグ
# ビルド設定を確認
python3 scripts/mcp-client.py call \
-s "npx next-devtools-mcp@latest" \
-t get-build-info
# next.config.jsを確認
python3 scripts/mcp-client.py call \
-s "npx next-devtools-mcp@latest" \
-t get-config
パターン3:コンポーネント探索
python3 scripts/mcp-client.py call \
-s "npx next-devtools-mcp@latest" \
-t list-components
スクリプト
start-server.sh
永続的なサーバー(複数回呼び出し)用:
bash scripts/start-server.sh
# サーバーはデフォルトポートで起動
# その場合はmcp-client.pyで-uフラグを使う(-sの代わり)
オンデマンド(推奨)
単発の呼び出しには-sフラグを使用します。これにより呼び出しごとにサーバーが起動します:
python3 scripts/mcp-client.py call \
-s "npx next-devtools-mcp@latest" \
-t <ツール名>
トラブルシューティング
| 問題 | 解決策 |
|---|---|
| サーバーが起動しない | npx next-devtools-mcp@latest が手動で動作するか確認 |
| ルートが見つからない | Next.jsプロジェクトのルートから実行していることを確認 |
| ビルド情報が空 | 事前に next build を実行 |