Build This Now
Build This Now
What Is Claude CodeInstallationNative InstallerFirst Project
speedy_devvkoen_salo
Blog/Handbook/Workflow/Next.js DevTools MCP

Next.js DevTools MCP With Claude Code: Complete Setup

Connect Claude Code to Next.js DevTools MCP for live runtime errors, logs, route metadata, browser verification, and safer Next.js 16 upgrades.

Want the framework behind these builds?

Get the Claude Code system we use to plan, build, test, and ship production software.

See what we build for companies →
speedy_devvkoen_salo
speedy_devvWritten by speedy_devvPublished Jul 28, 202610 min readHandbook hubWorkflow index

Next.js DevTools MCP lets Claude Code inspect a running Next.js application instead of reasoning only from source files. It can retrieve current errors and logs, inspect routes and project metadata, look up Server Actions, query framework knowledge, and help verify changes in the browser.

The setup takes one JSON entry. The improvement comes from changing your workflow so runtime evidence is required before the agent says a task is complete.

What Next.js DevTools MCP exposes

Next.js 16 includes a development MCP endpoint inside the running application. The next-devtools-mcp package discovers compatible local instances and presents their capabilities to MCP clients such as Claude Code.

The official Next.js MCP documentation lists:

  • Build, runtime, and type error retrieval
  • Development log access
  • Page and project metadata
  • Server Action lookup
  • Next.js documentation and best-practice knowledge
  • Migration and upgrade tooling
  • Browser testing integration

This is development tooling, not a production backdoor. Use it while the local development server is running.

Requirements

You need:

  • Next.js 16 or later
  • A working Node.js and package manager environment
  • Claude Code
  • A project-scoped .mcp.json
  • A running Next.js development server

Check the application version:

node -p "require('./node_modules/next/package.json').version"

If the package is missing, install dependencies first. If the app is on Next.js 15, upgrade before expecting the built-in development endpoint.

Add next-devtools-mcp to Claude Code

Create .mcp.json in the project root:

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

The @latest tag follows the official Next.js setup and keeps the bridge aligned with current framework tooling. In a tightly controlled environment, pin a tested version and update it through normal dependency review.

Start the app:

npm run dev

Then restart Claude Code or reload its MCP configuration. Project-scoped servers require trust because .mcp.json can launch a local command.

Check the connection:

claude mcp list

Inside Claude Code, open:

/mcp

The server should appear as connected or ready. Ask it to discover the app:

Use Next.js DevTools MCP to discover every running Next.js instance.
Report project metadata and current errors. Do not edit files.

Use live errors as the first debugging step

Without runtime access, an agent often begins by searching for code that looks suspicious. With DevTools MCP, it can start from the actual failure.

Use:

Query the running Next.js app for current errors.
For each error, identify the route, error class, and likely source file.
Do not change code until you have traced the evidence.

If the browser reports a hydration mismatch, Claude can retrieve that error, inspect the affected route and component boundary, then propose a focused fix. After editing, query the errors again.

That closed loop is better than "fix hydration" because it preserves the before-and-after evidence.

Inspect logs without pasting them into chat

The MCP server can return the development log path. Ask:

Use Next.js DevTools MCP to locate the development logs.
Read only the entries related to the current /settings request
and summarize the first causal error.

This avoids dumping an entire terminal history into the context window. It also gives Claude the current log file even when the dev server runs in another terminal.

Keep secrets out of application logs. MCP makes logs easier to consume, which also makes careless logging easier to expose to the model.

Query route and page metadata

For unfamiliar applications:

Inspect the project and page metadata for /dashboard.
Explain which route, layouts, and relevant components participate.
Then identify the smallest boundary for adding an empty state.

Metadata does not replace reading source. It helps the agent start at the route the runtime actually rendered.

For Server Actions:

Look up the Server Action referenced by this runtime error.
Find its source and trace authorization and validation before proposing a fix.

This is especially useful when a production-style action identifier appears in an error and the source function is not obvious from the message.

Verify a feature after implementation

A useful completion prompt is explicit:

Verify the account settings feature.

1. Run typecheck and the targeted tests.
2. Start or reuse the Next.js dev server.
3. Query Next.js DevTools MCP for current errors.
4. Open /settings in the browser.
5. Test loading, success, validation failure, and unauthorized states.
6. Query runtime errors again.
7. Report the commands, routes, and observed results.

Do not say "verified" without the evidence.

The MCP server can surface errors and metadata. A browser tool supplies interaction and screenshots. Use both when visual or user-flow behavior matters.

Next.js documents Playwright MCP integration as part of the development toolchain. Keep browser access narrowly scoped to test environments and non-production credentials.

Use MCP for a Next.js 16 upgrade

The official Next.js 16 upgrade guide recommends Next.js DevTools MCP for agent-assisted migrations.

Start in Claude Code Plan Mode:

/plan

Inspect the installed Next.js version, configuration, routing,
request APIs, caching, and proxy or middleware usage.
Use the Next.js MCP knowledge and upgrade tools.
Separate automated codemods from decisions that require review.
Return a migration, verification, rollout, and rollback plan.

Approve the plan, run the migration in small steps, and use the live error endpoint after each meaningful stage. Do not combine dependency upgrade, codemods, cache redesign, and unrelated feature changes in one diff.

Troubleshoot a missing connection

The server is absent

Confirm .mcp.json is at the project root and valid:

jq empty .mcp.json
claude mcp list

Claude Code prompts before trusting project MCP commands. Reset or review project choices if the server was previously denied.

npx cannot start

Test the exact command:

npx -y next-devtools-mcp@latest --help

If Claude Code cannot resolve npx, use the correct absolute path or fix the environment that launches Claude Code.

The MCP server connects but finds no app

Start the Next.js development server and confirm it is version 16 or later. Restart a server that was already running before the MCP configuration was added.

npm run dev

Then ask the MCP server to discover instances again.

Tools appear but return no browser state

Open the target page in a browser. Some runtime information exists only after the application has served or rendered the route.

Several apps are running

Ask the server to list every discovered instance and identify each port and project root before calling a route-specific tool.

Pair MCP with agent instructions

MCP gives Claude live evidence. It does not explain your preferred architecture.

Use a small AGENTS.md to point coding agents to version-matched documentation and a CLAUDE.md to define project boundaries, commands, and verification expectations. The Next.js CLAUDE.md and AGENTS.md setup provides a production template.

The three layers are complementary:

LayerAnswers
Installed Next.js docsWhat does this framework version require?
Project agent filesHow does this repository expect work to be done?
DevTools MCPWhat is the running application doing now?

Next.js DevTools MCP FAQs

Does this work with Cursor and other coding agents?

It works with MCP-compatible coding agents. The exact configuration and approval interface depends on the client.

Can I use it against production?

The documented workflow targets the Next.js development server. Do not expose development MCP endpoints as an unauthenticated production control surface.

Does it replace Playwright?

No. DevTools MCP exposes framework runtime information. Playwright drives and observes browser behavior. Use both for end-to-end verification.

Should I commit .mcp.json?

Commit the project configuration when every contributor should have the tool and the entry contains no secrets. Review it like executable configuration because it launches a package.

Why use @latest in the config?

The official setup uses it to follow active Next.js tooling. Security-sensitive or reproducible environments may prefer a pinned, reviewed version.

Build This Now uses the same evidence loop across the rest of a product: inspect the architecture, implement within its boundaries, then verify the live system instead of trusting source code alone.

Next.js DevTools MCP is valuable because it makes the agent answer a harder question than "does this code look right?" It asks "what did the application actually do?"

Posted by @speedy_devv

Continue in Workflow

  • Agentic Commerce: How to Build an App AI Agents Can Pay For
    A plain-English guide to agentic commerce in 2026: what x402, ACP, and the Machine Payments Protocol do, plus a weekend walkthrough for shipping a paid API that AI agents can buy from.
  • Claude Code Best Practices
    Five habits separate engineers who ship with Claude Code: PRDs, modular CLAUDE.md rules, custom slash commands, /clear resets, and a system-evolution mindset.
  • Claude Code Auto Mode
    A second Sonnet model reviews every Claude Code tool call before it fires. What auto mode blocks, what it allows, and the allow rules it drops in your settings.
  • Channels, Routines, Teleport, Dispatch
    The four Claude Code features Anthropic shipped in March and April 2026 that turn the CLI into an event-driven coordination layer across phone, web, and desktop.
  • Claude Code 1M Context in Practice: When Bigger Isn't Better
    The 1M-token context window is GA at flat pricing, but bigger isn't always better. A decision framework, token-cost math, and when to use /compact, subagents, and dynamic workflows instead.
  • How to Build an Admin Dashboard With Claude Code
    Ship an internal admin panel with Claude Code: role-gated routes, a searchable users and orders table with pagination, impersonation-safe RLS, and metrics tiles pulled through a type-safe API.

More from Handbook

  • Deep Thinking Techniques
    Thinking trigger phrases like think harder, ultrathink, and think step by step push Claude Code into extended reasoning and more test-time compute, same model.
  • Efficiency Patterns
    Permutation frameworks turn 8 to 12 manual builds into a CLAUDE.md template Claude Code uses to generate variations 11, 12, and 13 on demand. Captured once.
  • Claude Code Fast Mode
    Fast mode routes your Opus 4.6 requests down a priority serving path in Claude Code. Same weights, same ceiling, replies 2.5x quicker at a higher token rate.
  • Speed Optimization
    Model selection, context size, and prompt specificity are the three levers that decide how fast Claude Code replies. /model haiku, /compact, and /clear covered.

Want the framework behind these builds?

Get the Claude Code system we use to plan, build, test, and ship production software.

See what we build for companies →
speedy_devvkoen_salo

On this page

What Next.js DevTools MCP exposes
Requirements
Add next-devtools-mcp to Claude Code
Use live errors as the first debugging step
Inspect logs without pasting them into chat
Query route and page metadata
Verify a feature after implementation
Use MCP for a Next.js 16 upgrade
Troubleshoot a missing connection
The server is absent
npx cannot start
The MCP server connects but finds no app
Tools appear but return no browser state
Several apps are running
Pair MCP with agent instructions
Next.js DevTools MCP FAQs
Does this work with Cursor and other coding agents?
Can I use it against production?
Does it replace Playwright?
Should I commit .mcp.json?
Why use @latest in the config?

Want the framework behind these builds?

Get the Claude Code system we use to plan, build, test, and ship production software.

See what we build for companies →