Next.js DevTools MCP
next-devtools-mcp is a MCP server that provides Next.js development tools and utilities for AI coding assistants like Claude and Cursor.
Next.js DevTools MCP
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.
Features
This MCP server provides coding agents with comprehensive Next.js development capabilities through three primary mechanisms:
1. Runtime Diagnostics & Live State Access (Next.js 16+)
Connect directly to your running Next.js dev server's built-in MCP endpoint to query:
- Real-time build and runtime errors
- Application routes, pages, and component metadata
- Development server logs and diagnostics
- Server Actions and component hierarchies
2. Development Automation
Tools for common Next.js workflows:
- Automated Next.js 16 upgrades with official codemods
- Cache Components setup with error detection and automated fixes
- Browser testing integration via Playwright for visual verification
3. Knowledge Base & Documentation
- Curated Next.js 16 knowledge base (12 focused resources on Cache Components, async APIs, etc.)
- Direct access to official Next.js documentation via search API
- Pre-configured prompts for upgrade guidance and Cache Components enablement
Learn more: See the Next.js MCP documentation for details on how MCP servers work with Next.js and coding agents.
How It Works
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:
-
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. -
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.
-
Auto-discovery: The
nextjs_runtimetool scans common ports (3000, 3001, etc.) to find running Next.js servers, so you don't need to manually specify ports in most cases.
Requirements
- Node.js v20.19 or a newer latest maintenance LTS version
- npm or pnpm
Getting Started
Add the following config to your MCP client:
{
"mcpServers": {
"next-devtools": {
"command": "npx",
"args": ["-y", "next-devtools-mcp@latest"]
}
}
}
[!NOTE] Using
next-devtools-mcp@latestensures that your MCP client will always use the latest version of the Next.js DevTools MCP server.
MCP Client Configuration
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.
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.
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:
- Command:
npx - Arguments:
-y, next-devtools-mcp@latest
Windows 11 Special Configuration:
Update .codex/config.toml with environment variables and increased startup timeout:
env = { SystemRoot="C:\\Windows", PROGRAMFILES="C:\\Program Files" }
startup_timeout_ms = 20_000
Click the button to install:
Or install manually:
Go to Cursor Settings → MCP → New MCP Server. Use the config provided above.
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:
- Command:
npx - Arguments:
-y, next-devtools-mcp@latest
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.
Using Warp UI:
Navigate to Settings | AI | Manage MCP Servers and select + Add to register a new MCP server with the following configuration:
- Name:
next-devtools - Command:
npx - Arguments:
-y, next-devtools-mcp@latest
Quick Start
For Next.js 16+ Projects (Recommended)
To 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_runtime tool to query your running application's actual state.
For All Next.js Projects
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
💡 Pro Tip: Auto-Initialize on Every Session
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:
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.**
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.
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:
- ✅ Ensures consistent context across all Next.js work
- ✅ Automatically establishes the documentation-first requirement
- ✅ No need to manually call init every time
- ✅ Works across all your Next.js projects
MCP Resources
Next.js 16 knowledge base resources are automatically available to your coding agent.
These resources provide comprehensive documentation split into focused sections for efficient context management:
nextjs16://knowledge/overview- Overview and critical errors AI agents makenextjs16://knowledge/core-mechanics- Fundamental paradigm shift and how cacheComponents worksnextjs16://knowledge/public-caches- Public cache mechanics with 'use cache'nextjs16://knowledge/private-caches- Private cache patterns with 'use cache: private'nextjs16://knowledge/runtime-prefetching- Runtime prefetch configuration and patternsnextjs16://knowledge/request-apis- Async params, searchParams, cookies, headers APIsnextjs16://knowledge/cache-invalidation- updateTag, revalidateTag, and refresh patternsnextjs16://knowledge/advanced-patterns- cacheLife, cacheTag, draft mode, and morenextjs16://knowledge/build-behavior- Prerendering, resume data cache, and metadatanextjs16://knowledge/error-patterns- Common errors and how to fix themnextjs16://knowledge/test-patterns- E2E patterns from 125+ test fixturesnextjs16://knowledge/reference- API reference, checklists, and comprehensive nuances
Resources are loaded on-demand by your coding agent, providing targeted knowledge without overwhelming the context window.
MCP Prompts
Pre-configured prompts to help with common Next.js development tasks:
init- Initialize context for Next.js development with MCP tools and documentation requirementsupgrade-nextjs-16- Guide for upgrading to Next.js 16enable-cache-components- Enable caching for React components
MCP Tools
Initialize Next.js DevTools MCP context and establish documentation requirements.
Capabilities:
- Sets up proper context for AI assistants working with Next.js
- Establishes requirement to use
nextjs_docsfor ALL Next.js-related queries - Documents all available MCP tools and their use cases
- Provides best practices for Next.js development with MCP
- Includes example workflows and quick start checklist
When to use:
- At the beginning of a Next.js development session
- To understand available tools and establish proper context
- To ensure documentation-first approach for Next.js development
Input:
project_path(optional) - Path to Next.js project (defaults to current directory)
Output:
- Comprehensive initialization context and guidance for Next.js development with MCP tools
Search and retrieve Next.js official documentation and knowledge base.
Capabilities:
- Two-step process: 1) Search for docs by keyword to get paths, 2) Fetch full markdown content by path
- Uses official Next.js documentation search API
- Provides access to comprehensive Next.js guides, API references, and best practices
- Supports filtering by router type (App Router, Pages Router, or both)
Input:
action(required) - Action to perform:searchto find docs,getto fetch full contentquery(optional) - Required forsearch. Keyword search query (e.g., 'metadata', 'generateStaticParams', 'middleware')path(optional) - Required forget. Doc path from search results (e.g., '/docs/app/api-reference/functions/refresh')anchor(optional) - Optional forget. Anchor/section from search results (e.g., 'usage')routerType(optional) - Forsearchonly. Filter by:app,pages, orall(default:all)
Output:
- Search results with doc titles, paths, content snippets, sections, and anchors
- Full markdown content for specific documentation pages
Automate and test web applications using Playwright browser automation.
When to use:
- Verifying pages in Next.js projects (especially during upgrades or testing)
- Testing user interactions and flows
- Taking screenshots for visual verification
- Detecting runtime errors, hydration issues, and client-side problems
- Capturing browser console errors and warnings
Important: For Next.js projects, prioritize using the nextjs_runtime tool instead of browser console log forwarding. Only use browser_eval's console_messages action as a fallback when nextjs_runtime 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 server
Input:
action(required) - The action to performbrowser(optional) - Browser to use:chrome,firefox,webkit,msedge(default:chrome)headless(optional) - Run browser in headless mode (default:true)- Action-specific parameters (see tool description for details)
Output:
- JSON with action result, screenshots (base64), console messages, or error information
Connect to your running Next.js dev server's built-in MCP endpoint to access live application state, runtime diagnostics, and internal information.
What this tool does:
This tool acts as a bridge between your coding agent and Next.js 16's built-in MCP endpoint at /_next/mcp. It provides three key actions:
discover_servers: Find all running Next.js dev servers on your machinelist_tools: See what runtime diagnostic tools are available from Next.jscall_tool: Execute a specific Next.js runtime tool (e.g., get errors, query routes, fetch logs)
Available Next.js Runtime Tools (accessed via call_tool):
Once connected to a Next.js 16+ dev server, you can access these built-in tools:
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 files
Requirements:
- Next.js 16+ (MCP enabled by default)
- Running dev server (
npm run dev)
Typical workflow:
// Step 1: Discover running servers (optional - auto-discovery works in most cases)
{
"action": "discover_servers"
}
// Step 2: List available runtime tools
{
"action": "list_tools",
"port": 3000 // optional if only one server is running
}
// Step 3: Call a specific tool
{
"action": "call_tool",
"port": 3000,
"toolName": "get_errors"
// args is optional and only needed if the tool requires parameters
}
Input Parameters:
action(required) -discover_servers,list_tools, orcall_toolport(optional) - Dev server port (auto-discovers if not provided)toolName(required forcall_tool) - Name of the Next.js tool to invokeargs(optional) - Arguments object for the tool (only if required by that tool)includeUnverified(optional) - Fordiscover_servers: include servers even if MCP verification fails
Output:
- JSON with discovered servers, available tools list, or tool execution results
Example prompts that use this tool:
- "Next Devtools, what errors are in my Next.js app?"
- "Next Devtools, show me my application routes"
- "Next Devtools, what's in the dev server logs?"
- "Next Devtools, find the Server Action with ID xyz"
Guides through upgrading Next.js to version 16 with automated codemod execution.
Capabilities:
- Runs official Next.js codemod automatically (requires clean git state)
- Handles async API changes (params, searchParams, cookies, headers)
- Migrates configuration changes
- Updates image defaults and optimization
- Fixes parallel routes and dynamic segments
- Handles deprecated API removals
- Provides guidance for React 19 compatibility
Input:
project_path(optional) - Path to Next.js project (defaults to current directory)
Output:
- Structured JSON with step-by-step upgrade guidance
Complete Cache Components setup and enablement for Next.js 16 with automated error detection and fixing.
Capabilities:
- Pre-flight checks (package manager, Next.js version, configuration)
- Enable Cache Components configuration
- Start dev server with MCP enabled
- Automated route verification and error detection
- Automated error fixing with intelligent boundary setup (Suspense, caching directives, static params)
- Final verification and build testing
Input:
project_path(optional) - Path to Next.js project (defaults to current directory)
Output:
- Structured JSON with complete setup guidance and phase-by-phase instructions
Example Usage:
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"
}
}
Local Development
To run the MCP server locally for development:
-
Clone the repository
-
Install dependencies:
pnpm install pnpm build -
Configure your MCP client to use the local version:
{ "mcpServers": { "next-devtools": { "command": "node", "args": ["/absolute/path/to/next-devtools-mcp/dist/stdio.js"] } } }Note: Replace
/absolute/path/to/next-devtools-mcpwith the actual absolute path to your cloned repository.or manually add, e.g. with codex:
codex mcp add next-devtools-local -- node dist/stdio.js
License
MIT License
Related Servers
Docker MCP
A Ruby implementation of an MCP server for managing and using Docker
ActionKit MCP Starter
A demonstration server for ActionKit, providing access to Slack actions via Claude Desktop.
Facets Module
Create and manage Terraform modules for cloud-native infrastructure using the Facets.cloud FTF CLI.
Deep Code Reasoning MCP Server
Performs complementary code analysis by combining Claude Code and Google's Gemini AI.
ts-morph Refactoring Tools
Refactor TypeScript and JavaScript codebases using ts-morph. Supports renaming symbols and files, moving symbols, and searching for references.
UML-MCP-Server
Generate various UML diagrams from natural language or PlantUML code. Returns PlantUML code, image URLs, and saves diagrams locally.
BioMCP
Enhances large language models with protein structure analysis capabilities, including active site analysis and disease-protein searches, by connecting to the RCSB Protein Data Bank.
Manim MCP Server
Executes Manim Python scripts to generate and return rendered video animations.
Remote MCP Server (Authless)
An example of a remote MCP server deployable on Cloudflare Workers, without authentication.
MCP Bridge
A proxy server that enables existing REST APIs to be used as Model Context Protocol (MCP) servers.