mes-mcp 0.3.3 → 0.3.4

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.
@@ -29,6 +29,7 @@ export class MesAgentApiClient {
29
29
  // 动作目录缓存最近成功刷新时间;驱动每日首用/TTL 自动刷新,并对外报告。
30
30
  // undefined 且 promise 存在 = 拉取在途(并发复用同一 promise,避免重复请求)。
31
31
  businessActionsFetchedAt;
32
+ businessActionsVersion = 0;
32
33
  constructor(config) {
33
34
  this.config = config;
34
35
  }
@@ -82,6 +83,7 @@ export class MesAgentApiClient {
82
83
  this.businessActionsPromise = this.fetchBusinessActions()
83
84
  .then((actions) => {
84
85
  this.businessActionsFetchedAt = new Date();
86
+ this.businessActionsVersion += 1;
85
87
  return actions;
86
88
  })
87
89
  .catch((error) => {
@@ -111,6 +113,10 @@ export class MesAgentApiClient {
111
113
  ? this.businessActionsFetchedAt.toISOString()
112
114
  : null;
113
115
  }
116
+ /** 动作目录缓存版本;每次成功刷新递增,用于让下游检索索引失效。 */
117
+ businessActionsCatalogVersion() {
118
+ return this.businessActionsVersion;
119
+ }
114
120
  async getBusinessAction(actionCode) {
115
121
  const actions = await this.listBusinessActions();
116
122
  const cached = actions.find((action) => action.actionCode === actionCode);
@@ -19,16 +19,30 @@ export class ActionSearchService {
19
19
  this.client.listBusinessActions(),
20
20
  createEmbeddingProvider(this.mode),
21
21
  ]);
22
- return new ActionSearchIndex(actions, provider);
22
+ return {
23
+ index: new ActionSearchIndex(actions, provider),
24
+ version: this.client.businessActionsCatalogVersion(),
25
+ };
23
26
  }
24
- async search(query, options) {
27
+ async getIndex() {
25
28
  if (!this.indexPromise) {
26
29
  this.indexPromise = this.buildIndex().catch((error) => {
27
30
  this.indexPromise = undefined;
28
31
  throw error;
29
32
  });
30
33
  }
31
- const index = await this.indexPromise;
34
+ let indexed = await this.indexPromise;
35
+ if (indexed.version !== this.client.businessActionsCatalogVersion()) {
36
+ this.indexPromise = this.buildIndex().catch((error) => {
37
+ this.indexPromise = undefined;
38
+ throw error;
39
+ });
40
+ indexed = await this.indexPromise;
41
+ }
42
+ return indexed.index;
43
+ }
44
+ async search(query, options) {
45
+ const index = await this.getIndex();
32
46
  const results = await index.search(query, options);
33
47
  return { total: index.size, results };
34
48
  }
@@ -275,6 +275,8 @@ function registerGenericActionTools(server, client, searchService) {
275
275
  return formatToolResult({
276
276
  query: keyword || null,
277
277
  ranked: Boolean(keyword),
278
+ catalogVersion: client.businessActionsCatalogVersion(),
279
+ refreshedAt: client.businessActionsRefreshedAt(),
278
280
  total,
279
281
  returned: results.length,
280
282
  list: results.map((r) => listActionView(r.action, r.score)),
@@ -334,6 +336,7 @@ function registerGenericActionTools(server, client, searchService) {
334
336
  }));
335
337
  return formatToolResult({
336
338
  refreshedAt: client.businessActionsRefreshedAt(),
339
+ catalogVersion: client.businessActionsCatalogVersion(),
337
340
  total: filtered.length,
338
341
  moduleCount: modules.length,
339
342
  filteredModule: moduleFilter ?? null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mes-mcp",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "type": "module",
5
5
  "description": "MES MCP adapter for Marvis and AI agents",
6
6
  "license": "UNLICENSED",