@mebular/mcp 0.1.0 → 0.1.2
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 +3 -3
- package/scripts/publish-manifest.mjs +7 -6
- package/src/client.mjs +3 -1
- package/src/serve.mjs +5 -2
- package/src/server.mjs +2 -1
- package/src/version.mjs +8 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mebular/mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Mebular MCP server(stdio + Streamable HTTP):把 Mebular 记忆能力暴露给任意 MCP client",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@mebular/core": "^0.1.
|
|
27
|
+
"@mebular/core": "^0.1.2",
|
|
28
28
|
"@modelcontextprotocol/server": "^2.3.1",
|
|
29
29
|
"zod": "^4.6.7",
|
|
30
|
-
"@mebular/fleet": "^0.1.
|
|
30
|
+
"@mebular/fleet": "^0.1.2"
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
//
|
|
2
|
+
// 發布期改寫 @mebular/core / @mebular/fleet 依賴。
|
|
3
3
|
//
|
|
4
4
|
// 開發期以 `file:../..` 本地連結(根包非 workspace 成員、本環境 npm 不支援 `workspace:`);
|
|
5
|
-
// `npm pack`/`npm publish` 的 prepack 階段改為
|
|
5
|
+
// `npm pack`/`npm publish` 的 prepack 階段改為 `^<本包 package.json version>`,postpack 還原。
|
|
6
|
+
// 版本區間從 package.json 讀取,不在腳本內硬編碼;升級版本只需跑 scripts/bump_version.sh。
|
|
6
7
|
//
|
|
7
8
|
// 用法:node scripts/publish-manifest.mjs set|restore
|
|
8
9
|
|
|
@@ -14,7 +15,6 @@ import { fileURLToPath } from 'node:url';
|
|
|
14
15
|
const pkgDir = join(dirname(fileURLToPath(import.meta.url)), '..');
|
|
15
16
|
const pkgFile = join(pkgDir, 'package.json');
|
|
16
17
|
const backupFile = `${pkgFile}.packbak`;
|
|
17
|
-
const PUBLISH_RANGE = '^0.1.0';
|
|
18
18
|
|
|
19
19
|
const action = process.argv[2];
|
|
20
20
|
|
|
@@ -24,15 +24,16 @@ async function writeJson(file, data) {
|
|
|
24
24
|
|
|
25
25
|
if (action === 'set') {
|
|
26
26
|
const original = await readFile(pkgFile, 'utf-8');
|
|
27
|
-
if (!existsSync(backupFile)) await writeFile(backupFile, original, 'utf-8');
|
|
28
27
|
const pkg = JSON.parse(original);
|
|
28
|
+
const publishRange = `^${pkg.version}`;
|
|
29
|
+
if (!existsSync(backupFile)) await writeFile(backupFile, original, 'utf-8');
|
|
29
30
|
pkg.dependencies = pkg.dependencies ?? {};
|
|
30
31
|
// F-UNI:統一入口复用 fleet 的任務 handler/令牌原語 → 發布時一併宣告
|
|
31
32
|
for (const dep of ['@mebular/core', '@mebular/fleet']) {
|
|
32
|
-
if (pkg.dependencies[dep] !== undefined) pkg.dependencies[dep] =
|
|
33
|
+
if (pkg.dependencies[dep] !== undefined) pkg.dependencies[dep] = publishRange;
|
|
33
34
|
}
|
|
34
35
|
await writeJson(pkgFile, pkg);
|
|
35
|
-
console.error(`[publish-manifest] @mebular/{core,fleet} -> ${
|
|
36
|
+
console.error(`[publish-manifest] @mebular/{core,fleet} -> ${publishRange}(備份 ${backupFile})`);
|
|
36
37
|
} else if (action === 'restore') {
|
|
37
38
|
if (existsSync(backupFile)) {
|
|
38
39
|
await rename(backupFile, pkgFile);
|
package/src/client.mjs
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
// 仅覆盖 CLI 所需:initialize → notifications/initialized → tools/call。
|
|
4
4
|
// 复用既有 bearer token 体系(`mebular token`)。
|
|
5
5
|
|
|
6
|
+
import { APP_VERSION } from './version.mjs';
|
|
7
|
+
|
|
6
8
|
async function rpc(endpoint, token, message, sessionId, timeoutMs) {
|
|
7
9
|
const controller = new AbortController();
|
|
8
10
|
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
@@ -39,7 +41,7 @@ export async function callToolViaHttp({ endpoint, token, name, args, timeoutMs =
|
|
|
39
41
|
jsonrpc: '2.0',
|
|
40
42
|
id: 1,
|
|
41
43
|
method: 'initialize',
|
|
42
|
-
params: { protocolVersion: '2024-11-05', capabilities: {}, clientInfo: { name: 'mebular-cli', version:
|
|
44
|
+
params: { protocolVersion: '2024-11-05', capabilities: {}, clientInfo: { name: 'mebular-cli', version: APP_VERSION } },
|
|
43
45
|
}, null, timeoutMs);
|
|
44
46
|
const sessionId = init.sessionId;
|
|
45
47
|
await rpc(url, token, { jsonrpc: '2.0', method: 'notifications/initialized' }, sessionId, timeoutMs);
|
package/src/serve.mjs
CHANGED
|
@@ -19,6 +19,10 @@ import { attachFleetEvents, resolveFleetNamespace } from './fleet-events.mjs';
|
|
|
19
19
|
import { READ_ROUTES, buildHandoffPlan } from './admin.mjs';
|
|
20
20
|
import { configPath } from './config.mjs';
|
|
21
21
|
import { createServiceFacade } from './service-facade.mjs';
|
|
22
|
+
import { APP_VERSION } from './version.mjs';
|
|
23
|
+
|
|
24
|
+
// 兼容既有导入方:APP_VERSION 的真源是 ./version.mjs。
|
|
25
|
+
export { APP_VERSION } from './version.mjs';
|
|
22
26
|
|
|
23
27
|
// ---------- 控制台配置写入(schema 驱动:editable 可写 / status-only 只读 / internal 默认不可写) ----------
|
|
24
28
|
// 单一真源:packages/mcp/src/config-schema.mjs。写入策略(原子写 + .bak 备份;全部需重启生效):
|
|
@@ -220,8 +224,7 @@ function settleWithin(promise, ms) {
|
|
|
220
224
|
}
|
|
221
225
|
|
|
222
226
|
// /healthz、/app/embed/info 与 <home>/runtime.json 共用的对外版本号与 embed 协议版本。
|
|
223
|
-
//
|
|
224
|
-
export const APP_VERSION = '0.1.0';
|
|
227
|
+
// APP_VERSION 的唯一真源是 ./version.mjs;不要在 buildEmbedInfo / runtime 写入处再写字面量。
|
|
225
228
|
export const EMBED_PROTOCOL = 1;
|
|
226
229
|
|
|
227
230
|
// ---------- 控制台静态托管(D1) ----------
|
package/src/server.mjs
CHANGED
|
@@ -10,6 +10,7 @@ import { MemoryService } from '@mebular/core';
|
|
|
10
10
|
import { createMebular, homeDir, loadConfigFile } from './config.mjs';
|
|
11
11
|
import { registerTools } from './tools.mjs';
|
|
12
12
|
import { startHttpServer, acquireLock, pidAlive } from './serve.mjs';
|
|
13
|
+
import { APP_VERSION } from './version.mjs';
|
|
13
14
|
import { createJoinServer } from './jointoken.mjs';
|
|
14
15
|
import { clearApplyPending, readApplyPending, writeApplyResult, writeServeReady } from './config-apply.mjs';
|
|
15
16
|
import { buildSettings } from './admin.mjs';
|
|
@@ -26,7 +27,7 @@ const MEMORY_POLICY = `# Mebular 记忆使用规约(memory_policy)
|
|
|
26
27
|
6. 无结果别编:召回为空就如实说明,不要臆造记忆。`;
|
|
27
28
|
|
|
28
29
|
export function buildServer(service, options = {}) {
|
|
29
|
-
const server = new McpServer({ name: 'mebular', version:
|
|
30
|
+
const server = new McpServer({ name: 'mebular', version: APP_VERSION });
|
|
30
31
|
registerTools(server, service, options);
|
|
31
32
|
server.registerPrompt(
|
|
32
33
|
'memory_policy',
|
package/src/version.mjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// MCP 包对外报告的版本号唯一真源。
|
|
2
|
+
//
|
|
3
|
+
// serve.mjs 的 /healthz、/app/embed/info、runtime.json,server.mjs 的 MCP server
|
|
4
|
+
// 元数据,client.mjs 的 clientInfo 都从这里读取。发布脚本
|
|
5
|
+
// scripts/bump-version.mjs 只改这一处,scripts/verify-release-version.mjs
|
|
6
|
+
// 校验它等于发布版本;不要在其它文件再写版本字面量。
|
|
7
|
+
|
|
8
|
+
export const APP_VERSION = '0.1.2';
|