@weapp-vite/mcp 1.1.1 → 1.2.0

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/README.md CHANGED
@@ -43,6 +43,8 @@ await handle.close?.()
43
43
  - `search_source_code`: 在包源码中检索关键词
44
44
  - `run_package_script`: 在指定包目录执行 `pnpm run <script>`
45
45
  - `run_weapp_vite_cli`: 执行 `node packages/weapp-vite/bin/weapp-vite.js ...`
46
+ - `take_weapp_screenshot`: 面向“小程序截图 / 页面快照”语义,执行 `weapp-vite screenshot --json`
47
+ - `compare_weapp_screenshot`: 面向“截图对比 / diff / baseline / 视觉回归”语义,执行 `weapp-vite compare --json`
46
48
  - `run_repo_command`: 执行仓库级命令(`pnpm/node/git/rg`)
47
49
 
48
50
  ## 主要 Resources
package/dist/index.d.mts CHANGED
@@ -6,16 +6,19 @@ declare const EXPOSED_PACKAGES: {
6
6
  readonly 'weapp-vite': {
7
7
  readonly id: "weapp-vite";
8
8
  readonly label: "weapp-vite";
9
+ readonly packageName: "weapp-vite";
9
10
  readonly relativePath: string;
10
11
  };
11
12
  readonly wevu: {
12
13
  readonly id: "wevu";
13
14
  readonly label: "wevu";
15
+ readonly packageName: "wevu";
14
16
  readonly relativePath: string;
15
17
  };
16
18
  readonly 'wevu-compiler': {
17
19
  readonly id: "wevu-compiler";
18
20
  readonly label: "wevu-compiler";
21
+ readonly packageName: "@wevu/compiler";
19
22
  readonly relativePath: string;
20
23
  };
21
24
  };
@@ -26,7 +29,7 @@ declare const DEFAULT_MAX_FILE_CHARS = 80000;
26
29
  declare const DEFAULT_MAX_RESULTS = 200;
27
30
  declare const SKIPPED_DIR_NAMES: Set<string>;
28
31
 
29
- interface ExposedPackageSummary {
32
+ interface ResolvedExposedPackage {
30
33
  id: ExposedPackageId;
31
34
  label: string;
32
35
  packageName: string;
@@ -38,9 +41,14 @@ interface ExposedPackageSummary {
38
41
  readme?: string;
39
42
  changelog?: string;
40
43
  };
44
+ sourceRoot?: string;
45
+ cliPath?: string;
46
+ }
47
+
48
+ interface ExposedPackageSummary extends ResolvedExposedPackage {
41
49
  }
42
50
  declare function loadPackageSummary(workspaceRoot: string, id: ExposedPackageId): Promise<ExposedPackageSummary>;
43
- declare function loadExposedCatalog(workspaceRoot: string): Promise<ExposedPackageSummary[]>;
51
+ declare function loadExposedCatalog(workspaceRoot: string): Promise<ResolvedExposedPackage[]>;
44
52
 
45
53
  interface CommandResult {
46
54
  command: string;
package/dist/index.d.ts CHANGED
@@ -6,16 +6,19 @@ declare const EXPOSED_PACKAGES: {
6
6
  readonly 'weapp-vite': {
7
7
  readonly id: "weapp-vite";
8
8
  readonly label: "weapp-vite";
9
+ readonly packageName: "weapp-vite";
9
10
  readonly relativePath: string;
10
11
  };
11
12
  readonly wevu: {
12
13
  readonly id: "wevu";
13
14
  readonly label: "wevu";
15
+ readonly packageName: "wevu";
14
16
  readonly relativePath: string;
15
17
  };
16
18
  readonly 'wevu-compiler': {
17
19
  readonly id: "wevu-compiler";
18
20
  readonly label: "wevu-compiler";
21
+ readonly packageName: "@wevu/compiler";
19
22
  readonly relativePath: string;
20
23
  };
21
24
  };
@@ -26,7 +29,7 @@ declare const DEFAULT_MAX_FILE_CHARS = 80000;
26
29
  declare const DEFAULT_MAX_RESULTS = 200;
27
30
  declare const SKIPPED_DIR_NAMES: Set<string>;
28
31
 
29
- interface ExposedPackageSummary {
32
+ interface ResolvedExposedPackage {
30
33
  id: ExposedPackageId;
31
34
  label: string;
32
35
  packageName: string;
@@ -38,9 +41,14 @@ interface ExposedPackageSummary {
38
41
  readme?: string;
39
42
  changelog?: string;
40
43
  };
44
+ sourceRoot?: string;
45
+ cliPath?: string;
46
+ }
47
+
48
+ interface ExposedPackageSummary extends ResolvedExposedPackage {
41
49
  }
42
50
  declare function loadPackageSummary(workspaceRoot: string, id: ExposedPackageId): Promise<ExposedPackageSummary>;
43
- declare function loadExposedCatalog(workspaceRoot: string): Promise<ExposedPackageSummary[]>;
51
+ declare function loadExposedCatalog(workspaceRoot: string): Promise<ResolvedExposedPackage[]>;
44
52
 
45
53
  interface CommandResult {
46
54
  command: string;
package/dist/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import process from 'node:process';
2
2
  import { fileURLToPath } from 'node:url';
3
3
  import fs$1 from 'node:fs/promises';
4
+ import { createRequire } from 'node:module';
4
5
  import path from 'node:path';
5
6
  import fs from 'node:fs';
6
7
  import { spawn } from 'node:child_process';
@@ -17,17 +18,20 @@ const EXPOSED_PACKAGES = {
17
18
  "weapp-vite": {
18
19
  id: "weapp-vite",
19
20
  label: "weapp-vite",
21
+ packageName: "weapp-vite",
20
22
  relativePath: path.join("packages", "weapp-vite")
21
23
  },
22
24
  "wevu": {
23
25
  id: "wevu",
24
26
  label: "wevu",
25
- relativePath: path.join("packages", "wevu")
27
+ packageName: "wevu",
28
+ relativePath: path.join("packages-runtime", "wevu")
26
29
  },
27
30
  "wevu-compiler": {
28
31
  id: "wevu-compiler",
29
32
  label: "wevu-compiler",
30
- relativePath: path.join("packages", "wevu-compiler")
33
+ packageName: "@wevu/compiler",
34
+ relativePath: path.join("packages-runtime", "wevu-compiler")
31
35
  }
32
36
  };
33
37
  const DEFAULT_TIMEOUT_MS = 12e4;
@@ -80,10 +84,6 @@ function resolveSubPath(root, relativePath) {
80
84
  return assertInsideRoot(root, path.resolve(root, relativePath));
81
85
  }
82
86
 
83
- async function readJsonFile(filePath) {
84
- const content = await fs$1.readFile(filePath, "utf8");
85
- return JSON.parse(content);
86
- }
87
87
  async function pathExists(filePath) {
88
88
  try {
89
89
  await fs$1.access(filePath);
@@ -92,17 +92,40 @@ async function pathExists(filePath) {
92
92
  return false;
93
93
  }
94
94
  }
95
- async function loadPackageSummary(workspaceRoot, id) {
95
+ async function toWorkspaceRelativePath(workspaceRoot, absolutePath) {
96
+ const [realWorkspaceRoot, realAbsolutePath] = await Promise.all([
97
+ fs$1.realpath(workspaceRoot),
98
+ fs$1.realpath(absolutePath)
99
+ ]);
100
+ const relativePath = path.relative(realWorkspaceRoot, realAbsolutePath);
101
+ if (!relativePath || relativePath === ".") {
102
+ return ".";
103
+ }
104
+ return relativePath;
105
+ }
106
+ async function readPackageJson(filePath) {
107
+ const content = await fs$1.readFile(filePath, "utf8");
108
+ return JSON.parse(content);
109
+ }
110
+ function createWorkspaceRequire(workspaceRoot) {
111
+ return createRequire(path.join(workspaceRoot, "__weapp_vite_mcp__.cjs"));
112
+ }
113
+ async function resolveMonorepoPackage(workspaceRoot, id) {
96
114
  const config = EXPOSED_PACKAGES[id];
97
115
  const absolutePath = assertInsideRoot(workspaceRoot, path.join(workspaceRoot, config.relativePath));
98
116
  const packageJsonPath = path.join(absolutePath, "package.json");
99
- const packageJson = await readJsonFile(packageJsonPath);
117
+ if (!await pathExists(packageJsonPath)) {
118
+ return void 0;
119
+ }
120
+ const packageJson = await readPackageJson(packageJsonPath);
100
121
  const readmePath = path.join(absolutePath, "README.md");
101
122
  const changelogPath = path.join(absolutePath, "CHANGELOG.md");
123
+ const sourceRoot = await pathExists(path.join(absolutePath, "src")) ? absolutePath : void 0;
124
+ const cliPath = id === "weapp-vite" ? await pathExists(path.join(absolutePath, "bin", "weapp-vite.js")) ? path.join(absolutePath, "bin", "weapp-vite.js") : void 0 : void 0;
102
125
  return {
103
126
  id,
104
127
  label: config.label,
105
- packageName: packageJson.name ?? config.label,
128
+ packageName: packageJson.name ?? config.packageName,
106
129
  version: packageJson.version ?? "0.0.0",
107
130
  absolutePath,
108
131
  relativePath: config.relativePath,
@@ -110,14 +133,73 @@ async function loadPackageSummary(workspaceRoot, id) {
110
133
  docs: {
111
134
  readme: await pathExists(readmePath) ? readmePath : void 0,
112
135
  changelog: await pathExists(changelogPath) ? changelogPath : void 0
136
+ },
137
+ sourceRoot,
138
+ cliPath
139
+ };
140
+ }
141
+ async function resolveInstalledPackage(workspaceRoot, id) {
142
+ const config = EXPOSED_PACKAGES[id];
143
+ const workspaceRequire = createWorkspaceRequire(workspaceRoot);
144
+ let packageJsonPath;
145
+ try {
146
+ packageJsonPath = workspaceRequire.resolve(`${config.packageName}/package.json`);
147
+ } catch {
148
+ return void 0;
149
+ }
150
+ const absolutePath = path.dirname(packageJsonPath);
151
+ const relativePath = await toWorkspaceRelativePath(workspaceRoot, absolutePath);
152
+ const packageJson = await readPackageJson(packageJsonPath);
153
+ const docsRoot = path.join(absolutePath, "dist", "docs");
154
+ const installedReadmePath = path.join(docsRoot, "README.md");
155
+ const installedChangelogPath = path.join(docsRoot, "CHANGELOG.md");
156
+ const sourceRoot = await pathExists(path.join(absolutePath, "src")) ? absolutePath : void 0;
157
+ let cliPath;
158
+ if (id === "weapp-vite") {
159
+ const binEntry = typeof packageJson.bin === "string" ? packageJson.bin : packageJson.bin?.["weapp-vite"];
160
+ if (typeof binEntry === "string" && binEntry.trim()) {
161
+ const resolvedCliPath = path.resolve(absolutePath, binEntry);
162
+ if (await pathExists(resolvedCliPath)) {
163
+ cliPath = resolvedCliPath;
164
+ }
113
165
  }
166
+ }
167
+ return {
168
+ id,
169
+ label: config.label,
170
+ packageName: packageJson.name ?? config.packageName,
171
+ version: packageJson.version ?? "0.0.0",
172
+ absolutePath,
173
+ relativePath,
174
+ scripts: Object.keys(packageJson.scripts ?? {}),
175
+ docs: {
176
+ readme: await pathExists(installedReadmePath) ? installedReadmePath : void 0,
177
+ changelog: await pathExists(installedChangelogPath) ? installedChangelogPath : void 0
178
+ },
179
+ sourceRoot,
180
+ cliPath
114
181
  };
115
182
  }
116
- async function loadExposedCatalog(workspaceRoot) {
117
- const summaries = await Promise.all(
118
- Object.keys(EXPOSED_PACKAGES).map((id) => loadPackageSummary(workspaceRoot, id))
183
+ async function resolveExposedPackage(workspaceRoot, id) {
184
+ return await resolveMonorepoPackage(workspaceRoot, id) ?? await resolveInstalledPackage(workspaceRoot, id) ?? Promise.reject(new Error(`\u672A\u627E\u5230\u66B4\u9732\u5305\uFF1A${id}`));
185
+ }
186
+ async function resolveExposedPackages(workspaceRoot) {
187
+ const resolved = await Promise.allSettled(
188
+ Object.keys(EXPOSED_PACKAGES).map((id) => resolveExposedPackage(workspaceRoot, id))
119
189
  );
120
- return summaries.sort((a, b) => a.id.localeCompare(b.id));
190
+ return resolved.flatMap((result) => {
191
+ if (result.status === "fulfilled") {
192
+ return [result.value];
193
+ }
194
+ return [];
195
+ }).sort((a, b) => a.id.localeCompare(b.id));
196
+ }
197
+
198
+ async function loadPackageSummary(workspaceRoot, id) {
199
+ return resolveExposedPackage(workspaceRoot, id);
200
+ }
201
+ async function loadExposedCatalog(workspaceRoot) {
202
+ return resolveExposedPackages(workspaceRoot);
121
203
  }
122
204
 
123
205
  const ALLOWED_COMMANDS = /* @__PURE__ */ new Set([
@@ -318,8 +400,12 @@ function toToolError(error) {
318
400
 
319
401
  const packageIds = Object.keys(EXPOSED_PACKAGES);
320
402
  const packageIdSchema = z.enum(packageIds);
321
- function resolvePackageRoot(workspaceRoot, packageId) {
322
- return assertInsideRoot(workspaceRoot, path.join(workspaceRoot, EXPOSED_PACKAGES[packageId].relativePath));
403
+ async function resolvePackageRoot(workspaceRoot, packageId) {
404
+ const resolved = await resolveExposedPackage(workspaceRoot, packageId);
405
+ if (!resolved.sourceRoot) {
406
+ throw new Error(`\u5F53\u524D\u5DE5\u4F5C\u533A\u4E2D\u7684 ${packageId} \u4E0D\u5305\u542B\u6E90\u7801\u76EE\u5F55\uFF0C\u8BF7\u6539\u4E3A\u4F18\u5148\u8BFB\u53D6\u672C\u5730\u968F\u5305\u6587\u6863\u3002`);
407
+ }
408
+ return assertInsideRoot(workspaceRoot, resolved.sourceRoot);
323
409
  }
324
410
  function toDocsUri(packageId, fileName) {
325
411
  return `weapp-vite://docs/${packageId}/${fileName}`;
@@ -327,6 +413,25 @@ function toDocsUri(packageId, fileName) {
327
413
  async function readTextFile(filePath) {
328
414
  return fs$1.readFile(filePath, "utf8");
329
415
  }
416
+ async function runWeappViteCliTool(workspaceRoot, input) {
417
+ const cliPath = (await resolveExposedPackage(workspaceRoot, "weapp-vite")).cliPath;
418
+ if (!cliPath) {
419
+ throw new Error("\u5F53\u524D\u5DE5\u4F5C\u533A\u4E2D\u7684 weapp-vite \u672A\u66B4\u9732 CLI \u5165\u53E3");
420
+ }
421
+ const finalArgs = [cliPath, input.subCommand];
422
+ if (input.projectPath) {
423
+ finalArgs.push(resolveSubPath(workspaceRoot, input.projectPath));
424
+ }
425
+ if (input.platform) {
426
+ finalArgs.push("--platform", input.platform);
427
+ }
428
+ if (Array.isArray(input.args) && input.args.length > 0) {
429
+ finalArgs.push(...input.args);
430
+ }
431
+ return runCommand(workspaceRoot, "node", finalArgs, {
432
+ timeoutMs: input.timeoutMs ?? DEFAULT_TIMEOUT_MS
433
+ });
434
+ }
330
435
  async function createWeappViteMcpServer(options) {
331
436
  const workspaceRoot = resolveWorkspaceRoot(options?.workspaceRoot);
332
437
  const server = new McpServer({
@@ -357,7 +462,7 @@ async function createWeappViteMcpServer(options) {
357
462
  }
358
463
  }, async ({ packageId, directory, maxResults }) => {
359
464
  try {
360
- const packageRoot = resolvePackageRoot(workspaceRoot, packageId);
465
+ const packageRoot = await resolvePackageRoot(workspaceRoot, packageId);
361
466
  const files = await listFilesInDirectory(packageRoot, directory ?? "src", maxResults ?? DEFAULT_MAX_RESULTS);
362
467
  return toToolResult({
363
468
  packageId,
@@ -381,7 +486,7 @@ async function createWeappViteMcpServer(options) {
381
486
  }
382
487
  }, async ({ packageId, filePath, startLine, endLine, maxChars }) => {
383
488
  try {
384
- const packageRoot = resolvePackageRoot(workspaceRoot, packageId);
489
+ const packageRoot = await resolvePackageRoot(workspaceRoot, packageId);
385
490
  const { filePath: absolutePath, content } = await readFileContent(packageRoot, filePath, {
386
491
  startLine,
387
492
  endLine,
@@ -417,7 +522,7 @@ async function createWeappViteMcpServer(options) {
417
522
  if (allMatches.length >= safeMax) {
418
523
  break;
419
524
  }
420
- const packageRoot = resolvePackageRoot(workspaceRoot, id);
525
+ const packageRoot = await resolvePackageRoot(workspaceRoot, id);
421
526
  const matches = await searchTextInDirectory(packageRoot, query, {
422
527
  relativeDirectory: directory ?? "src",
423
528
  maxResults: safeMax - allMatches.length
@@ -447,9 +552,9 @@ async function createWeappViteMcpServer(options) {
447
552
  }
448
553
  }, async ({ packageId, script, args, timeoutMs }) => {
449
554
  try {
450
- const cwdRelative = EXPOSED_PACKAGES[packageId].relativePath;
555
+ const resolvedPackage = await resolveExposedPackage(workspaceRoot, packageId);
451
556
  const result = await runCommand(workspaceRoot, "pnpm", ["run", script, ...args ?? []], {
452
- cwdRelative,
557
+ cwdRelative: resolvedPackage.relativePath,
453
558
  timeoutMs: timeoutMs ?? DEFAULT_TIMEOUT_MS
454
559
  });
455
560
  return toToolResult(result);
@@ -469,21 +574,103 @@ async function createWeappViteMcpServer(options) {
469
574
  }
470
575
  }, async ({ subCommand, projectPath, platform, args, timeoutMs }) => {
471
576
  try {
472
- const cliPath = path.join("packages", "weapp-vite", "bin", "weapp-vite.js");
473
- const finalArgs = [cliPath, subCommand];
474
- if (projectPath) {
475
- finalArgs.push(resolveSubPath(workspaceRoot, projectPath));
577
+ const result = await runWeappViteCliTool(workspaceRoot, {
578
+ subCommand,
579
+ projectPath,
580
+ platform,
581
+ args,
582
+ timeoutMs
583
+ });
584
+ return toToolResult(result);
585
+ } catch (error) {
586
+ return toToolError(error);
587
+ }
588
+ });
589
+ server.registerTool("take_weapp_screenshot", {
590
+ title: "Take Weapp Screenshot",
591
+ description: "\u5F53\u7528\u6237\u63D0\u5230\u622A\u56FE\u3001\u9875\u9762\u5FEB\u7167\u3001\u8FD0\u884C\u65F6\u622A\u56FE\u65F6\uFF0C\u4F18\u5148\u8C03\u7528\u6B64\u5DE5\u5177\u6267\u884C weapp-vite screenshot",
592
+ inputSchema: {
593
+ projectPath: z.string().describe("\u76F8\u5BF9 workspace \u6839\u8DEF\u5F84\uFF0C\u901A\u5E38\u662F dist/build/mp-weixin \u6216\u5177\u4F53\u5C0F\u7A0B\u5E8F\u9879\u76EE\u76EE\u5F55"),
594
+ page: z.string().optional().describe("\u622A\u56FE\u524D\u5148\u8DF3\u8F6C\u7684\u5C0F\u7A0B\u5E8F\u9875\u9762\u8DEF\u5F84"),
595
+ outputPath: z.string().optional().describe("\u622A\u56FE\u8F93\u51FA\u8DEF\u5F84\uFF0C\u5EFA\u8BAE\u5199\u5165 .tmp/ \u6216\u5DE5\u4F5C\u533A\u76F8\u5BF9\u8DEF\u5F84"),
596
+ timeoutMs: z.number().int().positive().max(9e5).optional()
597
+ }
598
+ }, async ({ projectPath, page, outputPath, timeoutMs }) => {
599
+ try {
600
+ const args = ["--json"];
601
+ if (page) {
602
+ args.push("--page", page);
476
603
  }
477
- if (platform) {
478
- finalArgs.push("--platform", platform);
604
+ if (outputPath) {
605
+ args.push("--output", outputPath);
479
606
  }
480
- if (Array.isArray(args) && args.length > 0) {
481
- finalArgs.push(...args);
607
+ const result = await runWeappViteCliTool(workspaceRoot, {
608
+ subCommand: "screenshot",
609
+ projectPath,
610
+ args,
611
+ timeoutMs
612
+ });
613
+ return toToolResult({
614
+ ...result,
615
+ projectPath,
616
+ page: page ?? null,
617
+ outputPath: outputPath ?? null,
618
+ recommendedIntent: "screenshot"
619
+ });
620
+ } catch (error) {
621
+ return toToolError(error);
622
+ }
623
+ });
624
+ server.registerTool("compare_weapp_screenshot", {
625
+ title: "Compare Weapp Screenshot",
626
+ description: "\u5F53\u7528\u6237\u63D0\u5230\u622A\u56FE\u5BF9\u6BD4\u3001diff\u3001baseline\u3001\u89C6\u89C9\u56DE\u5F52\u3001\u50CF\u7D20\u5BF9\u6BD4\u65F6\uFF0C\u4F18\u5148\u8C03\u7528\u6B64\u5DE5\u5177\u6267\u884C weapp-vite compare",
627
+ inputSchema: {
628
+ projectPath: z.string().describe("\u76F8\u5BF9 workspace \u6839\u8DEF\u5F84\uFF0C\u901A\u5E38\u662F dist/build/mp-weixin \u6216\u5177\u4F53\u5C0F\u7A0B\u5E8F\u9879\u76EE\u76EE\u5F55"),
629
+ baselinePath: z.string().describe("\u76F8\u5BF9 workspace \u6839\u8DEF\u5F84\u7684 baseline \u56FE\u7247\u8DEF\u5F84"),
630
+ page: z.string().optional().describe("\u622A\u56FE\u5BF9\u6BD4\u524D\u5148\u8DF3\u8F6C\u7684\u5C0F\u7A0B\u5E8F\u9875\u9762\u8DEF\u5F84"),
631
+ currentOutputPath: z.string().optional().describe("\u5F53\u524D\u622A\u56FE\u8F93\u51FA\u8DEF\u5F84"),
632
+ diffOutputPath: z.string().optional().describe("diff \u56FE\u7247\u8F93\u51FA\u8DEF\u5F84"),
633
+ threshold: z.number().min(0).max(1).optional(),
634
+ maxDiffPixels: z.number().int().min(0).optional(),
635
+ maxDiffRatio: z.number().min(0).max(1).optional(),
636
+ timeoutMs: z.number().int().positive().max(9e5).optional()
637
+ }
638
+ }, async ({ projectPath, baselinePath, page, currentOutputPath, diffOutputPath, threshold, maxDiffPixels, maxDiffRatio, timeoutMs }) => {
639
+ try {
640
+ const args = ["--json", "--baseline", baselinePath];
641
+ if (page) {
642
+ args.push("--page", page);
482
643
  }
483
- const result = await runCommand(workspaceRoot, "node", finalArgs, {
484
- timeoutMs: timeoutMs ?? DEFAULT_TIMEOUT_MS
644
+ if (currentOutputPath) {
645
+ args.push("--current-output", currentOutputPath);
646
+ }
647
+ if (diffOutputPath) {
648
+ args.push("--diff-output", diffOutputPath);
649
+ }
650
+ if (threshold != null) {
651
+ args.push("--threshold", String(threshold));
652
+ }
653
+ if (maxDiffPixels != null) {
654
+ args.push("--max-diff-pixels", String(maxDiffPixels));
655
+ }
656
+ if (maxDiffRatio != null) {
657
+ args.push("--max-diff-ratio", String(maxDiffRatio));
658
+ }
659
+ const result = await runWeappViteCliTool(workspaceRoot, {
660
+ subCommand: "compare",
661
+ projectPath,
662
+ args,
663
+ timeoutMs
664
+ });
665
+ return toToolResult({
666
+ ...result,
667
+ projectPath,
668
+ baselinePath,
669
+ page: page ?? null,
670
+ currentOutputPath: currentOutputPath ?? null,
671
+ diffOutputPath: diffOutputPath ?? null,
672
+ recommendedIntent: "compare"
485
673
  });
486
- return toToolResult(result);
487
674
  } catch (error) {
488
675
  return toToolError(error);
489
676
  }
@@ -575,7 +762,7 @@ async function createWeappViteMcpServer(options) {
575
762
  }]
576
763
  };
577
764
  });
578
- const catalog = await loadExposedCatalog(workspaceRoot);
765
+ const catalog = await resolveExposedPackages(workspaceRoot);
579
766
  for (const summary of catalog) {
580
767
  if (summary.docs.readme) {
581
768
  const uri = toDocsUri(summary.id, "README.md");
@@ -619,7 +806,7 @@ async function createWeappViteMcpServer(options) {
619
806
  throw new Error(`\u672A\u77E5 package\uFF1A${packageId}`);
620
807
  }
621
808
  const relativePath = decodeURIComponent(String(variables.path ?? ""));
622
- const packageRoot = resolvePackageRoot(workspaceRoot, packageId);
809
+ const packageRoot = await resolvePackageRoot(workspaceRoot, packageId);
623
810
  const { content } = await readFileContent(packageRoot, relativePath, {
624
811
  maxChars: DEFAULT_MAX_FILE_CHARS
625
812
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@weapp-vite/mcp",
3
3
  "type": "module",
4
- "version": "1.1.1",
4
+ "version": "1.2.0",
5
5
  "description": "mcp",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "ISC",
@@ -31,7 +31,7 @@
31
31
  "node": "^20.19.0 || >=22.12.0"
32
32
  },
33
33
  "dependencies": {
34
- "@modelcontextprotocol/sdk": "^1.27.1",
34
+ "@modelcontextprotocol/sdk": "^1.29.0",
35
35
  "zod": "^4.3.6"
36
36
  },
37
37
  "scripts": {