Next.js Development for Coding Agent
https://github.com/vercel/next-devtools-mcp.git
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.
Install the MCP server for all your coding agents:
npx add-mcp next-devtools-mcp@latest
Add -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.
Add the following config to your MCP client:
{
"mcpServers": {
"next-devtools": {
"command": "npx",
"args": ["-y", "next-devtools-mcp@latest"]
}
}
}
[!NOTE]
Usingnext-devtools-mcp@latestensures that your MCP client will always use the latest version of the Next.js DevTools MCP server.
Amp
Using Amp CLI:
amp mcp add next-devtools -- npx next-devtools-mcp@latest
Or configure manually:
Follow Amp's MCP documentation and apply the standard configuration shown above.
Claude Code
Use the Claude Code CLI to add the Next.js DevTools MCP server:
claude mcp add next-devtools npx next-devtools-mcp@latest
Alternatively, manually configure Claude by editing your MCP settings file and adding the configuration shown above.
Codex
Using Codex CLI:
codex mcp add next-devtools -- npx next-devtools-mcp@latest
Or configure manually:
Follow the MCP setup guide with the standard configuration format:
npx-y, next-devtools-mcp@latestUpdate .codex/config.toml with environment variables and increased startup timeout:
env = { SystemRoot="C:\\Windows", PROGRAMFILES="C:\\Program Files" }
startup_timeout_ms = 20_000
Cursor
Click the button to install:
Or install manually:
Go to Cursor Settings โ MCP โ New MCP Server. Use the config provided above.
Gemini
Using Gemini CLI:
Project-wide installation:
gemini mcp add next-devtools npx next-devtools-mcp@latest
Global installation:
gemini mcp add -s user next-devtools npx next-devtools-mcp@latest
Or configure manually:
Follow the MCP setup guide with these parameters:
npx-y, next-devtools-mcp@latestGoogle Antigravity
Configure in MCP config file:
Add this to your Antigravity MCP config file: .gemini/antigravity/mcp_config.json
{
"mcpServers": {
"next-devtools": {
"command": "npx",
"args": ["-y", "next-devtools-mcp@latest"]
}
}
}
See Antigravity MCP docs for more info.
VS Code / Copilot
Using VS Code CLI:
code --add-mcp '{"name":"next-devtools","command":"npx","args":["-y","next-devtools-mcp@latest"]}'
Or configure manually:
Follow the official VS Code MCP server setup guide and add the Next.js DevTools server through VS Code settings.
Warp
Using Warp UI:
Navigate to Settings | AI | Manage MCP Servers and select + Add to register a new MCP server with the following configuration:
next-devtoolsnpx-y, next-devtools-mcp@latestTo unlock the full power of runtime diagnostics, start your Next.js dev server:
npm run dev
Next.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.
โ ๏ธ IMPORTANT: Start every Next.js session by calling the init tool to set up proper context:
Use the init tool to set up Next.js DevTools context
This initializes the MCP context and ensures the AI assistant uses official Next.js documentation for all queries.
After initialization, try these prompts to explore runtime diagnostics:
Next Devtools, what errors are in my Next.js application?
Next Devtools, show me the structure of my routes
Next Devtools, what's in the development server logs?
Your coding agent will use the nextjs_index and nextjs_call tools to query your running application's actual state.
You can use the development automation and documentation tools regardless of Next.js version:
Next Devtools, help me upgrade my Next.js app to version 16
Next Devtools, enable Cache Components in my Next.js app
Next Devtools, search Next.js docs for generateMetadata
To 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:
Claude Code / Claude Desktop
Add to ~/.claude/CLAUDE.md (global) or ./.claude/CLAUDE.md (project-specific):
**When starting work on a Next.js project, ALWAYS call the `init` tool from
next-devtools-mcp FIRST to set up proper context and establish documentation
requirements. Do this automatically without being asked.**
Cursor
Add to .cursorrules in your project root or global Cursor settings:
When working with Next.js, always call the init tool from next-devtools-mcp
at the start of the session to establish proper context and documentation requirements.
Codex / Other AI Coding Assistants
Add to your agent's configuration file (e.g., .codex/instructions.md, agent.md, or similar):
**Next.js Initialization**: When starting work on a Next.js project, automatically
call the `init` tool from the next-devtools-mcp server FIRST. This establishes
proper context and ensures all Next.js queries use official documentation.
Why this matters:
The knowledge base resources are automatically available to your coding agent and are split into focused sections for efficient context management. Current resource URIs:
๐ Available Knowledge Base Resources (click to expand)
cache-components://overviewcache-components://core-mechanicscache-components://public-cachescache-components://private-cachescache-components://runtime-prefetchingcache-components://request-apiscache-components://cache-invalidationcache-components://advanced-patternscache-components://build-behaviorcache-components://error-patternscache-components://test-patternscache-components://referencenextjs16://migration/beta-to-stablenextjs16://migration/examplesnextjs-fundamentals://use-clientResources are loaded on-demand by your coding agent, providing targeted knowledge without overwhelming the context window.
Pre-configured prompts to help with common Next.js development tasks:
๐ก Available Prompts (click to expand)
upgrade-nextjs-16 - Guide for upgrading to Next.js 16enable-cache-components - Migrate and enable Cache Components mode for Next.js 16init
Initialize Next.js DevTools MCP context and establish documentation requirements.
Capabilities:
nextjs_docs for ALL Next.js-related queriesproject_path (optional) - Path to Next.js project (defaults to current directory)nextjs_docs
Search and retrieve Next.js official documentation and knowledge base.
Capabilities:
action (required) - Action to perform: search to find docs, get to fetch full contentquery (optional) - Required for search. Keyword search query (e.g., 'metadata', 'generateStaticParams', 'middleware')path (optional) - Required for get. Doc path from search results (e.g., '/docs/app/api-reference/functions/refresh')anchor (optional) - Optional for get. Anchor/section from search results (e.g., 'usage')routerType (optional) - For search only. Filter by: app, pages, or all (default: all)browser_eval
Automate and test web applications using Playwright browser automation.
When to use:
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.
Available actions:
start - Start browser automation (automatically installs if needed)navigate - Navigate to a URLclick - Click on an elementtype - Type text into an elementfill_form - Fill multiple form fields at onceevaluate - Execute JavaScript in browser contextscreenshot - Take a screenshot of the pageconsole_messages - Get browser console messagesclose - Close the browserdrag - Perform drag and dropupload_file - Upload fileslist_tools - List all available browser automation tools from the serveraction (required) - The action to performbrowser (optional) - Browser to use: chrome, firefox, webkit, msedge (default: chrome)headless (optional) - Run browser in headless mode (default: true)nextjs_index
Discover all running Next.js dev servers and list their available MCP tools.
What this tool does:
Automatically 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.
No parameters required - Just call the tool and it will scan for servers.
Available Next.js Runtime Tools (varies by Next.js version):
get_errors - Get current build, runtime, and type errorsget_logs - Get path to development log file (browser console + server output)get_page_metadata - Query application routes, pages, and component metadataget_project_metadata - Get project structure, config, and dev server URLget_server_action_by_id - Look up Server Actions by ID to find source filesnpm run dev)nextjs_call
Execute a specific MCP tool on a running Next.js dev server.
What this tool does:
Calls a specific runtime diagnostic tool on a Next.js 16+ dev server's built-in MCP endpoint at /_next/mcp.
Input Parameters:
port (required) - Dev server port (use nextjs_index first to discover)toolName (required) - Name of the Next.js tool to invokeargs (optional) - Arguments object for the tool (only if required by that tool)npm run dev)nextjs_index first to discover available servers and tools// Step 1: Discover servers and tools
// (call nextjs_index first)
// Step 2: Call a specific tool
{
"port": 3000,
"toolName": "get_errors"
// args is optional and only needed if the tool requires parameters
}
Output:
upgradenextjs16
Guides through upgrading Next.js to version 16 with automated codemod execution.
Capabilities:
project_path (optional) - Path to Next.js project (defaults to current directory)enablecachecomponents
Complete 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.
Capabilities:
project_path (optional) - Path to Next.js project (defaults to current directory)With Claude Code:
Next Devtools, help me enable Cache Components in my Next.js 16 app
With other agents or programmatically:
{
"tool": "enable_cache_components",
"args": {
"project_path": "/path/to/project"
}
}
next-devtools-mcp collects anonymous usage telemetry to help improve the tool. The following data is collected:
nextjs_index, nextjs_call, browser_eval, upgrade_nextjs_16)~/.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.
To disable telemetry completely, set the environment variable:
export NEXT_TELEMETRY_DISABLED=1
Add this to your shell configuration file (e.g., ~/.bashrc, ~/.zshrc) to make it permanent.
You can also delete your local telemetry data at any time:
rm -rf ~/.next-devtools-mcp
If you encounter an error like:
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '...\next-devtools-mcp\dist\resources\(cache-components)\...'
Solution: Clear your npx cache and restart your MCP client (Cursor, Claude Code, etc.). The server will be freshly installed.
If you see [error] No server info found:
Solutions:
npm run devupgrade_nextjs_16 tool to upgrade to Next.js 16+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.
To run the MCP server locally for development:
pnpm install
pnpm build
{
"mcpServers": {
"next-devtools": {
"command": "node",
"args": ["/absolute/path/to/next-devtools-mcp/dist/index.js"]
}
}
}
Note: Replace /absolute/path/to/next-devtools-mcp with the actual absolute path to your cloned repository.
or manually add, e.g. with codex:
codex mcp add next-devtools-local -- node dist/index.js
This MCP server provides coding agents with comprehensive Next.js development capabilities through three primary mechanisms:
Learn more: See the Next.js MCP documentation for details on how MCP servers work with Next.js and coding agents.
This package provides a bridge MCP server that connects your coding agent to Next.js development tools:
Coding Agent
โ
next-devtools-mcp (this package)
โ
โโโ Next.js Dev Server MCP Endpoint (/_next/mcp) โ Runtime diagnostics
โโโ Playwright MCP Server โ Browser automation
โโโ Knowledge Base & Tools โ Documentation, upgrades, setup automation
Key Architecture Points:
http://localhost:PORT/_next/mcp. This gives coding agents direct access to runtime errors, routes, logs, and application state.nextjs_index to see all servers and available tools, then call nextjs_call with the specific port and tool name you want to execute.MIT License