@mandujs/mcp 0.38.9 → 0.38.11

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mandujs/mcp",
3
- "version": "0.38.9",
3
+ "version": "0.38.11",
4
4
  "description": "Mandu MCP Server - Agent-native interface for Mandu framework operations",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -34,7 +34,7 @@
34
34
  "access": "public"
35
35
  },
36
36
  "dependencies": {
37
- "@mandujs/core": "^0.54.17",
37
+ "@mandujs/core": "^0.54.19",
38
38
  "@mandujs/ate": "^0.26.1",
39
39
  "@mandujs/skills": "^0.20.1",
40
40
  "@modelcontextprotocol/sdk": "^1.25.3"
@@ -232,31 +232,39 @@ export function hydrationTools(projectRoot: string) {
232
232
  };
233
233
  },
234
234
 
235
- "mandu.pageClientMount.list": async () => {
236
- // Load manifest
237
- const manifestResult = await loadManifest(paths.manifestPath);
238
- if (!manifestResult.success || !manifestResult.data) {
239
- return { error: manifestResult.errors };
240
- }
241
-
242
- const pageClientMounts = manifestResult.data.routes
243
- .filter((route) => route.kind === "page")
244
- .map((route) => {
245
- const hydration = getRouteHydration(route);
246
- const needsClientMount = needsHydration(route);
247
- const warning = needsClientMount && !route.clientModule
248
- ? `Route has hydration strategy '${hydration.strategy}' but no clientModule; build would emit no route bundle.`
249
- : null;
250
-
235
+ "mandu.pageClientMount.list": async () => {
236
+ // Load manifest
237
+ const manifestResult = await loadManifest(paths.manifestPath);
238
+ if (!manifestResult.success || !manifestResult.data) {
239
+ return { error: manifestResult.errors };
240
+ }
241
+ const bundleManifest = await readJsonFile<BundleManifest>(
242
+ path.join(projectRoot, ".mandu", "manifest.json"),
243
+ );
244
+ const partialBoundaryCount = Object.keys(bundleManifest?.partials ?? {}).length;
245
+
246
+ const pageClientMounts = manifestResult.data.routes
247
+ .filter((route) => route.kind === "page")
248
+ .map((route) => {
249
+ const hydration = getRouteHydration(route);
250
+ const needsClientMount = needsHydration(route);
251
+ const clientBoundaryCount = route.boundaries?.length ?? 0;
252
+ const hasRouteLevelClientMount = needsClientMount && !!route.clientModule;
253
+ const warning = needsClientMount && !route.clientModule
254
+ ? `Route has hydration strategy '${hydration.strategy}' but no clientModule; build would emit no route bundle.`
255
+ : null;
256
+
251
257
  return {
252
258
  routeId: route.id,
253
- pattern: route.pattern,
254
- hasClientModule: !!route.clientModule,
255
- clientModule: route.clientModule || null,
256
- needsClientMount,
257
- // Backward compatibility for older agents that read `isIsland`.
258
- isIsland: needsClientMount,
259
- status: needsClientMount ? (route.clientModule ? "ready" : "broken") : "static",
259
+ pattern: route.pattern,
260
+ hasClientModule: !!route.clientModule,
261
+ clientModule: route.clientModule || null,
262
+ needsClientMount,
263
+ hasRouteLevelClientMount,
264
+ clientBoundaryCount,
265
+ // Backward compatibility for older agents that read `isIsland`.
266
+ isIsland: needsClientMount,
267
+ status: needsClientMount ? (route.clientModule ? "ready" : "broken") : "static",
260
268
  warning,
261
269
  hydration: {
262
270
  strategy: hydration.strategy,
@@ -266,23 +274,38 @@ export function hydrationTools(projectRoot: string) {
266
274
  };
267
275
  });
268
276
 
269
- const pageClientMountCount = pageClientMounts.filter((i) => i.needsClientMount).length;
270
- const staticCount = pageClientMounts.filter((i) => !i.needsClientMount).length;
271
- const activeMounts = pageClientMounts.filter((i) => i.needsClientMount);
272
- const staticPages = pageClientMounts.filter((i) => !i.needsClientMount);
273
-
274
- return {
275
- terminology: {
276
- pageClientMount:
277
- "A page route whose whole page is hydrated from a route-level clientModule and route bundle.",
278
- island:
279
- "A nested or route-local island bundle, distinct from page client mounts. Use mandu.runtime.status for both collections.",
280
- },
281
- totalPages: pageClientMounts.length,
282
- pageClientMountCount,
283
- staticCount,
284
- pageClientMounts: activeMounts,
285
- staticPages,
277
+ const pageClientMountCount = pageClientMounts.filter((i) => i.needsClientMount).length;
278
+ const staticCount = pageClientMounts.filter((i) => !i.needsClientMount).length;
279
+ const activeMounts = pageClientMounts.filter((i) => i.needsClientMount);
280
+ const staticPages = pageClientMounts.filter((i) => !i.needsClientMount);
281
+ const clientBoundaryCount = pageClientMounts.reduce(
282
+ (count, route) => count + route.clientBoundaryCount,
283
+ 0,
284
+ );
285
+
286
+ return {
287
+ terminology: {
288
+ pageClientMount:
289
+ "A page route whose whole page is hydrated from a route-level clientModule and route bundle.",
290
+ clientBoundary:
291
+ "A compiler-discovered nested client component marker recorded on RouteSpec.boundaries.",
292
+ partialBoundary:
293
+ "A legacy/runtime partial bundle listed in .mandu/manifest.json partials.",
294
+ island:
295
+ "Legacy umbrella term. Prefer pageClientMount, clientBoundary, or partialBoundary for precise reports.",
296
+ },
297
+ boundarySummary: {
298
+ clientBoundaryCount,
299
+ partialBoundaryCount,
300
+ pageClientMountCount,
301
+ },
302
+ totalPages: pageClientMounts.length,
303
+ pageClientMountCount,
304
+ clientBoundaryCount,
305
+ partialBoundaryCount,
306
+ staticCount,
307
+ pageClientMounts: activeMounts,
308
+ staticPages,
286
309
  // Backward compatibility for older clients.
287
310
  islandCount: pageClientMountCount,
288
311
  islands: activeMounts,
package/src/tools/spec.ts CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  loadManifest,
4
4
  generateManifest,
5
5
  } from "@mandujs/core";
6
- import { getProjectPaths, isInsideProject } from "../utils/project.js";
6
+ import { getProjectPaths, isInsideProject, readJsonFile } from "../utils/project.js";
7
7
  import path from "path";
8
8
  import fs from "fs/promises";
9
9
 
@@ -21,8 +21,8 @@ export const specToolDefinitions: Tool[] = [
21
21
  required: [],
22
22
  },
23
23
  },
24
- {
25
- name: "mandu.route.get",
24
+ {
25
+ name: "mandu.route.get",
26
26
  description:
27
27
  "Get full details of a specific route by its ID. Use before modifying a route.",
28
28
  annotations: {
@@ -37,10 +37,32 @@ export const specToolDefinitions: Tool[] = [
37
37
  },
38
38
  },
39
39
  required: ["routeId"],
40
- },
41
- },
42
- {
43
- name: "mandu.route.add",
40
+ },
41
+ },
42
+ {
43
+ name: "mandu.route.boundaries",
44
+ description:
45
+ "Inspect compiler-discovered client boundary metadata for one route or all routes, including route manifest records and optional bundle manifest entries.",
46
+ annotations: {
47
+ readOnlyHint: true,
48
+ },
49
+ inputSchema: {
50
+ type: "object",
51
+ properties: {
52
+ routeId: {
53
+ type: "string",
54
+ description: "Optional route ID to inspect. Omit to list boundaries for all routes.",
55
+ },
56
+ includeBundle: {
57
+ type: "boolean",
58
+ description: "When true, also correlate route boundaries with .mandu/manifest.json boundary bundle entries.",
59
+ },
60
+ },
61
+ required: [],
62
+ },
63
+ },
64
+ {
65
+ name: "mandu.route.add",
44
66
  description:
45
67
  "Scaffold a new route in app/ with optional slot and contract files, then regenerate the manifest.",
46
68
  annotations: {
@@ -129,7 +151,7 @@ export function specTools(projectRoot: string) {
129
151
  };
130
152
  },
131
153
 
132
- "mandu.route.get": async (args: Record<string, unknown>) => {
154
+ "mandu.route.get": async (args: Record<string, unknown>) => {
133
155
  const { routeId } = args as { routeId: string };
134
156
 
135
157
  const result = await loadManifest(paths.manifestPath);
@@ -142,10 +164,117 @@ export function specTools(projectRoot: string) {
142
164
  return { error: `Route not found: ${routeId}` };
143
165
  }
144
166
 
145
- return { route };
146
- },
147
-
148
- "mandu.route.add": async (args: Record<string, unknown>) => {
167
+ return { route };
168
+ },
169
+
170
+ "mandu.route.boundaries": async (args: Record<string, unknown>) => {
171
+ const { routeId, includeBundle = false } = args as { routeId?: string; includeBundle?: boolean };
172
+
173
+ const result = await loadManifest(paths.manifestPath);
174
+ if (!result.success || !result.data) {
175
+ return { error: result.errors };
176
+ }
177
+
178
+ const bundleManifestPath = path.join(projectRoot, ".mandu", "manifest.json");
179
+ const bundleManifest = includeBundle
180
+ ? await readJsonFile<{
181
+ boundaries?: Record<string, {
182
+ route?: string;
183
+ js?: string;
184
+ module?: string;
185
+ exportName?: string;
186
+ priority?: string;
187
+ hydrate?: string;
188
+ }>;
189
+ }>(bundleManifestPath)
190
+ : null;
191
+
192
+ const routes = routeId
193
+ ? result.data.routes.filter((route) => route.id === routeId)
194
+ : result.data.routes;
195
+
196
+ if (routeId && routes.length === 0) {
197
+ return { error: `Route not found: ${routeId}` };
198
+ }
199
+
200
+ const inspected = routes.map((route) => {
201
+ const boundaries = route.boundaries ?? [];
202
+ const diagnostics: Array<{
203
+ code: string;
204
+ severity: "warning";
205
+ message: string;
206
+ routeId: string;
207
+ boundaryId?: string;
208
+ }> = [];
209
+
210
+ if (includeBundle && boundaries.length > 0 && !bundleManifest) {
211
+ diagnostics.push({
212
+ code: "MANDU_BOUNDARY_BUNDLE_MANIFEST_MISSING",
213
+ severity: "warning",
214
+ message: "Route has compiler-discovered client boundaries, but .mandu/manifest.json was not found. Run mandu build to inspect generated boundary chunks.",
215
+ routeId: route.id,
216
+ });
217
+ }
218
+
219
+ const boundaryRecords = boundaries.map((boundary) => {
220
+ const bundle = bundleManifest?.boundaries?.[boundary.id];
221
+ if (includeBundle && bundleManifest && !bundle) {
222
+ diagnostics.push({
223
+ code: "MANDU_BOUNDARY_BUNDLE_ENTRY_MISSING",
224
+ severity: "warning",
225
+ message: `Boundary '${boundary.id}' is present in routes manifest but missing from .mandu/manifest.json boundaries.`,
226
+ routeId: route.id,
227
+ boundaryId: boundary.id,
228
+ });
229
+ }
230
+
231
+ return {
232
+ id: boundary.id,
233
+ routeId: boundary.routeId,
234
+ module: boundary.module,
235
+ importSpecifier: boundary.importSpecifier,
236
+ exportName: boundary.exportName,
237
+ localName: boundary.localName,
238
+ hydrate: boundary.hydrate,
239
+ ordinal: boundary.ordinal,
240
+ propsSource: boundary.propsSource,
241
+ propsKeys: boundary.propsKeys ?? [],
242
+ hasSpreadProps: !!boundary.hasSpreadProps,
243
+ source: boundary.source,
244
+ bundle: bundle
245
+ ? {
246
+ js: bundle.js ?? null,
247
+ priority: bundle.priority ?? null,
248
+ hydrate: bundle.hydrate ?? null,
249
+ }
250
+ : null,
251
+ };
252
+ });
253
+
254
+ return {
255
+ routeId: route.id,
256
+ pattern: route.pattern,
257
+ module: route.module,
258
+ boundaryCount: boundaryRecords.length,
259
+ boundaries: boundaryRecords,
260
+ diagnostics,
261
+ };
262
+ });
263
+
264
+ return {
265
+ source: {
266
+ routesManifest: ".mandu/routes.manifest.json",
267
+ bundleManifest: includeBundle && bundleManifest ? ".mandu/manifest.json" : null,
268
+ },
269
+ includeBundle,
270
+ routeId: routeId ?? null,
271
+ routeCount: inspected.length,
272
+ boundaryCount: inspected.reduce((count, route) => count + route.boundaryCount, 0),
273
+ routes: inspected,
274
+ };
275
+ },
276
+
277
+ "mandu.route.add": async (args: Record<string, unknown>) => {
149
278
  const { path: routePath, kind, withSlot = true, withContract = false } = args as {
150
279
  path: string;
151
280
  kind: "api" | "page";
@@ -276,8 +405,8 @@ export function specTools(projectRoot: string) {
276
405
  };
277
406
 
278
407
  // Backward-compatible aliases (deprecated)
279
- handlers["mandu_list_routes"] = handlers["mandu.route.list"];
280
- handlers["mandu_get_route"] = handlers["mandu.route.get"];
408
+ handlers["mandu_list_routes"] = handlers["mandu.route.list"];
409
+ handlers["mandu_get_route"] = handlers["mandu.route.get"];
281
410
  handlers["mandu_add_route"] = handlers["mandu.route.add"];
282
411
  handlers["mandu_delete_route"] = handlers["mandu.route.delete"];
283
412
  handlers["mandu_validate_manifest"] = handlers["mandu.manifest.validate"];