@mandujs/mcp 0.38.9 → 0.38.10

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 (2) hide show
  1. package/package.json +2 -2
  2. package/src/tools/spec.ts +143 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mandujs/mcp",
3
- "version": "0.38.9",
3
+ "version": "0.38.10",
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.18",
38
38
  "@mandujs/ate": "^0.26.1",
39
39
  "@mandujs/skills": "^0.20.1",
40
40
  "@modelcontextprotocol/sdk": "^1.25.3"
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"];