MCP.so
ログイン
N

Next.js MCP Server (Official)

@vercel

基本情報

カテゴリ

開発者ツール

バージョン

0.4.0

ライセンス

MIT

トランスポート

stdio

認証方式

none

作者

vercel

Next.js MCP Server について

コーディングエージェントを実行中の Next.js 16+ 開発サーバーに接続し、ライブのエラー、ルート、ログを提供する Vercel 公式の Next.js MCP サーバー。

Next.js MCP Server の設定

以下の設定を使って、このサーバーを MCP 対応クライアントに追加してください。

{
  "mcpServers": {
    "next-devtools": {
      "command": "npx",
      "args": [
        "-y",
        "next-devtools-mcp@latest"
      ]
    }
  }
}

Next.js MCP Server のツール

4

Set up and use browser automation for this project via the agent-browser CLI. This tool does NOT drive the browser itself. It points you at `agent-browser` — a fast, native browser-automation CLI built for agents (https://github.com/vercel-labs/agent-browser) — and tells you how to install it (if needed) and where to start. You then run its commands directly (you have shell access), which is faster and more capable than proxying automation through MCP. Call this when you need to open pages, click, type, screenshot, or capture console errors in a real browser.

Find the version-accurate Next.js documentation for THIS project. This tool does NOT fetch documentation. Next.js 16+ ships its full docs inside the installed package at `node_modules/next/dist/docs/` (markdown), kept in sync with the exact version you have installed. This tool tells you where those docs are and how to read them — so you read the docs that match this project, not a generic or outdated copy. Call this before answering Next.js questions or writing Next.js code. Then read the relevant guide from the path it returns. If the project is on an older Next.js, it will tell you how to upgrade.

Discover all running Next.js development servers and list their available MCP tools. WHEN TO USE THIS TOOL - Use proactively in these scenarios: 1. **Before implementing ANY changes to the app**: When asked to add, modify, or fix anything in the application: - "Add a loading state" → Check current component structure and routes first - "Fix the navigation" → Inspect existing routes and components - "Update the API endpoint" → Query current routes and data flows - "Add error handling" → Check runtime errors and component hierarchy - "Refactor the auth logic" → Inspect current auth implementation and routes - "Optimize performance" → Check runtime diagnostics and component tree Use this to understand where changes should be made and what currently exists. 2. **For diagnostic and investigation questions**: - "What's happening?" / "What's going on?" / "Why isn't this working?" - "Check the errors" / "See what's wrong" - "What routes are available?" / "Show me the routes" - "Clear the cache" / "Reset everything" - Questions about build status, compilation errors, or runtime diagnostics 3. **For agentic codebase search**: Use this as FIRST CHOICE for searching the currently running app. If not found, fallback to static codebase search tools. KEY PRINCIPLE: If the request involves the running Next.js application (whether to investigate OR modify it), query the runtime FIRST to understand current state before proceeding. REQUIREMENTS: - Next.js 16 or later (MCP support was added in v16) - If you're on Next.js 15 or earlier, upgrade first by running 'npx @next/codemod@latest upgrade latest' Next.js 16+ exposes an MCP (Model Context Protocol) endpoint at /_next/mcp automatically when the dev server starts. No configuration needed - MCP is enabled by default in Next.js 16 and later. This tool discovers all running Next.js servers and returns: - Server port, PID, and URL - Complete list of available MCP tools for each server - Tool descriptions and input schemas After calling this tool, use 'nextjs_call' to execute specific tools. [IMPORTANT] If auto-discovery returns no servers: 1. Ask the user which port their Next.js dev server is running on 2. Call this tool again with the 'port' parameter set to the user-provided port If the MCP endpoint is not available: 1. Ensure you're running Next.js 16 or later (upgrade with 'npx @next/codemod@latest upgrade latest') 2. Verify the dev server is running (npm run dev) 3. Check that the dev server started successfully without errors

Call a specific MCP tool on a running Next.js development server. REQUIREMENTS: - Port number of the target Next.js dev server - Tool name to execute - Optional arguments object (if the tool requires parameters) Use 'nextjs_index' first to discover available servers, tools, and their input schemas. If 'nextjs_index' auto-discovery fails, ask the user for the port and call 'nextjs_index' again with the 'port' parameter. IMPORTANT: When calling tools: - The 'args' parameter MUST be an object (e.g., {key: "value"}), NOT a string - If a tool doesn't require arguments, OMIT the 'args' parameter entirely - do NOT pass {} or "{}" - Check the tool's inputSchema from 'nextjs_index' to see what arguments are required Common Next.js MCP tools include: - Error diagnostics (get compilation/runtime errors) - Route information (list all routes) - Build status (check compilation state) - Cache management (clear caches) - And more (varies by Next.js version) Example usage: 1. Call 'nextjs_index' to see servers and tools 2. Call 'nextjs_call' with port=3000, toolName="get_errors" to get errors from server on port 3000

概要

Next.js MCP Server (Official) とは?

公式の Next.js MCP サーバーは Vercel の next-devtools-mcp です。Claude や Cursor などのコーディングエージェントを実行中の Next.js 開発サーバーに接続し、ライブのエラー、ルート、ログ、コンパイルの問題を読み取れるようにします。

Next.js 16 以降では、開発サーバー自体が /_next/mcp に組み込みの MCP エンドポイントを公開しています。next-devtools-mcp は薄いコネクターで、手元のマシンで動いている Next.js 16+ の開発サーバーを検出し、そのエンドポイントをエージェントにプロキシします。さらに、node_modules/next/dist/docs/ に同梱されたバージョンに合ったドキュメントと、agent-browser CLI へエージェントを案内する 2 つのゲートウェイツールも備えています。プロジェクトは vercel/next-devtools-mcp にあり、MIT ライセンスで、API キー不要で無料で使えます。

Next.js MCP Server (Official) の使い方

前提条件:

  • Node.js v20.19 以降の LTS バージョン
  • npm または pnpm
  • Next.js 16 以降と、実行中の開発サーバー(nextjs_index と nextjs_call に必要)

最も手早い方法では、マシン上で検出されたすべてのコーディングエージェントにまとめて設定されます:

npx add-mcp next-devtools-mcp@latest

-y を付けると確認をスキップし、-g を付けるとグローバルにインストールします。あるいは、プロジェクトのルートにある .mcp.json(またはクライアントの MCP 設定)に追加します:

{
  "mcpServers": {
    "next-devtools": {
      "command": "npx",
      "args": ["-y", "next-devtools-mcp@latest"]
    }
  }
}

その後 npm run dev でアプリを起動します。Next.js 16+ はデフォルトで http://localhost:3000/_next/mcp のエンドポイントを有効にしており、next-devtools-mcp が追加設定なしで自動的に見つけます。get_errors や get_page_metadata などのツールはアクティブなブラウザーセッションから情報を読むため、作業中のページをブラウザーで開いておいてください。

Claude Code

claude mcp add next-devtools npx next-devtools-mcp@latest

Cursor

README の「Install in Cursor」リンクを使うか、Cursor Settings → MCP → New MCP Server を開いて上記の設定を貼り付けます。

VS Code

code --add-mcp '{"name":"next-devtools","command":"npx","args":["-y","next-devtools-mcp@latest"]}'

Codex

codex mcp add next-devtools -- npx next-devtools-mcp@latest

Windows 11 では、.codex/config.toml のサーバーエントリに env = { SystemRoot="C:\\Windows", PROGRAMFILES="C:\\Program Files" } と startup_timeout_ms = 20_000 を追加します。

README には Amp、Gemini CLI、Google Antigravity、Warp の手順も記載されています。

プロンプト例:「Next Devtools, what errors are in my Next.js application?」や「Next Devtools, show me the structure of my routes.」

Next.js MCP Server (Official) の主な機能

  • ライブのランタイムコンテキスト:エージェントはソースから推測するのではなく、実行中アプリの実際のエラー、ルート、ログを確認できます。
  • 自動検出:よく使われるポートをスキャンし、実行中のすべての Next.js 16+ 開発サーバーに接続します。複数プロジェクトの同時接続にも対応します。
  • next build 不要のコンパイルチェック:Turbopack プロジェクトでは、開発サーバーからルートごとのコンパイル問題を直接取得できます。
  • バージョンに合ったドキュメント:nextjs_docs は、インストール済みの Next.js に同梱されたドキュメントへエージェントを案内します。
  • ブラウザーでの検証:browser_eval は agent-browser CLI のインストール方法と実行方法をエージェントに伝えます。
  • 公式かつ軽量:Vercel がメンテナンスしており、0.4.0 で 4 つのツールに絞り込まれました。
  • プライバシー設定:匿名テレメトリは NEXT_TELEMETRY_DISABLED=1 で無効にできます。

Next.js MCP Server (Official) のツール

サーバー自体が公開するツールは 4 つです:

  • nextjs_index は実行中の開発サーバーを検出し、それぞれが公開しているランタイムツールを一覧表示します。
  • nextjs_call は検出したサーバー上のランタイムツールを 1 つ呼び出します。引数は port、toolName、任意の args です。
  • nextjs_docs はゲートウェイで、同梱ドキュメントのパスを返します(Next.js 16 未満ではアップグレードを提案します)。
  • browser_eval はゲートウェイで、agent-browser のセットアップ手順を返します。ブラウザー自体は操作しません。

nextjs_call を通じて、エージェントは Next.js が /_next/mcp で提供するランタイムツール(バージョンにより異なります)を利用できます:get_errors、get_logs、get_page_metadata、get_project_metadata、get_routes、get_server_action_by_id、Turbopack 専用の get_compilation_issues と compile_route、そして experimental.requestInsights が必要な get_request_insights です。

Next.js MCP Server (Official) のユースケース

  • ランタイムエラーの修正:「今アプリにどんなエラーがある?」エージェントが get_errors を呼び出し、たとえばハイドレーションの不一致に対する修正を提案します。
  • 不慣れなコードベースの把握:「App Router と Pages Router のルートをすべて見せて。」
  • 変更がコンパイルできるかの確認:フルの next build の代わりに、/blog/[slug] に対して compile_route を実行するようエージェントに依頼します。
  • Server Action の追跡:エラーに出てきた action ID を get_server_action_by_id でソースファイルまでたどります。
  • インストール済みバージョンに合ったドキュメントでフレームワークの質問に回答:「App Router ではいつ 'use client' を使うべき?」

Next.js MCP Server (Official) と代替ツールの比較

  • 組み込みの /_next/mcp エンドポイントが公式構成の中核です。next-dev-loop などのエージェント skills はこれを直接呼び出すため、next-devtools-mcp なしでも動作します。MCP パッケージは、プロジェクトやバージョンをまたいで一貫したツールセットをエージェントに提供します。
  • jazelly による Next.js MCP Server はコミュニティ製のルーター解析ツールです。実行中の開発サーバーではなくソースコードからアプリディレクトリをスキャンし、API ルートのパス、HTTP メソッド、パラメーター、スキーマを抽出します。
  • より詳しいブラウザーデバッグには、Chrome DevTools MCP Server と組み合わせて使えます。

Next.js MCP Server (Official) のトラブルシューティング

  • [error] No server info found:nextjs_index と nextjs_call には実行中の Next.js 16+ 開発サーバーが必要です。npm run dev で起動し、バージョンが 16 以降であること、エラーなく起動したことを確認します。nextjs_docs と browser_eval は開発サーバーなしでも動きます。
  • エージェントが接続できない:next.config で experimental.mcpServer が false になっていないか確認し、開発サーバーを再起動して、クライアントが MCP 設定を読み込んでいるか確かめます。
  • next-devtools-mcp/dist を参照する ERR_MODULE_NOT_FOUND:npx のキャッシュを消去し、MCP クライアントを再起動します。
  • 以前のツールが見当たらない:init、upgrade_nextjs_16、enable_cache_components は 0.4.0 で削除されました。アップグレードと Cache Components のワークフローは、現在エージェント skills として提供されています。

よくある質問

1

公式の Next.js MCP サーバーはありますか?

はい。Next.js 16+ には `/_next/mcp` に組み込みの MCP エンドポイントがあり、Vercel がコーディングエージェントをそこへ接続するための `next-devtools-mcp` を公開しています。どちらも Next.js の公式ドキュメントで説明されています。

2

どの Next.js バージョンが必要ですか?

ランタイムツールには Next.js 16 以降が必要です。古いバージョンでは、`nextjs_docs` が `npx @next/codemod@latest upgrade latest` によるアップグレードを勧めます。

3

next-devtools-mcp は無料ですか?

はい。MIT ライセンスのオープンソースで、アカウントも API キーも不要です。

4

Claude Code、Cursor、VS Code で使えますか?

はい。README には Claude Code、Cursor、VS Code/Copilot、Codex、Gemini CLI、Amp、Antigravity、Warp の手順があります。

5

`/_next/mcp` エンドポイントの設定は必要ですか?

不要です。Next.js 16+ ではデフォルトで有効です。無効にするには、`next.config` で `experimental.mcpServer` を `false` に設定します。

6

ローカルとリモートのどちらですか?

ローカルです。サーバーは npx 経由の stdio で動作し、手元のマシンの開発サーバーと通信します。本番デプロイには接続しません。

7

どんなデータを収集しますか?

匿名のツール使用状況、エラーイベント、基本的なセッションメタデータです。コード、ファイルパス、ツールの引数は収集しません。`export NEXT_TELEMETRY_DISABLED=1` でオプトアウトでき、`rm -rf ~/.next-devtools-mcp` でローカルデータを削除できます。

8

アプリを Next.js 16 にアップグレードできますか?

現在はできません。アップグレード用ツールは 0.4.0 で削除され、アップグレードのワークフローはエージェント skills として配布されています。

コメント

「開発者ツール」の他のコンテンツ