āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā š nextjs/app/guides/mcp ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā
The Model Context Protocol (MCP) is an open standard that allows AI agents and coding assistants to interact with your applications through a standardized interface.
Next.js 16+ includes MCP support that enables coding agents to access your application's internals in real-time. To use this functionality, install the next-devtools-mcp package.
Requirements: Next.js 16 or above
Add next-devtools-mcp to the .mcp.json file at the root of your project:
{
"mcpServers": {
"next-devtools": {
"command": "npx",
"args": ["-y", "next-devtools-mcp@latest"]
}
}
}
That's it! When you start your development server, next-devtools-mcp will automatically discover and connect to your running Next.js instance.
For more configuration options, see the next-devtools-mcp repository.
next-devtools-mcp provides coding agents with a growing set of capabilities:
Note: The Next.js team is actively expanding these capabilities. New tools and features are added regularly to improve the agent development experience.
npm run dev
Your Coding Agent will automatically connect to the running Next.js instance via next-devtools-mcp
Open your application in the browser to view pages
Query your agent for insights and diagnostics (see examples below)
Through next-devtools-mcp, agents can use the following tools:
get_errors: Retrieve current build errors, runtime errors, and type errors from your dev serverget_logs: Get the path to the development log file containing browser console logs and server outputget_page_metadata: Get metadata about specific pages including routes, components, and rendering informationget_project_metadata: Retrieve project structure, configuration, and dev server URLget_server_action_by_id: Look up Server Actions by their ID to find the source file and function nameMCP-compatible Coding Agents can automatically discover and connect to your Next.js development server, providing them with rich context about your project.
Agents can:
Ask your agent about errors in real-time:
User: "What errors are currently in my application?"
The agent will:
next-devtools-mcp> fix errors on the page
āŗ I'll help you fix the errors on the page. Let me first check what errors exist by looking at the
current state of the project.
āŗ next-devtools - nextjs_runtime (MCP)(action: "discover_servers")
āŗ next-devtools - nextjs_runtime (MCP)(action: "call_tool", toolName: "get_errors")
āŗ I found a hydration error on the /about page. The error shows that the server is rendering
"server" but the client is rendering "client", causing a mismatch. Let me create a todo list and fix
this issue.
āŗ Perfect! Now let me check for errors on the page. 01:14 PM claude-sonnet-4-5-20250929
āŗ next-devtools - nextjs_runtime (MCP)(action: "call_tool", toolName: "get_errors")
āæ {
"success": true,
"port": 3000,
"toolName": "get_errors",
"result": {
"content": [
{
"type": "text",
"text": "# Found errors in 1 browser session(s)\n\n## Session: /about\n\n**1 error(s)
found**\n\n### Runtime Errors\n\n#### Error 1 (Type: recoverable)\n\n**Error**: Hydration failed
</details>
Get help with Next.js concepts and migrations:
User: "Help me upgrade my Next.js app to version 16"
The agent will analyze your current version, guide you through automated migrations with codemods, and provide step-by-step instructions for handling breaking changes.
Ask conceptual questions:
User: "When should I use 'use client' in App Router?"
The agent will query the Next.js knowledge base and provide documentation-backed explanations with examples from your codebase.
Next.js 16+ includes a built-in MCP endpoint at /_next/mcp that runs within your development server. The next-devtools-mcp package automatically discovers and communicates with these endpoints, allowing it to:
This architecture decouples the agent interface from the internal implementation, enabling next-devtools-mcp to work seamlessly across different Next.js projects.
next-devtools-mcp is configured in your .mcp.jsonnpm run devā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā