next-devtools-mcp is a Model Context Protocol (MCP) server that provides Next.js development tools and utilities for coding agents like Claude and Cursor. - Node.js v20.19 or a newer latest maintenance LTS version - npm or pnpm Install the MCP server for all your coding agents: Add -y to skip the confirmation prompt and install to all detected agents already in use in the project directory. Add -g
Add this skill
npx mdskills install vercel/next-devtools-mcpComprehensive MCP server providing Next.js development tools with runtime diagnostics, documentation search, and browser automation
1# Next.js DevTools MCP23[](https://npmjs.org/package/next-devtools-mcp)45`next-devtools-mcp` is a Model Context Protocol (MCP) server that provides Next.js development tools and utilities for coding agents like Claude and Cursor.678## Getting Started910### Requirements1112- [Node.js](https://nodejs.org/) v20.19 or a newer [latest maintenance LTS](https://github.com/nodejs/Release#release-schedule) version13- [npm](https://www.npmjs.com/) or [pnpm](https://pnpm.io/)141516### Install with add-mcp1718Install the MCP server for all your coding agents:1920```bash21npx add-mcp next-devtools-mcp@latest22```2324Add `-y` to skip the confirmation prompt and install to all detected agents already in use in the project directory. Add `-g` to install globally across all projects.252627### Manual installation2829Add the following config to your MCP client:3031```json32{33 "mcpServers": {34 "next-devtools": {35 "command": "npx",36 "args": ["-y", "next-devtools-mcp@latest"]37 }38 }39}40```4142> [!NOTE]43> Using `next-devtools-mcp@latest` ensures that your MCP client will always use the latest version of the Next.js DevTools MCP server.4445### MCP Client Configuration4647<details>48<summary>Amp</summary>4950**Using Amp CLI:**5152```bash53amp mcp add next-devtools -- npx next-devtools-mcp@latest54```5556**Or configure manually:**5758Follow [Amp's MCP documentation](https://ampcode.com/manual#mcp) and apply the standard configuration shown above.5960</details>6162<details>63<summary>Claude Code</summary>6465Use the Claude Code CLI to add the Next.js DevTools MCP server:6667```bash68claude mcp add next-devtools npx next-devtools-mcp@latest69```7071Alternatively, manually configure Claude by editing your MCP settings file and adding the configuration shown above.7273</details>7475<details>76<summary>Codex</summary>7778**Using Codex CLI:**7980```bash81codex mcp add next-devtools -- npx next-devtools-mcp@latest82```8384**Or configure manually:**8586Follow the MCP setup guide with the standard configuration format:87- Command: `npx`88- Arguments: `-y, next-devtools-mcp@latest`8990**Windows 11 Special Configuration:**9192Update `.codex/config.toml` with environment variables and increased startup timeout:9394```toml95env = { SystemRoot="C:\\Windows", PROGRAMFILES="C:\\Program Files" }96startup_timeout_ms = 20_00097```9899</details>100101<details>102<summary>Cursor</summary>103104**Click the button to install:**105106[Install in Cursor](https://cursor.com/en/install-mcp?name=next-devtools&config=eyJjb21tYW5kIjoibnB4IC15IG5leHQtZGV2dG9vbHMtbWNwQGxhdGVzdCJ9)107108**Or install manually:**109110Go to `Cursor Settings` → `MCP` → `New MCP Server`. Use the config provided above.111112</details>113114<details>115<summary>Gemini</summary>116117**Using Gemini CLI:**118119Project-wide installation:120```bash121gemini mcp add next-devtools npx next-devtools-mcp@latest122```123124Global installation:125```bash126gemini mcp add -s user next-devtools npx next-devtools-mcp@latest127```128129**Or configure manually:**130131Follow the MCP setup guide with these parameters:132- Command: `npx`133- Arguments: `-y, next-devtools-mcp@latest`134135</details>136137<details>138<summary>Google Antigravity</summary>139140**Configure in MCP config file:**141142Add this to your Antigravity MCP config file: `.gemini/antigravity/mcp_config.json`143144```json145{146 "mcpServers": {147 "next-devtools": {148 "command": "npx",149 "args": ["-y", "next-devtools-mcp@latest"]150 }151 }152}153```154155See [Antigravity MCP docs](https://antigravity.google/docs/mcp) for more info.156157</details>158159<details>160<summary>VS Code / Copilot</summary>161162**Using VS Code CLI:**163164```bash165code --add-mcp '{"name":"next-devtools","command":"npx","args":["-y","next-devtools-mcp@latest"]}'166```167168**Or configure manually:**169170Follow the official VS Code MCP server setup guide and add the Next.js DevTools server through VS Code settings.171172</details>173174<details>175<summary>Warp</summary>176177**Using Warp UI:**178179Navigate to `Settings | AI | Manage MCP Servers` and select `+ Add` to register a new MCP server with the following configuration:180- Name: `next-devtools`181- Command: `npx`182- Arguments: `-y, next-devtools-mcp@latest`183184</details>185186## Quick Start187188### For Next.js 16+ Projects (Recommended)189190To unlock the full power of runtime diagnostics, start your Next.js dev server:191192```bash193npm run dev194```195196Next.js 16+ has MCP enabled by default at `http://localhost:3000/_next/mcp` (or whichever port your dev server uses). The `next-devtools-mcp` server will automatically discover and connect to it.197198**⚠️ IMPORTANT: Start every Next.js session by calling the `init` tool to set up proper context:**199200```201Use the init tool to set up Next.js DevTools context202```203204This initializes the MCP context and ensures the AI assistant uses official Next.js documentation for all queries.205206**After initialization, try these prompts to explore runtime diagnostics:**207208```209Next Devtools, what errors are in my Next.js application?210```211212```213Next Devtools, show me the structure of my routes214```215216```217Next Devtools, what's in the development server logs?218```219220Your coding agent will use the `nextjs_index` and `nextjs_call` tools to query your running application's actual state.221222### For All Next.js Projects223224You can use the development automation and documentation tools regardless of Next.js version:225226```227Next Devtools, help me upgrade my Next.js app to version 16228```229230```231Next Devtools, enable Cache Components in my Next.js app232```233234```235Next Devtools, search Next.js docs for generateMetadata236```237238### 💡 Pro Tip: Auto-Initialize on Every Session239240To make your AI assistant **automatically call the `init` tool** at the start of every Next.js session without being asked, add this instruction to your agent's configuration file:241242<details>243<summary>Claude Code / Claude Desktop</summary>244245Add to `~/.claude/CLAUDE.md` (global) or `./.claude/CLAUDE.md` (project-specific):246247```markdown248**When starting work on a Next.js project, ALWAYS call the `init` tool from249next-devtools-mcp FIRST to set up proper context and establish documentation250requirements. Do this automatically without being asked.**251```252253</details>254255<details>256<summary>Cursor</summary>257258Add to `.cursorrules` in your project root or global Cursor settings:259260```261When working with Next.js, always call the init tool from next-devtools-mcp262at the start of the session to establish proper context and documentation requirements.263```264265</details>266267<details>268<summary>Codex / Other AI Coding Assistants</summary>269270Add to your agent's configuration file (e.g., `.codex/instructions.md`, `agent.md`, or similar):271272```markdown273**Next.js Initialization**: When starting work on a Next.js project, automatically274call the `init` tool from the next-devtools-mcp server FIRST. This establishes275proper context and ensures all Next.js queries use official documentation.276```277278</details>279280**Why this matters:**281- ✅ Ensures consistent context across all Next.js work282- ✅ Automatically establishes the documentation-first requirement283- ✅ No need to manually call init every time284- ✅ Works across all your Next.js projects285286## MCP Resources287288The knowledge base resources are automatically available to your coding agent and are split into focused sections for efficient context management. Current resource URIs:289290<details>291<summary>📚 Available Knowledge Base Resources (click to expand)</summary>292293- Cache Components (12 sections):294 - `cache-components://overview`295 - `cache-components://core-mechanics`296 - `cache-components://public-caches`297 - `cache-components://private-caches`298 - `cache-components://runtime-prefetching`299 - `cache-components://request-apis`300 - `cache-components://cache-invalidation`301 - `cache-components://advanced-patterns`302 - `cache-components://build-behavior`303 - `cache-components://error-patterns`304 - `cache-components://test-patterns`305 - `cache-components://reference`306307- Next.js 16 migration:308 - `nextjs16://migration/beta-to-stable`309 - `nextjs16://migration/examples`310311- Next.js fundamentals:312 - `nextjs-fundamentals://use-client`313314</details>315316Resources are loaded on-demand by your coding agent, providing targeted knowledge without overwhelming the context window.317318## MCP Prompts319320Pre-configured prompts to help with common Next.js development tasks:321322<details>323<summary>💡 Available Prompts (click to expand)</summary>324325- **`upgrade-nextjs-16`** - Guide for upgrading to Next.js 16326- **`enable-cache-components`** - Migrate and enable Cache Components mode for Next.js 16327328</details>329330## MCP Tools331332<details>333<summary><code>init</code></summary>334335Initialize Next.js DevTools MCP context and establish documentation requirements.336337**Capabilities:**338- Sets up proper context for AI assistants working with Next.js339- Establishes requirement to use `nextjs_docs` for ALL Next.js-related queries340- Documents all available MCP tools and their use cases341- Provides best practices for Next.js development with MCP342- Includes example workflows and quick start checklist343344**When to use:**345- At the beginning of a Next.js development session346- To understand available tools and establish proper context347- To ensure documentation-first approach for Next.js development348349**Input:**350- `project_path` (optional) - Path to Next.js project (defaults to current directory)351352**Output:**353- Comprehensive initialization context and guidance for Next.js development with MCP tools354355</details>356357<details>358<summary><code>nextjs_docs</code></summary>359360Search and retrieve Next.js official documentation and knowledge base.361362**Capabilities:**363- Two-step process: 1) Search for docs by keyword to get paths, 2) Fetch full markdown content by path364- Uses official Next.js documentation search API365- Provides access to comprehensive Next.js guides, API references, and best practices366- Supports filtering by router type (App Router, Pages Router, or both)367368**Input:**369- `action` (required) - Action to perform: `search` to find docs, `get` to fetch full content370- `query` (optional) - Required for `search`. Keyword search query (e.g., 'metadata', 'generateStaticParams', 'middleware')371- `path` (optional) - Required for `get`. Doc path from search results (e.g., '/docs/app/api-reference/functions/refresh')372- `anchor` (optional) - Optional for `get`. Anchor/section from search results (e.g., 'usage')373- `routerType` (optional) - For `search` only. Filter by: `app`, `pages`, or `all` (default: `all`)374375**Output:**376- Search results with doc titles, paths, content snippets, sections, and anchors377- Full markdown content for specific documentation pages378379</details>380381<details>382<summary><code>browser_eval</code></summary>383384Automate and test web applications using Playwright browser automation.385386**When to use:**387- Verifying pages in Next.js projects (especially during upgrades or testing)388- Testing user interactions and flows389- Taking screenshots for visual verification390- Detecting runtime errors, hydration issues, and client-side problems391- Capturing browser console errors and warnings392393**Important:** For Next.js projects, prioritize using the `nextjs_index` and `nextjs_call` tools instead of browser console log forwarding. Only use browser_eval's `console_messages` action as a fallback when these tools are not available.394395**Available actions:**396- `start` - Start browser automation (automatically installs if needed)397- `navigate` - Navigate to a URL398- `click` - Click on an element399- `type` - Type text into an element400- `fill_form` - Fill multiple form fields at once401- `evaluate` - Execute JavaScript in browser context402- `screenshot` - Take a screenshot of the page403- `console_messages` - Get browser console messages404- `close` - Close the browser405- `drag` - Perform drag and drop406- `upload_file` - Upload files407- `list_tools` - List all available browser automation tools from the server408409**Input:**410- `action` (required) - The action to perform411- `browser` (optional) - Browser to use: `chrome`, `firefox`, `webkit`, `msedge` (default: `chrome`)412- `headless` (optional) - Run browser in headless mode (default: `true`)413- Action-specific parameters (see tool description for details)414415**Output:**416- JSON with action result, screenshots (base64), console messages, or error information417418</details>419420<details>421<summary><code>nextjs_index</code></summary>422423Discover all running Next.js dev servers and list their available MCP tools.424425**What this tool does:**426427Automatically discovers all running Next.js 16+ dev servers on your machine and lists the runtime diagnostic tools available from each server's built-in MCP endpoint at `/_next/mcp`.428429**No parameters required** - Just call the tool and it will scan for servers.430431**Available Next.js Runtime Tools** (varies by Next.js version):432- `get_errors` - Get current build, runtime, and type errors433- `get_logs` - Get path to development log file (browser console + server output)434- `get_page_metadata` - Query application routes, pages, and component metadata435- `get_project_metadata` - Get project structure, config, and dev server URL436- `get_server_action_by_id` - Look up Server Actions by ID to find source files437438**Requirements:**439- Next.js 16+ (MCP enabled by default)440- Running dev server (`npm run dev`)441442**Output:**443- JSON with list of discovered servers, each containing:444 - Port, PID, URL445 - Available tools with descriptions and input schemas446447**Example prompts:**448- "Next Devtools, what servers are running?"449- "Next Devtools, show me available diagnostic tools"450451</details>452453<details>454<summary><code>nextjs_call</code></summary>455456Execute a specific MCP tool on a running Next.js dev server.457458**What this tool does:**459460Calls a specific runtime diagnostic tool on a Next.js 16+ dev server's built-in MCP endpoint at `/_next/mcp`.461462**Input Parameters:**463- `port` (required) - Dev server port (use `nextjs_index` first to discover)464- `toolName` (required) - Name of the Next.js tool to invoke465- `args` (optional) - Arguments object for the tool (only if required by that tool)466467**Requirements:**468- Next.js 16+ (MCP enabled by default)469- Running dev server (`npm run dev`)470- Use `nextjs_index` first to discover available servers and tools471472**Typical workflow:**473474```javascript475// Step 1: Discover servers and tools476// (call nextjs_index first)477478// Step 2: Call a specific tool479{480 "port": 3000,481 "toolName": "get_errors"482 // args is optional and only needed if the tool requires parameters483}484```485486**Output:**487- JSON with tool execution results488489**Example prompts that use this tool:**490- "Next Devtools, what errors are in my Next.js app?"491- "Next Devtools, show me my application routes"492- "Next Devtools, what's in the dev server logs?"493- "Next Devtools, find the Server Action with ID xyz"494495</details>496497<details>498<summary><code>upgrade_nextjs_16</code></summary>499500Guides through upgrading Next.js to version 16 with automated codemod execution.501502**Capabilities:**503- Runs official Next.js codemod automatically (requires clean git state)504- Handles async API changes (params, searchParams, cookies, headers)505- Migrates configuration changes506- Updates image defaults and optimization507- Fixes parallel routes and dynamic segments508- Handles deprecated API removals509- Provides guidance for React 19 compatibility510511**Input:**512- `project_path` (optional) - Path to Next.js project (defaults to current directory)513514**Output:**515- Structured JSON with step-by-step upgrade guidance516517</details>518519<details>520<summary><code>enable_cache_components</code></summary>521522Complete Cache Components setup, enablement, and migration for Next.js 16 with automated error detection and fixing. This tool is used for migrating Next.js applications to Cache Components mode.523524**Capabilities:**525- Pre-flight checks (package manager, Next.js version, configuration)526- Enable Cache Components configuration527- Start dev server with MCP enabled528- Automated route verification and error detection529- Automated error fixing with intelligent boundary setup (Suspense, caching directives, static params)530- Final verification and build testing531532**Input:**533- `project_path` (optional) - Path to Next.js project (defaults to current directory)534535**Output:**536- Structured JSON with complete setup guidance and phase-by-phase instructions537538**Example Usage:**539540With Claude Code:541```542Next Devtools, help me enable Cache Components in my Next.js 16 app543```544545With other agents or programmatically:546```json547{548 "tool": "enable_cache_components",549 "args": {550 "project_path": "/path/to/project"551 }552}553```554555</details>556557## Privacy & Telemetry558559### What Data is Collected560561`next-devtools-mcp` collects anonymous usage telemetry to help improve the tool. The following data is collected:562563- **Tool usage**: Which MCP tools are invoked (e.g., `nextjs_index`, `nextjs_call`, `browser_eval`, `upgrade_nextjs_16`)564- **Error events**: Anonymous error messages when tools fail565- **Session metadata**: Session ID, timestamps, and basic environment info (OS, Node.js version)566567**What is NOT collected:**568- Your project code, file contents, or file paths569- Personal information or identifiable data570- API keys, credentials, or sensitive configuration571- Arguments passed to tools (except tool names)572573Local files are written under `~/.next-devtools-mcp/` (anonymous `telemetry-id`, `telemetry-salt`, and a debug log `mcp.log`). Events are sent to the telemetry endpoint in the background to help us understand usage patterns and improve reliability.574575### Opt-Out576577To disable telemetry completely, set the environment variable:578579```bash580export NEXT_TELEMETRY_DISABLED=1581```582583Add this to your shell configuration file (e.g., `~/.bashrc`, `~/.zshrc`) to make it permanent.584585You can also delete your local telemetry data at any time:586587```bash588rm -rf ~/.next-devtools-mcp589```590591## Troubleshooting592593### Module Not Found Error594595If you encounter an error like:596597```598Error [ERR_MODULE_NOT_FOUND]: Cannot find module '...\next-devtools-mcp\dist\resources\(cache-components)\...'599```600601**Solution:** Clear your npx cache and restart your MCP client (Cursor, Claude Code, etc.). The server will be freshly installed.602603### "No server info found" Error604605If you see `[error] No server info found`:606607**Solutions:**6081. Make sure your Next.js dev server is running: `npm run dev`6092. If using Next.js 15 or earlier, use the `upgrade_nextjs_16` tool to upgrade to Next.js 16+6103. Verify your dev server started successfully without errors611612**Note:** The `nextjs_index` and `nextjs_call` tools require Next.js 16+ with a running dev server. Other tools (`nextjs_docs`, `browser_eval`, `upgrade_nextjs_16`, `enable_cache_components`) work without a running server.613614## Local Development615616To run the MCP server locally for development:6176181. Clone the repository6192. Install dependencies:620 ```bash621 pnpm install622 pnpm build623 ```6243. Configure your MCP client to use the local version:625 ```json626 {627 "mcpServers": {628 "next-devtools": {629 "command": "node",630 "args": ["/absolute/path/to/next-devtools-mcp/dist/index.js"]631 }632 }633 }634 ```635636 Note: Replace `/absolute/path/to/next-devtools-mcp` with the actual absolute path to your cloned repository.637638 or manually add, e.g. with codex:639 ```640 codex mcp add next-devtools-local -- node dist/index.js641 ```642643## Features644645This MCP server provides coding agents with comprehensive Next.js development capabilities through three primary mechanisms:646647### **1. Runtime Diagnostics & Live State Access** (Next.js 16+)648Connect directly to your running Next.js dev server's built-in MCP endpoint to query:649- Real-time build and runtime errors650- Application routes, pages, and component metadata651- Development server logs and diagnostics652- Server Actions and component hierarchies653654### **2. Development Automation**655Tools for common Next.js workflows:656- **Automated Next.js 16 upgrades** with official codemods657- **Cache Components migration and setup** with error detection and automated fixes658- **Browser testing integration** via Playwright for visual verification659660### **3. Knowledge Base & Documentation**661- Curated Next.js 16 knowledge base (12 focused resources on Cache Components, async APIs, etc.)662- Direct access to official Next.js documentation via search API663- Pre-configured prompts for upgrade guidance and Cache Components enablement664665> **Learn more:** See the [Next.js MCP documentation](https://nextjs.org/docs/app/guides/mcp) for details on how MCP servers work with Next.js and coding agents.666667## How It Works668669This package provides a **bridge MCP server** that connects your coding agent to Next.js development tools:670671```672Coding Agent673 ↓674 next-devtools-mcp (this package)675 ↓676 ├─→ Next.js Dev Server MCP Endpoint (/_next/mcp) ← Runtime diagnostics677 ├─→ Playwright MCP Server ← Browser automation678 └─→ Knowledge Base & Tools ← Documentation, upgrades, setup automation679```680681**Key Architecture Points:**6826831. **For Next.js 16+ projects**: This server automatically discovers and connects to your running Next.js dev server's built-in MCP endpoint at `http://localhost:PORT/_next/mcp`. This gives coding agents direct access to runtime errors, routes, logs, and application state.6846852. **For all Next.js projects**: Provides development automation tools (upgrades, Cache Components setup), documentation access, and browser testing capabilities that work independently of the runtime connection.6866873. **Simple workflow**: Call `nextjs_index` to see all servers and available tools, then call `nextjs_call` with the specific port and tool name you want to execute.688689690## License691692MIT License693
Full transparency — inspect the skill content before installing.