next 15.4.2-canary.22 → 15.4.2-canary.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/bin/next +1 -1
  2. package/dist/build/index.js +2 -2
  3. package/dist/build/swc/generated-native.d.ts +0 -33
  4. package/dist/build/swc/index.js +1 -11
  5. package/dist/build/swc/index.js.map +1 -1
  6. package/dist/build/swc/types.d.ts +1 -7
  7. package/dist/build/webpack-config.js +2 -2
  8. package/dist/client/app-bootstrap.js +1 -1
  9. package/dist/client/index.js +1 -1
  10. package/dist/compiled/@vercel/og/emoji/index.d.ts +15 -0
  11. package/dist/compiled/@vercel/og/figma/index.d.ts +7 -0
  12. package/dist/compiled/@vercel/og/index.edge.d.ts +5 -9
  13. package/dist/compiled/@vercel/og/index.edge.js +2587 -3024
  14. package/dist/compiled/@vercel/og/index.node.d.ts +7 -10
  15. package/dist/compiled/@vercel/og/index.node.js +2585 -3022
  16. package/dist/compiled/@vercel/og/language/index.d.ts +28 -0
  17. package/dist/compiled/@vercel/og/og.d.ts +1 -0
  18. package/dist/compiled/@vercel/og/package.json +1 -1
  19. package/dist/compiled/@vercel/og/satori/index.d.ts +4 -1
  20. package/dist/compiled/@vercel/og/types.d.ts +118 -0
  21. package/dist/compiled/@vercel/og/yoga.wasm +0 -0
  22. package/dist/esm/build/index.js +2 -2
  23. package/dist/esm/build/swc/generated-native.d.ts +0 -33
  24. package/dist/esm/build/swc/index.js +1 -11
  25. package/dist/esm/build/swc/index.js.map +1 -1
  26. package/dist/esm/build/swc/types.js.map +1 -1
  27. package/dist/esm/build/webpack-config.js +2 -2
  28. package/dist/esm/client/app-bootstrap.js +1 -1
  29. package/dist/esm/client/index.js +1 -1
  30. package/dist/esm/server/dev/hot-reloader-turbopack.js +1 -1
  31. package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
  32. package/dist/esm/server/lib/app-info-log.js +1 -1
  33. package/dist/esm/server/lib/router-utils/setup-dev-bundler.js +3 -84
  34. package/dist/esm/server/lib/router-utils/setup-dev-bundler.js.map +1 -1
  35. package/dist/esm/server/lib/start-server.js +1 -1
  36. package/dist/esm/shared/lib/canary-only.js +1 -1
  37. package/dist/esm/shared/lib/turbopack/utils.js +28 -32
  38. package/dist/esm/shared/lib/turbopack/utils.js.map +1 -1
  39. package/dist/server/dev/hot-reloader-turbopack.js +1 -1
  40. package/dist/server/dev/hot-reloader-webpack.js +1 -1
  41. package/dist/server/lib/app-info-log.js +1 -1
  42. package/dist/server/lib/router-utils/setup-dev-bundler.js +3 -84
  43. package/dist/server/lib/router-utils/setup-dev-bundler.js.map +1 -1
  44. package/dist/server/lib/start-server.js +1 -1
  45. package/dist/shared/lib/canary-only.js +1 -1
  46. package/dist/shared/lib/turbopack/utils.d.ts +1 -2
  47. package/dist/shared/lib/turbopack/utils.js +28 -36
  48. package/dist/shared/lib/turbopack/utils.js.map +1 -1
  49. package/dist/telemetry/anonymous-meta.js +1 -1
  50. package/dist/telemetry/events/session-stopped.js +2 -2
  51. package/dist/telemetry/events/version.js +2 -2
  52. package/package.json +15 -20
  53. package/server.d.ts +1 -1
  54. package/dist/compiled/@vercel/og/types-d38469ff.d.ts +0 -74
  55. package/dist/esm/server/lib/router-utils/mcp.js +0 -471
  56. package/dist/esm/server/lib/router-utils/mcp.js.map +0 -1
  57. package/dist/server/lib/router-utils/mcp.d.ts +0 -4
  58. package/dist/server/lib/router-utils/mcp.js +0 -534
  59. package/dist/server/lib/router-utils/mcp.js.map +0 -1
@@ -1,471 +0,0 @@
1
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import { z } from 'next/dist/compiled/zod';
3
- import { runInNewContext } from 'node:vm';
4
- import * as Log from '../../../build/output/log';
5
- import { formatImportTraces } from '../../../shared/lib/turbopack/utils';
6
- import { inspect } from 'node:util';
7
- export { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
8
- const QUERY_DESCRIPTION = `A piece of JavaScript code that will be executed.
9
- It can access the module graph and extract information it finds useful.
10
- The \`console.log\` function can be used to log messages, which will also be returned in the response.
11
- No Node.js or browser APIs are available, but JavaScript language features are available.
12
- When the user is interested in used exports of modules, you can use the \`export\` property of ModuleReferences (\`incomingReferences\`).
13
- When the user is interested in the import path of a module, follow one of the \`incomingReferences\` with a smaller \`depth\` value than the current module until you hit the root.
14
- Do not try to make any assumptions or estimations. See the typings to see which data you have available. If you don't have the data, tell the user that this data is not available and list alternatives that are available.
15
- See the following TypeScript typings for reference:
16
-
17
- \`\`\` typescript
18
- interface Module {
19
- /// The identifier of the module, which is a unique string.
20
- /// Example: "[project]/packages/next-app/src/app/folder/page.tsx [app-rsc] (ecmascript, Next.js Server Component)"
21
- /// These layers exist in App Router:
22
- /// * Server Components: [app-rsc], [app-edge-rsc]
23
- /// * API routes: [app-route], [app-edge-route]
24
- /// * Client Components: [app-client]
25
- /// * Server Side Rendering of Client Components: [app-ssr], [app-edge-ssr]
26
- /// These layers exist in Pages Router:
27
- /// * Client-side rendering: [client]
28
- /// * Server-side rendering: [ssr], [edge-ssr]
29
- /// * API routes: [api], [edge-api]
30
- /// And these layers also exist:
31
- /// * Middleware: [middleware], [middleware-edge]
32
- /// * Instrumentation: [instrumentation], [instrumentation-edge]
33
- ident: string,
34
- /// The path of the module. It's not unique as multiple modules can have the same path.
35
- /// Separate between application code and node_modules (npm packages, vendor code).
36
- /// Example: "[project]/pages/folder/index.js",
37
- /// Example: "[project]/node_modules/.pnpm/next@file+..+next.js+packages+next_@babel+core@7.27.4_@opentelemetry+api@1.7.0_@playwright+te_5kenhtwdm6lrgjpao5hc34lkgy/node_modules/next/dist/compiled/fresh/index.js",
38
- /// Example: "[project]/apps/site/node_modules/@opentelemtry/api/build/src/trace/instrumentation.js",
39
- path: string,
40
- /// The distance to the entries of the module graph. Use this to traverse the graph in the right direction.
41
- /// This is useful when trying to find the path from a module to the root of the module graph.
42
- /// Example: 0 for the entrypoint, 1 for the first layer of modules, etc.
43
- depth: number,
44
- /// The size of the source code of the module in bytes.
45
- /// Note that it's not the final size of the generated code, but can be a good indicator of that.
46
- /// It's only the size of this single module, not the size of the whole subgraph behind it (see retainedSize instead).
47
- size: number,
48
- /// The size of the whole subgraph behind this module in bytes.
49
- /// Use this value if the user is interested in sizes of modules (except when they are interested in the size of the module itself).
50
- /// Never try to compute the retained size yourself, but use this value instead.
51
- retainedSize: number,
52
- /// The modules that are referenced by this module.
53
- /// Modules could be referenced by \`import\`, \`require\`, \`new URL\`, etc.
54
- /// Beware cycles in the module graph. You can avoid that by only walking edges with a bigger \`depth\` value than the current module.
55
- references: ModuleReference[],
56
- /// The modules that reference this module.
57
- /// Beware cycles in the module graph.
58
- /// You can use this to walk up the graph up to the root. When doing this only walk edges with a smaller \`depth\` value than the current module.
59
- incomingReferences: ModuleReference[],
60
- }
61
-
62
- interface ModuleReference {
63
- /// The referenced/referencing module.
64
- module: Module
65
- /// The thing that is used from the module.
66
- /// export {name}: The named export that is used.
67
- /// evaluation: Imported for side effects only.
68
- /// all: All exports and the side effects.
69
- export: "evaluation" | "all" | \`export \${string}\`
70
- /// How this reference affects chunking of the module.
71
- /// hoisted | sync: The module is placed in the same chunk group as the referencing module.
72
- /// hoisted: The module is loaded before all "sync" modules.
73
- /// async: The module forms a separate chunk group which is loaded asynchronously.
74
- /// isolated: The module forms a separate chunk group which is loaded as separate entry. When it has a name, all modules imported with this name are placed in the same chunk group.
75
- /// shared: The module forms a separate chunk group which is loaded before the current chunk group. When it has a name, all modules imported with this name are placed in the same chunk group.
76
- /// traced: The module is not bundled, but the graph is still traced and all modules are included unbundled.
77
- chunkingType: "hoisted" | "sync" | "async" | "isolated" | \`isolated \${string}\` | "shared" | \`shared \${string}\` | "traced"
78
- }
79
-
80
- // The following global variables are available in the query:
81
-
82
- /// The entries of the module graph.
83
- /// Note that this only includes the entrypoints of the module graph and not all modules.
84
- /// You need to traverse it recursively to find not only children, but also grandchildren (resp, grandparents).
85
- /// Prefer to use \`modules\` over \`entries\` as it contains all modules, not only the entrypoints.
86
- const entries: Module[]
87
-
88
- /// All modules in the module graph.
89
- /// Note that this array already contains all the modules as flat list.
90
- /// Make sure to iterate over this array and not only consider the first one.
91
- /// Prefer to use \`modules\` over \`entries\` as it contains all modules, not only the entrypoints.
92
- const modules: Module[]
93
-
94
- const console: {
95
- /// Logs a message to the console.
96
- /// The message will be returned in the response.
97
- /// The message can be a string or any other value that can be inspected.
98
- log: (...data: any[]) => void
99
- }
100
- \`\`\`
101
- `;
102
- async function measureAndHandleErrors(name, fn) {
103
- const start = performance.now();
104
- let content = [];
105
- try {
106
- content = await fn();
107
- } catch (error) {
108
- content.push({
109
- type: 'text',
110
- text: `Error: ${error instanceof Error ? error.stack : String(error)}`
111
- });
112
- content.push({
113
- type: 'text',
114
- text: 'Fix the error and try again.'
115
- });
116
- }
117
- const duration = performance.now() - start;
118
- const formatDurationText = duration > 2000 ? `${Math.round(duration / 100) / 10}s` : `${Math.round(duration)}ms`;
119
- Log.event(`MCP ${name} in ${formatDurationText}`);
120
- return {
121
- content
122
- };
123
- }
124
- function invariant(value, errorMessage) {
125
- throw Object.defineProperty(new Error(errorMessage(value)), "__NEXT_ERROR_CODE", {
126
- value: "E394",
127
- enumerable: false,
128
- configurable: true
129
- });
130
- }
131
- function styledStringToMarkdown(styledString) {
132
- if (!styledString) {
133
- return '';
134
- }
135
- switch(styledString.type){
136
- case 'text':
137
- return styledString.value;
138
- case 'strong':
139
- return `*${styledString.value}*`;
140
- case 'code':
141
- return `\`${styledString.value}\``;
142
- case 'line':
143
- return styledString.value.map(styledStringToMarkdown).join('');
144
- case 'stack':
145
- return styledString.value.map(styledStringToMarkdown).join('\n\n');
146
- default:
147
- invariant(styledString, (s)=>`Unknown styled string type: ${s.type}`);
148
- }
149
- }
150
- function indent(str, spaces = 2) {
151
- const indentStr = ' '.repeat(spaces);
152
- return `${indentStr}${str.replace(/\n/g, `\n${indentStr}`)}`;
153
- }
154
- function issueToString(issue) {
155
- var _issue_source_range, _issue_source_range1, _issue_source_range2, _issue_source_range3;
156
- return [
157
- `${issue.severity} in ${issue.stage} on ${issue.route}`,
158
- `File Path: ${issue.filePath}`,
159
- issue.source && `Source:
160
- ${issue.source.source.ident}
161
- ${issue.source.range ? `Range: ${(_issue_source_range = issue.source.range) == null ? void 0 : _issue_source_range.start.line}:${(_issue_source_range1 = issue.source.range) == null ? void 0 : _issue_source_range1.start.column} - ${(_issue_source_range2 = issue.source.range) == null ? void 0 : _issue_source_range2.end.line}:${(_issue_source_range3 = issue.source.range) == null ? void 0 : _issue_source_range3.end.column}` : 'Unknown range'}
162
- `,
163
- `Title: ${styledStringToMarkdown(issue.title)}`,
164
- issue.description && `Description:
165
- ${indent(styledStringToMarkdown(issue.description))}`,
166
- issue.detail && `Details:
167
- ${indent(styledStringToMarkdown(issue.detail))}`,
168
- issue.documentationLink && `Documentation: ${issue.documentationLink}`,
169
- issue.importTraces && issue.importTraces.length > 0 && formatImportTraces(issue.importTraces)
170
- ].filter(Boolean).join('\n');
171
- }
172
- function issuesReference(issues) {
173
- if (issues.length === 0) {
174
- return {
175
- type: 'text',
176
- text: 'Note: There are no issues.'
177
- };
178
- }
179
- const countBySeverity = new Map();
180
- for (const issue of issues){
181
- const count = countBySeverity.get(issue.severity) || 0;
182
- countBySeverity.set(issue.severity, count + 1);
183
- }
184
- const text = [
185
- `Note: There are ${issues.length} issues in total, with the following severities: ${Array.from(countBySeverity.entries()).map(([severity, count])=>`${count} x ${severity}`).join(', ')}.`
186
- ];
187
- return {
188
- type: 'text',
189
- text: text.join('\n')
190
- };
191
- }
192
- function routeToTitle(route) {
193
- switch(route.type){
194
- case 'page':
195
- return 'A page using Pages Router.';
196
- case 'app-page':
197
- return `A page using App Router. Original names: ${route.pages.map((page)=>page.originalName).join(', ')}.`;
198
- case 'page-api':
199
- return 'An API route using Pages Router.';
200
- case 'app-route':
201
- return `A route using App Router. Original name: ${route.originalName}.`;
202
- case 'conflict':
203
- return 'Multiple routes conflict on this path. This is an error in the folder structure.';
204
- default:
205
- invariant(route, (r)=>`Unknown route type: ${r.type}`);
206
- }
207
- }
208
- function routeToEndpoints(route) {
209
- switch(route.type){
210
- case 'page':
211
- return [
212
- route.htmlEndpoint
213
- ];
214
- case 'app-page':
215
- return route.pages.map((p)=>p.htmlEndpoint);
216
- case 'page-api':
217
- return [
218
- route.endpoint
219
- ];
220
- case 'app-route':
221
- return [
222
- route.endpoint
223
- ];
224
- case 'conflict':
225
- return [];
226
- default:
227
- invariant(route, (r)=>`Unknown route type: ${r.type}`);
228
- }
229
- }
230
- function arrayOrSingle(value) {
231
- return Array.isArray(value) ? value : [
232
- value
233
- ];
234
- }
235
- function createModuleObject(rawModule) {
236
- return {
237
- ident: rawModule.ident,
238
- path: rawModule.path,
239
- depth: rawModule.depth,
240
- size: rawModule.size,
241
- retainedSize: rawModule.retainedSize,
242
- references: [],
243
- incomingReferences: []
244
- };
245
- }
246
- function processModuleGraphSnapshot(moduleGraph, modules, entries) {
247
- const queryModules = moduleGraph.modules.map(createModuleObject);
248
- for(let i = 0; i < queryModules.length; i++){
249
- const rawModule = moduleGraph.modules[i];
250
- const queryModule = queryModules[i];
251
- queryModule.references = rawModule.references.map((ref)=>({
252
- module: queryModules[ref.index],
253
- export: ref.export,
254
- chunkingType: ref.chunkingType
255
- }));
256
- queryModule.incomingReferences = rawModule.incomingReferences.map((ref)=>({
257
- module: queryModules[ref.index],
258
- export: ref.export,
259
- chunkingType: ref.chunkingType
260
- }));
261
- modules.push(queryModule);
262
- }
263
- for (const entry of moduleGraph.entries){
264
- const queryModule = queryModules[entry];
265
- entries.push(queryModule);
266
- }
267
- }
268
- function runQuery(query, modules, entries) {
269
- const response = [];
270
- const proto = {
271
- modules,
272
- entries,
273
- console: {
274
- log: (...data)=>{
275
- response.push({
276
- type: 'text',
277
- text: data.map((item)=>typeof item === 'string' ? item : inspect(item, false, 2, false)).join(' ')
278
- });
279
- }
280
- }
281
- };
282
- const contextObject = Object.create(proto);
283
- contextObject.global = contextObject;
284
- contextObject.self = contextObject;
285
- contextObject.globalThis = contextObject;
286
- runInNewContext(query, contextObject, {
287
- displayErrors: true,
288
- filename: 'query.js',
289
- timeout: 20000,
290
- contextName: 'Query Context'
291
- });
292
- for (const [key, value] of Object.entries(contextObject)){
293
- if (typeof value === 'function') continue;
294
- if (key === 'global' || key === 'self' || key === 'globalThis') continue;
295
- response.push({
296
- type: 'text',
297
- text: `Global variable \`${key}\` = ${inspect(value, false, 2, false)}`
298
- });
299
- }
300
- return response;
301
- }
302
- const ROUTES_DESCRIPTION = 'The routes from which to query the module graph. Can be a single string or an array of strings.';
303
- export function createMcpServer(hotReloader) {
304
- const turbopack = hotReloader.turbopackProject;
305
- if (!turbopack) return undefined;
306
- const server = new McpServer({
307
- name: 'next.js',
308
- version: '1.0.0',
309
- instructions: `This is a running next.js dev server with Turbopack.
310
- You can use the Model Context Protocol to query information about pages and modules and their relations.`
311
- });
312
- server.registerTool('entrypoints', {
313
- title: 'Entrypoints',
314
- description: 'Get all entrypoints of a Turbopack project, which are all pages, routes and the middleware.'
315
- }, async ()=>measureAndHandleErrors('entrypoints', async ()=>{
316
- let entrypoints = await turbopack.getEntrypoints();
317
- const list = [];
318
- for (const [key, route] of entrypoints.routes.entries()){
319
- list.push(`\`${key}\` (${routeToTitle(route)})`);
320
- }
321
- if (entrypoints.middleware) {
322
- list.push('Middleware');
323
- }
324
- if (entrypoints.instrumentation) {
325
- list.push('Instrumentation');
326
- }
327
- const content = [
328
- issuesReference(entrypoints.issues),
329
- {
330
- type: 'text',
331
- text: `These are the routes of the application:
332
-
333
- ${list.map((e)=>`- ${e}`).join('\n')}`
334
- }
335
- ];
336
- return content;
337
- }));
338
- server.registerTool('query-routes-module-graph', {
339
- title: 'Query module graph of routes',
340
- description: 'Query details about the module graph of routes.',
341
- inputSchema: {
342
- routes: z.union([
343
- z.string(),
344
- z.array(z.string())
345
- ]).describe(ROUTES_DESCRIPTION),
346
- query: z.string().describe(QUERY_DESCRIPTION)
347
- }
348
- }, async ({ routes, query })=>measureAndHandleErrors(`module graph query on ${arrayOrSingle(routes).join(', ')}`, async ()=>{
349
- const entrypoints = await turbopack.getEntrypoints();
350
- const endpoints = [];
351
- for (const route of arrayOrSingle(routes)){
352
- const routeInfo = entrypoints.routes.get(route);
353
- if (!routeInfo) {
354
- throw Object.defineProperty(new Error(`Route ${route} not found`), "__NEXT_ERROR_CODE", {
355
- value: "E756",
356
- enumerable: false,
357
- configurable: true
358
- });
359
- }
360
- endpoints.push(...routeToEndpoints(routeInfo));
361
- }
362
- const issues = [];
363
- const modules = [];
364
- const entries = [];
365
- for (const endpoint of endpoints){
366
- const result = await endpoint.moduleGraphs();
367
- issues.push(...result.issues);
368
- const moduleGraphs = result.moduleGraphs;
369
- for (const moduleGraph of moduleGraphs){
370
- processModuleGraphSnapshot(moduleGraph, modules, entries);
371
- }
372
- }
373
- const content = [];
374
- content.push(issuesReference(issues));
375
- const response = runQuery(query, modules, entries);
376
- content.push(...response);
377
- return content;
378
- }));
379
- server.registerTool('query-module-graph', {
380
- title: 'Query whole app module graph',
381
- description: 'Query details about the module graph the whole application. This is a expensive operation and should only be used when module graph of the whole application is needed.',
382
- inputSchema: {
383
- query: z.string().describe(QUERY_DESCRIPTION)
384
- }
385
- }, async ({ query })=>measureAndHandleErrors(`whole app module graph query`, async ()=>{
386
- const moduleGraph = await turbopack.moduleGraph();
387
- const issues = moduleGraph.issues;
388
- const modules = [];
389
- const entries = [];
390
- processModuleGraphSnapshot(moduleGraph, modules, entries);
391
- const content = [];
392
- content.push(issuesReference(issues));
393
- const response = runQuery(query, modules, entries);
394
- content.push(...response);
395
- return content;
396
- }));
397
- server.registerTool('query-issues', {
398
- title: 'Query issues of routes',
399
- description: 'Query issues (errors, warnings, lints, etc.) that are reported on routes.',
400
- inputSchema: {
401
- routes: z.union([
402
- z.string(),
403
- z.array(z.string())
404
- ]).describe(ROUTES_DESCRIPTION),
405
- page: z.optional(z.number()).describe('Issues are paginated when there are more than 50 issues. The first page is number 0.')
406
- }
407
- }, async ({ routes, page })=>measureAndHandleErrors(`issues on ${arrayOrSingle(routes).join(', ')}`, async ()=>{
408
- const entrypoints = await turbopack.getEntrypoints();
409
- const issues = [];
410
- for (const route of arrayOrSingle(routes)){
411
- const routeInfo = entrypoints.routes.get(route);
412
- if (!routeInfo) {
413
- throw Object.defineProperty(new Error(`Route ${route} not found`), "__NEXT_ERROR_CODE", {
414
- value: "E756",
415
- enumerable: false,
416
- configurable: true
417
- });
418
- }
419
- for (const endpoint of routeToEndpoints(routeInfo)){
420
- const result = await endpoint.moduleGraphs();
421
- for (const issue of result.issues){
422
- const issuesWithRoute = issue;
423
- issuesWithRoute.route = route;
424
- issues.push(issuesWithRoute);
425
- }
426
- }
427
- }
428
- const severitiesArray = [
429
- 'bug',
430
- 'fatal',
431
- 'error',
432
- 'warning',
433
- 'hint',
434
- 'note',
435
- 'suggestion',
436
- 'info'
437
- ];
438
- const severities = new Map(severitiesArray.map((severity, index)=>[
439
- severity,
440
- index
441
- ]));
442
- issues.sort((a, b)=>{
443
- const severityA = severities.get(a.severity);
444
- const severityB = severities.get(b.severity);
445
- if (severityA !== undefined && severityB !== undefined) {
446
- return severityA - severityB;
447
- }
448
- return 0;
449
- });
450
- const content = [];
451
- content.push(issuesReference(issues));
452
- page = page ?? 0;
453
- const currentPage = issues.slice(page * 50, (page + 1) * 50);
454
- for (const issue of currentPage){
455
- content.push({
456
- type: 'text',
457
- text: issueToString(issue)
458
- });
459
- }
460
- if (issues.length >= (page + 1) * 50) {
461
- content.push({
462
- type: 'text',
463
- text: `Note: There are more issues available. Use the \`page\` parameter to query the next page.`
464
- });
465
- }
466
- return content;
467
- }));
468
- return server;
469
- }
470
-
471
- //# sourceMappingURL=mcp.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/server/lib/router-utils/mcp.ts"],"sourcesContent":["import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'\nimport { z } from 'next/dist/compiled/zod'\nimport type { NextJsHotReloaderInterface } from '../../dev/hot-reloader-types'\nimport type {\n Endpoint,\n Issue,\n Route,\n StyledString,\n} from '../../../build/swc/types'\nimport type { CallToolResult } from '@modelcontextprotocol/sdk/types'\nimport type {\n NapiModuleGraphSnapshot,\n NapiModuleInfo,\n NapiModuleReference,\n} from '../../../build/swc/generated-native'\nimport { runInNewContext } from 'node:vm'\nimport * as Log from '../../../build/output/log'\nimport { formatImportTraces } from '../../../shared/lib/turbopack/utils'\nimport { inspect } from 'node:util'\n\nexport { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js'\n\nconst QUERY_DESCRIPTION = `A piece of JavaScript code that will be executed.\nIt can access the module graph and extract information it finds useful.\nThe \\`console.log\\` function can be used to log messages, which will also be returned in the response.\nNo Node.js or browser APIs are available, but JavaScript language features are available.\nWhen the user is interested in used exports of modules, you can use the \\`export\\` property of ModuleReferences (\\`incomingReferences\\`).\nWhen the user is interested in the import path of a module, follow one of the \\`incomingReferences\\` with a smaller \\`depth\\` value than the current module until you hit the root.\nDo not try to make any assumptions or estimations. See the typings to see which data you have available. If you don't have the data, tell the user that this data is not available and list alternatives that are available.\nSee the following TypeScript typings for reference:\n\n\\`\\`\\` typescript\ninterface Module {\n /// The identifier of the module, which is a unique string.\n /// Example: \"[project]/packages/next-app/src/app/folder/page.tsx [app-rsc] (ecmascript, Next.js Server Component)\"\n /// These layers exist in App Router:\n /// * Server Components: [app-rsc], [app-edge-rsc]\n /// * API routes: [app-route], [app-edge-route]\n /// * Client Components: [app-client]\n /// * Server Side Rendering of Client Components: [app-ssr], [app-edge-ssr]\n /// These layers exist in Pages Router:\n /// * Client-side rendering: [client]\n /// * Server-side rendering: [ssr], [edge-ssr]\n /// * API routes: [api], [edge-api]\n /// And these layers also exist:\n /// * Middleware: [middleware], [middleware-edge]\n /// * Instrumentation: [instrumentation], [instrumentation-edge]\n ident: string,\n /// The path of the module. It's not unique as multiple modules can have the same path.\n /// Separate between application code and node_modules (npm packages, vendor code).\n /// Example: \"[project]/pages/folder/index.js\",\n /// Example: \"[project]/node_modules/.pnpm/next@file+..+next.js+packages+next_@babel+core@7.27.4_@opentelemetry+api@1.7.0_@playwright+te_5kenhtwdm6lrgjpao5hc34lkgy/node_modules/next/dist/compiled/fresh/index.js\",\n /// Example: \"[project]/apps/site/node_modules/@opentelemtry/api/build/src/trace/instrumentation.js\",\n path: string,\n /// The distance to the entries of the module graph. Use this to traverse the graph in the right direction.\n /// This is useful when trying to find the path from a module to the root of the module graph.\n /// Example: 0 for the entrypoint, 1 for the first layer of modules, etc.\n depth: number,\n /// The size of the source code of the module in bytes.\n /// Note that it's not the final size of the generated code, but can be a good indicator of that.\n /// It's only the size of this single module, not the size of the whole subgraph behind it (see retainedSize instead).\n size: number,\n /// The size of the whole subgraph behind this module in bytes.\n /// Use this value if the user is interested in sizes of modules (except when they are interested in the size of the module itself).\n /// Never try to compute the retained size yourself, but use this value instead.\n retainedSize: number,\n /// The modules that are referenced by this module.\n /// Modules could be referenced by \\`import\\`, \\`require\\`, \\`new URL\\`, etc.\n /// Beware cycles in the module graph. You can avoid that by only walking edges with a bigger \\`depth\\` value than the current module.\n references: ModuleReference[],\n /// The modules that reference this module.\n /// Beware cycles in the module graph. \n /// You can use this to walk up the graph up to the root. When doing this only walk edges with a smaller \\`depth\\` value than the current module.\n incomingReferences: ModuleReference[],\n}\n\ninterface ModuleReference {\n /// The referenced/referencing module.\n module: Module\n /// The thing that is used from the module.\n /// export {name}: The named export that is used.\n /// evaluation: Imported for side effects only.\n /// all: All exports and the side effects.\n export: \"evaluation\" | \"all\" | \\`export \\${string}\\`\n /// How this reference affects chunking of the module.\n /// hoisted | sync: The module is placed in the same chunk group as the referencing module.\n /// hoisted: The module is loaded before all \"sync\" modules.\n /// async: The module forms a separate chunk group which is loaded asynchronously.\n /// isolated: The module forms a separate chunk group which is loaded as separate entry. When it has a name, all modules imported with this name are placed in the same chunk group.\n /// shared: The module forms a separate chunk group which is loaded before the current chunk group. When it has a name, all modules imported with this name are placed in the same chunk group.\n /// traced: The module is not bundled, but the graph is still traced and all modules are included unbundled.\n chunkingType: \"hoisted\" | \"sync\" | \"async\" | \"isolated\" | \\`isolated \\${string}\\` | \"shared\" | \\`shared \\${string}\\` | \"traced\"\n}\n\n// The following global variables are available in the query:\n\n/// The entries of the module graph.\n/// Note that this only includes the entrypoints of the module graph and not all modules.\n/// You need to traverse it recursively to find not only children, but also grandchildren (resp, grandparents).\n/// Prefer to use \\`modules\\` over \\`entries\\` as it contains all modules, not only the entrypoints.\nconst entries: Module[]\n\n/// All modules in the module graph.\n/// Note that this array already contains all the modules as flat list.\n/// Make sure to iterate over this array and not only consider the first one.\n/// Prefer to use \\`modules\\` over \\`entries\\` as it contains all modules, not only the entrypoints.\nconst modules: Module[]\n\nconst console: {\n /// Logs a message to the console.\n /// The message will be returned in the response.\n /// The message can be a string or any other value that can be inspected.\n log: (...data: any[]) => void\n}\n\\`\\`\\`\n`\n\nasync function measureAndHandleErrors(\n name: string,\n fn: () => Promise<CallToolResult['content']>\n): Promise<CallToolResult> {\n const start = performance.now()\n let content: CallToolResult['content'] = []\n try {\n content = await fn()\n } catch (error) {\n content.push({\n type: 'text',\n text: `Error: ${error instanceof Error ? error.stack : String(error)}`,\n })\n content.push({\n type: 'text',\n text: 'Fix the error and try again.',\n })\n }\n const duration = performance.now() - start\n const formatDurationText =\n duration > 2000\n ? `${Math.round(duration / 100) / 10}s`\n : `${Math.round(duration)}ms`\n Log.event(`MCP ${name} in ${formatDurationText}`)\n return {\n content,\n }\n}\n\nfunction invariant(value: never, errorMessage: (value: any) => string): never {\n throw new Error(errorMessage(value))\n}\n\nfunction styledStringToMarkdown(\n styledString: StyledString | undefined\n): string {\n if (!styledString) {\n return ''\n }\n switch (styledString.type) {\n case 'text':\n return styledString.value\n case 'strong':\n return `*${styledString.value}*`\n case 'code':\n return `\\`${styledString.value}\\``\n case 'line':\n return styledString.value.map(styledStringToMarkdown).join('')\n case 'stack':\n return styledString.value.map(styledStringToMarkdown).join('\\n\\n')\n default:\n invariant(styledString, (s) => `Unknown styled string type: ${s.type}`)\n }\n}\n\nfunction indent(str: string, spaces: number = 2): string {\n const indentStr = ' '.repeat(spaces)\n return `${indentStr}${str.replace(/\\n/g, `\\n${indentStr}`)}`\n}\n\nfunction issueToString(issue: Issue & { route: string }): string {\n return [\n `${issue.severity} in ${issue.stage} on ${issue.route}`,\n `File Path: ${issue.filePath}`,\n issue.source &&\n `Source:\n ${issue.source.source.ident}\n ${issue.source.range ? `Range: ${issue.source.range?.start.line}:${issue.source.range?.start.column} - ${issue.source.range?.end.line}:${issue.source.range?.end.column}` : 'Unknown range'}\n`,\n `Title: ${styledStringToMarkdown(issue.title)}`,\n issue.description &&\n `Description:\n${indent(styledStringToMarkdown(issue.description))}`,\n issue.detail &&\n `Details:\n${indent(styledStringToMarkdown(issue.detail))}`,\n issue.documentationLink && `Documentation: ${issue.documentationLink}`,\n issue.importTraces &&\n issue.importTraces.length > 0 &&\n formatImportTraces(issue.importTraces),\n ]\n .filter(Boolean)\n .join('\\n')\n}\n\nfunction issuesReference(issues: Issue[]): { type: 'text'; text: string } {\n if (issues.length === 0) {\n return {\n type: 'text',\n text: 'Note: There are no issues.',\n }\n }\n\n const countBySeverity = new Map()\n\n for (const issue of issues) {\n const count = countBySeverity.get(issue.severity) || 0\n countBySeverity.set(issue.severity, count + 1)\n }\n\n const text = [\n `Note: There are ${issues.length} issues in total, with the following severities: ${Array.from(\n countBySeverity.entries()\n )\n .map(([severity, count]) => `${count} x ${severity}`)\n .join(', ')}.`,\n ]\n\n return {\n type: 'text',\n text: text.join('\\n'),\n }\n}\n\nfunction routeToTitle(route: Route): string {\n switch (route.type) {\n case 'page':\n return 'A page using Pages Router.'\n case 'app-page':\n return `A page using App Router. Original names: ${route.pages.map((page) => page.originalName).join(', ')}.`\n case 'page-api':\n return 'An API route using Pages Router.'\n case 'app-route':\n return `A route using App Router. Original name: ${route.originalName}.`\n case 'conflict':\n return 'Multiple routes conflict on this path. This is an error in the folder structure.'\n default:\n invariant(route, (r) => `Unknown route type: ${r.type}`)\n }\n}\n\nfunction routeToEndpoints(route: Route): Endpoint[] {\n switch (route.type) {\n case 'page':\n return [route.htmlEndpoint]\n case 'app-page':\n return route.pages.map((p) => p.htmlEndpoint)\n case 'page-api':\n return [route.endpoint]\n case 'app-route':\n return [route.endpoint]\n case 'conflict':\n return []\n default:\n invariant(route, (r) => `Unknown route type: ${r.type}`)\n }\n}\n\nfunction arrayOrSingle<T>(value: T | T[]): T[] {\n return Array.isArray(value) ? value : [value]\n}\n\ninterface ModuleReference {\n module: Module\n export: string\n chunkingType: string\n}\ninterface Module {\n /// The identifier of the module, which is a unique string.\n ident: string\n /// The path of the module. It's not unique as multiple modules can have the same path.\n path: string\n /// The distance to the entries of the module graph. Use this to traverse the graph in the right direction.\n depth: number\n /// The size of the source code of the module in bytes.\n size: number\n /// The size of the whole subgraph behind this module in bytes.\n retainedSize: number\n /// The modules that are referenced by this module.\n references: ModuleReference[]\n /// The modules that reference this module.\n incomingReferences: ModuleReference[]\n}\n\nfunction createModuleObject(rawModule: NapiModuleInfo): Module {\n return {\n ident: rawModule.ident,\n path: rawModule.path,\n depth: rawModule.depth,\n size: rawModule.size,\n retainedSize: rawModule.retainedSize,\n references: [],\n incomingReferences: [],\n }\n}\n\nfunction processModuleGraphSnapshot(\n moduleGraph: NapiModuleGraphSnapshot,\n modules: Module[],\n entries: Module[]\n) {\n const queryModules = moduleGraph.modules.map(createModuleObject)\n for (let i = 0; i < queryModules.length; i++) {\n const rawModule = moduleGraph.modules[i]\n const queryModule = queryModules[i]\n\n queryModule.references = rawModule.references.map(\n (ref: NapiModuleReference) => ({\n module: queryModules[ref.index],\n export: ref.export,\n chunkingType: ref.chunkingType,\n })\n )\n queryModule.incomingReferences = rawModule.incomingReferences.map(\n (ref: NapiModuleReference) => ({\n module: queryModules[ref.index],\n export: ref.export,\n chunkingType: ref.chunkingType,\n })\n )\n modules.push(queryModule)\n }\n for (const entry of moduleGraph.entries) {\n const queryModule = queryModules[entry]\n entries.push(queryModule)\n }\n}\n\nfunction runQuery(\n query: string,\n modules: Module[],\n entries: Module[]\n): CallToolResult['content'] {\n const response: CallToolResult['content'] = []\n const proto = {\n modules,\n entries,\n console: {\n log: (...data: any[]) => {\n response.push({\n type: 'text',\n text: data\n .map((item) =>\n typeof item === 'string' ? item : inspect(item, false, 2, false)\n )\n .join(' '),\n })\n },\n },\n }\n const contextObject = Object.create(proto)\n contextObject.global = contextObject\n contextObject.self = contextObject\n contextObject.globalThis = contextObject\n runInNewContext(query, contextObject, {\n displayErrors: true,\n filename: 'query.js',\n timeout: 20000,\n contextName: 'Query Context',\n })\n for (const [key, value] of Object.entries(contextObject)) {\n if (typeof value === 'function') continue\n if (key === 'global' || key === 'self' || key === 'globalThis') continue\n response.push({\n type: 'text',\n text: `Global variable \\`${key}\\` = ${inspect(value, false, 2, false)}`,\n })\n }\n return response\n}\n\nconst ROUTES_DESCRIPTION =\n 'The routes from which to query the module graph. Can be a single string or an array of strings.'\nexport function createMcpServer(\n hotReloader: NextJsHotReloaderInterface\n): McpServer | undefined {\n const turbopack = hotReloader.turbopackProject\n if (!turbopack) return undefined\n const server = new McpServer({\n name: 'next.js',\n version: '1.0.0',\n instructions: `This is a running next.js dev server with Turbopack.\nYou can use the Model Context Protocol to query information about pages and modules and their relations.`,\n })\n\n server.registerTool(\n 'entrypoints',\n {\n title: 'Entrypoints',\n description:\n 'Get all entrypoints of a Turbopack project, which are all pages, routes and the middleware.',\n },\n async () =>\n measureAndHandleErrors('entrypoints', async () => {\n let entrypoints = await turbopack.getEntrypoints()\n\n const list = []\n\n for (const [key, route] of entrypoints.routes.entries()) {\n list.push(`\\`${key}\\` (${routeToTitle(route)})`)\n }\n\n if (entrypoints.middleware) {\n list.push('Middleware')\n }\n\n if (entrypoints.instrumentation) {\n list.push('Instrumentation')\n }\n\n const content: CallToolResult['content'] = [\n issuesReference(entrypoints.issues),\n {\n type: 'text',\n text: `These are the routes of the application:\n\n${list.map((e) => `- ${e}`).join('\\n')}`,\n },\n ]\n return content\n })\n )\n\n server.registerTool(\n 'query-routes-module-graph',\n {\n title: 'Query module graph of routes',\n description: 'Query details about the module graph of routes.',\n inputSchema: {\n routes: z\n .union([z.string(), z.array(z.string())])\n .describe(ROUTES_DESCRIPTION),\n query: z.string().describe(QUERY_DESCRIPTION),\n },\n },\n async ({ routes, query }) =>\n measureAndHandleErrors(\n `module graph query on ${arrayOrSingle(routes).join(', ')}`,\n async () => {\n const entrypoints = await turbopack.getEntrypoints()\n const endpoints = []\n for (const route of arrayOrSingle(routes)) {\n const routeInfo = entrypoints.routes.get(route)\n if (!routeInfo) {\n throw new Error(`Route ${route} not found`)\n }\n endpoints.push(...routeToEndpoints(routeInfo))\n }\n const issues = []\n const modules: Module[] = []\n const entries: Module[] = []\n\n for (const endpoint of endpoints) {\n const result = await endpoint.moduleGraphs()\n issues.push(...result.issues)\n const moduleGraphs = result.moduleGraphs\n for (const moduleGraph of moduleGraphs) {\n processModuleGraphSnapshot(moduleGraph, modules, entries)\n }\n }\n const content: CallToolResult['content'] = []\n content.push(issuesReference(issues))\n const response = runQuery(query, modules, entries)\n content.push(...response)\n return content\n }\n )\n )\n\n server.registerTool(\n 'query-module-graph',\n {\n title: 'Query whole app module graph',\n description:\n 'Query details about the module graph the whole application. This is a expensive operation and should only be used when module graph of the whole application is needed.',\n inputSchema: {\n query: z.string().describe(QUERY_DESCRIPTION),\n },\n },\n async ({ query }) =>\n measureAndHandleErrors(`whole app module graph query`, async () => {\n const moduleGraph = await turbopack.moduleGraph()\n const issues = moduleGraph.issues\n const modules: Module[] = []\n const entries: Module[] = []\n processModuleGraphSnapshot(moduleGraph, modules, entries)\n const content: CallToolResult['content'] = []\n content.push(issuesReference(issues))\n const response = runQuery(query, modules, entries)\n content.push(...response)\n return content\n })\n )\n\n server.registerTool(\n 'query-issues',\n {\n title: 'Query issues of routes',\n description:\n 'Query issues (errors, warnings, lints, etc.) that are reported on routes.',\n inputSchema: {\n routes: z\n .union([z.string(), z.array(z.string())])\n .describe(ROUTES_DESCRIPTION),\n page: z\n .optional(z.number())\n .describe(\n 'Issues are paginated when there are more than 50 issues. The first page is number 0.'\n ),\n },\n },\n async ({ routes, page }) =>\n measureAndHandleErrors(\n `issues on ${arrayOrSingle(routes).join(', ')}`,\n async () => {\n const entrypoints = await turbopack.getEntrypoints()\n const issues = []\n for (const route of arrayOrSingle(routes)) {\n const routeInfo = entrypoints.routes.get(route)\n if (!routeInfo) {\n throw new Error(`Route ${route} not found`)\n }\n for (const endpoint of routeToEndpoints(routeInfo)) {\n const result = await endpoint.moduleGraphs()\n for (const issue of result.issues) {\n const issuesWithRoute = issue as Issue & { route: string }\n issuesWithRoute.route = route\n issues.push(issuesWithRoute)\n }\n }\n }\n const severitiesArray = [\n 'bug',\n 'fatal',\n 'error',\n 'warning',\n 'hint',\n 'note',\n 'suggestion',\n 'info',\n ]\n const severities = new Map(\n severitiesArray.map((severity, index) => [severity, index])\n )\n issues.sort((a, b) => {\n const severityA = severities.get(a.severity)\n const severityB = severities.get(b.severity)\n if (severityA !== undefined && severityB !== undefined) {\n return severityA - severityB\n }\n return 0\n })\n\n const content: CallToolResult['content'] = []\n content.push(issuesReference(issues))\n page = page ?? 0\n const currentPage = issues.slice(page * 50, (page + 1) * 50)\n for (const issue of currentPage) {\n content.push({\n type: 'text',\n text: issueToString(issue),\n })\n }\n if (issues.length >= (page + 1) * 50) {\n content.push({\n type: 'text',\n text: `Note: There are more issues available. Use the \\`page\\` parameter to query the next page.`,\n })\n }\n\n return content\n }\n )\n )\n\n return server\n}\n"],"names":["McpServer","z","runInNewContext","Log","formatImportTraces","inspect","StreamableHTTPServerTransport","QUERY_DESCRIPTION","measureAndHandleErrors","name","fn","start","performance","now","content","error","push","type","text","Error","stack","String","duration","formatDurationText","Math","round","event","invariant","value","errorMessage","styledStringToMarkdown","styledString","map","join","s","indent","str","spaces","indentStr","repeat","replace","issueToString","issue","severity","stage","route","filePath","source","ident","range","line","column","end","title","description","detail","documentationLink","importTraces","length","filter","Boolean","issuesReference","issues","countBySeverity","Map","count","get","set","Array","from","entries","routeToTitle","pages","page","originalName","r","routeToEndpoints","htmlEndpoint","p","endpoint","arrayOrSingle","isArray","createModuleObject","rawModule","path","depth","size","retainedSize","references","incomingReferences","processModuleGraphSnapshot","moduleGraph","modules","queryModules","i","queryModule","ref","module","index","export","chunkingType","entry","runQuery","query","response","proto","console","log","data","item","contextObject","Object","create","global","self","globalThis","displayErrors","filename","timeout","contextName","key","ROUTES_DESCRIPTION","createMcpServer","hotReloader","turbopack","turbopackProject","undefined","server","version","instructions","registerTool","entrypoints","getEntrypoints","list","routes","middleware","instrumentation","e","inputSchema","union","string","array","describe","endpoints","routeInfo","result","moduleGraphs","optional","number","issuesWithRoute","severitiesArray","severities","sort","a","b","severityA","severityB","currentPage","slice"],"mappings":"AAAA,SAASA,SAAS,QAAQ,0CAAyC;AACnE,SAASC,CAAC,QAAQ,yBAAwB;AAc1C,SAASC,eAAe,QAAQ,UAAS;AACzC,YAAYC,SAAS,4BAA2B;AAChD,SAASC,kBAAkB,QAAQ,sCAAqC;AACxE,SAASC,OAAO,QAAQ,YAAW;AAEnC,SAASC,6BAA6B,QAAQ,qDAAoD;AAElG,MAAMC,oBAAoB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6F3B,CAAC;AAED,eAAeC,uBACbC,IAAY,EACZC,EAA4C;IAE5C,MAAMC,QAAQC,YAAYC,GAAG;IAC7B,IAAIC,UAAqC,EAAE;IAC3C,IAAI;QACFA,UAAU,MAAMJ;IAClB,EAAE,OAAOK,OAAO;QACdD,QAAQE,IAAI,CAAC;YACXC,MAAM;YACNC,MAAM,CAAC,OAAO,EAAEH,iBAAiBI,QAAQJ,MAAMK,KAAK,GAAGC,OAAON,QAAQ;QACxE;QACAD,Q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GAAG,CAACuF,EAAE9G,QAAQ;gBAC3C,MAAMiH,YAAYL,WAAWrF,GAAG,CAACwF,EAAE/G,QAAQ;gBAC3C,IAAIgH,cAAc7B,aAAa8B,cAAc9B,WAAW;oBACtD,OAAO6B,YAAYC;gBACrB;gBACA,OAAO;YACT;YAEA,MAAM9I,UAAqC,EAAE;YAC7CA,QAAQE,IAAI,CAAC6C,gBAAgBC;YAC7BW,OAAOA,QAAQ;YACf,MAAMoF,cAAc/F,OAAOgG,KAAK,CAACrF,OAAO,IAAI,AAACA,CAAAA,OAAO,CAAA,IAAK;YACzD,KAAK,MAAM/B,SAASmH,YAAa;gBAC/B/I,QAAQE,IAAI,CAAC;oBACXC,MAAM;oBACNC,MAAMuB,cAAcC;gBACtB;YACF;YACA,IAAIoB,OAAOJ,MAAM,IAAI,AAACe,CAAAA,OAAO,CAAA,IAAK,IAAI;gBACpC3D,QAAQE,IAAI,CAAC;oBACXC,MAAM;oBACNC,MAAM,CAAC,yFAAyF,CAAC;gBACnG;YACF;YAEA,OAAOJ;QACT;IAIN,OAAOiH;AACT","ignoreList":[0]}
@@ -1,4 +0,0 @@
1
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import type { NextJsHotReloaderInterface } from '../../dev/hot-reloader-types';
3
- export { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
4
- export declare function createMcpServer(hotReloader: NextJsHotReloaderInterface): McpServer | undefined;