@mebular/mcp 0.2.0 → 0.2.1

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": "@mebular/mcp",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Mebular MCP server(stdio + Streamable HTTP):把 Mebular 记忆能力暴露给任意 MCP client",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -29,9 +29,9 @@
29
29
  "access": "public"
30
30
  },
31
31
  "dependencies": {
32
- "@mebular/core": "^0.2.0",
32
+ "@mebular/core": "^0.2.1",
33
33
  "@modelcontextprotocol/server": "^2.3.1",
34
34
  "zod": "^4.6.7",
35
- "@mebular/fleet": "^0.2.0"
35
+ "@mebular/fleet": "^0.2.1"
36
36
  }
37
37
  }
@@ -0,0 +1,22 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { dirname, join } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+
5
+ /**
6
+ * Resolve Console and locale assets for both the core-internal MCP and standalone @mebular/mcp layouts.
7
+ * @param moduleUrl serve.mjs 的 `import.meta.url`。
8
+ * @returns {{ consoleDir: string, localesDir: string }} console 与 locale pack 的绝对目录。
9
+ */
10
+ export function resolveStaticAssetRoots(moduleUrl) {
11
+ const directory = dirname(fileURLToPath(moduleUrl));
12
+ const consoleCandidate = join(directory, '..', '..', 'console');
13
+ const localesCandidate = join(directory, '..', '..', '..', 'locales');
14
+ return {
15
+ consoleDir: existsSync(consoleCandidate)
16
+ ? consoleCandidate
17
+ : join(directory, '..', '..', '..', '@mebular', 'core', 'packages', 'console'),
18
+ localesDir: existsSync(localesCandidate)
19
+ ? localesCandidate
20
+ : join(directory, '..', '..', '..', '@mebular', 'core', 'locales'),
21
+ };
22
+ }
@@ -470,15 +470,15 @@ export async function discoverRuntimeProviders({
470
470
  };
471
471
  }
472
472
 
473
- /** provider 启动命令:JS 入口用当前 Node 运行时;可执行文件直接执行。 */
474
- export function runtimeCommandForProvider(provider, { execPath = process.execPath } = {}) {
473
+ /** provider 启动命令:JS 入口用当前 Node 运行时;Windows 批处理经 shell;其他可执行文件直接执行。 */
474
+ export function runtimeCommandForProvider(provider, { execPath = process.execPath, platform = process.platform } = {}) {
475
475
  if (!provider || typeof provider.path !== 'string' || provider.path.length === 0) {
476
476
  throw cloudError('RUNTIME_PROVIDER_INVALID', '缺少可启动的 runtime provider');
477
477
  }
478
478
  if (/\.(mjs|cjs|js)$/i.test(provider.path)) {
479
- return { execPath, args: [provider.path, 'serve'] };
479
+ return { execPath, args: [provider.path, 'serve'], shell: false };
480
480
  }
481
- return { execPath: provider.path, args: ['serve'] };
481
+ return { execPath: provider.path, args: ['serve'], shell: platform === 'win32' && /\.(cmd|bat)$/i.test(provider.path) };
482
482
  }
483
483
 
484
484
  /** 默认 service 适配器:复用共享 service 层(current 优先);状态失败不阻塞 attach/provider 兜底。 */
package/src/serve.mjs CHANGED
@@ -20,6 +20,7 @@ import { READ_ROUTES, buildHandoffPlan } from './admin.mjs';
20
20
  import { configPath } from './config.mjs';
21
21
  import { createServiceFacade } from './service-facade.mjs';
22
22
  import { APP_VERSION } from './version.mjs';
23
+ import { resolveStaticAssetRoots } from './asset-roots.mjs';
23
24
 
24
25
  // 兼容既有导入方:APP_VERSION 的真源是 ./version.mjs。
25
26
  export { APP_VERSION } from './version.mjs';
@@ -229,12 +230,11 @@ export const EMBED_PROTOCOL = 1;
229
230
 
230
231
  // ---------- 控制台静态托管(D1) ----------
231
232
  // 路径白名单:只认识这几个确切文件名,天然防目录穿越。允许 MEBULAR_CONSOLE_DIR 覆盖。
232
- const CONSOLE_DIR =
233
- process.env.MEBULAR_CONSOLE_DIR ?? join(dirname(fileURLToPath(import.meta.url)), '..', '..', 'console');
233
+ const DEFAULT_ASSET_ROOTS = resolveStaticAssetRoots(import.meta.url);
234
+ const CONSOLE_DIR = process.env.MEBULAR_CONSOLE_DIR ?? DEFAULT_ASSET_ROOTS.consoleDir;
234
235
  // locale pack 数据层:唯一注册表 + 每语言目录(只读 JSON)。
235
236
  // 允许 MEBULAR_LOCALES_DIR 覆盖(桌面打包时 extraResources 落在 <resources>/locales)。
236
- const LOCALES_DIR =
237
- process.env.MEBULAR_LOCALES_DIR ?? join(dirname(fileURLToPath(import.meta.url)), '..', '..', '..', 'locales');
237
+ const LOCALES_DIR = process.env.MEBULAR_LOCALES_DIR ?? DEFAULT_ASSET_ROOTS.localesDir;
238
238
  const LOCALE_CODE_RE = /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/;
239
239
  const LOCALE_PACK_FILES = new Set(['console.json', 'desktop.json', 'errors.json']);
240
240
  const CONSOLE_FILES = {
@@ -53,6 +53,7 @@ export function serviceDescriptor({ home, execPath = process.execPath, extraArgs
53
53
  MEBULAR_RUNTIME_PROVIDER: 'cli',
54
54
  MEBULAR_RUNTIME_OWNER: 'cli',
55
55
  MEBULAR_RUNTIME_PATH: cliPath,
56
+ ELECTRON_RUN_AS_NODE: '1',
56
57
  },
57
58
  runtime: {
58
59
  version: null,
@@ -61,7 +62,7 @@ export function serviceDescriptor({ home, execPath = process.execPath, extraArgs
61
62
  provider: 'cli',
62
63
  owner: 'cli',
63
64
  execPath,
64
- electron: false,
65
+ electron: Boolean(process.versions.electron),
65
66
  cloudRoot: typeof cloudRoot === 'string' && cloudRoot.length > 0 ? cloudRoot : null,
66
67
  home,
67
68
  },
package/src/version.mjs CHANGED
@@ -5,4 +5,4 @@
5
5
  // scripts/bump-version.mjs 只改这一处,scripts/verify-release-version.mjs
6
6
  // 校验它等于发布版本;不要在其它文件再写版本字面量。
7
7
 
8
- export const APP_VERSION = '0.2.0';
8
+ export const APP_VERSION = '0.2.1';