Skip to content

The Next.js MCP Server: Letting AI Agents See Your App While They Build It

An AI agent guessing at your app’s state is slow and wrong. One that can read it live is a different tool entirely.

John Cravey with EleviFounder9 min read

There’s a difference between an AI coding agent that reads your code and one that can read your running app. The first works from static files and has to guess what’s actually happening at runtime — which route rendered, what error the browser threw, what the dev server logged. The second can just look. Next.js 16 ships a Model Context Protocol server that gives AI agents exactly that live view, and it changes the quality of AI-assisted development from “plausible guesses” to “grounded in what the app is actually doing.” This is what it is, how to turn it on, and what it’s worth to a team of your size.

What MCP is, without the jargon

The Model Context Protocol is an open standard that lets AI assistants talk to your tools through a common interface. Instead of an agent being a closed box that only knows what you paste into it, MCP lets it call out to services — including, now, your own running Next.js app. The Next.js MCP server exposes your dev server’s internals so an agent can query them live while it works.

Turning it on: one file

The setup is genuinely a single config file. Add `next-devtools-mcp` to a `.mcp.json` at your project root, start your dev server, and your MCP-compatible agent discovers and connects to the running app automatically. Requires Next.js 16 or above.

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

That’s the whole install. Next.js 16 runs a built-in MCP endpoint inside your dev server, and the `next-devtools-mcp` package finds it and bridges it to your agent. Start `npm run dev`, open your app in the browser, and the agent can now see it.

What the agent can actually see

The value is in the specific things the agent can now query instead of guess at:

  • get_errors — the current build errors, runtime errors, and type errors from your dev server. The agent reads the real error instead of you copy-pasting it.
  • get_logs — the development log file with browser console output and server logs, so the agent can trace what actually happened.
  • get_routes — every route in your app, grouped by router type, with dynamic segments shown as [param]. The agent knows your real URL structure.
  • get_page_metadata — the components and rendering details for a specific page, so the agent knows exactly what rendered where.
  • get_project_metadata — your project structure, config, and dev server URL, so suggestions fit your actual setup.
  • get_server_action_by_id — look up a Server Action by ID to find its source file and function.

The workflow, start to finish

  1. Start your dev server with npm run dev.
  2. Your agent auto-connects to the running instance through next-devtools-mcp.
  3. Open the app in the browser so there’s live state to read.
  4. Ask the agent about errors, routes, or behavior — it queries the app instead of guessing, and gives you fixes grounded in what’s really happening.

A worked example: the hydration bug the agent just reads

Hydration errors are a rite of passage in React and Next.js, and they’re miserable to debug from code alone because the symptom — a mismatch between what the server rendered and what the browser rendered — often points nowhere near the cause. Here’s the difference MCP makes. Without it, you tell the agent “my page flickers and the console has a hydration warning,” and it reads your code and guesses at the usual suspects: a `Date` rendered on the server, a `window` check, a random value. With MCP, the agent calls `get_errors`, reads the actual hydration error and the specific component it names, calls `get_page_metadata` to confirm what rendered there, and goes straight to the line — a timestamp formatted differently on server and client. One diagnosis instead of three guesses. The agent isn’t smarter; it just stopped working blind. That shift, from theorizing about runtime state to reading it, is the whole value proposition.

Where this fits in a bigger shift

MCP isn’t a Next.js-only idea — it’s an open standard that a growing ecosystem of tools implement, from databases to browsers to issue trackers, all so AI assistants can read and act on real state instead of guessing. Next.js implementing it for your running app is one instance of a broader move: AI development tools are getting eyes and hands on the systems they help build, rather than being clever text boxes you copy-paste into. For a business, the takeaway isn’t the protocol — it’s that the developers and agencies who adopt this class of tooling debug faster and ship with more confidence, because their AI works from facts about your app instead of assumptions. It’s a reasonable proxy for how current a team’s workflow is.

The limits worth knowing

Set expectations honestly. This is a development-time tool, so its benefit is entirely in how your site gets built and maintained, not in anything a visitor experiences — it makes developers faster, which shows up as lower cost and fewer bugs, not as a feature. It shines on runtime debugging and on understanding an unfamiliar or large codebase quickly; it does less for greenfield feature work where there’s no running state to read yet. And it runs inside the dev server, so it belongs on a developer’s machine and nowhere near production. Adopt it where the evidence says it helps — messy bugs and onboarding — and don’t oversell it as a transformation. It’s a sharp tool for a specific, common job, and that’s enough to earn its one-line install.

Getting the value in a team, not just a demo

A tool like this is easy to demo and easy to leave unused, so the difference between a novelty and a real productivity gain is whether it’s standardized. Put the `.mcp.json` in your project template so every repo has it from the first commit and no developer has to remember a setup ritual — the connection just works when they run the dev server. Then point people at the specific jobs where it earns its keep, because that’s where adoption sticks: debugging a runtime error, understanding an unfamiliar area of the codebase, confirming which route and component actually rendered. Those are the moments the live view beats guessing, and once a developer feels that once, they reach for it again.

Be honest about measuring it, too. The claim is faster debugging and faster onboarding, so if you want to know whether it’s paying off, watch cycle time on runtime-bug tickets and how quickly new developers get productive on the codebase — not some abstract “AI adoption” metric. At a small scale you’ll feel the benefit anecdotally the first time an agent reads an error instead of asking you to paste it. At a larger scale, decide your policy deliberately — local development only, never production — and roll it into standard tooling so it’s consistent across teams rather than a thing one enthusiast uses. The pattern that runs through this whole series holds here: give the machine real context — accurate docs, structured data, a live view of the app — and it works with you instead of guessing. MCP is that principle applied to the moment of building, and it costs one line of config to try.

What this means for your business

This is a developer-productivity tool, so its value tracks how much building and maintaining your site involves AI agents at all.

For agencies

This is straight throughput. Your developers using MCP-connected agents debug faster because the agent reads the real error instead of round-tripping through a human copy-pasting stack traces. Across a book of client projects, that’s meaningful time back on every runtime bug and every “why isn’t this rendering” question — and time is your unit of cost. Standardize the `.mcp.json` in your Next.js starter so every project has it from the first commit and every developer benefits without a setup ritual. It pairs naturally with the AGENTS.md setup: one file tells the agent how the framework works, the other lets it see your specific app running. Together they make AI-assisted delivery both accurate and fast.

For micro businesses (1–5 people)

If you or a solo developer maintain your own Next.js site with an AI assistant, this turns a frustrating debugging session into a short one — the agent can see the actual error on your actual page instead of you trying to describe it. You won’t use most of the advanced tools, but get_errors alone earns the one-line install the first time something breaks and the agent just reads what’s wrong. It’s the kind of quiet leverage that makes a one-person operation punch above its weight. If your site is maintained by a contractor, it’s worth asking whether they use tooling like this — it’s a fair proxy for how modern their workflow is.

For small businesses (SMEs)

For your in-house or contracted developers, MCP is a modest but real speedup on exactly the work that eats time: diagnosing runtime issues and understanding an app that’s grown past what one person holds in their head. get_routes and get_page_metadata are genuinely useful when someone new (or an AI agent) needs to understand a site with dozens of pages quickly. Add the `.mcp.json` to your project and let your team opt in. It’s not a transformation, but it’s a free efficiency gain on the maintenance work you’re already paying for.

For mid-size companies

At your scale the win is onboarding and consistency. An MCP-connected agent that can enumerate routes, inspect rendering, and surface real errors helps developers navigate a large, unfamiliar codebase faster — which matters when you have many engineers moving between many surfaces. Evaluate it as part of your standard developer tooling, decide your policy on where and how agents connect (local dev only), and roll the `.mcp.json` into your project templates so it’s consistent across teams. Track whether it actually reduces debugging cycle time before you mandate it; the honest answer at your scale is that it helps most on runtime bugs and unfamiliar code, which may or may not be your bottleneck. Adopt it where the evidence says it helps.

How we run this at Frontend Horizon

We wire the Next.js MCP server into our development setup so the AI agents in our loop can read the real state of the app they’re working on — errors, routes, rendering — instead of guessing from the code alone. It’s a build-time tool that makes our AI-assisted work faster and more grounded, and it lives entirely in development. If you want your project set up so AI can help maintain it well — MCP for the live view, AGENTS.md for the docs — run a free discovery and we’ll get you there. That closes this series on Next.js, SEO, and AI: from metadata and structured data to performance and the AI-legibility layer — every piece of it built into the sites we ship.

Written by
John Cravey
Founder

Founder of Frontend Horizon. Writes most of the long-form work on the FH blog.

Newer post
AI Search for Mid-Size Companies: Production Vector Search, RAG Permissions, and AEO at Scale
Older post
The Professional Services Growth Playbook, by Firm Size
Keep reading

More from the blog

Next.js·10 min

AGENTS.md and llms.txt: Making Your Next.js Project Legible to AI

AI reads your code and your site whether you help it or not. Two small files decide whether it reads them right.

Next.js·10 min

Structured Data in Next.js: How JSON-LD Gets You Cited by Google and AI

Structured data is how you tell Google and AI what your page means, not just what it says. Here’s the Next.js way to ship it.

Next.js·6 min

Next.js 16.1 in Production: The Migration Playbook We Run on Every FH Site

Next 16.1 is the lean target. Here’s the exact migration we run, what breaks, and what to delete after.