Логотип NextJS

NextJS

Організація
vercel

Next.js Development for Coding Agent

Видавецьvercel
Репозиторійnext-devtools-mcp
МоваTypeScript
Форки
66
Зірки
824
Доступні інструменти
5
Тип транспортуstdio
Категорії
Посилання
  • Підключайте інструменти до робочих процесів із ШІ

    NextJS надає можливості MCP, які можуть використовувати сумісні клієнтські ШІ-застосунки та агенти.

  • Доступні інструменти: 5

    Перегляньте нижче дії, які можна викликати, з назвами й описами, якщо сервер їх надає.

  • Готова конфігурація для копіювання

    Скористайтеся прикладами конфігурації, щоб налаштувати цей сервер у вибраному клієнті MCP.

  • Показники інтересу до відкритого коду

    Зірки: 824, форки: 66 — у пов’язаному репозиторії.

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

Встановлення

TypingMind
Передумови:

Node.js 18+

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

Доступні інструменти

  • 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:

Використовуйте MCP NextJS з різними моделями ШІ

TypingMind підключає інструменти MCP на рівні робочого простору, тож після підключення NextJS ви можете використовувати їх із різними моделями ШІ в TypingMind, а не налаштовувати окремо для кожної моделі. Ця інтеграція MCP працює локально через конектор MCP TypingMind на вашому пристрої.

Інструкція з налаштування локального конектора

Виберіть цей варіант, якщо серверу MCP потрібен доступ до локальних файлів, програм або приватних ресурсів на вашому комп’ютері.

1

Відкрийте налаштування MCP

У TypingMind перейдіть до розділу «Налаштування», відкрийте «Розширені налаштування», потім «Протокол контексту моделі» й виберіть «Параметри конектора».

  1. Відкрийте TypingMind у браузері.
  2. Натисніть значок налаштувань.
  3. Перейдіть до розділу «Розширені налаштування».
  4. Відкрийте розділ «Протокол контексту моделі».
  5. Натисніть «Параметри конектора» й виберіть «Цей пристрій».
Екран налаштування конектора MCP у TypingMind з вибраним варіантом «Цей пристрій»
2

Виконайте команду конектора

Виберіть «Цей пристрій», скопіюйте команду з TypingMind і виконайте її в терміналі. Не зупиняйте процес, поки користуєтеся MCP.

  1. Скопіюйте команду налаштування, показану в TypingMind.
  2. Відкрийте «Термінал» у macOS або Windows Terminal у Windows.
  3. Вставте й виконайте команду.
  4. Підтвердьте встановлення пакета, якщо термінал запитає дозволу продовжити.
  5. Не закривайте вікно термінала й не зупиняйте процес, поки користуєтеся інструментами MCP.
3

Додайте NextJS як сервер

Коли статус конектора зміниться на «Готово», натисніть «Змінити сервери» та вставте конфігурацію сервера MCP.

  1. Зачекайте, доки статус конектора зміниться на «Готово».
  2. Натисніть «Змінити сервери».
  3. Вставте конфігурацію сервера MCP NextJS.
  4. Збережіть список серверів.
  5. Оновіть дані, щоб переконатися, що конектор досі готовий до роботи.
Налаштування MCP у TypingMind з активним сервером і кнопкою «Змінити сервери»
{
  "mcpServers": {
    "nextjs": {
      "command": "npx",
      "args": [
        "-y",
        "next-devtools-mcp"
      ]
    }
  }
}
4

Використовуйте підключення з різними моделями

Збережіть список серверів, відкрийте «Плагіни», увімкніть інструменти MCP для NextJS, а потім виберіть будь-яку підтримувану модель ШІ в TypingMind і використовуйте інструменти в чаті або призначте їх агенту ШІ.

  1. Відкрийте сторінку «Плагіни» в TypingMind.
  2. Увімкніть інструменти MCP для NextJS.
  3. Почніть чат і виберіть модель ШІ, яку хочете використовувати.
  4. Використовуйте інструменти MCP у чаті або призначте їх агенту ШІ.
  5. За потреби перемикайтеся на іншу модель ШІ без повторного підключення MCP.
Чат TypingMind із використанням увімкнених інструментів MCP і вибраної моделі ШІ
Допоможете з цим завданням через NextJS?
NextJS
Звісно. Я це прочитав.
Ось що я знайшов за допомогою NextJS.

Поширені запитання

Для чого використовується сервер MCP NextJS?

NextJS — це сервер MCP, який дає змогу сумісним клієнтам ШІ підключатися до зовнішніх інструментів і контексту. У TypingMind ви можете додати цей сервер MCP один раз і зробити його інструменти доступними у своєму робочому просторі ШІ.

Чи можу я використовувати MCP NextJS з кількома моделями ШІ в TypingMind?

Так. TypingMind підключає інструменти MCP на рівні робочого простору, тому ви можете використовувати NextJS з різними моделями ШІ, як-от Claude, ChatGPT, Gemini або іншими моделями, які ви налаштували в TypingMind, без окремого налаштування сервера MCP для кожної моделі.

Навіщо використовувати MCP NextJS із TypingMind?

TypingMind — один із найкращих інтерфейсів для чату з великими мовними моделями, адже він об’єднує різні моделі ШІ, промпти, плагіни, агентів ШІ, ключі API та інструменти MCP в одному робочому просторі. Підключивши NextJS, ви зможете використовувати його інструменти MCP з вибраними моделями та впорядковано працювати з чатами в TypingMind.

Як підключити MCP NextJS до TypingMind?

NextJS працює через локальний конектор MCP TypingMind. Це найкращий варіант, коли серверу MCP потрібен доступ до локальних файлів, настільних застосунків, інструментів командного рядка або приватних ресурсів на вашому комп’ютері.

Які інструменти надає MCP NextJS у TypingMind?

NextJS надає інструменти MCP (5), які можна ввімкнути на сторінці «Плагіни» в TypingMind і використовувати в чаті або призначати агентам ШІ.

Чи потрібно передавати свої ключі API в TypingMind, щоб використовувати MCP NextJS?

Ні. TypingMind орієнтований насамперед на локальну роботу й дає змогу зберігати контроль над постачальниками моделей, ключами API, промптами та конфігурацією MCP. Якщо NextJS потребує автентифікації, під час створення підключення додайте потрібні заголовки, налаштування OAuth або локальну конфігурацію для цього сервера MCP.

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.

Схожі сервери MCP

Усі

Створіть власний ШІ-простір уже зараз

Підпишіться на нашу розсилку, щоб дізнаватися про нові функції та майбутні розіграші 👇