Logo van NextJS

NextJS

Organisatie
vercel

Next.js Development for Coding Agent

Uitgeververcel
Repositorynext-devtools-mcp
TaalTypeScript
Forks
66
Sterren
824
Beschikbare tools
5
Transporttypestdio
Categorieën
Links
  • Koppel tools aan AI-workflows

    NextJS biedt MCP-functionaliteit die compatibele AI-clients en agenten kunnen gebruiken.

  • 5 beschikbare tools

    Bekijk hieronder de aanroepbare acties, inclusief namen en beschrijvingen als de server die beschikbaar stelt.

  • Configuratie om direct te kopiëren

    Gebruik de installatievoorbeelden om deze server in je favoriete MCP-client te configureren.

  • Indicatoren van opensource-interesse

    824 sterren en 66 forks in de gekoppelde repository.

Next.js DevTools MCP

npm next-devtools-mcp package

next-devtools-mcp is a Model Context Protocol (MCP) server that connects coding agents like Claude and Cursor to your running Next.js dev server.

It is a thin connector. It discovers running Next.js 16+ dev servers and proxies their built-in MCP endpoint (/_next/mcp) so agents get live runtime errors, routes, and logs. It also ships two gateways that point agents at tools they run directly: version-accurate docs and the agent-browser CLI.

[!NOTE] Docs and migration workflows no longer live in this server. Next.js bundles its own docs at node_modules/next/dist/docs/, and upgrade / Cache Components workflows are distributed as agent skills. See Migrating from 0.3.x.

Requirements

  • Node.js v20.19 or a newer LTS version
  • npm or pnpm
  • Next.js 16+ with a running dev server (for nextjs_index / nextjs_call)

Install

Install for all your coding agents with add-mcp:

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

Add -y to skip the prompt and install to all detected agents. Add -g to install globally across all projects.

Or add the config to your MCP client manually:

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

[!NOTE] next-devtools-mcp@latest keeps your client on the latest version.

Client-specific setup

bash
amp mcp add next-devtools -- npx next-devtools-mcp@latest

Or follow Amp's MCP docs with the config above.

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

Or edit your MCP settings file with the config above.

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

Windows 11: add environment variables and a longer startup timeout to .codex/config.toml:

toml
env = { SystemRoot="C:\\Windows", PROGRAMFILES="C:\\Program Files" }
startup_timeout_ms = 20_000

Install in Cursor

Or go to Cursor Settings → MCP → New MCP Server and use the config above.

bash
# Project
gemini mcp add next-devtools npx next-devtools-mcp@latest

# Global
gemini mcp add -s user next-devtools npx next-devtools-mcp@latest

Add to .gemini/antigravity/mcp_config.json:

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

See the Antigravity MCP docs.

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

Or follow the official VS Code MCP setup guide.

Settings | AI | Manage MCP Servers → + Add:

  • Name: next-devtools
  • Command: npx
  • Arguments: -y, next-devtools-mcp@latest

Quick Start

Start your Next.js dev server:

bash
npm run dev

Next.js 16+ enables its MCP endpoint by default at http://localhost:3000/_next/mcp. next-devtools-mcp discovers and connects to it automatically — no config needed.

Then ask your agent about the running app:

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?

The agent calls nextjs_index to discover servers, then nextjs_call to query their real state.

Tools

ToolWhat it does
nextjs_indexDiscover running Next.js dev servers and list each one's runtime MCP tools.
nextjs_callCall a runtime tool on a discovered server (errors, routes, logs, Server Actions).
nextjs_docsGateway. Point the agent at version-accurate docs in node_modules/next/dist/docs/.
browser_evalGateway. Point the agent at the agent-browser CLI for browser automation.

The gateways do not do the work themselves — they tell the agent where the docs are or how to install/run the CLI, and the agent runs it directly (faster than proxying through MCP).

Scans common ports for running Next.js 16+ dev servers and lists each server's built-in runtime tools at /_next/mcp. No parameters.

Runtime tools exposed by Next.js (varies by version):

  • get_errors — current build, runtime, and type errors
  • get_logs — path to the dev log file (browser console + server output)
  • get_page_metadata — routes, pages, component metadata
  • get_project_metadata — project structure, config, dev server URL
  • get_server_action_by_id — resolve a Server Action ID to its source file

Output: JSON listing discovered servers (port, PID, URL) and their tools.

Calls one runtime tool on a discovered server. Run nextjs_index first to find the port and tool name.

Input:

  • port (required) — dev server port
  • toolName (required) — runtime tool to invoke
  • args (optional) — arguments object, only if the tool requires them
jsonc
{ "port": 3000, "toolName": "get_errors" }

Output: JSON with the tool's result. Upstream requests, including response-body reads, have a 60-second deadline. Cancelling an MCP request aborts its upstream network work; discovery also releases response bodies used only to detect the protocol.

Does not fetch docs. Recent Next.js releases bundle their docs (markdown, matching your installed version) at node_modules/next/dist/docs/. This tool checks for those files before returning reading instructions. If an installed release has no bundled docs (including early 16.x releases), it offers https://nextjs.org/docs as a fallback and asks the agent to verify APIs against the installed version. Missing dependencies receive installation guidance instead. On Next.js below 16, it recommends npx @next/codemod@latest upgrade latest.

Input: topic (optional), project_path (optional, defaults to cwd). The tool resolves next/package.json from that project, including hoisted workspace dependencies, and returns an absolute docsPath for the installed package.

Does not drive the browser. It detects whether agent-browser is installed and returns either the entry point (agent-browser skills get core --full) or the install steps (npm install -g agent-browser, then agent-browser install), so the agent runs the CLI directly.

Input: task (optional) — used only to tailor the guidance.

Migrating from 0.3.x

Starting in 0.4.0, next-devtools-mcp is a thin connector.

Changed:

  • nextjs_docs no longer fetches docs over the network. It points the agent at the docs Next.js bundles at node_modules/next/dist/docs/ (or recommends upgrading). The nextjs-docs://llms-index resource is removed.

Removed:

  • init tool — it only enforced the old docs-fetch workflow.
  • upgrade_nextjs_16 and enable_cache_components tools and their prompts — now distributed as agent skills.
  • All cache-components://, nextjs16://, and nextjs-fundamentals:// resources — superseded by the bundled docs.

What remains: nextjs_index, nextjs_call, nextjs_docs, and browser_eval.

Privacy & Telemetry

next-devtools-mcp collects anonymous usage telemetry to improve the tool:

  • Tool usage — which MCP tools are invoked (e.g. nextjs_index, nextjs_call)
  • Error events — anonymous error messages when tools fail
  • Session metadata — session ID, timestamps, basic environment (OS, Node.js version)

Not collected: your code, file contents or paths, personal data, credentials, or tool arguments (only tool names).

Local files live under ~/.next-devtools-mcp/ (anonymous telemetry-id, telemetry-salt, and a debug log mcp.log).

Opt out by setting the environment variable (add it to ~/.zshrc / ~/.bashrc to persist):

bash
export NEXT_TELEMETRY_DISABLED=1

Delete local telemetry data anytime:

bash
rm -rf ~/.next-devtools-mcp

Troubleshooting

ERR_MODULE_NOT_FOUND referencing next-devtools-mcp/dist — clear your npx cache and restart your MCP client. The server reinstalls fresh.

[error] No server info found — nextjs_index / nextjs_call need a running Next.js 16+ dev server:

  1. Start it: npm run dev
  2. Confirm Next.js 16+ (the /_next/mcp endpoint only exists there)
  3. Verify it started without errors

browser_eval and nextjs_docs work without a dev server.

Local Development

bash
git clone https://github.com/vercel/next-devtools-mcp.git
cd next-devtools-mcp
pnpm install
pnpm build

Point your MCP client at the local build:

json
{
  "mcpServers": {
    "next-devtools": {
      "command": "node",
      "args": ["/absolute/path/to/next-devtools-mcp/dist/index.js"]
    }
  }
}

Or with Codex:

bash
codex mcp add next-devtools-local -- node dist/index.js

See the Next.js MCP documentation for how MCP works with Next.js and coding agents.

License

MIT

Installatie

TypingMind
Vereisten:

Node.js 18+

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

Beschikbare tools

  • nextjs_docs

    Search and retrieve Next.js official documentation. First searches MCP resources (Next.js 16 knowledge base) for latest information, then falls back to official Next.js documentation if nothing is found. Provides access to comprehensive Next.js guides, API references, and best practices.

  • browser_eval

    Automate and test web applications using Playwright browser automation. This tool connects to playwright-mcp server and provides access to all Playwright capabilities.

    CRITICAL FOR PAGE VERIFICATION: When verifying pages in Next.js projects (especially during upgrades or testing), you MUST use browser automation to load pages in a real browser instead of curl or simple HTTP requests. This is because:

    • Browser automation actually renders the page and executes JavaScript (curl only fetches HTML)
    • Detects runtime errors, hydration issues, and client-side problems that curl cannot catch
    • Verifies the full user experience, not just HTTP status codes
    • Captures browser console errors and warnings via console_messages action

    IMPORTANT FOR NEXT.JS PROJECTS: If working with a Next.js application, PRIORITIZE using the 'nextjs_runtime' tool instead of browser console log forwarding. Next.js has built-in MCP integration that provides superior error reporting, build diagnostics, and runtime in

  • nextjs_runtime

    Interact with a running Next.js development server's MCP endpoint to query runtime information, diagnostics, and internals.

    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"
  • upgrade_nextjs_16

    Guide through upgrading Next.js to version 16.

    CRITICAL: Runs the official codemod FIRST (requires clean git state) for automatic upgrades and fixes, then handles remaining issues manually. The codemod upgrades Next.js, React, and React DOM automatically.

    Covers:

    • Next.js version upgrade to 16
    • Async API changes (params, searchParams, cookies, headers)
    • Config migration (next.config changes)
    • Image defaults and optimization
    • Parallel routes and dynamic segments
    • Deprecated API removals
    • React 19 compatibility

    The codemod requires:

    • Clean git working directory (commit or stash changes first)
    • Node.js 18+
    • npm/pnpm/yarn/bun installed

    After codemod runs, provides manual guidance for any remaining issues not covered by the codemod.

  • enable_cache_components

    Complete Cache Components setup for Next.js 16.

    Handles ALL steps for enabling and verifying Cache Components:

    • Configuration: Updates cacheComponents flag (experimental in 16.0.0, stable in canary > 16), removes incompatible flags
    • Dev Server: Starts dev server with MCP enabled (__NEXT_EXPERIMENTAL_MCP_SERVER=true)
    • Error Detection: Loads all routes via browser automation, collects errors using Next.js MCP
    • Automated Fixing: Adds Suspense boundaries, "use cache" directives, generateStaticParams, cacheLife profiles, cache tags
    • Verification: Validates all routes work with zero errors

    Key Features:

    • One-time dev server start (no restarts needed)
    • Automated error detection using Next.js MCP tools
    • Browser-based testing with browser automation
    • Fast Refresh applies fixes instantly
    • Comprehensive fix strategies for all error types
    • Support for "use cache", "use cache: private", Suspense boundaries
    • Cache invalidation with cacheTag() and cacheLife() configuration

    Requires:

Gebruik NextJS MCP met meerdere AI-modellen

TypingMind koppelt MCP-tools aan de werkruimte. Zodra NextJS is verbonden, kun je deze dus met verschillende AI-modellen in TypingMind gebruiken, zonder de verbinding voor elk model apart in te stellen. Deze MCP-integratie draait lokaal via de TypingMind MCP-connector op je apparaat.

Installatiehandleiding voor de lokale connector

Gebruik dit als de MCP-server toegang nodig heeft tot lokale bestanden, apps of privébronnen op je computer.

1

Open de MCP-instellingen

Ga in TypingMind naar Instellingen, Geavanceerde instellingen en vervolgens Model Context Protocol. Kies daar Connector instellen.

  1. Open TypingMind in je browser.
  2. Klik op het pictogram Instellingen.
  3. Ga naar Geavanceerde instellingen.
  4. Open het gedeelte Model Context Protocol.
  5. Klik op Connector instellen en kies Dit apparaat.
Instelscherm voor de TypingMind MCP-connector met Dit apparaat geselecteerd
2

Voer de connectoropdracht uit

Kies Dit apparaat, kopieer de opdracht uit TypingMind en voer deze uit in Terminal. Laat het proces draaien zolang je MCP gebruikt.

  1. Kopieer de installatieopdracht die TypingMind toont.
  2. Open Terminal op macOS of Windows Terminal op Windows.
  3. Plak de opdracht en voer deze uit.
  4. Keur de pakketinstallatie goed als Terminal vraagt of je wilt doorgaan.
  5. Laat het proces in het Terminal-venster draaien zolang je MCP-tools gebruikt.
3

Voeg NextJS toe als server

Klik op Servers bewerken zodra de connectorstatus Gereed is en plak de MCP-serverconfiguratie.

  1. Wacht tot de connectorstatus Gereed aangeeft.
  2. Klik op Servers bewerken.
  3. Plak de MCP-serverconfiguratie van NextJS.
  4. Sla de serverlijst op.
  5. Vernieuw om te controleren of de connector nog steeds klaar is voor gebruik.
MCP-instellingen van TypingMind met een actieve server en de knop Servers bewerken
{
  "mcpServers": {
    "nextjs": {
      "command": "npx",
      "args": [
        "-y",
        "next-devtools-mcp"
      ]
    }
  }
}
4

Gebruik de verbinding met verschillende modellen

Sla de serverlijst op, open Plug-ins en schakel de MCP-tools van NextJS in. Selecteer vervolgens een ondersteund AI-model in TypingMind en gebruik de tools in de chat of wijs ze toe aan een AI-agent.

  1. Open de pagina Plug-ins in TypingMind.
  2. Schakel de MCP-tools van NextJS in.
  3. Start een chat en kies het AI-model dat je wilt gebruiken.
  4. Gebruik de MCP-tools in een chat of wijs ze toe aan een AI-agent.
  5. Schakel wanneer nodig over naar een ander AI-model zonder opnieuw verbinding te maken met MCP.
TypingMind-chat met ingeschakelde MCP-tools en een geselecteerd AI-model
Kun je NextJS gebruiken om me hiermee te helpen?
NextJS
Zeker. Ik heb het gelezen.
Dit vond ik met NextJS.

Veelgestelde vragen

Waarvoor wordt de MCP-server NextJS gebruikt?

NextJS is een MCP-server waarmee compatibele AI-clients verbinding kunnen maken met externe tools en context. In TypingMind hoef je deze MCP-server maar één keer toe te voegen om de tools beschikbaar te maken in je AI-werkruimte.

Kan ik NextJS MCP met meerdere AI-modellen in TypingMind gebruiken?

Ja. TypingMind verbindt MCP-tools op werkruimteniveau. Daardoor kun je NextJS gebruiken met verschillende AI-modellen, zoals Claude, ChatGPT, Gemini of andere modellen die je in TypingMind hebt ingesteld, zonder de MCP-server voor elk model afzonderlijk in te stellen.

Waarom NextJS MCP gebruiken met TypingMind?

TypingMind is een van de beste interfaces voor chats met LLM's, omdat het meerdere AI-modellen, prompts, plug-ins, AI-agenten, API-sleutels en MCP-tools samenbrengt in één werkruimte. Als NextJS verbonden is, kun je de MCP-tools ervan gebruiken met je favoriete modellen en je chatworkflow overzichtelijk houden in TypingMind.

Hoe verbind ik NextJS MCP met TypingMind?

NextJS werkt via de lokale MCP-connector van TypingMind. Dit is de beste optie als de MCP-server toegang nodig heeft tot lokale bestanden, desktopapps, opdrachtregeltools of privébronnen op je computer.

Welke tools biedt NextJS MCP in TypingMind?

NextJS biedt 5 MCP-tools die je kunt inschakelen via de pagina Plug-ins in TypingMind. Je kunt ze gebruiken in chats of toewijzen aan AI-agenten.

Moet ik mijn API-sleutels delen met TypingMind om NextJS MCP te gebruiken?

Nee. TypingMind werkt in de eerste plaats lokaal en laat je de controle houden over je modelaanbieders, API-sleutels, prompts en MCP-configuratie. Als NextJS authenticatie vereist, voeg je bij het maken van de verbinding de vereiste headers, OAuth-instellingen of lokale configuratie voor die MCP-server toe.

Next.js 16 Overview

Document overview, critical errors AI agents make, and table of contents. Start here for a quick reference of common mistakes.

Core Mechanics

Part 1: Fundamental paradigm shift, how cacheComponents works, and the three types of rendering in Next.js 16.

Public Caches

Part 2: Public cache mechanics using 'use cache', cache key generation, and non-serializable props patterns.

Private Caches

Part 3: Private cache mechanics using 'use cache: private', when private cache is included/excluded, and patterns from tests.

Runtime Prefetching

Part 4: unstable_prefetch configuration, runtime prefetch patterns, what gets included in prefetch, and stale time thresholds (30s rule).

Request APIs

Part 6: Async params semantics, searchParams behavior, cookies(), headers(), and connection() API patterns.

Cache Invalidation

Part 7: updateTag() for read-your-own-writes, revalidateTag() with new signature, refresh() for router cache, and granular invalidation strategies.

Advanced Patterns

Part 8: cacheLife() profiles, cacheTag() multi-tag patterns, draft mode behavior, generateStaticParams integration, and Math.random()/Date.now() patterns.

Build Behavior

Part 9: What gets prerendered, resume data cache (RDC), static shell vs dynamic holes, generateMetadata and generateViewport patterns.

Error Patterns

Part 10: Segment config errors, dynamic metadata errors, missing suspense errors, and sync IO after dynamic API errors.

Real Test-Driven Patterns

Part 11: Complete E2E pattern library from 125+ test fixtures and decision trees based on actual test behavior.

Reference Materials

Mental model summary, complete API quick reference, checklists for AI agents, segment caching, generateStaticParams mechanics, and ultra-comprehensive nuances list.

Understanding 'use client' Directive

Learn when and why to use 'use client' in Server Components. Includes: when to mark components as client-only, why props must be serializable (functions/classes can't cross server-client boundary), composition patterns (moving 'use client' down tree, passing Server Components as children, context providers), common anti-patterns and fixes (wrapping entire app, passing functions from server), Server Actions as alternative to callbacks, React hooks that require 'use client', browser APIs, optimization checklist, and decision tree for Server vs Client components. Use this when confused about server/client boundaries, serialization errors, hydration issues, or deciding where to add 'use client'

Dynamic vs Static Rendering

Learn how components become dynamic in Next.js and when to use each API. Includes: how headers(), cookies(), draftMode() automatically make components dynamic, when and why to use connection() to explicitly mark components as dynamic, why you should NEVER use empty headers()/cookies() calls just to mark as dynamic (anti-pattern), real-world examples with current year/timestamps/random values, static vs dynamic decision guide, debugging dynamic rendering, common mistakes and fixes. CRITICAL: Use connection() to mark as dynamic, NOT empty headers() calls. Use this when deciding between static/dynamic rendering, using Date.now()/Math.random(), or getting 'used outside use cache without connection()' warnings.

Next.js 16 Beta to Stable Migration

Specific breaking changes and config migrations required when upgrading from Next.js 16 beta to stable (experimental.cacheLife → cacheLife, etc.)

Next.js 16 Migration Code Examples

Detailed before/after code examples for all Next.js 16 migration scenarios: removed features (AMP, runtime config, PPR), async APIs, image config, cache invalidation, middleware to proxy, and more

upgrade-nextjs-16

Guide through upgrading Next.js to version 16. CRITICAL: Runs the official codemod FIRST (requires clean git state) for automatic upgrades and fixes, then handles remaining issues manually. The codemod upgrades Next.js, React, and React DOM automatically. Covers async API changes, config moves, image defaults, parallel routes, and deprecations.

enable-cache-components

Complete Cache Components setup for Next.js 16. Handles ALL steps: updates experimental.cacheComponents flag, removes incompatible flags, migrates Route Segment Config, starts dev server with MCP, detects all errors via chrome_devtools + get_errors, automatically fixes all issues by adding Suspense boundaries, 'use cache' directives, generateStaticParams, cacheLife profiles, cache tags, and validates everything with zero errors.

Gerelateerde MCP-servers

Toon alles

Maak nu je eigen AI-werkruimte

Schrijf je in voor onze nieuwsbrief en blijf op de hoogte van nieuwe functies en toekomstige weggeefacties 👇