Add MCP get_compilation_issues tool and NAPI method#92062
Add MCP get_compilation_issues tool and NAPI method#92062
get_compilation_issues tool and NAPI method#92062Conversation
Adds a new `project_get_all_compilation_issues` NAPI method that builds the module graph for all entrypoints using `whole_app_module_graphs()` without chunking, code generation, or disk emission. This surfaces all compilation issues (resolve errors, missing modules, transform errors) from all routes in a single call. Wires this into a new `get_compilation_issues` MCP tool that works without requiring a browser session, covering all routes proactively. Includes an e2e test with a fixture app containing routes with different error types (module-not-found, syntax errors, and a valid page). Co-Authored-By: Claude <noreply@anthropic.com>
…app_module_graphs whole_app_module_graphs() calls drop_issues() in development mode to prevent duplicate issue reporting during HMR per-route subscriptions. This caused get_all_compilation_issues to return zero issues in dev mode. Fix by iterating all endpoint groups and calling module_graphs() on each, which builds the module graph and collects issues per endpoint without the dev-mode issue suppression. Co-Authored-By: Claude <noreply@anthropic.com>
Failing test suitesCommit: 4a69f6c | About building and testing Next.js
Expand output● mcp-server get_compilation_issues tool › should return compilation issues without requiring a browser session ● mcp-server get_compilation_issues tool › should detect module-not-found errors ● mcp-server get_compilation_issues tool › should detect syntax errors ● mcp-server get_compilation_issues tool › should include issue metadata fields
Expand output● app dir client cache with parallel routes › prefetch={true} › should prefetch the full page ● app dir client cache with parallel routes › prefetch={true} › should re-use the cache for the full page, only for 5 mins
Expand output● layout sharing in non-static prefetches › full prefetches should omit layouts that were already prefetched with a full prefetch ● layout sharing in non-static prefetches › segment-level prefetch config › does not unnecessarily use a runtime prefetch for sub-pages of runtime-prefetchable layouts ● layout sharing in non-static prefetches › segment-level prefetch config › statically prefetches a fully-static page segment if all its runtime-prefetchable parents are available ● layout sharing in non-static prefetches › segment-level prefetch config › uses a runtime prefetch for sub-pages of runtime-prefetchable layouts if requested
Expand output● segment cache (per-page dynamic stale time) › per-page value overrides global staleTimes.dynamic regardless of direction |
Merging this PR will degrade performance by 3.41%
Performance Changes
Comparing Footnotes
|
Stats from current PR🟢 3 improvements
📊 All Metrics📖 Metrics GlossaryDev Server Metrics:
Build Metrics:
Change Thresholds:
⚡ Dev Server
📦 Dev Server (Webpack) (Legacy)📦 Dev Server (Webpack)
⚡ Production Builds
📦 Production Builds (Webpack) (Legacy)📦 Production Builds (Webpack)
📦 Bundle SizesBundle Sizes⚡ TurbopackClient Main Bundles
Server Middleware
Build DetailsBuild Manifests
📦 WebpackClient Main Bundles
Polyfills
Pages
Server Edge SSR
Middleware
Build DetailsBuild Manifests
Build Cache
🔄 Shared (bundler-independent)Runtimes
📝 Changed Files (8 files)Files with changes:
View diffspages-api-tu..ntime.dev.jsDiff too large to display pages-api-tu..time.prod.jsDiff too large to display pages-api.runtime.dev.jsDiff too large to display pages-api.ru..time.prod.jsDiff too large to display pages-turbo...ntime.dev.jsDiff too large to display pages-turbo...time.prod.jsDiff too large to display pages.runtime.dev.jsDiff too large to display pages.runtime.prod.jsDiff too large to display 📎 Tarball URL |
What?
Adds a new
get_compilation_issuesMCP tool (and the underlyingprojectGetAllCompilationIssuesNAPI method) that returns all compilation issues from all routes in a single call.New files:
crates/next-napi-bindings/src/next_api/project.rs—project_get_all_compilation_issuesNAPI function +get_all_compilation_issues_operation/get_all_compilation_issues_inner_operationturbo-tasks operationspackages/next/src/server/mcp/tools/get-compilation-issues.ts— MCP tool implementationtest/development/mcp-server/mcp-server-get-compilation-issues.test.ts— e2e testtest/development/mcp-server/fixtures/compilation-errors-app/— fixture app with three routes (valid page, missing-module error, syntax error)Modified files:
packages/next/src/build/swc/generated-native.d.ts+types.ts+index.ts— expose the new NAPI methodpackages/next/src/server/mcp/get-or-create-mcp-server.ts— register the new tool, acceptgetTurbopackProjectoptionpackages/next/src/server/dev/hot-reloader-turbopack.ts— passprojectto MCP middlewarepackages/next/src/telemetry/events/build.ts— add'mcp/get_compilation_issues'to theMcpToolNameunionWhy?
The existing MCP tools require a browser session (and thus a specific route to be rendered) to surface compilation errors.
get_compilation_issuesworks without a browser session and covers all routes proactively — useful for AI coding agents that want to check for errors across the whole app before trying to render a page.How?
NAPI layer:
project_get_all_compilation_issuescalls a two-level turbo-tasks operation pair:get_all_compilation_issues_inner_operation— iterates all endpoint groups viaproject.get_all_endpoint_groups(false)and callsendpoint_group.module_graphs().as_side_effect()on each. This builds the module graph (resolution + transformation) for every entrypoint without chunking, emitting, or code generation. Issues are emitted as turbo-tasks collectables.get_all_compilation_issues_operation— wraps the inner op instrongly_consistent_catch_collectablesto harvest issues/diagnostics/effects, then returns anOperationResult.MCP tool (
get_compilation_issues):Calls
project.getAllCompilationIssues(), maps the result to a plain{issues, diagnostics}JSON object, and returns it. The tool works without a browser session and is available as soon as the dev server is ready.Test:
A fixture app with three routes (valid
app/page.tsx,app/missing-module/page.tsximporting a non-existent package,app/syntax-error/page.tsxwith unclosed JSX) is used to verify:severity,title,filePath, anddescriptionmetadata fieldse2e tests: added —
test/development/mcp-server/mcp-server-get-compilation-issues.test.ts