perfonext-build-mcp
Analyzes Next.js build artifacts to rank heaviest routes, identify shared chunks, compare builds for bundle growth, trace import chains, and suggest evidence-backed optimizations.
perfonext-build-mcp
Analyze Next.js build artifacts to find heavy routes, shared chunks, and bundle growth.
perfonext-build-mcp is a Model Context Protocol (MCP) server that gives GitHub Copilot, Claude Desktop,
Claude Code, and other MCP clients structured bundle analysis for Next.js performance work. It loads .next
build artifacts and turns them into route-size rankings, shared-chunk and duplication findings, and
severity-ranked fix suggestions — evidence agents can reason over instead of inspecting raw .next manifests.
Quick Start
perfonext-build-mcp is a standard MCP stdio server, so it works with any MCP-compatible client
(GitHub Copilot in VS Code, Claude Desktop, Claude Code, Cursor, and others). Run it directly with
npx:
npx -y @perfonext/build-mcpOr install globally:
npm install -g @perfonext/build-mcpThe executable command remains perfonext-build-mcp after installation.
VS Code
Add the server to .vscode/mcp.json (the workspace MCP configuration file):
{
"servers": {
"perfonext-build": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@perfonext/build-mcp"]
}
}
}Reload the VS Code window and run MCP: List Servers to start it, or accept the trust prompt when it appears.
Claude Desktop
Add the server to claude_desktop_config.json:
{
"mcpServers": {
"perfonext-build": {
"command": "npx",
"args": ["-y", "@perfonext/build-mcp"]
}
}
}Restart Claude Desktop to pick up the new server.
Claude Code
Add the server with the CLI:
claude mcp add perfonext-build -- npx -y @perfonext/build-mcpOr add it directly to .mcp.json:
{
"mcpServers": {
"perfonext-build": {
"command": "npx",
"args": ["-y", "@perfonext/build-mcp"]
}
}
}Other MCP clients
Any client that supports stdio MCP servers can launch the same command/args pair:
command: npx, args: ["-y", "@perfonext/build-mcp"]. Consult your client's docs for where its MCP
server configuration file lives.
For a locally-built checkout, point command/args at node and the repo's dist/index.js instead,
in any of the configurations above.
Then ask your assistant: "Load the Next.js build in ./.next and show me the largest routes."
Related MCP server: ContextCache MCP
Troubleshooting
spawn npx ENOENT / spawn node ENOENT on macOS with nvm
If the server fails to start with spawn npx ENOENT (or spawn node ENOENT), your editor/app was
likely launched from the Dock/Finder and cannot see nvm. GUI apps on macOS do not load shell config
(.zshrc/.bashrc), so npx/node installed via nvm are not on PATH. This applies to VS Code,
Claude Desktop, and any other GUI MCP client on macOS.
Fix it by giving the MCP config an absolute npx path and a PATH that includes the same Node bin
directory (dirname $(which npx)):
{
"command": "/Users/YOU/.nvm/versions/node/v<version>/bin/npx",
"args": ["-y", "@perfonext/build-mcp"],
"env": {
"PATH": "/Users/YOU/.nvm/versions/node/v<version>/bin:/usr/bin:/bin"
}
}Merge the command/args/env fields above into your client's server entry (e.g. under servers
for VS Code or mcpServers for Claude Desktop/Code).
What It Does
loads Next.js build artifacts from a
.nextdirectoryranks the largest user-facing routes by emitted bundle footprint
identifies the heaviest shared chunks that affect multiple routes
compares two builds and explains which routes and chunks drove bundle growth, with severity-ranked, evidence-backed fix suggestions
matches chunks across builds even though Next.js fingerprints filenames with content hashes
traces why a given module or npm package is bundled (import chain entry → module) when an optional webpack stats file is collected
finds npm packages duplicated across chunks and explains what dominates shared chunks
aggregates all of the above into severity-ranked, evidence-backed optimization suggestions tied to concrete Next.js actions
keeps loaded build snapshots in memory so an MCP client can inspect them without re-reading the same build
Tools
Tool | Description |
| Parse a Next.js |
| Rank the heaviest user-facing routes by total emitted chunk bytes |
| Rank shared chunks by size and show which routes depend on them |
| Compare a baseline and current build snapshot to show which routes and chunks grew or shrank |
| Severity-rank which routes and chunks drove bundle growth between two builds, with evidence-backed fix suggestions |
| Return the recipe (manual) or an action plan (automatic) to generate |
| Parse |
| Explain why a module or npm package is bundled by walking its import chain to the entry |
| Rank npm packages whose code is emitted into more than one chunk, by wasted bytes |
| Show which packages and app code dominate the shared chunks loaded by many routes |
| Aggregate route, chunk, and webpack-stats evidence into severity-ranked, evidence-backed fix suggestions |
The output stays machine-readable and includes raw byte counts so your MCP client can explain regressions, prioritise fixes, and suggest concrete dependency or import-level follow-up.
Every suggest_optimizations finding is sized in emittedBytes — actual on-disk chunk bytes — so suggestions of different kinds rank on one scale. Unminified webpack module sizes appear only where they are named as such (moduleSizeBytes, shareOfChunkModuleBytes).
Because Next.js content-hashes emitted filenames (framework-<hash>.js, and CSS files named purely by hash), compare_builds and explain_growth match chunks across builds by a hash-normalized identity. This prevents a rehashed-but-unchanged chunk from being misreported as removed-and-recreated, while still flagging genuinely new chunks.
Inputs
The core tools read build artifacts developers already have after running next build:
.next/build-manifest.json.next/prerender-manifest.jsonwhen present.next/app-build-manifest.jsonwhen present.next/app-path-routes-manifest.jsonwhen present — maps App Router manifest keys (/gallery/page) to the real paths (/gallery) the prerender manifest is keyed by, so routetype,isPrerendered, andprerenderBlockedReasonare read from the build rather than guessed from the pathoptional captured
next buildoutput text to derive build duration
Import-level attribution (trace_import, find_duplicates, explain_shared_chunks) and the
stats-enriched suggestions from suggest_optimizations additionally need a webpack module-stats file
at .next/stats.json. A stock next build does not emit one; how_to_collect_stats returns the
recipe to generate it. The manifest tools above never read it, so they work with or without it.
Deep bundle attribution (optional)
The manifest tools work with zero setup. To answer "why is this package bundled?", collect a webpack stats file first:
Call
how_to_collect_stats({ method: 'manual' | 'automatic' })and apply the returned steps — it addswebpack-stats-pluginandcross-env, gates anext.confighook behindANALYZE=true && !isServer, and rebuilds withcross-env ANALYZE=true next build --webpack. Turbopack builds will not produce.next/stats.json.Call
load_build_stats({ buildDir })to get abuildId.Call
load_webpack_stats({ buildId })to parse the generated.next/stats.json.Call
trace_import({ buildId, moduleName })to see the import chain that pulls a module in.Call
find_duplicates({ buildId })to find packages bundled into more than one chunk, andexplain_shared_chunks({ buildId })to see what dominates the chunks loaded by many routes.Call
suggest_optimizations({ buildId })for severity-ranked, evidence-backed recommendations. It works on manifests alone and is enriched with dedupe, shared-chunk, and package-import findings once stats are loaded. Code-split advice is tailored for Next.js framework routes (/404,/500,/_error,/_app,/_document) — these are flagged to be slimmed down by trimming imports rather than split withnext/dynamic, which does not apply to them.
If the app builds with Turbopack there is no webpack module graph, so how_to_collect_stats says so
and points back to the manifest-only tools. The attribution tools degrade gracefully with a
breadcrumb when no stats file is loaded — it is never an error.
Example Prompts
"Load the Next.js build in
./.nextand show me the largest routes.""Which shared chunks are affecting the most routes in this build?"
"Summarize the build footprint and tell me which routes ship the most JavaScript."
"Compare my baseline and current
.nextbuilds and show me which routes or shared chunks grew the most.""Explain what grew between my baseline and current
.nextbuilds and what I should fix first.""Set up webpack stats collection so I can see why a package is bundled."
"Why is
axiosin my bundle? Trace its import chain.""Which npm packages are duplicated across chunks and how many bytes are wasted?"
"What's dominating my shared chunks?"
"Suggest the highest-impact bundle optimizations for this build."
Related Perfonext Tools
perfonext-profiler-mcp — CPU profiling (V8/Chrome) for Next.js servers
perfonext-render-mcp — React render analysis for Next.js apps
Development
npm install
npm run build
npm testSample fixtures for local validation live under tests/fixtures/.
License
MIT
Available Tools
11 toolscompare_buildsCompare BuildsA
Compare two loaded Next.js builds and show which routes and chunks grew or shrank the most.
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | How many route and chunk deltas to include. Defaults to 10. | |
| currentBuildId | No | Current build ID from load_build_stats. Omit to list loaded builds. | |
| baselineBuildId | No | Baseline build ID from load_build_stats. Omit to list loaded builds. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden for behavioral disclosure, but it only describes the happy-path comparison. It fails to mention that omitting both build IDs lists loaded builds instead of comparing, and it says nothing about error behavior or reliance on load_build_stats. This is a notable transparency gap for a tool with a dual mode.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single, front-loaded sentence states the action, subject, and result with no filler. It is appropriately concise for the tool's complexity.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
There is no output schema, and the description only vaguely indicates the output ('which routes and chunks grew or shrank the most'). It omits the fallback behavior of listing loaded builds when IDs are omitted, which is important for correct invocation. Still, the primary use case is clear enough for an agent to attempt a correct call.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the baseline is 3. The description adds broad context about comparing routes and chunks but does not clarify parameter meaning beyond the schema, such as how limit applies or which build IDs to use.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses a specific verb ('Compare') with a clear resource ('two loaded Next.js builds') and a concrete outcome ('show which routes and chunks grew or shrank the most'). This clearly differentiates it from siblings like get_largest_routes, which analyze a single build, and load_build_stats, which loads builds.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description clearly implies when to use this tool: when the user wants to compare two builds that have already been loaded. However, it does not explicitly mention alternatives or exclusion conditions, such as using get_largest_routes for a single build or explain_growth for understanding why growth occurred.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
explain_growthExplain GrowthA
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.
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Max route findings and top growing chunks to return. Defaults to 10. | |
| currentBuildId | No | Current build ID from load_build_stats. Omit to list loaded builds. | |
| baselineBuildId | No | Baseline build ID from load_build_stats. Omit to list loaded builds. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full transparency burden. It discloses that the tool operates on already loaded builds, performs an analytical rather than mutating task, and returns a structured set of findings and summary. It does not explicitly discuss side effects or prerequisites beyond loaded builds, but the verbs and return list make the behavior clear.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two purpose-dense sentences contain every necessary element: the scope, the analytic target, and the returned output. There is no filler, no repetition of schema details, and the core intent is front-loaded.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a tool with no output schema, the description adequately names the main return categories and the precondition of two loaded builds. It does not explain ranking methodology or explicitly route around overlapping siblings, but parameter mechanics are fully covered by the schema, making the overall description sufficient.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
All three parameters have complete schema descriptions, including the omit-to-list behavior for build IDs. The tool description adds context about the overall analysis but no parameter-level meaning beyond the schema, so the baseline score of 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific analytical verb ('Identify') and resource ('routes and chunks') plus the exact condition ('bundle size growth between two loaded builds'). The mention of severity-ranked route findings, top growing chunks, and a regression summary distinguishes it from general comparison siblings like compare_builds.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description clearly implies a two-build comparison scenario, but it never explicitly states when to choose explain_growth over siblings such as compare_builds or explain_shared_chunks. There are no exclusions or alternative routing cues beyond what the name and scope suggest.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
find_duplicatesFind Duplicate PackagesA
Find npm packages whose code is bundled into more than one chunk, wasting bytes, ranked by wasted bytes. Requires load_webpack_stats first.
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum duplicate packages to return. Defaults to 20. | |
| buildId | Yes | Build ID returned by load_build_stats |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description must carry the behavioral burden. It usefully discloses that results are ranked by wasted bytes and that a prior webpack stats load is required. However, it does not mention the output shape, whether the operation is read-only, or failure/edge-case behavior.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two short sentences, front-loaded with the main purpose and ranking behavior, followed by the key prerequisite. Every word earns its place and there is no redundant filler.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a relatively simple analysis tool with two well-documented parameters, the description covers the core purpose, ranking behavior, and prerequisite. It is not fully complete because it ignores the overlapping sibling tools and provides no output format guidance, but it is sufficient for basic invocation.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so buildId and limit are already documented in the input schema. The description does not add parameter-level meaning beyond the schema, which is acceptable under the high-coverage baseline.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly identifies the resource (npm packages bundled into multiple chunks) and the action (find), with a specific ranking criterion (wasted bytes). It is not tautological and conveys a useful mental model, but it does not explicitly differentiate from overlapping siblings like get_shared_chunks or explain_shared_chunks.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides a clear prerequisite: 'Requires load_webpack_stats first.' However, it does not explain when to choose this tool over get_shared_chunks or other related siblings, nor does it mention when not to use it. This gives partial context but leaves selection logic to the agent.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_largest_routesGet Largest RoutesA
Rank the heaviest user-facing routes in a loaded Next.js build by emitted chunk bytes.
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | How many routes to include. Defaults to 10. | |
| buildId | No | Build ID returned from load_build_stats. Omit to list loaded builds. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries full behavioral burden. It communicates that this is a ranking/read operation on loaded build data and that it focuses on emitted chunk bytes, but it does not explicitly state read-only behavior, output shape, sorting direction, or error conditions. This is adequate but not rich.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
One sentence with no filler; the key scoping qualifiers ('loaded Next.js build', 'user-facing routes', 'emitted chunk bytes') are all included. It is efficiently front-loaded.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple read-ranked listing, the description plus a 100%-covered schema is nearly enough. Yet with no output schema and no annotations, the agent lacks explicit guidance on the result format or when to choose this tool over siblings like get_shared_chunks, leaving a small but real gap.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
All parameters are fully described in the schema (100% coverage), so the description need not add much. It adds no new parameter-level meaning beyond the schema; the schema already explains limit defaults and buildId provenance.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Clearly states the action (rank), the object (heaviest user-facing routes in a Next.js build), and the criterion (emitted chunk bytes). It does not explicitly distinguish itself from siblings like compare_builds, but the specific resource and measurement make the function unambiguous.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies the tool operates on an already-loaded build, and the schema's buildId note ('Build ID returned from load_build_stats. Omit to list loaded builds') hints at the workflow. However, the description itself gives no explicit when-to-use guidance or exclusions relative to the sibling tools.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
how_to_collect_statsHow To Collect Webpack StatsA
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).
| Name | Required | Description | Default |
|---|---|---|---|
| method | Yes | manual: return a recipe to apply yourself. automatic: return an action plan for Copilot to execute. | |
| scenario | No | Collection context. Defaults to webpack. Use turbopack if the app builds with --turbopack. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the burden of explaining behavior. It makes clear that the tool returns either a self-applied recipe or an action plan for Copilot to execute, which is the core behavioral distinction. It does not explicitly state that the tool itself does not modify anything, but its instructional nature is reasonably evident.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences, front-loaded with the primary purpose, and every clause earns its place. The choice between manual and automatic is stated immediately and economically.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple instructional tool with no output schema, the description is complete: it states what the tool produces, the two modes, and why it matters (required by bundle attribution tools). No critical information for calling it correctly is missing.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the baseline is 3. The description adds useful meaning for the 'method' parameter by defining manual and automatic modes, but it does not add anything about 'scenario' beyond the schema. The description does not need to compensate heavily because the schema already documents both parameters.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses a specific verb ('Explain how to generate') and a concrete resource ('.next/stats.json'), and it explicitly relates the tool to the bundle attribution tool family. It is clearly distinguished from siblings that analyze or load stats rather than explain how to collect them.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description gives clear context: this tool is the prerequisite for the bundle attribution tools, and it explains the manual versus automatic modes. It does not explicitly state when not to use it or name an alternative tool, but the context is strong enough for most agent routing decisions.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
load_build_statsLoad Build StatsA
Parse a Next.js .next directory and load route and chunk footprint data for later analysis.
| Name | Required | Description | Default |
|---|---|---|---|
| buildDir | Yes | Absolute or relative path to the project .next build directory, not .next/standalone | |
| buildOutputPath | No | Optional path to captured next build terminal output for deriving build duration |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the disclosure burden. 'Parse' and 'load' weakly imply a read-and-ingest operation with no file modifications, which is useful but not explicitly stated. The description does not mention side effects, session state, failure conditions, or whether any prior data is overwritten.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single well-structured sentence. It front-loads the action ('Parse a Next.js .next directory'), then states what is loaded and for what purpose, with no filler or redundant content.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The description explains the high-level purpose and what data is made available, but with no output schema and no annotations it leaves some gaps: the exact shape of the loaded data, whether it is stored in memory, and whether a prior build is required are not mentioned. It is adequate for a simple loader but not comprehensive.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the input schema already fully documents both parameters. The tool description itself adds no additional meaning about buildDir or buildOutputPath beyond what is already present in the schema, matching the baseline of 3.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses a specific verb ('Parse ... and load') and names a concrete resource (the Next.js .next directory) and data type (route and chunk footprint data). It distinguishes itself from analysis siblings by mentioning 'for later analysis,' but it does not explicitly differentiate itself from load_webpack_stats.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
'For later analysis' implies this tool is a first step before calling analysis tools like get_largest_routes or compare_builds. However, there is no explicit statement of when to use this tool versus alternatives, no exclusions, and no mention of prerequisites such as needing a completed Next.js build.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
load_webpack_statsLoad Webpack StatsA
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.
| Name | Required | Description | Default |
|---|---|---|---|
| buildId | Yes | Build ID returned by load_build_stats; the stats.json is read from that build directory |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the burden of behavioral disclosure. It reveals that the tool is stateful by linking to a build loaded with load_build_stats and that it unlocks other tools. However, it does not mention failure modes, idempotence, or what happens if the build is not available, leaving some behavioral gaps.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences deliver the core action, the prerequisite, and the downstream impact with no filler. The information is front-loaded and every clause earns its place.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a one-parameter loader with no output schema, the description covers what the tool does, how it connects to the build lifecycle, and which tools become available afterward. It does not describe the return value, but that omission is minor given the tool's enabling role and clear input contract.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100% and the single buildId parameter has a clear description: it is returned by load_build_stats and determines the stats.json directory. The tool description adds workflow context but no additional parameter-level meaning, so the baseline of 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description names a specific verb and resource: parsing the webpack module stats file and linking it to an already-loaded build. It also distinguishes the tool from siblings by listing exactly which stats-powered tools it unlocks, making its role in the workflow clear.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description clearly states the prerequisite of calling load_build_stats first and identifies when this tool is needed by naming the downstream tools it enables. It does not explicitly state when not to use it or name alternatives, but the context is strong enough for an agent to route correctly.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
suggest_optimizationsSuggest OptimizationsA
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.
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum suggestions to return. Defaults to 15. | |
| buildId | Yes | Build ID returned by load_build_stats |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the behavioral burden and does well: it discloses that every suggestion is sized in emitted on-disk bytes, that ranking is by severity, and that suggestions are evidence-backed. It also reveals the dependency on webpack stats for certain suggestion categories, which is non-obvious but important behavior.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is two sentences with high information density and no filler. The core behavior and output value are front-loaded, and the important prerequisite about load_webpack_stats appears at the end without burying the main point.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given no output schema and no annotations, the description explains what the tool returns (suggestions), how they are ranked, how they are sized, and what data is required. It does not detail the exact suggestion schema, but for an agent selecting and invoking the tool, the workflow caveat and output gist are sufficient.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100%, so the baseline is 3; buildId and limit are already documented in the schema. The description adds no parameter-specific semantics beyond the general workflow context, so it neither improves nor harms understanding of the inputs.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses a specific verb, 'Aggregate,' and names the resource domain: route, chunk, and webpack-stats evidence, producing 'bundle optimizations' with concrete Next.js actions. It clearly distinguishes itself from siblings by framing output as severity-ranked, evidence-backed suggestions rather than raw stats or duplicate lists.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description gives explicit sequencing guidance: 'load_webpack_stats first for dedupe, shared-chunk, and package-import suggestions,' and clarifies that it 'works on manifests alone' as a lower-fidelity baseline. It does not enumerate when to choose sibling tools instead, but the prerequisite instruction is strong context.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
trace_importTrace ImportA
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.
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum matching modules to trace. Defaults to 10. | |
| buildId | Yes | Build ID returned by load_build_stats | |
| moduleName | Yes | Module or package name to search for (case-insensitive substring), e.g. "lodash" |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the burden. It adds a valuable interpretive detail ('moduleSizeBytes is the unminified webpack module size, not emitted chunk size') and a prerequisite. It does not explicitly state read-only behavior or return shape, but 'trace' and 'explain' imply a non-mutating operation.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences with no filler. Purpose, output semantics, and prerequisites are all front-loaded and each sentence earns its place.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The description covers purpose, a prerequisite, and one output caveat, but it does not describe the trace result structure despite having no output schema. There is also a slight workflow ambiguity: the schema ties buildId to load_build_stats while the description only mentions loading webpack stats first.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100%, so the baseline applies. The schema already documents buildId, moduleName, and limit; the description does not add parameter-level detail beyond the schema. The moduleSizeBytes note is about output interpretation, not input parameters.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific action ('Explain why a module is bundled') and a specific method ('tracing its import chain from an entry point to the module'). This clearly distinguishes the tool from sibling tools focused on chunks, duplicates, or growth.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The use case is clearly framed: use it to explain why a particular module is bundled. It also gives a prerequisite ('Requires load_webpack_stats first'), which helps an agent sequence its calls. It does not explicitly name alternative tools or exclusions, but the context is strong.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
11 tool updates
v0.6.2- First observed
compare_builds - First observed
explain_growth - First observed
explain_shared_chunks - First observed
find_duplicates - First observed
get_largest_routes - First observed
get_shared_chunks - First observed
how_to_collect_stats - First observed
load_build_stats - First observed
load_webpack_stats - First observed
suggest_optimizations - First observed
trace_import
TDQS
Most tools have clearly distinct purposes, but compare_builds and explain_growth overlap in analyzing build differences, and get_shared_chunks vs explain_shared_chunks could be confused at first glance. The descriptions and dependency notes help disambiguate, so it is mostly clear.
Tool names largely follow a verb_noun snake_case pattern, with load_, get_, compare_, explain_, and suggest_ prefixes. The one outlier is how_to_collect_stats, which uses a non-standard how_to_ prefix but remains readable and understandable.
With 11 tools, the server is well-scoped for its purpose of Next.js bundle analysis. Each tool contributes to a distinct part of the workflow: data collection, loading stats, analysis, comparison, and optimization recommendations.
The tool set covers the full analysis lifecycle: collecting stats, loading build and webpack data, identifying large routes and shared chunks, finding duplicates, tracing imports, comparing builds, explaining growth, and suggesting optimizations. No significant gaps are apparent for the stated domain.
Maintenance
Related MCP Connectors
Bundlephobia MCP — npm bundle-size analysis
MCP server for progressive tool usage at any scale (see https://klavis.ai)
The official MCP Server for the Mux API
Related MCP Servers
- FlicenseAqualityDmaintenanceA comprehensive MCP server for frontend analysis. It provides Google Lighthouse audits, code quality checks, SEO metadata verification, accessibility analysis, and bundle optimization for React and Next.js projects.83-
- AlicenseNot gradedqualityBmaintenanceA local MCP server that indexes TypeScript/JavaScript projects and returns budget-aware, dependency-optimized context packs for AI coding assistants.1MIT
- AlicenseNot gradedqualityDmaintenanceUnified MCP server for searching, analyzing, and managing packages across npm, JSR, Deno, and multiple CDN providers with auto-detection.MIT
- AlicenseNot gradedqualityCmaintenanceCreates and manages an MCP server integrated with build tools (Rollup, Vite, Webpack, etc.) to enable AI assistants to analyze, inspect, and control the build process.3,60731MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/souvikdu/perfonext-build-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server