Perfonext Build MCP

v0.6.2
io.github.souvikdu/perfonext-build-mcp Checked 1 day ago Published 2 months ago

MCP server for Next.js build stats, chunk attribution, and bundle optimization advice.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

load_build_stats Load Build Stats

Parse a Next.js .next directory and load route and chunk footprint data for later analysis.

ParameterTypeDescription
buildDir *stringAbsolute or relative path to the project .next build directory, not .next/standalone
buildOutputPathstringOptional path to captured next build terminal output for deriving build duration

get_largest_routes Get Largest Routes

Rank the heaviest user-facing routes in a loaded Next.js build by emitted chunk bytes.

ParameterTypeDescription
buildIdstringBuild ID returned from load_build_stats. Omit to list loaded builds.
limitintegerHow many routes to include. Defaults to 10.

get_shared_chunks Get Shared Chunks

Rank the heaviest shared chunks in a loaded Next.js build and show which routes depend on them.

ParameterTypeDescription
buildIdstringBuild ID returned from load_build_stats. Omit to list loaded builds.
limitintegerHow many shared chunks to include. Defaults to 10.

compare_builds Compare Builds

Compare two loaded Next.js builds and show which routes and chunks grew or shrank the most.

ParameterTypeDescription
baselineBuildIdstringBaseline build ID from load_build_stats. Omit to list loaded builds.
currentBuildIdstringCurrent build ID from load_build_stats. Omit to list loaded builds.
limitintegerHow many route and chunk deltas to include. Defaults to 10.

explain_growth Explain Growth

Identify which routes and chunks are responsible for bundle size growth between two loaded builds. Returns severity-ranked route findings, the top growing chunks, and an overall regression summary.

ParameterTypeDescription
baselineBuildIdstringBaseline build ID from load_build_stats. Omit to list loaded builds.
currentBuildIdstringCurrent build ID from load_build_stats. Omit to list loaded builds.
limitintegerMax route findings and top growing chunks to return. Defaults to 10.

how_to_collect_stats How To Collect Webpack Stats

Explain how to generate the webpack stats file (.next/stats.json) required by the bundle attribution tools. Choose manual (a recipe you apply yourself) or automatic (an action plan Copilot executes).

ParameterTypeDescription
method *stringmanual: return a recipe to apply yourself. automatic: return an action plan for Copilot to execute.
scenariostringCollection context. Defaults to webpack. Use turbopack if the app builds with --turbopack.

load_webpack_stats Load Webpack Stats

Parse the webpack module stats file (.next/stats.json) and link it to a build loaded with load_build_stats. Unlocks the stats-powered tools: suggest_optimizations (enriched), find_duplicates, explain_shared_chunks, and trace_import.

ParameterTypeDescription
buildId *stringBuild ID returned by load_build_stats; the stats.json is read from that build directory

trace_import Trace Import

Explain why a module is bundled by tracing its import chain from an entry point to the module. moduleSizeBytes is the unminified webpack module size, not emitted chunk size. Requires load_webpack_stats first.

ParameterTypeDescription
buildId *stringBuild ID returned by load_build_stats
moduleName *stringModule or package name to search for (case-insensitive substring), e.g. "lodash"
limitintegerMaximum matching modules to trace. Defaults to 10.

find_duplicates Find Duplicate Packages

Find npm packages whose code is bundled into more than one chunk, wasting bytes, ranked by wasted bytes. Requires load_webpack_stats first.

ParameterTypeDescription
buildId *stringBuild ID returned by load_build_stats
limitintegerMaximum duplicate packages to return. Defaults to 20.

explain_shared_chunks Explain Shared Chunks

Show which npm packages and app code dominate the shared chunks loaded by many routes, to identify what bloats common bundles. Each package reports its unminified webpack module size, its share of the chunk's module bytes, and that share applied to the chunk's emitted size. Requires load_build_stats and load_webpack_stats first.

ParameterTypeDescription
buildId *stringBuild ID returned by load_build_stats
limitintegerMaximum shared chunks to analyse. Defaults to 5.

suggest_optimizations Suggest Optimizations

Aggregate route, chunk, and (when loaded) webpack-stats evidence into severity-ranked, evidence-backed bundle optimizations tied to concrete Next.js actions. Every suggestion is sized in emitted on-disk bytes. Works on manifests alone; load_webpack_stats first for dedupe, shared-chunk, and package-import suggestions.

ParameterTypeDescription
buildId *stringBuild ID returned by load_build_stats
limitintegerMaximum suggestions to return. Defaults to 15.