@lark-apaas/nestjs-mcp 0.1.2 → 0.1.3-beta.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/dist/chunk-CFHAFLNN.cjs +161 -0
- package/dist/chunk-CFHAFLNN.cjs.map +1 -0
- package/dist/chunk-GGRPUFD7.js +161 -0
- package/dist/chunk-GGRPUFD7.js.map +1 -0
- package/dist/index.cjs +357 -1201
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +101 -896
- package/dist/index.js.map +1 -1
- package/dist/protocol-runtime-EKXYSMME.js +723 -0
- package/dist/protocol-runtime-EKXYSMME.js.map +1 -0
- package/dist/protocol-runtime-RR5RVY4P.cjs +723 -0
- package/dist/protocol-runtime-RR5RVY4P.cjs.map +1 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,104 +1,39 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
|
|
31
|
-
// src/index.ts
|
|
32
|
-
var src_exports = {};
|
|
33
|
-
__export(src_exports, {
|
|
34
|
-
MCP_APP_REVISION_META_KEY: () => MCP_APP_REVISION_META_KEY,
|
|
35
|
-
MCP_APP_REVISION_MISMATCH: () => MCP_APP_REVISION_MISMATCH,
|
|
36
|
-
MCP_CONTROLLER_PATH: () => MCP_CONTROLLER_PATH,
|
|
37
|
-
MCP_DEFAULT_SERVER_NAME: () => MCP_DEFAULT_SERVER_NAME,
|
|
38
|
-
MCP_DEFAULT_SERVER_VERSION: () => MCP_DEFAULT_SERVER_VERSION,
|
|
39
|
-
MCP_ENDPOINT_PATH: () => MCP_ENDPOINT_PATH,
|
|
40
|
-
MCP_MANIFEST_VERSION: () => MCP_MANIFEST_VERSION,
|
|
41
|
-
MCP_MODULE_OPTIONS: () => MCP_MODULE_OPTIONS,
|
|
42
|
-
MCP_SKILLS_PATH: () => MCP_SKILLS_PATH,
|
|
43
|
-
MCP_TOOLS_METADATA_KEY: () => MCP_TOOLS_METADATA_KEY,
|
|
44
|
-
MCP_TOOL_METADATA_KEY: () => MCP_TOOL_METADATA_KEY,
|
|
45
|
-
MCP_TOOL_NAME_PATTERN: () => MCP_TOOL_NAME_PATTERN,
|
|
46
|
-
MCP_UI_DIST_DIR: () => MCP_UI_DIST_DIR,
|
|
47
|
-
MCP_UI_RESOURCE_METADATA_KEY: () => MCP_UI_RESOURCE_METADATA_KEY,
|
|
48
|
-
MCP_UI_RESOURCE_SCHEME: () => MCP_UI_RESOURCE_SCHEME,
|
|
49
|
-
McpModule: () => McpModule,
|
|
50
|
-
McpTool: () => McpTool,
|
|
51
|
-
McpToolError: () => McpToolError,
|
|
52
|
-
McpTools: () => McpTools,
|
|
53
|
-
McpUiResource: () => McpUiResource,
|
|
54
|
-
readMcpUiTemplate: () => readMcpUiTemplate
|
|
55
|
-
});
|
|
56
|
-
module.exports = __toCommonJS(src_exports);
|
|
57
|
-
|
|
58
|
-
// src/constants.ts
|
|
59
|
-
var MCP_ENDPOINT_PATH = "/__innerapi__/mcp";
|
|
60
|
-
var MCP_CONTROLLER_PATH = "__innerapi__/mcp";
|
|
61
|
-
var MCP_UI_DIST_DIR = "dist/mcp-ui";
|
|
62
|
-
var MCP_UI_RESOURCE_SCHEME = "ui://";
|
|
63
|
-
var MCP_TOOLS_METADATA_KEY = "mcp:tools";
|
|
64
|
-
var MCP_TOOL_METADATA_KEY = "mcp:tool";
|
|
65
|
-
var MCP_UI_RESOURCE_METADATA_KEY = "mcp:ui-resource";
|
|
66
|
-
var MCP_MODULE_OPTIONS = /* @__PURE__ */ Symbol("MCP_MODULE_OPTIONS");
|
|
67
|
-
var MCP_DEFAULT_SERVER_NAME = "miaoda-app";
|
|
68
|
-
var MCP_DEFAULT_SERVER_VERSION = "1.0.0";
|
|
69
|
-
var MCP_MANIFEST_VERSION = 3;
|
|
70
|
-
var MCP_TOOL_NAME_PATTERN = /^[A-Za-z0-9_.-]{1,128}$/;
|
|
71
|
-
var MCP_SKILLS_PATH = "server/mcp/skills";
|
|
72
|
-
|
|
73
|
-
// src/errors.ts
|
|
74
|
-
var McpToolError = class extends Error {
|
|
75
|
-
static {
|
|
76
|
-
__name(this, "McpToolError");
|
|
77
|
-
}
|
|
78
|
-
/** 可选的机器可读错误码,会一并放入返回内容 */
|
|
79
|
-
code;
|
|
80
|
-
/** 附加数据,会以 JSON 形式放入返回内容 */
|
|
81
|
-
data;
|
|
82
|
-
constructor(message, options = {}) {
|
|
83
|
-
super(message);
|
|
84
|
-
this.name = "McpToolError";
|
|
85
|
-
this.code = options.code;
|
|
86
|
-
this.data = options.data;
|
|
87
|
-
}
|
|
88
|
-
};
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5;
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
var _chunkCFHAFLNNcjs = require('./chunk-CFHAFLNN.cjs');
|
|
89
24
|
|
|
90
25
|
// src/decorators/mcp-tools.decorator.ts
|
|
91
|
-
var
|
|
92
|
-
var McpTools = /* @__PURE__ */ __name((options = {}) => {
|
|
26
|
+
var _common = require('@nestjs/common');
|
|
27
|
+
var McpTools = /* @__PURE__ */ _chunkCFHAFLNNcjs.__name.call(void 0, (options = {}) => {
|
|
93
28
|
return (target) => {
|
|
94
|
-
(0,
|
|
95
|
-
(0,
|
|
29
|
+
_common.Injectable.call(void 0, )(target);
|
|
30
|
+
_common.SetMetadata.call(void 0, _chunkCFHAFLNNcjs.MCP_TOOLS_METADATA_KEY, options)(target);
|
|
96
31
|
return target;
|
|
97
32
|
};
|
|
98
33
|
}, "McpTools");
|
|
99
34
|
|
|
100
35
|
// src/decorators/mcp-tool.decorator.ts
|
|
101
|
-
|
|
36
|
+
|
|
102
37
|
function McpTool(options) {
|
|
103
38
|
return (target, propertyKey, descriptor) => {
|
|
104
39
|
if (typeof propertyKey !== "string") {
|
|
@@ -107,38 +42,37 @@ function McpTool(options) {
|
|
|
107
42
|
if (!options || typeof options.description !== "string" || options.description.trim() === "") {
|
|
108
43
|
throw new TypeError(`@McpTool() \u4E8E ${target.constructor.name}.${propertyKey}\uFF1Adescription \u4E3A\u5FC5\u586B\u9879`);
|
|
109
44
|
}
|
|
110
|
-
(0,
|
|
45
|
+
_common.SetMetadata.call(void 0, _chunkCFHAFLNNcjs.MCP_TOOL_METADATA_KEY, options)(target, propertyKey, descriptor);
|
|
111
46
|
};
|
|
112
47
|
}
|
|
113
|
-
__name(McpTool, "McpTool");
|
|
48
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, McpTool, "McpTool");
|
|
114
49
|
|
|
115
50
|
// src/decorators/mcp-ui-resource.decorator.ts
|
|
116
|
-
|
|
51
|
+
|
|
117
52
|
function McpUiResource(options) {
|
|
118
53
|
return (target, propertyKey, descriptor) => {
|
|
119
54
|
if (typeof propertyKey !== "string") {
|
|
120
55
|
throw new TypeError("@McpUiResource() \u53EA\u80FD\u7528\u4E8E\u5177\u540D\u65B9\u6CD5");
|
|
121
56
|
}
|
|
122
|
-
if (!options
|
|
123
|
-
throw new TypeError(`@McpUiResource() \u4E8E ${target.constructor.name}.${propertyKey}\uFF1Auri \u5FC5\u987B\u4EE5 ${MCP_UI_RESOURCE_SCHEME} \u5F00\u5934`);
|
|
57
|
+
if (!_optionalChain([options, 'optionalAccess', _ => _.uri]) || !options.uri.startsWith(_chunkCFHAFLNNcjs.MCP_UI_RESOURCE_SCHEME)) {
|
|
58
|
+
throw new TypeError(`@McpUiResource() \u4E8E ${target.constructor.name}.${propertyKey}\uFF1Auri \u5FC5\u987B\u4EE5 ${_chunkCFHAFLNNcjs.MCP_UI_RESOURCE_SCHEME} \u5F00\u5934`);
|
|
124
59
|
}
|
|
125
|
-
(0,
|
|
60
|
+
_common.SetMetadata.call(void 0, _chunkCFHAFLNNcjs.MCP_UI_RESOURCE_METADATA_KEY, options)(target, propertyKey, descriptor);
|
|
126
61
|
};
|
|
127
62
|
}
|
|
128
|
-
__name(McpUiResource, "McpUiResource");
|
|
63
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, McpUiResource, "McpUiResource");
|
|
129
64
|
|
|
130
65
|
// src/mcp.module.ts
|
|
131
|
-
|
|
132
|
-
var
|
|
66
|
+
|
|
67
|
+
var _core = require('@nestjs/core');
|
|
133
68
|
|
|
134
69
|
// src/controllers/mcp-manifest.controller.ts
|
|
135
|
-
|
|
136
|
-
var
|
|
70
|
+
|
|
71
|
+
var _swagger = require('@nestjs/swagger');
|
|
137
72
|
|
|
138
73
|
// src/request-log.ts
|
|
139
|
-
var
|
|
140
|
-
|
|
141
|
-
var import_types = require("@modelcontextprotocol/sdk/types.js");
|
|
74
|
+
var _async_hooks = require('async_hooks');
|
|
75
|
+
|
|
142
76
|
var MCP_LOG_ATTRIBUTES = {
|
|
143
77
|
source_type: "platform",
|
|
144
78
|
paas_attributes_module: "mcp"
|
|
@@ -146,21 +80,21 @@ var MCP_LOG_ATTRIBUTES = {
|
|
|
146
80
|
function record(value) {
|
|
147
81
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
148
82
|
}
|
|
149
|
-
__name(record, "record");
|
|
83
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, record, "record");
|
|
150
84
|
function label(value) {
|
|
151
85
|
return typeof value === "string" ? value.slice(0, 256) : void 0;
|
|
152
86
|
}
|
|
153
|
-
__name(label, "label");
|
|
154
|
-
var McpRequestLog = class {
|
|
87
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, label, "label");
|
|
88
|
+
var McpRequestLog = (_class = class {
|
|
155
89
|
static {
|
|
156
|
-
__name(this, "McpRequestLog");
|
|
157
|
-
}
|
|
158
|
-
logger = new
|
|
159
|
-
started = performance.now()
|
|
160
|
-
|
|
161
|
-
failed = false
|
|
162
|
-
reported = false
|
|
163
|
-
constructor(req, res, operation = "rpc") {
|
|
90
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, this, "McpRequestLog");
|
|
91
|
+
}
|
|
92
|
+
__init() {this.logger = new (0, _common.Logger)("McpRequest")}
|
|
93
|
+
__init2() {this.started = performance.now()}
|
|
94
|
+
|
|
95
|
+
__init3() {this.failed = false}
|
|
96
|
+
__init4() {this.reported = false}
|
|
97
|
+
constructor(req, res, operation = "rpc") {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);
|
|
164
98
|
const body = operation === "rpc" ? record(req.body) : {};
|
|
165
99
|
const params = record(body.params);
|
|
166
100
|
this.fields = {
|
|
@@ -179,19 +113,19 @@ var McpRequestLog = class {
|
|
|
179
113
|
uri.search = "";
|
|
180
114
|
uri.hash = "";
|
|
181
115
|
this.fields.resource_uri = label(uri.href);
|
|
182
|
-
} catch {
|
|
116
|
+
} catch (e) {
|
|
183
117
|
}
|
|
184
118
|
}
|
|
185
|
-
res.once("finish",
|
|
186
|
-
res.once("close",
|
|
119
|
+
res.once("finish", _async_hooks.AsyncResource.bind(() => this.complete(res, false)));
|
|
120
|
+
res.once("close", _async_hooks.AsyncResource.bind(() => this.complete(res, !res.writableFinished)));
|
|
187
121
|
}
|
|
188
122
|
/** SDK 发出的协议结果;HTTP 200 也可能包含工具失败或 JSON-RPC 错误。 */
|
|
189
|
-
response(message) {
|
|
190
|
-
if (
|
|
123
|
+
response(message, { isJSONRPCErrorResponse, isJSONRPCResultResponse }) {
|
|
124
|
+
if (isJSONRPCErrorResponse(message)) {
|
|
191
125
|
this.failed = true;
|
|
192
126
|
this.fields.error_code = message.error.code;
|
|
193
127
|
this.fields.business_error_code = label(record(message.error.data).code);
|
|
194
|
-
} else if (
|
|
128
|
+
} else if (isJSONRPCResultResponse(message) && message.result.isError === true) {
|
|
195
129
|
this.failed = true;
|
|
196
130
|
this.fields.is_error = true;
|
|
197
131
|
this.fields.business_error_code = label(record(record(message.result._meta).error).code);
|
|
@@ -219,701 +153,38 @@ var McpRequestLog = class {
|
|
|
219
153
|
...fields,
|
|
220
154
|
...MCP_LOG_ATTRIBUTES
|
|
221
155
|
});
|
|
222
|
-
} catch {
|
|
156
|
+
} catch (e2) {
|
|
223
157
|
}
|
|
224
158
|
}
|
|
225
|
-
};
|
|
159
|
+
}, _class);
|
|
226
160
|
|
|
227
161
|
// src/services/mcp-manifest.service.ts
|
|
228
|
-
var import_common6 = require("@nestjs/common");
|
|
229
|
-
|
|
230
|
-
// src/manifest.ts
|
|
231
|
-
var import_client = require("@modelcontextprotocol/sdk/client/index.js");
|
|
232
|
-
var import_inMemory = require("@modelcontextprotocol/sdk/inMemory.js");
|
|
233
|
-
|
|
234
|
-
// src/server-factory.ts
|
|
235
|
-
var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
236
|
-
var import_types5 = require("@modelcontextprotocol/sdk/types.js");
|
|
237
|
-
|
|
238
|
-
// ../../../node_modules/@modelcontextprotocol/ext-apps/dist/src/server/index.js
|
|
239
|
-
var import_protocol = require("@modelcontextprotocol/sdk/shared/protocol.js");
|
|
240
|
-
var import_types2 = require("@modelcontextprotocol/sdk/types.js");
|
|
241
|
-
var import_protocol2 = require("@modelcontextprotocol/sdk/shared/protocol.js");
|
|
242
|
-
var import_types3 = require("@modelcontextprotocol/sdk/types.js");
|
|
243
|
-
var import_v4 = require("zod/v4");
|
|
244
|
-
var import_types4 = require("@modelcontextprotocol/sdk/types.js");
|
|
245
|
-
var import_v42 = require("zod/v4");
|
|
246
|
-
var r = ((Z) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(Z, {
|
|
247
|
-
get: /* @__PURE__ */ __name(($, J) => (typeof require < "u" ? require : $)[J], "get")
|
|
248
|
-
}) : Z)(function(Z) {
|
|
249
|
-
if (typeof require < "u") return require.apply(this, arguments);
|
|
250
|
-
throw Error('Dynamic require of "' + Z + '" is not supported');
|
|
251
|
-
});
|
|
252
|
-
var v = import_v4.z.union([
|
|
253
|
-
import_v4.z.literal("light"),
|
|
254
|
-
import_v4.z.literal("dark")
|
|
255
|
-
]).describe("Color theme preference for the host environment.");
|
|
256
|
-
var K = import_v4.z.union([
|
|
257
|
-
import_v4.z.literal("inline"),
|
|
258
|
-
import_v4.z.literal("fullscreen"),
|
|
259
|
-
import_v4.z.literal("pip")
|
|
260
|
-
]).describe("Display mode for UI presentation.");
|
|
261
|
-
var QQ = import_v4.z.union([
|
|
262
|
-
import_v4.z.literal("--color-background-primary"),
|
|
263
|
-
import_v4.z.literal("--color-background-secondary"),
|
|
264
|
-
import_v4.z.literal("--color-background-tertiary"),
|
|
265
|
-
import_v4.z.literal("--color-background-inverse"),
|
|
266
|
-
import_v4.z.literal("--color-background-ghost"),
|
|
267
|
-
import_v4.z.literal("--color-background-info"),
|
|
268
|
-
import_v4.z.literal("--color-background-danger"),
|
|
269
|
-
import_v4.z.literal("--color-background-success"),
|
|
270
|
-
import_v4.z.literal("--color-background-warning"),
|
|
271
|
-
import_v4.z.literal("--color-background-disabled"),
|
|
272
|
-
import_v4.z.literal("--color-text-primary"),
|
|
273
|
-
import_v4.z.literal("--color-text-secondary"),
|
|
274
|
-
import_v4.z.literal("--color-text-tertiary"),
|
|
275
|
-
import_v4.z.literal("--color-text-inverse"),
|
|
276
|
-
import_v4.z.literal("--color-text-ghost"),
|
|
277
|
-
import_v4.z.literal("--color-text-info"),
|
|
278
|
-
import_v4.z.literal("--color-text-danger"),
|
|
279
|
-
import_v4.z.literal("--color-text-success"),
|
|
280
|
-
import_v4.z.literal("--color-text-warning"),
|
|
281
|
-
import_v4.z.literal("--color-text-disabled"),
|
|
282
|
-
import_v4.z.literal("--color-border-primary"),
|
|
283
|
-
import_v4.z.literal("--color-border-secondary"),
|
|
284
|
-
import_v4.z.literal("--color-border-tertiary"),
|
|
285
|
-
import_v4.z.literal("--color-border-inverse"),
|
|
286
|
-
import_v4.z.literal("--color-border-ghost"),
|
|
287
|
-
import_v4.z.literal("--color-border-info"),
|
|
288
|
-
import_v4.z.literal("--color-border-danger"),
|
|
289
|
-
import_v4.z.literal("--color-border-success"),
|
|
290
|
-
import_v4.z.literal("--color-border-warning"),
|
|
291
|
-
import_v4.z.literal("--color-border-disabled"),
|
|
292
|
-
import_v4.z.literal("--color-ring-primary"),
|
|
293
|
-
import_v4.z.literal("--color-ring-secondary"),
|
|
294
|
-
import_v4.z.literal("--color-ring-inverse"),
|
|
295
|
-
import_v4.z.literal("--color-ring-info"),
|
|
296
|
-
import_v4.z.literal("--color-ring-danger"),
|
|
297
|
-
import_v4.z.literal("--color-ring-success"),
|
|
298
|
-
import_v4.z.literal("--color-ring-warning"),
|
|
299
|
-
import_v4.z.literal("--font-sans"),
|
|
300
|
-
import_v4.z.literal("--font-mono"),
|
|
301
|
-
import_v4.z.literal("--font-weight-normal"),
|
|
302
|
-
import_v4.z.literal("--font-weight-medium"),
|
|
303
|
-
import_v4.z.literal("--font-weight-semibold"),
|
|
304
|
-
import_v4.z.literal("--font-weight-bold"),
|
|
305
|
-
import_v4.z.literal("--font-text-xs-size"),
|
|
306
|
-
import_v4.z.literal("--font-text-sm-size"),
|
|
307
|
-
import_v4.z.literal("--font-text-md-size"),
|
|
308
|
-
import_v4.z.literal("--font-text-lg-size"),
|
|
309
|
-
import_v4.z.literal("--font-heading-xs-size"),
|
|
310
|
-
import_v4.z.literal("--font-heading-sm-size"),
|
|
311
|
-
import_v4.z.literal("--font-heading-md-size"),
|
|
312
|
-
import_v4.z.literal("--font-heading-lg-size"),
|
|
313
|
-
import_v4.z.literal("--font-heading-xl-size"),
|
|
314
|
-
import_v4.z.literal("--font-heading-2xl-size"),
|
|
315
|
-
import_v4.z.literal("--font-heading-3xl-size"),
|
|
316
|
-
import_v4.z.literal("--font-text-xs-line-height"),
|
|
317
|
-
import_v4.z.literal("--font-text-sm-line-height"),
|
|
318
|
-
import_v4.z.literal("--font-text-md-line-height"),
|
|
319
|
-
import_v4.z.literal("--font-text-lg-line-height"),
|
|
320
|
-
import_v4.z.literal("--font-heading-xs-line-height"),
|
|
321
|
-
import_v4.z.literal("--font-heading-sm-line-height"),
|
|
322
|
-
import_v4.z.literal("--font-heading-md-line-height"),
|
|
323
|
-
import_v4.z.literal("--font-heading-lg-line-height"),
|
|
324
|
-
import_v4.z.literal("--font-heading-xl-line-height"),
|
|
325
|
-
import_v4.z.literal("--font-heading-2xl-line-height"),
|
|
326
|
-
import_v4.z.literal("--font-heading-3xl-line-height"),
|
|
327
|
-
import_v4.z.literal("--border-radius-xs"),
|
|
328
|
-
import_v4.z.literal("--border-radius-sm"),
|
|
329
|
-
import_v4.z.literal("--border-radius-md"),
|
|
330
|
-
import_v4.z.literal("--border-radius-lg"),
|
|
331
|
-
import_v4.z.literal("--border-radius-xl"),
|
|
332
|
-
import_v4.z.literal("--border-radius-full"),
|
|
333
|
-
import_v4.z.literal("--border-width-regular"),
|
|
334
|
-
import_v4.z.literal("--shadow-hairline"),
|
|
335
|
-
import_v4.z.literal("--shadow-sm"),
|
|
336
|
-
import_v4.z.literal("--shadow-md"),
|
|
337
|
-
import_v4.z.literal("--shadow-lg")
|
|
338
|
-
]).describe("CSS variable keys available to MCP apps for theming.");
|
|
339
|
-
var ZQ = import_v4.z.record(QQ.describe(`Style variables for theming MCP apps.
|
|
340
|
-
|
|
341
|
-
Individual style keys are optional - hosts may provide any subset of these values.
|
|
342
|
-
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
343
|
-
|
|
344
|
-
Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
|
|
345
|
-
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`), import_v4.z.union([
|
|
346
|
-
import_v4.z.string(),
|
|
347
|
-
import_v4.z.undefined()
|
|
348
|
-
]).describe(`Style variables for theming MCP apps.
|
|
349
|
-
|
|
350
|
-
Individual style keys are optional - hosts may provide any subset of these values.
|
|
351
|
-
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
352
|
-
|
|
353
|
-
Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
|
|
354
|
-
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`)).describe(`Style variables for theming MCP apps.
|
|
355
|
-
|
|
356
|
-
Individual style keys are optional - hosts may provide any subset of these values.
|
|
357
|
-
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
358
|
-
|
|
359
|
-
Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
|
|
360
|
-
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`);
|
|
361
|
-
var $Q = import_v4.z.object({
|
|
362
|
-
method: import_v4.z.literal("ui/open-link"),
|
|
363
|
-
params: import_v4.z.object({
|
|
364
|
-
url: import_v4.z.string().describe("URL to open in the host's browser")
|
|
365
|
-
})
|
|
366
|
-
});
|
|
367
|
-
var I = import_v4.z.object({
|
|
368
|
-
isError: import_v4.z.boolean().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")
|
|
369
|
-
}).passthrough();
|
|
370
|
-
var P = import_v4.z.object({
|
|
371
|
-
isError: import_v4.z.boolean().optional().describe("True if the download failed (e.g., user cancelled or host denied).")
|
|
372
|
-
}).passthrough();
|
|
373
|
-
var w = import_v4.z.object({
|
|
374
|
-
isError: import_v4.z.boolean().optional().describe("True if the host rejected or failed to deliver the message.")
|
|
375
|
-
}).passthrough();
|
|
376
|
-
var JQ = import_v4.z.object({
|
|
377
|
-
method: import_v4.z.literal("ui/notifications/sandbox-proxy-ready"),
|
|
378
|
-
params: import_v4.z.object({})
|
|
379
|
-
});
|
|
380
|
-
var Y = import_v4.z.object({
|
|
381
|
-
connectDomains: import_v4.z.array(import_v4.z.string()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
|
|
382
|
-
|
|
383
|
-
- Maps to CSP \`connect-src\` directive
|
|
384
|
-
- Empty or omitted \u2192 no network connections (secure default)`),
|
|
385
|
-
resourceDomains: import_v4.z.array(import_v4.z.string()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted \u2192 no network resources (secure default)"),
|
|
386
|
-
frameDomains: import_v4.z.array(import_v4.z.string()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted \u2192 no nested iframes allowed (`frame-src 'none'`)"),
|
|
387
|
-
baseUriDomains: import_v4.z.array(import_v4.z.string()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted \u2192 only same origin allowed (`base-uri 'self'`)")
|
|
388
|
-
});
|
|
389
|
-
var j = import_v4.z.object({
|
|
390
|
-
camera: import_v4.z.object({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),
|
|
391
|
-
microphone: import_v4.z.object({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),
|
|
392
|
-
geolocation: import_v4.z.object({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),
|
|
393
|
-
clipboardWrite: import_v4.z.object({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")
|
|
394
|
-
});
|
|
395
|
-
var XQ = import_v4.z.object({
|
|
396
|
-
method: import_v4.z.literal("ui/notifications/size-changed"),
|
|
397
|
-
params: import_v4.z.object({
|
|
398
|
-
width: import_v4.z.number().optional().describe("New width in pixels."),
|
|
399
|
-
height: import_v4.z.number().optional().describe("New height in pixels.")
|
|
400
|
-
})
|
|
401
|
-
});
|
|
402
|
-
var H = import_v4.z.object({
|
|
403
|
-
method: import_v4.z.literal("ui/notifications/tool-input"),
|
|
404
|
-
params: import_v4.z.object({
|
|
405
|
-
arguments: import_v4.z.record(import_v4.z.string(), import_v4.z.unknown().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")
|
|
406
|
-
})
|
|
407
|
-
});
|
|
408
|
-
var _ = import_v4.z.object({
|
|
409
|
-
method: import_v4.z.literal("ui/notifications/tool-input-partial"),
|
|
410
|
-
params: import_v4.z.object({
|
|
411
|
-
arguments: import_v4.z.record(import_v4.z.string(), import_v4.z.unknown().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")
|
|
412
|
-
})
|
|
413
|
-
});
|
|
414
|
-
var A = import_v4.z.object({
|
|
415
|
-
method: import_v4.z.literal("ui/notifications/tool-cancelled"),
|
|
416
|
-
params: import_v4.z.object({
|
|
417
|
-
reason: import_v4.z.string().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')
|
|
418
|
-
})
|
|
419
|
-
});
|
|
420
|
-
var f = import_v4.z.object({
|
|
421
|
-
fonts: import_v4.z.string().optional()
|
|
422
|
-
});
|
|
423
|
-
var u = import_v4.z.object({
|
|
424
|
-
variables: ZQ.optional().describe("CSS variables for theming the app."),
|
|
425
|
-
css: f.optional().describe("CSS blocks that apps can inject.")
|
|
426
|
-
});
|
|
427
|
-
var E = import_v4.z.object({
|
|
428
|
-
method: import_v4.z.literal("ui/resource-teardown"),
|
|
429
|
-
params: import_v4.z.object({})
|
|
430
|
-
});
|
|
431
|
-
var VQ = import_v4.z.record(import_v4.z.string(), import_v4.z.unknown());
|
|
432
|
-
var O = import_v4.z.object({
|
|
433
|
-
text: import_v4.z.object({}).optional().describe("Host supports text content blocks."),
|
|
434
|
-
image: import_v4.z.object({}).optional().describe("Host supports image content blocks."),
|
|
435
|
-
audio: import_v4.z.object({}).optional().describe("Host supports audio content blocks."),
|
|
436
|
-
resource: import_v4.z.object({}).optional().describe("Host supports resource content blocks."),
|
|
437
|
-
resourceLink: import_v4.z.object({}).optional().describe("Host supports resource link content blocks."),
|
|
438
|
-
structuredContent: import_v4.z.object({}).optional().describe("Host supports structured content.")
|
|
439
|
-
});
|
|
440
|
-
var DQ = import_v4.z.object({
|
|
441
|
-
method: import_v4.z.literal("ui/notifications/request-teardown"),
|
|
442
|
-
params: import_v4.z.object({}).optional()
|
|
443
|
-
});
|
|
444
|
-
var d = import_v4.z.object({
|
|
445
|
-
experimental: import_v4.z.record(import_v4.z.string(), import_v4.z.record(import_v4.z.string(), import_v4.z.any()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),
|
|
446
|
-
openLinks: import_v4.z.object({}).optional().describe("Host supports opening external URLs."),
|
|
447
|
-
downloadFile: import_v4.z.object({}).optional().describe("Host supports file downloads via ui/download-file."),
|
|
448
|
-
serverTools: import_v4.z.object({
|
|
449
|
-
listChanged: import_v4.z.boolean().optional().describe("Host supports tools/list_changed notifications.")
|
|
450
|
-
}).optional().describe("Host can proxy tool calls to the MCP server."),
|
|
451
|
-
serverResources: import_v4.z.object({
|
|
452
|
-
listChanged: import_v4.z.boolean().optional().describe("Host supports resources/list_changed notifications.")
|
|
453
|
-
}).optional().describe("Host can proxy resource reads to the MCP server."),
|
|
454
|
-
logging: import_v4.z.object({}).optional().describe("Host accepts log messages."),
|
|
455
|
-
sandbox: import_v4.z.object({
|
|
456
|
-
permissions: j.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),
|
|
457
|
-
csp: Y.optional().describe("CSP domains approved by the host.")
|
|
458
|
-
}).optional().describe("Sandbox configuration applied by the host."),
|
|
459
|
-
updateModelContext: O.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),
|
|
460
|
-
message: O.optional().describe("Host supports receiving content messages (ui/message) from the view."),
|
|
461
|
-
sampling: import_v4.z.object({
|
|
462
|
-
tools: import_v4.z.object({}).optional().describe("Host supports tool use via `tools` and `toolChoice` parameters.")
|
|
463
|
-
}).optional().describe("Host supports LLM sampling (sampling/createMessage) from the view.\nMirrors the MCP `ClientCapabilities.sampling` shape so hosts can pass it through.")
|
|
464
|
-
});
|
|
465
|
-
var h = import_v4.z.object({
|
|
466
|
-
experimental: import_v4.z.record(import_v4.z.string(), import_v4.z.record(import_v4.z.string(), import_v4.z.any()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),
|
|
467
|
-
tools: import_v4.z.object({
|
|
468
|
-
listChanged: import_v4.z.boolean().optional().describe("App supports tools/list_changed notifications.")
|
|
469
|
-
}).optional().describe("App exposes MCP-style tools that the host can call."),
|
|
470
|
-
availableDisplayModes: import_v4.z.array(K).optional().describe("Display modes the app supports.")
|
|
471
|
-
});
|
|
472
|
-
var LQ = import_v4.z.object({
|
|
473
|
-
method: import_v4.z.literal("ui/notifications/initialized"),
|
|
474
|
-
params: import_v4.z.object({}).optional()
|
|
475
|
-
});
|
|
476
|
-
var WQ = import_v4.z.object({
|
|
477
|
-
csp: Y.optional().describe("Content Security Policy configuration for UI resources."),
|
|
478
|
-
permissions: j.optional().describe("Sandbox permissions requested by the UI resource."),
|
|
479
|
-
domain: import_v4.z.string().optional().describe(`Dedicated origin for view sandbox.
|
|
480
|
-
|
|
481
|
-
Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
|
|
482
|
-
|
|
483
|
-
**Host-dependent:** The format and validation rules for this field are determined by each host. Servers MUST consult host-specific documentation for the expected domain format. Common patterns include:
|
|
484
|
-
- Hash-based subdomains (e.g., \`{hash}.claudemcpcontent.com\`)
|
|
485
|
-
- URL-derived subdomains (e.g., \`www-example-com.oaiusercontent.com\`)
|
|
486
|
-
|
|
487
|
-
If omitted, host uses default sandbox origin (typically per-conversation).`),
|
|
488
|
-
prefersBorder: import_v4.z.boolean().optional().describe(`Visual boundary preference - true if view prefers a visible border.
|
|
489
|
-
|
|
490
|
-
Boolean requesting whether a visible border and background is provided by the host. Specifying an explicit value for this is recommended because hosts' defaults may vary.
|
|
491
|
-
|
|
492
|
-
- \`true\`: request visible border + background
|
|
493
|
-
- \`false\`: request no visible border + background
|
|
494
|
-
- omitted: host decides border`)
|
|
495
|
-
});
|
|
496
|
-
var BQ = import_v4.z.object({
|
|
497
|
-
method: import_v4.z.literal("ui/request-display-mode"),
|
|
498
|
-
params: import_v4.z.object({
|
|
499
|
-
mode: K.describe("The display mode being requested.")
|
|
500
|
-
})
|
|
501
|
-
});
|
|
502
|
-
var R = import_v4.z.object({
|
|
503
|
-
mode: K.describe("The display mode that was actually set. May differ from requested if not supported.")
|
|
504
|
-
}).passthrough();
|
|
505
|
-
var m = import_v4.z.union([
|
|
506
|
-
import_v4.z.literal("model"),
|
|
507
|
-
import_v4.z.literal("app")
|
|
508
|
-
]).describe("Tool visibility scope - who can access the tool.");
|
|
509
|
-
var GQ = import_v4.z.object({
|
|
510
|
-
resourceUri: import_v4.z.string().optional(),
|
|
511
|
-
visibility: import_v4.z.array(m).optional().describe(`Who can access this tool. Default: ["model", "app"]
|
|
512
|
-
- "model": Tool visible to and callable by the agent
|
|
513
|
-
- "app": Tool callable by the app from this server only`),
|
|
514
|
-
csp: import_v4.z.never().optional(),
|
|
515
|
-
permissions: import_v4.z.never().optional()
|
|
516
|
-
});
|
|
517
|
-
var dQ = import_v4.z.object({
|
|
518
|
-
mimeTypes: import_v4.z.array(import_v4.z.string()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')
|
|
519
|
-
});
|
|
520
|
-
var KQ = import_v4.z.object({
|
|
521
|
-
method: import_v4.z.literal("ui/download-file"),
|
|
522
|
-
params: import_v4.z.object({
|
|
523
|
-
contents: import_v4.z.array(import_v4.z.union([
|
|
524
|
-
import_types4.EmbeddedResourceSchema,
|
|
525
|
-
import_types4.ResourceLinkSchema
|
|
526
|
-
])).describe("Resource contents to download \u2014 embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")
|
|
527
|
-
})
|
|
528
|
-
});
|
|
529
|
-
var NQ = import_v4.z.object({
|
|
530
|
-
method: import_v4.z.literal("ui/message"),
|
|
531
|
-
params: import_v4.z.object({
|
|
532
|
-
role: import_v4.z.literal("user").describe('Message role, currently only "user" is supported.'),
|
|
533
|
-
content: import_v4.z.array(import_types4.ContentBlockSchema).describe("Message content blocks (text, image, etc.).")
|
|
534
|
-
})
|
|
535
|
-
});
|
|
536
|
-
var YQ = import_v4.z.object({
|
|
537
|
-
method: import_v4.z.literal("ui/notifications/sandbox-resource-ready"),
|
|
538
|
-
params: import_v4.z.object({
|
|
539
|
-
html: import_v4.z.string().describe("HTML content to load into the inner iframe."),
|
|
540
|
-
sandbox: import_v4.z.string().optional().describe("Optional override for the inner iframe's sandbox attribute."),
|
|
541
|
-
csp: Y.optional().describe("CSP configuration from resource metadata."),
|
|
542
|
-
permissions: j.optional().describe("Sandbox permissions from resource metadata.")
|
|
543
|
-
})
|
|
544
|
-
});
|
|
545
|
-
var U = import_v4.z.object({
|
|
546
|
-
method: import_v4.z.literal("ui/notifications/tool-result"),
|
|
547
|
-
params: import_types4.CallToolResultSchema.describe("Standard MCP tool execution result.")
|
|
548
|
-
});
|
|
549
|
-
var T = import_v4.z.object({
|
|
550
|
-
toolInfo: import_v4.z.object({
|
|
551
|
-
id: import_types4.RequestIdSchema.optional().describe("JSON-RPC id of the tools/call request."),
|
|
552
|
-
tool: import_types4.ToolSchema.describe("Tool definition including name, inputSchema, etc.")
|
|
553
|
-
}).optional().describe("Metadata of the tool call that instantiated this App."),
|
|
554
|
-
theme: v.optional().describe("Current color theme preference."),
|
|
555
|
-
styles: u.optional().describe("Style configuration for theming the app."),
|
|
556
|
-
displayMode: K.optional().describe("How the UI is currently displayed."),
|
|
557
|
-
availableDisplayModes: import_v4.z.array(K).optional().describe("Display modes the host supports."),
|
|
558
|
-
containerDimensions: import_v4.z.union([
|
|
559
|
-
import_v4.z.object({
|
|
560
|
-
height: import_v4.z.number().describe("Fixed container height in pixels.")
|
|
561
|
-
}),
|
|
562
|
-
import_v4.z.object({
|
|
563
|
-
maxHeight: import_v4.z.union([
|
|
564
|
-
import_v4.z.number(),
|
|
565
|
-
import_v4.z.undefined()
|
|
566
|
-
]).optional().describe("Maximum container height in pixels.")
|
|
567
|
-
})
|
|
568
|
-
]).and(import_v4.z.union([
|
|
569
|
-
import_v4.z.object({
|
|
570
|
-
width: import_v4.z.number().describe("Fixed container width in pixels.")
|
|
571
|
-
}),
|
|
572
|
-
import_v4.z.object({
|
|
573
|
-
maxWidth: import_v4.z.union([
|
|
574
|
-
import_v4.z.number(),
|
|
575
|
-
import_v4.z.undefined()
|
|
576
|
-
]).optional().describe("Maximum container width in pixels.")
|
|
577
|
-
})
|
|
578
|
-
])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
579
|
-
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),
|
|
580
|
-
locale: import_v4.z.string().optional().describe("User's language and region preference in BCP 47 format."),
|
|
581
|
-
timeZone: import_v4.z.string().optional().describe("User's timezone in IANA format."),
|
|
582
|
-
userAgent: import_v4.z.string().optional().describe("Host application identifier."),
|
|
583
|
-
platform: import_v4.z.union([
|
|
584
|
-
import_v4.z.literal("web"),
|
|
585
|
-
import_v4.z.literal("desktop"),
|
|
586
|
-
import_v4.z.literal("mobile")
|
|
587
|
-
]).optional().describe("Platform type for responsive design decisions."),
|
|
588
|
-
deviceCapabilities: import_v4.z.object({
|
|
589
|
-
touch: import_v4.z.boolean().optional().describe("Whether the device supports touch input."),
|
|
590
|
-
hover: import_v4.z.boolean().optional().describe("Whether the device supports hover interactions.")
|
|
591
|
-
}).optional().describe("Device input capabilities."),
|
|
592
|
-
safeAreaInsets: import_v4.z.object({
|
|
593
|
-
top: import_v4.z.number().describe("Top safe area inset in pixels."),
|
|
594
|
-
right: import_v4.z.number().describe("Right safe area inset in pixels."),
|
|
595
|
-
bottom: import_v4.z.number().describe("Bottom safe area inset in pixels."),
|
|
596
|
-
left: import_v4.z.number().describe("Left safe area inset in pixels.")
|
|
597
|
-
}).optional().describe("Mobile safe area boundaries in pixels.")
|
|
598
|
-
}).passthrough();
|
|
599
|
-
var k = import_v4.z.object({
|
|
600
|
-
method: import_v4.z.literal("ui/notifications/host-context-changed"),
|
|
601
|
-
params: T.describe("Partial context update containing only changed fields.")
|
|
602
|
-
});
|
|
603
|
-
var jQ = import_v4.z.object({
|
|
604
|
-
method: import_v4.z.literal("ui/update-model-context"),
|
|
605
|
-
params: import_v4.z.object({
|
|
606
|
-
content: import_v4.z.array(import_types4.ContentBlockSchema).optional().describe("Context content blocks (text, image, etc.)."),
|
|
607
|
-
structuredContent: import_v4.z.record(import_v4.z.string(), import_v4.z.unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")
|
|
608
|
-
})
|
|
609
|
-
});
|
|
610
|
-
var FQ = import_v4.z.object({
|
|
611
|
-
method: import_v4.z.literal("ui/initialize"),
|
|
612
|
-
params: import_v4.z.object({
|
|
613
|
-
appInfo: import_types4.ImplementationSchema.describe("App identification (name and version)."),
|
|
614
|
-
appCapabilities: h.describe("Features and capabilities this app provides."),
|
|
615
|
-
protocolVersion: import_v4.z.string().describe("Protocol version this app supports.")
|
|
616
|
-
})
|
|
617
|
-
});
|
|
618
|
-
var M = import_v4.z.object({
|
|
619
|
-
protocolVersion: import_v4.z.string().describe('Negotiated protocol version string (e.g., "2025-11-21").'),
|
|
620
|
-
hostInfo: import_types4.ImplementationSchema.describe("Host application identification and version."),
|
|
621
|
-
hostCapabilities: d.describe("Features and capabilities provided by the host."),
|
|
622
|
-
hostContext: T.describe("Rich context about the host environment.")
|
|
623
|
-
}).passthrough();
|
|
624
|
-
var C = "ui/resourceUri";
|
|
625
|
-
var p = "text/html;profile=mcp-app";
|
|
626
|
-
function K3(Z, $, J, X) {
|
|
627
|
-
let V = J._meta, D = V.ui, L = V[C], W = V;
|
|
628
|
-
if (D?.resourceUri && !L) W = {
|
|
629
|
-
...V,
|
|
630
|
-
[C]: D.resourceUri
|
|
631
|
-
};
|
|
632
|
-
else if (L && !D?.resourceUri) W = {
|
|
633
|
-
...V,
|
|
634
|
-
ui: {
|
|
635
|
-
...D,
|
|
636
|
-
resourceUri: L
|
|
637
|
-
}
|
|
638
|
-
};
|
|
639
|
-
return Z.registerTool($, {
|
|
640
|
-
...J,
|
|
641
|
-
_meta: W
|
|
642
|
-
}, X);
|
|
643
|
-
}
|
|
644
|
-
__name(K3, "K3");
|
|
645
|
-
function N3(Z, $, J, X, V) {
|
|
646
|
-
return Z.registerResource($, J, {
|
|
647
|
-
mimeType: p,
|
|
648
|
-
...X
|
|
649
|
-
}, V);
|
|
650
|
-
}
|
|
651
|
-
__name(N3, "N3");
|
|
652
162
|
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
return schema ?? {};
|
|
663
|
-
}
|
|
664
|
-
__name(normalizeSchema, "normalizeSchema");
|
|
665
|
-
function buildToolMeta(def) {
|
|
666
|
-
const { ui, meta } = def.options;
|
|
667
|
-
if (!ui && !meta) return void 0;
|
|
668
|
-
const merged = {
|
|
669
|
-
...meta ?? {}
|
|
670
|
-
};
|
|
671
|
-
if (ui) {
|
|
672
|
-
merged.ui = {
|
|
673
|
-
...merged.ui ?? {},
|
|
674
|
-
resourceUri: ui.resourceUri,
|
|
675
|
-
...ui.visibility ? {
|
|
676
|
-
visibility: ui.visibility
|
|
677
|
-
} : {}
|
|
678
|
-
};
|
|
679
|
-
}
|
|
680
|
-
return merged;
|
|
681
|
-
}
|
|
682
|
-
__name(buildToolMeta, "buildToolMeta");
|
|
683
|
-
var MISSING_USER_MESSAGE = "\u8C03\u7528\u8005\u8EAB\u4EFD\u7F3A\u5931\uFF1A\u8BF7\u6C42\u672A\u643A\u5E26\u7528\u6237\u4FE1\u606F\uFF08x-larkgw-suda-webuser\uFF09\u3002\u8BF7\u901A\u8FC7 MCP Gateway \u6216\u5F00\u53D1\u670D\u52A1\u5165\u53E3\u8BBF\u95EE\uFF0C\u6216\u5728\u6A21\u5757\u914D\u7F6E\u4E2D\u8BBE\u7F6E requireUser: false\u3002";
|
|
684
|
-
function assertUser(ctx, options) {
|
|
685
|
-
if (options.requireUser === false) return;
|
|
686
|
-
if (!ctx.user?.userId) {
|
|
687
|
-
throw new McpToolError(MISSING_USER_MESSAGE, {
|
|
688
|
-
code: "MCP_USER_REQUIRED"
|
|
689
|
-
});
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
__name(assertUser, "assertUser");
|
|
693
|
-
function toErrorResult(error, location, onError) {
|
|
694
|
-
if (error instanceof McpToolError) {
|
|
695
|
-
const payload = {
|
|
696
|
-
message: error.message
|
|
697
|
-
};
|
|
698
|
-
if (error.code !== void 0) payload.code = error.code;
|
|
699
|
-
if (error.data !== void 0) payload.data = error.data;
|
|
700
|
-
return {
|
|
701
|
-
isError: true,
|
|
702
|
-
content: [
|
|
703
|
-
{
|
|
704
|
-
type: "text",
|
|
705
|
-
text: error.code ? `[${error.code}] ${error.message}` : error.message
|
|
706
|
-
}
|
|
707
|
-
],
|
|
708
|
-
structuredContent: void 0,
|
|
709
|
-
_meta: {
|
|
710
|
-
error: payload
|
|
711
|
-
}
|
|
712
|
-
};
|
|
713
|
-
}
|
|
714
|
-
onError?.(error, location);
|
|
715
|
-
return {
|
|
716
|
-
isError: true,
|
|
717
|
-
content: [
|
|
718
|
-
{
|
|
719
|
-
type: "text",
|
|
720
|
-
text: `\u5DE5\u5177\u6267\u884C\u5931\u8D25\uFF08${location}\uFF09\uFF0C\u8BF7\u67E5\u770B\u5E94\u7528\u65E5\u5FD7`
|
|
721
|
-
}
|
|
722
|
-
]
|
|
723
|
-
};
|
|
724
|
-
}
|
|
725
|
-
__name(toErrorResult, "toErrorResult");
|
|
726
|
-
function createMcpServer(input) {
|
|
727
|
-
const { tools, resources, options, createContext, onError } = input;
|
|
728
|
-
const server = new import_mcp.McpServer(resolveServerInfo(options), {
|
|
729
|
-
instructions: options.instructions
|
|
730
|
-
});
|
|
731
|
-
const noContext = /* @__PURE__ */ __name(() => {
|
|
732
|
-
throw new Error("\u5F53\u524D McpServer \u5B9E\u4F8B\u672A\u7ED1\u5B9A\u8BF7\u6C42\u4E0A\u4E0B\u6587\uFF0C\u4E0D\u80FD\u6267\u884C\u5DE5\u5177");
|
|
733
|
-
}, "noContext");
|
|
734
|
-
for (const def of tools) {
|
|
735
|
-
const location = `${def.className}.${def.methodName}`;
|
|
736
|
-
const config = {
|
|
737
|
-
title: def.options.title,
|
|
738
|
-
description: def.options.description,
|
|
739
|
-
inputSchema: normalizeSchema(def.options.inputSchema),
|
|
740
|
-
outputSchema: def.options.outputSchema,
|
|
741
|
-
annotations: def.options.annotations,
|
|
742
|
-
_meta: buildToolMeta(def)
|
|
743
|
-
};
|
|
744
|
-
const callback = /* @__PURE__ */ __name(async (args, extra) => {
|
|
745
|
-
try {
|
|
746
|
-
const ctx = createContext ? createContext(extra) : noContext();
|
|
747
|
-
assertUser(ctx, options);
|
|
748
|
-
if (!def.handler) {
|
|
749
|
-
throw new Error(`\u5DE5\u5177\u300C${def.name}\u300D\u672A\u7ED1\u5B9A\u5B9E\u4F8B\uFF08${location}\uFF09`);
|
|
750
|
-
}
|
|
751
|
-
const result = await def.handler(args ?? {}, ctx);
|
|
752
|
-
if (def.options.outputSchema && result && !result.content) {
|
|
753
|
-
return {
|
|
754
|
-
...result,
|
|
755
|
-
content: [
|
|
756
|
-
{
|
|
757
|
-
type: "text",
|
|
758
|
-
text: JSON.stringify(result.structuredContent ?? null)
|
|
759
|
-
}
|
|
760
|
-
]
|
|
761
|
-
};
|
|
762
|
-
}
|
|
763
|
-
return result;
|
|
764
|
-
} catch (error) {
|
|
765
|
-
return toErrorResult(error, location, onError);
|
|
766
|
-
}
|
|
767
|
-
}, "callback");
|
|
768
|
-
if (def.options.ui) {
|
|
769
|
-
K3(server, def.name, config, callback);
|
|
770
|
-
} else {
|
|
771
|
-
server.registerTool(def.name, config, callback);
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
for (const def of resources) {
|
|
775
|
-
const location = `${def.className}.${def.methodName}`;
|
|
776
|
-
const { uri, title, description, csp, permissions, meta } = def.options;
|
|
777
|
-
const uiMeta = {
|
|
778
|
-
...meta ?? {}
|
|
779
|
-
};
|
|
780
|
-
if (csp) uiMeta.csp = csp;
|
|
781
|
-
if (permissions) uiMeta.permissions = permissions;
|
|
782
|
-
N3(server, def.name, uri, {
|
|
783
|
-
title,
|
|
784
|
-
description,
|
|
785
|
-
mimeType: p,
|
|
786
|
-
_meta: Object.keys(uiMeta).length > 0 ? {
|
|
787
|
-
ui: uiMeta
|
|
788
|
-
} : void 0
|
|
789
|
-
}, async (resourceUri, extra) => {
|
|
790
|
-
try {
|
|
791
|
-
const ctx = createContext ? createContext(extra) : noContext();
|
|
792
|
-
assertUser(ctx, options);
|
|
793
|
-
if (!def.handler) {
|
|
794
|
-
throw new Error(`\u8D44\u6E90\u300C${uri}\u300D\u672A\u7ED1\u5B9A\u5B9E\u4F8B\uFF08${location}\uFF09`);
|
|
795
|
-
}
|
|
796
|
-
const html = await def.handler(ctx);
|
|
797
|
-
return {
|
|
798
|
-
contents: [
|
|
799
|
-
{
|
|
800
|
-
uri: resourceUri.href,
|
|
801
|
-
mimeType: p,
|
|
802
|
-
text: html
|
|
803
|
-
}
|
|
804
|
-
]
|
|
805
|
-
};
|
|
806
|
-
} catch (error) {
|
|
807
|
-
if (!(error instanceof McpToolError)) onError?.(error, location);
|
|
808
|
-
throw error;
|
|
809
|
-
}
|
|
810
|
-
});
|
|
811
|
-
}
|
|
812
|
-
const skills = input.skills ?? [];
|
|
813
|
-
const names = /* @__PURE__ */ new Set();
|
|
814
|
-
for (const skill of skills) {
|
|
815
|
-
if (names.has(skill.name)) throw new Error("MCP Prompt name \u91CD\u590D");
|
|
816
|
-
names.add(skill.name);
|
|
817
|
-
const text = skill.content.replace(/^---\r?\n[\s\S]*?\r?\n---(?:\r?\n|$)/, "");
|
|
818
|
-
server.registerPrompt(skill.name, {
|
|
819
|
-
description: skill.description
|
|
820
|
-
}, async (extra) => {
|
|
821
|
-
const ctx = createContext ? createContext(extra) : noContext();
|
|
822
|
-
assertUser(ctx, options);
|
|
823
|
-
return {
|
|
824
|
-
description: skill.description,
|
|
825
|
-
messages: [
|
|
826
|
-
{
|
|
827
|
-
role: "user",
|
|
828
|
-
content: {
|
|
829
|
-
type: "text",
|
|
830
|
-
text
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
]
|
|
834
|
-
};
|
|
835
|
-
});
|
|
836
|
-
}
|
|
837
|
-
server.server.registerCapabilities({
|
|
838
|
-
...tools.length ? {
|
|
839
|
-
tools: {
|
|
840
|
-
listChanged: false
|
|
841
|
-
}
|
|
842
|
-
} : {},
|
|
843
|
-
...resources.length ? {
|
|
844
|
-
resources: {
|
|
845
|
-
listChanged: false
|
|
846
|
-
}
|
|
847
|
-
} : {},
|
|
848
|
-
prompts: {
|
|
849
|
-
listChanged: false
|
|
850
|
-
}
|
|
851
|
-
});
|
|
852
|
-
if (!skills.length) {
|
|
853
|
-
server.server.setRequestHandler(import_types5.ListPromptsRequestSchema, () => ({
|
|
854
|
-
prompts: []
|
|
855
|
-
}));
|
|
856
|
-
server.server.setRequestHandler(import_types5.GetPromptRequestSchema, ({ params }) => {
|
|
857
|
-
throw new import_types5.McpError(import_types5.ErrorCode.InvalidParams, `Prompt ${params.name} not found`);
|
|
163
|
+
|
|
164
|
+
// src/protocol.ts
|
|
165
|
+
var pending;
|
|
166
|
+
function loadMcpProtocol() {
|
|
167
|
+
if (!pending) {
|
|
168
|
+
const loading = Promise.resolve().then(() => _interopRequireWildcard(require("./protocol-runtime-RR5RVY4P.cjs")));
|
|
169
|
+
pending = loading;
|
|
170
|
+
loading.catch(() => {
|
|
171
|
+
if (pending === loading) pending = void 0;
|
|
858
172
|
});
|
|
859
173
|
}
|
|
860
|
-
return
|
|
861
|
-
}
|
|
862
|
-
__name(createMcpServer, "createMcpServer");
|
|
863
|
-
|
|
864
|
-
// src/manifest.ts
|
|
865
|
-
async function buildManifest(input) {
|
|
866
|
-
const skills = input.skills ?? [];
|
|
867
|
-
const server = createMcpServer({
|
|
868
|
-
tools: input.tools,
|
|
869
|
-
resources: input.resources,
|
|
870
|
-
options: input.options,
|
|
871
|
-
skills
|
|
872
|
-
});
|
|
873
|
-
const client = new import_client.Client({
|
|
874
|
-
name: "miaoda-mcp-manifest",
|
|
875
|
-
version: "1.0.0"
|
|
876
|
-
});
|
|
877
|
-
const [clientTransport, serverTransport] = import_inMemory.InMemoryTransport.createLinkedPair();
|
|
878
|
-
try {
|
|
879
|
-
await Promise.all([
|
|
880
|
-
server.connect(serverTransport),
|
|
881
|
-
client.connect(clientTransport)
|
|
882
|
-
]);
|
|
883
|
-
const tools = input.tools.length > 0 ? (await client.listTools()).tools : [];
|
|
884
|
-
const resources = input.resources.length > 0 ? (await client.listResources()).resources : [];
|
|
885
|
-
const prompts = skills.length ? (await client.listPrompts()).prompts : [];
|
|
886
|
-
return {
|
|
887
|
-
version: MCP_MANIFEST_VERSION,
|
|
888
|
-
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
889
|
-
endpoint: MCP_ENDPOINT_PATH,
|
|
890
|
-
serverInfo: {
|
|
891
|
-
name: resolveServerInfo(input.options).name
|
|
892
|
-
},
|
|
893
|
-
tools: tools.sort((a2, b) => a2.name.localeCompare(b.name)),
|
|
894
|
-
resources: resources.sort((a2, b) => a2.uri.localeCompare(b.uri)),
|
|
895
|
-
prompts,
|
|
896
|
-
skills
|
|
897
|
-
};
|
|
898
|
-
} finally {
|
|
899
|
-
await Promise.allSettled([
|
|
900
|
-
client.close(),
|
|
901
|
-
server.close()
|
|
902
|
-
]);
|
|
903
|
-
}
|
|
174
|
+
return pending;
|
|
904
175
|
}
|
|
905
|
-
__name(
|
|
176
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, loadMcpProtocol, "loadMcpProtocol");
|
|
906
177
|
|
|
907
178
|
// src/services/mcp-registry.service.ts
|
|
908
|
-
|
|
909
|
-
|
|
179
|
+
|
|
180
|
+
|
|
910
181
|
|
|
911
182
|
// src/metadata.ts
|
|
912
|
-
|
|
183
|
+
require('reflect-metadata');
|
|
913
184
|
function isMcpToolsClass(target) {
|
|
914
|
-
return typeof target === "function" && Reflect.getMetadata(MCP_TOOLS_METADATA_KEY, target) !== void 0;
|
|
185
|
+
return typeof target === "function" && Reflect.getMetadata(_chunkCFHAFLNNcjs.MCP_TOOLS_METADATA_KEY, target) !== void 0;
|
|
915
186
|
}
|
|
916
|
-
__name(isMcpToolsClass, "isMcpToolsClass");
|
|
187
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, isMcpToolsClass, "isMcpToolsClass");
|
|
917
188
|
function getAllMethodNames(prototype) {
|
|
918
189
|
const names = /* @__PURE__ */ new Set();
|
|
919
190
|
let current = prototype;
|
|
@@ -931,21 +202,21 @@ function getAllMethodNames(prototype) {
|
|
|
931
202
|
...names
|
|
932
203
|
];
|
|
933
204
|
}
|
|
934
|
-
__name(getAllMethodNames, "getAllMethodNames");
|
|
205
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, getAllMethodNames, "getAllMethodNames");
|
|
935
206
|
function collectFromClass(target, instance) {
|
|
936
|
-
const classOptions = Reflect.getMetadata(MCP_TOOLS_METADATA_KEY, target)
|
|
207
|
+
const classOptions = _nullishCoalesce(Reflect.getMetadata(_chunkCFHAFLNNcjs.MCP_TOOLS_METADATA_KEY, target), () => ( {}));
|
|
937
208
|
const prototype = target.prototype;
|
|
938
209
|
const tools = [];
|
|
939
210
|
const resources = [];
|
|
940
211
|
for (const methodName of getAllMethodNames(prototype)) {
|
|
941
212
|
const method = prototype[methodName];
|
|
942
|
-
const toolOptions = Reflect.getMetadata(MCP_TOOL_METADATA_KEY, method);
|
|
943
|
-
const resourceOptions = Reflect.getMetadata(MCP_UI_RESOURCE_METADATA_KEY, method);
|
|
213
|
+
const toolOptions = Reflect.getMetadata(_chunkCFHAFLNNcjs.MCP_TOOL_METADATA_KEY, method);
|
|
214
|
+
const resourceOptions = Reflect.getMetadata(_chunkCFHAFLNNcjs.MCP_UI_RESOURCE_METADATA_KEY, method);
|
|
944
215
|
if (toolOptions && resourceOptions) {
|
|
945
216
|
throw new Error(`${target.name}.${methodName} \u4E0D\u80FD\u540C\u65F6\u6807\u8BB0 @McpTool() \u4E0E @McpUiResource()`);
|
|
946
217
|
}
|
|
947
218
|
if (toolOptions) {
|
|
948
|
-
const name = `${classOptions.prefix
|
|
219
|
+
const name = `${_nullishCoalesce(classOptions.prefix, () => ( ""))}${_nullishCoalesce(toolOptions.name, () => ( methodName))}`;
|
|
949
220
|
tools.push({
|
|
950
221
|
name,
|
|
951
222
|
options: toolOptions,
|
|
@@ -955,7 +226,7 @@ function collectFromClass(target, instance) {
|
|
|
955
226
|
});
|
|
956
227
|
} else if (resourceOptions) {
|
|
957
228
|
resources.push({
|
|
958
|
-
name: resourceOptions.name
|
|
229
|
+
name: _nullishCoalesce(resourceOptions.name, () => ( methodName)),
|
|
959
230
|
options: resourceOptions,
|
|
960
231
|
className: target.name,
|
|
961
232
|
methodName,
|
|
@@ -968,7 +239,7 @@ function collectFromClass(target, instance) {
|
|
|
968
239
|
resources
|
|
969
240
|
};
|
|
970
241
|
}
|
|
971
|
-
__name(collectFromClass, "collectFromClass");
|
|
242
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, collectFromClass, "collectFromClass");
|
|
972
243
|
function mergeAndValidate(parts) {
|
|
973
244
|
const tools = [];
|
|
974
245
|
const resources = [];
|
|
@@ -978,8 +249,8 @@ function mergeAndValidate(parts) {
|
|
|
978
249
|
for (const part of parts) {
|
|
979
250
|
for (const tool of part.tools) {
|
|
980
251
|
const location = `${tool.className}.${tool.methodName}`;
|
|
981
|
-
if (!MCP_TOOL_NAME_PATTERN.test(tool.name)) {
|
|
982
|
-
problems.push(`\u5DE5\u5177\u540D\u300C${tool.name}\u300D\u4E0D\u5408\u6CD5\uFF08${location}\uFF09\uFF0C\u9700\u5339\u914D ${MCP_TOOL_NAME_PATTERN}`);
|
|
252
|
+
if (!_chunkCFHAFLNNcjs.MCP_TOOL_NAME_PATTERN.test(tool.name)) {
|
|
253
|
+
problems.push(`\u5DE5\u5177\u540D\u300C${tool.name}\u300D\u4E0D\u5408\u6CD5\uFF08${location}\uFF09\uFF0C\u9700\u5339\u914D ${_chunkCFHAFLNNcjs.MCP_TOOL_NAME_PATTERN}`);
|
|
983
254
|
}
|
|
984
255
|
const existing = toolNames.get(tool.name);
|
|
985
256
|
if (existing) {
|
|
@@ -992,8 +263,8 @@ function mergeAndValidate(parts) {
|
|
|
992
263
|
for (const resource of part.resources) {
|
|
993
264
|
const location = `${resource.className}.${resource.methodName}`;
|
|
994
265
|
const uri = resource.options.uri;
|
|
995
|
-
if (!uri.startsWith(MCP_UI_RESOURCE_SCHEME)) {
|
|
996
|
-
problems.push(`\u8D44\u6E90 URI\u300C${uri}\u300D\u5FC5\u987B\u4EE5 ${MCP_UI_RESOURCE_SCHEME} \u5F00\u5934\uFF08${location}\uFF09`);
|
|
266
|
+
if (!uri.startsWith(_chunkCFHAFLNNcjs.MCP_UI_RESOURCE_SCHEME)) {
|
|
267
|
+
problems.push(`\u8D44\u6E90 URI\u300C${uri}\u300D\u5FC5\u987B\u4EE5 ${_chunkCFHAFLNNcjs.MCP_UI_RESOURCE_SCHEME} \u5F00\u5934\uFF08${location}\uFF09`);
|
|
997
268
|
}
|
|
998
269
|
const existing = resourceUris.get(uri);
|
|
999
270
|
if (existing) {
|
|
@@ -1005,7 +276,7 @@ function mergeAndValidate(parts) {
|
|
|
1005
276
|
}
|
|
1006
277
|
}
|
|
1007
278
|
for (const tool of tools) {
|
|
1008
|
-
const resourceUri = tool.options.ui
|
|
279
|
+
const resourceUri = _optionalChain([tool, 'access', _2 => _2.options, 'access', _3 => _3.ui, 'optionalAccess', _4 => _4.resourceUri]);
|
|
1009
280
|
if (resourceUri && !resourceUris.has(resourceUri)) {
|
|
1010
281
|
problems.push(`\u5DE5\u5177\u300C${tool.name}\u300D\u5F15\u7528\u7684 ui.resourceUri\u300C${resourceUri}\u300D\u672A\u627E\u5230\u5BF9\u5E94\u7684 @McpUiResource()\uFF08${tool.className}.${tool.methodName}\uFF09`);
|
|
1011
282
|
}
|
|
@@ -1019,39 +290,39 @@ function mergeAndValidate(parts) {
|
|
|
1019
290
|
resources
|
|
1020
291
|
};
|
|
1021
292
|
}
|
|
1022
|
-
__name(mergeAndValidate, "mergeAndValidate");
|
|
293
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, mergeAndValidate, "mergeAndValidate");
|
|
1023
294
|
|
|
1024
295
|
// src/services/mcp-registry.service.ts
|
|
1025
296
|
function _ts_decorate(decorators, target, key, desc) {
|
|
1026
|
-
var c = arguments.length,
|
|
1027
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1028
|
-
else for (var
|
|
1029
|
-
return c > 3 &&
|
|
297
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
298
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
299
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
300
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1030
301
|
}
|
|
1031
|
-
__name(_ts_decorate, "_ts_decorate");
|
|
1032
|
-
function _ts_metadata(
|
|
1033
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(
|
|
302
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, _ts_decorate, "_ts_decorate");
|
|
303
|
+
function _ts_metadata(k, v) {
|
|
304
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1034
305
|
}
|
|
1035
|
-
__name(_ts_metadata, "_ts_metadata");
|
|
306
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, _ts_metadata, "_ts_metadata");
|
|
1036
307
|
function _ts_param(paramIndex, decorator) {
|
|
1037
308
|
return function(target, key) {
|
|
1038
309
|
decorator(target, key, paramIndex);
|
|
1039
310
|
};
|
|
1040
311
|
}
|
|
1041
|
-
__name(_ts_param, "_ts_param");
|
|
1042
|
-
var McpRegistryService = class _McpRegistryService {
|
|
312
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, _ts_param, "_ts_param");
|
|
313
|
+
var McpRegistryService = (_class2 = class _McpRegistryService {
|
|
1043
314
|
static {
|
|
1044
|
-
__name(this, "McpRegistryService");
|
|
315
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, this, "McpRegistryService");
|
|
1045
316
|
}
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
logger = new
|
|
1049
|
-
definitions = {
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
__init5() {this.logger = new (0, _common.Logger)(_McpRegistryService.name)}
|
|
320
|
+
__init6() {this.definitions = {
|
|
1050
321
|
tools: [],
|
|
1051
322
|
resources: []
|
|
1052
|
-
}
|
|
1053
|
-
initialized = false
|
|
1054
|
-
constructor(discoveryService, options) {
|
|
323
|
+
}}
|
|
324
|
+
__init7() {this.initialized = false}
|
|
325
|
+
constructor(discoveryService, options) {;_class2.prototype.__init5.call(this);_class2.prototype.__init6.call(this);_class2.prototype.__init7.call(this);
|
|
1055
326
|
this.discoveryService = discoveryService;
|
|
1056
327
|
this.options = options;
|
|
1057
328
|
}
|
|
@@ -1086,7 +357,7 @@ var McpRegistryService = class _McpRegistryService {
|
|
|
1086
357
|
const parts = [];
|
|
1087
358
|
const seen = /* @__PURE__ */ new Set();
|
|
1088
359
|
for (const wrapper of wrappers) {
|
|
1089
|
-
if (isMcpToolsClass(wrapper.metatype) && (wrapper.scope ===
|
|
360
|
+
if (isMcpToolsClass(wrapper.metatype) && (wrapper.scope === _common.Scope.REQUEST || wrapper.scope === _common.Scope.TRANSIENT || !wrapper.isDependencyTreeStatic())) {
|
|
1090
361
|
throw new Error(`${wrapper.metatype.name}: MCP \u5DE5\u5177\u5FC5\u987B\u4F7F\u7528\u5355\u4F8B\u53CA\u5355\u4F8B\u4F9D\u8D56\uFF0C\u901A\u8FC7 ctx.user \u8BFB\u53D6\u8BF7\u6C42\u8EAB\u4EFD`);
|
|
1091
362
|
}
|
|
1092
363
|
const { instance } = wrapper;
|
|
@@ -1108,24 +379,23 @@ var McpRegistryService = class _McpRegistryService {
|
|
|
1108
379
|
this.logger.debug("\u672A\u53D1\u73B0 MCP \u5DE5\u5177\uFF0C/__innerapi__/mcp \u5C06\u8FD4\u56DE 404", MCP_LOG_ATTRIBUTES);
|
|
1109
380
|
return;
|
|
1110
381
|
}
|
|
1111
|
-
this.logger.log(`\u5DF2\u6CE8\u518C ${tools.length} \u4E2A MCP \u5DE5\u5177${resources.length ? `\u3001${resources.length} \u4E2A MCP Apps \u8D44\u6E90` : ""}\uFF1A${tools.map((
|
|
382
|
+
this.logger.log(`\u5DF2\u6CE8\u518C ${tools.length} \u4E2A MCP \u5DE5\u5177${resources.length ? `\u3001${resources.length} \u4E2A MCP Apps \u8D44\u6E90` : ""}\uFF1A${tools.map((t) => t.name).join(", ")}`, MCP_LOG_ATTRIBUTES);
|
|
1112
383
|
}
|
|
1113
|
-
};
|
|
384
|
+
}, _class2);
|
|
1114
385
|
McpRegistryService = _ts_decorate([
|
|
1115
|
-
(0,
|
|
1116
|
-
_ts_param(0, (0,
|
|
1117
|
-
_ts_param(1, (0,
|
|
386
|
+
_common.Injectable.call(void 0, ),
|
|
387
|
+
_ts_param(0, _common.Inject.call(void 0, _core.DiscoveryService)),
|
|
388
|
+
_ts_param(1, _common.Inject.call(void 0, _chunkCFHAFLNNcjs.MCP_MODULE_OPTIONS)),
|
|
1118
389
|
_ts_metadata("design:type", Function),
|
|
1119
390
|
_ts_metadata("design:paramtypes", [
|
|
1120
|
-
typeof
|
|
391
|
+
typeof _core.DiscoveryService === "undefined" ? Object : _core.DiscoveryService,
|
|
1121
392
|
typeof McpModuleOptions === "undefined" ? Object : McpModuleOptions
|
|
1122
393
|
])
|
|
1123
394
|
], McpRegistryService);
|
|
1124
395
|
|
|
1125
396
|
// src/skill.ts
|
|
1126
|
-
var
|
|
1127
|
-
var
|
|
1128
|
-
var import_yaml = require("yaml");
|
|
397
|
+
var _fs = require('fs');
|
|
398
|
+
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
1129
399
|
var FILE_LIMIT = 1024 * 1024;
|
|
1130
400
|
var TOTAL_LIMIT = 8 * FILE_LIMIT;
|
|
1131
401
|
var COUNT_LIMIT = 100;
|
|
@@ -1134,11 +404,11 @@ async function checkedPath(root, relative) {
|
|
|
1134
404
|
let file = root;
|
|
1135
405
|
for (const part of relative.split("/")) {
|
|
1136
406
|
if (!part || part === "." || part === "..") throw new Error("MCP Skill \u5FC5\u987B\u4F4D\u4E8E\u5E94\u7528\u5DE5\u7A0B\u5185");
|
|
1137
|
-
file =
|
|
407
|
+
file = _path2.default.join(file, part);
|
|
1138
408
|
try {
|
|
1139
|
-
const stat = await
|
|
409
|
+
const stat = await _fs.promises.lstat(file);
|
|
1140
410
|
if (stat.isSymbolicLink()) throw new Error("MCP Skill \u5FC5\u987B\u4F4D\u4E8E\u5E94\u7528\u5DE5\u7A0B\u5185\uFF0C\u4E0D\u5141\u8BB8\u7B26\u53F7\u94FE\u63A5");
|
|
1141
|
-
const resolved = await
|
|
411
|
+
const resolved = await _fs.promises.realpath(file);
|
|
1142
412
|
if (resolved !== file) throw new Error("MCP Skill \u5FC5\u987B\u4F4D\u4E8E\u5E94\u7528\u5DE5\u7A0B\u5185\uFF0C\u4E0D\u5141\u8BB8\u8DEF\u5F84\u91CD\u5B9A\u5411");
|
|
1143
413
|
} catch (error) {
|
|
1144
414
|
if (error.code === "ENOENT") return null;
|
|
@@ -1147,10 +417,10 @@ async function checkedPath(root, relative) {
|
|
|
1147
417
|
}
|
|
1148
418
|
return file;
|
|
1149
419
|
}
|
|
1150
|
-
__name(checkedPath, "checkedPath");
|
|
420
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, checkedPath, "checkedPath");
|
|
1151
421
|
async function readFile(file) {
|
|
1152
|
-
if (!(await
|
|
1153
|
-
const handle = await
|
|
422
|
+
if (!(await _fs.promises.stat(file)).isFile()) throw new Error("MCP Skill \u5FC5\u987B\u4E3A\u666E\u901A\u6587\u4EF6");
|
|
423
|
+
const handle = await _fs.promises.open(file, _fs.constants.O_RDONLY | _fs.constants.O_NONBLOCK | _fs.constants.O_NOFOLLOW);
|
|
1154
424
|
try {
|
|
1155
425
|
const stat = await handle.stat();
|
|
1156
426
|
if (!stat.isFile() || stat.size > FILE_LIMIT) throw new Error("MCP Skill \u5FC5\u987B\u4E3A\u4E0D\u8D85\u8FC7 1 MiB \u7684\u666E\u901A\u6587\u4EF6");
|
|
@@ -1172,11 +442,11 @@ async function readFile(file) {
|
|
|
1172
442
|
await handle.close();
|
|
1173
443
|
}
|
|
1174
444
|
}
|
|
1175
|
-
__name(readFile, "readFile");
|
|
1176
|
-
function metadata(content) {
|
|
445
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, readFile, "readFile");
|
|
446
|
+
function metadata(content, parseDocument) {
|
|
1177
447
|
const match = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(content);
|
|
1178
448
|
if (!match) throw new Error("MCP Skill \u7F3A\u5C11\u5B8C\u6574 YAML frontmatter");
|
|
1179
|
-
const doc =
|
|
449
|
+
const doc = parseDocument(match[1], {
|
|
1180
450
|
uniqueKeys: true,
|
|
1181
451
|
schema: "core"
|
|
1182
452
|
});
|
|
@@ -1194,19 +464,19 @@ function metadata(content) {
|
|
|
1194
464
|
description
|
|
1195
465
|
};
|
|
1196
466
|
}
|
|
1197
|
-
__name(metadata, "metadata");
|
|
467
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, metadata, "metadata");
|
|
1198
468
|
async function readMcpSkills(cwd = process.cwd()) {
|
|
1199
|
-
const root = await
|
|
469
|
+
const root = await _fs.promises.realpath(cwd);
|
|
1200
470
|
const candidates = [];
|
|
1201
|
-
const directory = await checkedPath(root, MCP_SKILLS_PATH);
|
|
471
|
+
const directory = await checkedPath(root, _chunkCFHAFLNNcjs.MCP_SKILLS_PATH);
|
|
1202
472
|
if (directory) {
|
|
1203
|
-
if (!(await
|
|
1204
|
-
for (const item of (await
|
|
473
|
+
if (!(await _fs.promises.stat(directory)).isDirectory()) throw new Error("MCP Skills \u8DEF\u5F84\u5FC5\u987B\u4E3A\u76EE\u5F55");
|
|
474
|
+
for (const item of (await _fs.promises.readdir(directory, {
|
|
1205
475
|
withFileTypes: true
|
|
1206
|
-
})).sort((
|
|
476
|
+
})).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
1207
477
|
if (item.isSymbolicLink()) throw new Error("MCP Skill \u5FC5\u987B\u4F4D\u4E8E\u5E94\u7528\u5DE5\u7A0B\u5185\uFF0C\u4E0D\u5141\u8BB8\u7B26\u53F7\u94FE\u63A5");
|
|
1208
478
|
if (!item.isDirectory()) continue;
|
|
1209
|
-
const relative = `${MCP_SKILLS_PATH}/${item.name}/SKILL.md`;
|
|
479
|
+
const relative = `${_chunkCFHAFLNNcjs.MCP_SKILLS_PATH}/${item.name}/SKILL.md`;
|
|
1210
480
|
const file = await checkedPath(root, relative);
|
|
1211
481
|
if (!file) continue;
|
|
1212
482
|
if (!NAME.test(item.name) || item.name.length > 64) throw new Error("MCP Skill \u76EE\u5F55\u540D\u987B\u4E3A1\u201364\u4F4D\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u53CA\u5355\u8FDE\u5B57\u7B26\uFF0C\u4E0D\u80FD\u9996\u5C3E\u8FDE\u5B57\u7B26");
|
|
@@ -1218,13 +488,15 @@ async function readMcpSkills(cwd = process.cwd()) {
|
|
|
1218
488
|
}
|
|
1219
489
|
}
|
|
1220
490
|
const skills = [];
|
|
491
|
+
if (!candidates.length) return skills;
|
|
492
|
+
const { parseDocument } = await Promise.resolve().then(() => _interopRequireWildcard(require("yaml")));
|
|
1221
493
|
const names = /* @__PURE__ */ new Set();
|
|
1222
494
|
let total = 0;
|
|
1223
495
|
for (const candidate of candidates) {
|
|
1224
496
|
const { content, bytes } = await readFile(candidate.file);
|
|
1225
497
|
total += bytes;
|
|
1226
498
|
if (total > TOTAL_LIMIT) throw new Error("MCP Skill \u603B\u6B63\u6587\u4E0D\u80FD\u8D85\u8FC7 8 MiB");
|
|
1227
|
-
const meta = metadata(content);
|
|
499
|
+
const meta = metadata(content, parseDocument);
|
|
1228
500
|
if (names.has(meta.name)) throw new Error("MCP Skill name \u91CD\u590D");
|
|
1229
501
|
names.add(meta.name);
|
|
1230
502
|
skills.push({
|
|
@@ -1235,12 +507,12 @@ async function readMcpSkills(cwd = process.cwd()) {
|
|
|
1235
507
|
}
|
|
1236
508
|
return skills;
|
|
1237
509
|
}
|
|
1238
|
-
__name(readMcpSkills, "readMcpSkills");
|
|
510
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, readMcpSkills, "readMcpSkills");
|
|
1239
511
|
|
|
1240
512
|
// src/source-locations.ts
|
|
1241
|
-
|
|
1242
|
-
var
|
|
1243
|
-
|
|
513
|
+
|
|
514
|
+
var _module = require('module');
|
|
515
|
+
|
|
1244
516
|
var sdkEntrypoints = /* @__PURE__ */ new Set([
|
|
1245
517
|
"@lark-apaas/nestjs-mcp",
|
|
1246
518
|
"@lark-apaas/fullstack-nestjs-core"
|
|
@@ -1256,33 +528,33 @@ var ignored = /* @__PURE__ */ new Set([
|
|
|
1256
528
|
"tests"
|
|
1257
529
|
]);
|
|
1258
530
|
function isInside(root, file) {
|
|
1259
|
-
const relative =
|
|
1260
|
-
return relative !== ".." && !relative.startsWith(`..${
|
|
531
|
+
const relative = _path2.default.relative(root, file);
|
|
532
|
+
return relative !== ".." && !relative.startsWith(`..${_path2.default.sep}`) && !_path2.default.isAbsolute(relative);
|
|
1261
533
|
}
|
|
1262
|
-
__name(isInside, "isInside");
|
|
534
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, isInside, "isInside");
|
|
1263
535
|
async function collectSourceLocations(tools, resources, cwd = process.cwd()) {
|
|
1264
|
-
const empty = /* @__PURE__ */ __name(() => ({
|
|
536
|
+
const empty = /* @__PURE__ */ _chunkCFHAFLNNcjs.__name.call(void 0, () => ({
|
|
1265
537
|
tools: {},
|
|
1266
538
|
resources: {},
|
|
1267
539
|
prompts: {}
|
|
1268
540
|
}), "empty");
|
|
1269
541
|
try {
|
|
1270
542
|
if (!tools.length && !resources.length) return empty();
|
|
1271
|
-
const root = await
|
|
1272
|
-
const server =
|
|
1273
|
-
if ((await
|
|
1274
|
-
const ts = (0,
|
|
543
|
+
const root = await _fs.promises.realpath(cwd);
|
|
544
|
+
const server = _path2.default.join(root, "server");
|
|
545
|
+
if ((await _fs.promises.lstat(server)).isSymbolicLink()) return empty();
|
|
546
|
+
const ts = _module.createRequire.call(void 0, _path2.default.join(root, "package.json"))("typescript");
|
|
1275
547
|
const sources = /* @__PURE__ */ new Map();
|
|
1276
|
-
const scan = /* @__PURE__ */ __name(async (directory) => {
|
|
1277
|
-
for (const item of await
|
|
548
|
+
const scan = /* @__PURE__ */ _chunkCFHAFLNNcjs.__name.call(void 0, async (directory) => {
|
|
549
|
+
for (const item of await _fs.promises.readdir(directory, {
|
|
1278
550
|
withFileTypes: true
|
|
1279
551
|
})) {
|
|
1280
552
|
if (item.isSymbolicLink() || item.name.startsWith(".") || ignored.has(item.name)) continue;
|
|
1281
|
-
const file =
|
|
1282
|
-
if (file ===
|
|
553
|
+
const file = _path2.default.join(directory, item.name);
|
|
554
|
+
if (file === _path2.default.join(server, "mcp", "ui") || file === _path2.default.join(server, "mcp", "skills")) continue;
|
|
1283
555
|
if (item.isDirectory()) await scan(file);
|
|
1284
556
|
else if (item.isFile() && /\.(?:ts|tsx|mts|cts)$/.test(item.name) && !/\.(?:d|spec|test)\.(?:ts|tsx|mts|cts)$/.test(item.name)) {
|
|
1285
|
-
sources.set(file, await
|
|
557
|
+
sources.set(file, await _fs.promises.readFile(file, "utf8"));
|
|
1286
558
|
}
|
|
1287
559
|
}
|
|
1288
560
|
}, "scan");
|
|
@@ -1303,7 +575,7 @@ async function collectSourceLocations(tools, resources, cwd = process.cwd()) {
|
|
|
1303
575
|
], options, host);
|
|
1304
576
|
if (program.getSyntacticDiagnostics().length) return empty();
|
|
1305
577
|
const checker = program.getTypeChecker();
|
|
1306
|
-
const isSdkReference = /* @__PURE__ */ __name((expression, exported) => {
|
|
578
|
+
const isSdkReference = /* @__PURE__ */ _chunkCFHAFLNNcjs.__name.call(void 0, (expression, exported) => {
|
|
1307
579
|
let identifier;
|
|
1308
580
|
let namespace = false;
|
|
1309
581
|
if (ts.isIdentifier(expression)) identifier = expression;
|
|
@@ -1311,24 +583,24 @@ async function collectSourceLocations(tools, resources, cwd = process.cwd()) {
|
|
|
1311
583
|
identifier = expression.expression;
|
|
1312
584
|
namespace = true;
|
|
1313
585
|
} else return false;
|
|
1314
|
-
const declarations = checker.getSymbolAtLocation(identifier)
|
|
1315
|
-
if (declarations
|
|
586
|
+
const declarations = _optionalChain([checker, 'access', _5 => _5.getSymbolAtLocation, 'call', _6 => _6(identifier), 'optionalAccess', _7 => _7.declarations]);
|
|
587
|
+
if (_optionalChain([declarations, 'optionalAccess', _8 => _8.length]) !== 1) return false;
|
|
1316
588
|
const declaration = declarations[0];
|
|
1317
589
|
let clause;
|
|
1318
|
-
if (!namespace && ts.isImportSpecifier(declaration) && !declaration.isTypeOnly && (declaration.propertyName
|
|
590
|
+
if (!namespace && ts.isImportSpecifier(declaration) && !declaration.isTypeOnly && (_nullishCoalesce(declaration.propertyName, () => ( declaration.name))).text === exported) {
|
|
1319
591
|
clause = declaration.parent.parent;
|
|
1320
592
|
} else if (namespace && ts.isNamespaceImport(declaration)) clause = declaration.parent;
|
|
1321
593
|
else return false;
|
|
1322
594
|
return !clause.isTypeOnly && ts.isStringLiteral(clause.parent.moduleSpecifier) && sdkEntrypoints.has(clause.parent.moduleSpecifier.text);
|
|
1323
595
|
}, "isSdkReference");
|
|
1324
|
-
const decorated = /* @__PURE__ */ __name((node, exported) => {
|
|
1325
|
-
return ts.canHaveDecorators(node) && !!ts.getDecorators(node)
|
|
596
|
+
const decorated = /* @__PURE__ */ _chunkCFHAFLNNcjs.__name.call(void 0, (node, exported) => {
|
|
597
|
+
return ts.canHaveDecorators(node) && !!_optionalChain([ts, 'access', _9 => _9.getDecorators, 'call', _10 => _10(node), 'optionalAccess', _11 => _11.some, 'call', _12 => _12(({ expression }) => ts.isCallExpression(expression) && isSdkReference(expression.expression, exported))]);
|
|
1326
598
|
}, "decorated");
|
|
1327
599
|
const classes = /* @__PURE__ */ new Map();
|
|
1328
600
|
for (const source of program.getSourceFiles()) {
|
|
1329
|
-
const visit = /* @__PURE__ */ __name((node) => {
|
|
601
|
+
const visit = /* @__PURE__ */ _chunkCFHAFLNNcjs.__name.call(void 0, (node) => {
|
|
1330
602
|
if (ts.isClassDeclaration(node) && node.name) {
|
|
1331
|
-
const matches = classes.get(node.name.text)
|
|
603
|
+
const matches = _nullishCoalesce(classes.get(node.name.text), () => ( []));
|
|
1332
604
|
matches.push(node);
|
|
1333
605
|
classes.set(node.name.text, matches);
|
|
1334
606
|
}
|
|
@@ -1336,20 +608,20 @@ async function collectSourceLocations(tools, resources, cwd = process.cwd()) {
|
|
|
1336
608
|
}, "visit");
|
|
1337
609
|
visit(source);
|
|
1338
610
|
}
|
|
1339
|
-
const methodFor = /* @__PURE__ */ __name((definition, decorator) => {
|
|
611
|
+
const methodFor = /* @__PURE__ */ _chunkCFHAFLNNcjs.__name.call(void 0, (definition, decorator) => {
|
|
1340
612
|
const matches = classes.get(definition.className);
|
|
1341
|
-
if (matches
|
|
613
|
+
if (_optionalChain([matches, 'optionalAccess', _13 => _13.length]) !== 1 || !decorated(matches[0], "McpTools")) return void 0;
|
|
1342
614
|
const methods = matches[0].members.filter((member) => ts.isMethodDeclaration(member) && (ts.isIdentifier(member.name) || ts.isStringLiteral(member.name)) && member.name.text === definition.methodName);
|
|
1343
615
|
if (methods.length !== 1 || !methods[0].body || !decorated(methods[0], decorator)) return void 0;
|
|
1344
616
|
return methods[0];
|
|
1345
617
|
}, "methodFor");
|
|
1346
618
|
const result = empty();
|
|
1347
|
-
const unique = /* @__PURE__ */ __name((items, key) => {
|
|
619
|
+
const unique = /* @__PURE__ */ _chunkCFHAFLNNcjs.__name.call(void 0, (items, key) => {
|
|
1348
620
|
const counts = /* @__PURE__ */ new Map();
|
|
1349
|
-
for (const item of items) counts.set(key(item), (counts.get(key(item))
|
|
621
|
+
for (const item of items) counts.set(key(item), (_nullishCoalesce(counts.get(key(item)), () => ( 0))) + 1);
|
|
1350
622
|
return items.filter((item) => counts.get(key(item)) === 1);
|
|
1351
623
|
}, "unique");
|
|
1352
|
-
const put = /* @__PURE__ */ __name((map, key, value) => {
|
|
624
|
+
const put = /* @__PURE__ */ _chunkCFHAFLNNcjs.__name.call(void 0, (map, key, value) => {
|
|
1353
625
|
Object.defineProperty(map, key, {
|
|
1354
626
|
value,
|
|
1355
627
|
enumerable: true,
|
|
@@ -1362,7 +634,7 @@ async function collectSourceLocations(tools, resources, cwd = process.cwd()) {
|
|
|
1362
634
|
if (!method) continue;
|
|
1363
635
|
const source = method.getSourceFile();
|
|
1364
636
|
put(result.tools, tool.name, {
|
|
1365
|
-
path:
|
|
637
|
+
path: _path2.default.relative(root, source.fileName).split(_path2.default.sep).join("/"),
|
|
1366
638
|
line: source.getLineAndCharacterOfPosition(method.name.getStart(source)).line + 1
|
|
1367
639
|
});
|
|
1368
640
|
}
|
|
@@ -1370,7 +642,7 @@ async function collectSourceLocations(tools, resources, cwd = process.cwd()) {
|
|
|
1370
642
|
const method = methodFor(resource, "McpUiResource");
|
|
1371
643
|
if (!method) continue;
|
|
1372
644
|
const calls = [];
|
|
1373
|
-
const visit = /* @__PURE__ */ __name((node) => {
|
|
645
|
+
const visit = /* @__PURE__ */ _chunkCFHAFLNNcjs.__name.call(void 0, (node) => {
|
|
1374
646
|
if (ts.isFunctionLike(node) || ts.isClassLike(node)) return;
|
|
1375
647
|
if (ts.isCallExpression(node) && isSdkReference(node.expression, "readMcpUiTemplate")) calls.push(node);
|
|
1376
648
|
ts.forEachChild(node, visit);
|
|
@@ -1381,52 +653,52 @@ async function collectSourceLocations(tools, resources, cwd = process.cwd()) {
|
|
|
1381
653
|
if (!(ts.isStringLiteral(entry) || ts.isNoSubstitutionTemplateLiteral(entry)) || !/^[A-Za-z0-9_-]+$/.test(entry.text)) continue;
|
|
1382
654
|
const relative = `server/mcp/ui/${entry.text}/index.html`;
|
|
1383
655
|
try {
|
|
1384
|
-
const file = await
|
|
1385
|
-
if (file !==
|
|
656
|
+
const file = await _fs.promises.realpath(_path2.default.join(root, relative));
|
|
657
|
+
if (file !== _path2.default.join(root, relative) || !isInside(root, file) || !(await _fs.promises.stat(file)).isFile()) continue;
|
|
1386
658
|
put(result.resources, resource.options.uri, {
|
|
1387
659
|
path: relative
|
|
1388
660
|
});
|
|
1389
|
-
} catch {
|
|
661
|
+
} catch (e3) {
|
|
1390
662
|
}
|
|
1391
663
|
}
|
|
1392
664
|
return result;
|
|
1393
|
-
} catch {
|
|
665
|
+
} catch (e4) {
|
|
1394
666
|
return empty();
|
|
1395
667
|
}
|
|
1396
668
|
}
|
|
1397
|
-
__name(collectSourceLocations, "collectSourceLocations");
|
|
669
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, collectSourceLocations, "collectSourceLocations");
|
|
1398
670
|
|
|
1399
671
|
// src/services/mcp-manifest.service.ts
|
|
1400
672
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
1401
|
-
var c = arguments.length,
|
|
1402
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1403
|
-
else for (var
|
|
1404
|
-
return c > 3 &&
|
|
673
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
674
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
675
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
676
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1405
677
|
}
|
|
1406
|
-
__name(_ts_decorate2, "_ts_decorate");
|
|
1407
|
-
function _ts_metadata2(
|
|
1408
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(
|
|
678
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, _ts_decorate2, "_ts_decorate");
|
|
679
|
+
function _ts_metadata2(k, v) {
|
|
680
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1409
681
|
}
|
|
1410
|
-
__name(_ts_metadata2, "_ts_metadata");
|
|
682
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, _ts_metadata2, "_ts_metadata");
|
|
1411
683
|
function _ts_param2(paramIndex, decorator) {
|
|
1412
684
|
return function(target, key) {
|
|
1413
685
|
decorator(target, key, paramIndex);
|
|
1414
686
|
};
|
|
1415
687
|
}
|
|
1416
|
-
__name(_ts_param2, "_ts_param");
|
|
1417
|
-
var McpManifestService = class _McpManifestService {
|
|
688
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, _ts_param2, "_ts_param");
|
|
689
|
+
var McpManifestService = (_class3 = class _McpManifestService {
|
|
1418
690
|
static {
|
|
1419
|
-
__name(this, "McpManifestService");
|
|
691
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, this, "McpManifestService");
|
|
1420
692
|
}
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
logger = new
|
|
1424
|
-
sources = {
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
__init8() {this.logger = new (0, _common.Logger)(_McpManifestService.name)}
|
|
696
|
+
__init9() {this.sources = {
|
|
1425
697
|
tools: {},
|
|
1426
698
|
resources: {},
|
|
1427
699
|
prompts: {}
|
|
1428
|
-
}
|
|
1429
|
-
constructor(registry, options) {
|
|
700
|
+
}}
|
|
701
|
+
constructor(registry, options) {;_class3.prototype.__init8.call(this);_class3.prototype.__init9.call(this);
|
|
1430
702
|
this.registry = registry;
|
|
1431
703
|
this.options = options;
|
|
1432
704
|
}
|
|
@@ -1441,6 +713,7 @@ var McpManifestService = class _McpManifestService {
|
|
|
1441
713
|
/** 面板查询不读写派生清单;与本次 MCP 请求使用同一份 Skill 文件读取逻辑。 */
|
|
1442
714
|
async catalog() {
|
|
1443
715
|
const skills = await readMcpSkills();
|
|
716
|
+
const { buildManifest } = await loadMcpProtocol();
|
|
1444
717
|
const manifest = await buildManifest({
|
|
1445
718
|
tools: this.registry.getTools(),
|
|
1446
719
|
resources: this.registry.getResources(),
|
|
@@ -1464,11 +737,11 @@ var McpManifestService = class _McpManifestService {
|
|
|
1464
737
|
sources
|
|
1465
738
|
};
|
|
1466
739
|
}
|
|
1467
|
-
};
|
|
740
|
+
}, _class3);
|
|
1468
741
|
McpManifestService = _ts_decorate2([
|
|
1469
|
-
(0,
|
|
1470
|
-
_ts_param2(0, (0,
|
|
1471
|
-
_ts_param2(1, (0,
|
|
742
|
+
_common.Injectable.call(void 0, ),
|
|
743
|
+
_ts_param2(0, _common.Inject.call(void 0, McpRegistryService)),
|
|
744
|
+
_ts_param2(1, _common.Inject.call(void 0, _chunkCFHAFLNNcjs.MCP_MODULE_OPTIONS)),
|
|
1472
745
|
_ts_metadata2("design:type", Function),
|
|
1473
746
|
_ts_metadata2("design:paramtypes", [
|
|
1474
747
|
typeof McpRegistryService === "undefined" ? Object : McpRegistryService,
|
|
@@ -1478,28 +751,28 @@ McpManifestService = _ts_decorate2([
|
|
|
1478
751
|
|
|
1479
752
|
// src/controllers/mcp-manifest.controller.ts
|
|
1480
753
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
1481
|
-
var c = arguments.length,
|
|
1482
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1483
|
-
else for (var
|
|
1484
|
-
return c > 3 &&
|
|
754
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
755
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
756
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
757
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1485
758
|
}
|
|
1486
|
-
__name(_ts_decorate3, "_ts_decorate");
|
|
1487
|
-
function _ts_metadata3(
|
|
1488
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(
|
|
759
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, _ts_decorate3, "_ts_decorate");
|
|
760
|
+
function _ts_metadata3(k, v) {
|
|
761
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1489
762
|
}
|
|
1490
|
-
__name(_ts_metadata3, "_ts_metadata");
|
|
763
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, _ts_metadata3, "_ts_metadata");
|
|
1491
764
|
function _ts_param3(paramIndex, decorator) {
|
|
1492
765
|
return function(target, key) {
|
|
1493
766
|
decorator(target, key, paramIndex);
|
|
1494
767
|
};
|
|
1495
768
|
}
|
|
1496
|
-
__name(_ts_param3, "_ts_param");
|
|
769
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, _ts_param3, "_ts_param");
|
|
1497
770
|
var McpManifestController = class {
|
|
1498
771
|
static {
|
|
1499
|
-
__name(this, "McpManifestController");
|
|
772
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, this, "McpManifestController");
|
|
1500
773
|
}
|
|
1501
|
-
|
|
1502
|
-
|
|
774
|
+
|
|
775
|
+
|
|
1503
776
|
constructor(manifest, registry) {
|
|
1504
777
|
this.manifest = manifest;
|
|
1505
778
|
this.registry = registry;
|
|
@@ -1528,9 +801,9 @@ var McpManifestController = class {
|
|
|
1528
801
|
}
|
|
1529
802
|
};
|
|
1530
803
|
_ts_decorate3([
|
|
1531
|
-
(0,
|
|
1532
|
-
_ts_param3(0, (0,
|
|
1533
|
-
_ts_param3(1, (0,
|
|
804
|
+
_common.Get.call(void 0, ),
|
|
805
|
+
_ts_param3(0, _common.Req.call(void 0, )),
|
|
806
|
+
_ts_param3(1, _common.Res.call(void 0, )),
|
|
1534
807
|
_ts_metadata3("design:type", Function),
|
|
1535
808
|
_ts_metadata3("design:paramtypes", [
|
|
1536
809
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -1539,10 +812,10 @@ _ts_decorate3([
|
|
|
1539
812
|
_ts_metadata3("design:returntype", Promise)
|
|
1540
813
|
], McpManifestController.prototype, "get", null);
|
|
1541
814
|
McpManifestController = _ts_decorate3([
|
|
1542
|
-
(0,
|
|
1543
|
-
(0,
|
|
1544
|
-
_ts_param3(0, (0,
|
|
1545
|
-
_ts_param3(1, (0,
|
|
815
|
+
_swagger.ApiExcludeController.call(void 0, ),
|
|
816
|
+
_common.Controller.call(void 0, "__innerapi__/mcp/manifest"),
|
|
817
|
+
_ts_param3(0, _common.Inject.call(void 0, McpManifestService)),
|
|
818
|
+
_ts_param3(1, _common.Inject.call(void 0, McpRegistryService)),
|
|
1546
819
|
_ts_metadata3("design:type", Function),
|
|
1547
820
|
_ts_metadata3("design:paramtypes", [
|
|
1548
821
|
typeof McpManifestService === "undefined" ? Object : McpManifestService,
|
|
@@ -1551,137 +824,19 @@ McpManifestController = _ts_decorate3([
|
|
|
1551
824
|
], McpManifestController);
|
|
1552
825
|
|
|
1553
826
|
// src/controllers/mcp.controller.ts
|
|
1554
|
-
|
|
1555
|
-
|
|
827
|
+
|
|
828
|
+
|
|
1556
829
|
|
|
1557
830
|
// src/services/mcp-server.service.ts
|
|
1558
|
-
|
|
1559
|
-
var import_streamableHttp = require("@modelcontextprotocol/sdk/server/streamableHttp.js");
|
|
1560
|
-
var import_types7 = require("@modelcontextprotocol/sdk/types.js");
|
|
1561
|
-
|
|
1562
|
-
// src/revision.ts
|
|
1563
|
-
var import_node_async_hooks2 = require("async_hooks");
|
|
1564
|
-
var import_node_crypto = require("crypto");
|
|
1565
|
-
var import_node_fs3 = require("fs");
|
|
1566
|
-
var import_node_path3 = __toESM(require("path"), 1);
|
|
1567
|
-
var import_types6 = require("@modelcontextprotocol/sdk/types.js");
|
|
1568
|
-
var MCP_APP_REVISION_META_KEY = "com.feishu.miaoda/appRevision";
|
|
1569
|
-
var MCP_APP_REVISION_MISMATCH = "MCP_APP_REVISION_MISMATCH";
|
|
1570
|
-
function revisionHash(value) {
|
|
1571
|
-
return (0, import_node_crypto.createHash)("sha256").update(JSON.stringify(value)).digest("hex");
|
|
1572
|
-
}
|
|
1573
|
-
__name(revisionHash, "revisionHash");
|
|
1574
|
-
function assertAppRevision(meta, actual) {
|
|
1575
|
-
if (!meta || typeof meta !== "object" || !Object.prototype.hasOwnProperty.call(meta, MCP_APP_REVISION_META_KEY)) return;
|
|
1576
|
-
const expected = meta[MCP_APP_REVISION_META_KEY];
|
|
1577
|
-
if (typeof expected !== "string" || !expected || expected.length > 256) {
|
|
1578
|
-
throw new import_types6.McpError(import_types6.ErrorCode.InvalidParams, "appRevision \u5FC5\u987B\u4E3A 1\u2013256 \u5B57\u7B26\u7684\u5B57\u7B26\u4E32");
|
|
1579
|
-
}
|
|
1580
|
-
if (actual === void 0) {
|
|
1581
|
-
throw new import_types6.McpError(-32e3, "\u5F53\u524D\u8FD0\u884C\u73AF\u5883\u7F3A\u5C11\u53D1\u5E03\u7248\u672C\u6807\u8BC6\uFF0C\u8BF7\u68C0\u67E5\u5E73\u53F0\u73AF\u5883\u6216\u914D\u7F6E appBuildId", {
|
|
1582
|
-
code: "MCP_APP_REVISION_UNAVAILABLE"
|
|
1583
|
-
});
|
|
1584
|
-
}
|
|
1585
|
-
if (expected !== actual) {
|
|
1586
|
-
throw new import_types6.McpError(-32e3, "\u5E94\u7528\u5DF2\u66F4\u65B0\uFF0C\u8BF7\u91CD\u65B0\u8C03\u8BD5\uFF1B\u672C\u6B21\u64CD\u4F5C\u672A\u6267\u884C", {
|
|
1587
|
-
code: MCP_APP_REVISION_MISMATCH,
|
|
1588
|
-
expectedRevision: expected,
|
|
1589
|
-
actualRevision: actual
|
|
1590
|
-
});
|
|
1591
|
-
}
|
|
1592
|
-
}
|
|
1593
|
-
__name(assertAppRevision, "assertAppRevision");
|
|
1594
|
-
var uiContext = new import_node_async_hooks2.AsyncLocalStorage();
|
|
1595
|
-
function withUiSnapshot(snapshot, callback) {
|
|
1596
|
-
return uiContext.run(snapshot, callback);
|
|
1597
|
-
}
|
|
1598
|
-
__name(withUiSnapshot, "withUiSnapshot");
|
|
1599
|
-
async function snapshotUiTemplate(entry, cwd) {
|
|
1600
|
-
const snapshot = uiContext.getStore();
|
|
1601
|
-
if (!snapshot || await import_node_fs3.promises.realpath(cwd) !== snapshot.root) return void 0;
|
|
1602
|
-
const html = snapshot.files.get(`${entry}.html`);
|
|
1603
|
-
if (html === void 0) throw new Error(`\u5F53\u524D MCP \u4FEE\u8BA2\u4E2D\u4E0D\u5B58\u5728 UI \u4EA7\u7269\uFF1A${entry}.html`);
|
|
1604
|
-
return {
|
|
1605
|
-
html
|
|
1606
|
-
};
|
|
1607
|
-
}
|
|
1608
|
-
__name(snapshotUiTemplate, "snapshotUiTemplate");
|
|
1609
|
-
var UiSnapshotReader = class {
|
|
1610
|
-
static {
|
|
1611
|
-
__name(this, "UiSnapshotReader");
|
|
1612
|
-
}
|
|
1613
|
-
cache = /* @__PURE__ */ new Map();
|
|
1614
|
-
inFlight = /* @__PURE__ */ new Map();
|
|
1615
|
-
async read(cwd) {
|
|
1616
|
-
const root = await import_node_fs3.promises.realpath(cwd);
|
|
1617
|
-
const existing = this.inFlight.get(root);
|
|
1618
|
-
if (existing) return existing;
|
|
1619
|
-
const pending = this.readWithRetry(root).finally(() => {
|
|
1620
|
-
this.inFlight.delete(root);
|
|
1621
|
-
});
|
|
1622
|
-
this.inFlight.set(root, pending);
|
|
1623
|
-
return pending;
|
|
1624
|
-
}
|
|
1625
|
-
async readWithRetry(root) {
|
|
1626
|
-
for (let attempt = 0; ; attempt++) {
|
|
1627
|
-
try {
|
|
1628
|
-
return await this.readSnapshot(root);
|
|
1629
|
-
} catch (error) {
|
|
1630
|
-
if (error.code !== "ENOENT" || attempt >= 2) throw error;
|
|
1631
|
-
}
|
|
1632
|
-
}
|
|
1633
|
-
}
|
|
1634
|
-
async readSnapshot(root) {
|
|
1635
|
-
const dir = import_node_path3.default.join(root, MCP_UI_DIST_DIR);
|
|
1636
|
-
let names;
|
|
1637
|
-
try {
|
|
1638
|
-
names = await import_node_fs3.promises.readdir(dir);
|
|
1639
|
-
} catch (error) {
|
|
1640
|
-
if (error.code !== "ENOENT") throw error;
|
|
1641
|
-
names = [];
|
|
1642
|
-
}
|
|
1643
|
-
const files = /* @__PURE__ */ new Map();
|
|
1644
|
-
const next = /* @__PURE__ */ new Map();
|
|
1645
|
-
for (const name of names.filter((name2) => /^[A-Za-z0-9_-]+\.html$/.test(name2)).sort()) {
|
|
1646
|
-
const file = import_node_path3.default.join(dir, name);
|
|
1647
|
-
const stat = await import_node_fs3.promises.lstat(file, {
|
|
1648
|
-
bigint: true
|
|
1649
|
-
});
|
|
1650
|
-
if (!stat.isFile()) throw new Error(`MCP UI \u4EA7\u7269\u5FC5\u987B\u4E3A\u666E\u901A\u6587\u4EF6\uFF1A${name}`);
|
|
1651
|
-
const signature = `${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}`;
|
|
1652
|
-
let cached = this.cache.get(file);
|
|
1653
|
-
if (cached?.signature !== signature) {
|
|
1654
|
-
const html = await import_node_fs3.promises.readFile(file, "utf8");
|
|
1655
|
-
cached = {
|
|
1656
|
-
signature,
|
|
1657
|
-
html,
|
|
1658
|
-
hash: revisionHash(html)
|
|
1659
|
-
};
|
|
1660
|
-
}
|
|
1661
|
-
next.set(file, cached);
|
|
1662
|
-
files.set(name, cached.html);
|
|
1663
|
-
}
|
|
1664
|
-
this.cache = next;
|
|
1665
|
-
return {
|
|
1666
|
-
root,
|
|
1667
|
-
files,
|
|
1668
|
-
fingerprint: revisionHash([
|
|
1669
|
-
...next
|
|
1670
|
-
].map(([file, value]) => [
|
|
1671
|
-
import_node_path3.default.basename(file),
|
|
1672
|
-
value.hash
|
|
1673
|
-
]))
|
|
1674
|
-
};
|
|
1675
|
-
}
|
|
1676
|
-
};
|
|
831
|
+
|
|
1677
832
|
|
|
1678
833
|
// src/services/mcp-revision.service.ts
|
|
1679
|
-
|
|
834
|
+
|
|
1680
835
|
|
|
1681
836
|
// src/development-revision.ts
|
|
1682
|
-
var
|
|
1683
|
-
|
|
1684
|
-
|
|
837
|
+
var _crypto = require('crypto');
|
|
838
|
+
|
|
839
|
+
|
|
1685
840
|
var CODE_FILE = /\.(?:[cm]?js|json|node)$/;
|
|
1686
841
|
var IGNORED_PATHS = /* @__PURE__ */ new Set([
|
|
1687
842
|
"dist/client",
|
|
@@ -1692,30 +847,30 @@ var IGNORED_PATHS = /* @__PURE__ */ new Set([
|
|
|
1692
847
|
]);
|
|
1693
848
|
function developmentBuildId(cwd, entrypoint) {
|
|
1694
849
|
if (!entrypoint) return void 0;
|
|
1695
|
-
const root = (0,
|
|
1696
|
-
const entry =
|
|
850
|
+
const root = _fs.realpathSync.call(void 0, cwd);
|
|
851
|
+
const entry = _path2.default.resolve(cwd, entrypoint);
|
|
1697
852
|
const executable = [
|
|
1698
853
|
entry,
|
|
1699
854
|
`${entry}.js`,
|
|
1700
855
|
`${entry}.cjs`,
|
|
1701
856
|
`${entry}.mjs`
|
|
1702
|
-
].find((file) => (0,
|
|
857
|
+
].find((file) => _fs.existsSync.call(void 0, file) && _fs.lstatSync.call(void 0, file).isFile());
|
|
1703
858
|
if (!executable) return void 0;
|
|
1704
|
-
const relative =
|
|
859
|
+
const relative = _path2.default.relative(root, _fs.realpathSync.call(void 0, executable)).split(_path2.default.sep).join("/");
|
|
1705
860
|
if (!/^dist\/(?:server\/)?main\.[cm]?js$/.test(relative)) return void 0;
|
|
1706
861
|
const files = [];
|
|
1707
862
|
function scan(dir) {
|
|
1708
|
-
if (!(0,
|
|
1709
|
-
for (const name of (0,
|
|
1710
|
-
const file =
|
|
863
|
+
if (!_fs.existsSync.call(void 0, _path2.default.join(root, dir))) return;
|
|
864
|
+
for (const name of _fs.readdirSync.call(void 0, _path2.default.join(root, dir)).sort()) {
|
|
865
|
+
const file = _path2.default.posix.join(dir, name);
|
|
1711
866
|
if (IGNORED_PATHS.has(file) || name === "node_modules" || name === ".git") continue;
|
|
1712
|
-
const stat = (0,
|
|
867
|
+
const stat = _fs.lstatSync.call(void 0, _path2.default.join(root, file));
|
|
1713
868
|
if (stat.isDirectory()) scan(file);
|
|
1714
869
|
else if (stat.isFile() && CODE_FILE.test(name)) files.push(file);
|
|
1715
870
|
else if (stat.isSymbolicLink()) throw new Error(`MCP \u5F00\u53D1\u7F16\u8BD1\u4EA7\u7269\u4E0D\u80FD\u5305\u542B\u7B26\u53F7\u94FE\u63A5\uFF1A${file}`);
|
|
1716
871
|
}
|
|
1717
872
|
}
|
|
1718
|
-
__name(scan, "scan");
|
|
873
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, scan, "scan");
|
|
1719
874
|
if (relative.startsWith("dist/server/")) {
|
|
1720
875
|
scan("dist/server");
|
|
1721
876
|
scan("dist/shared");
|
|
@@ -1730,16 +885,16 @@ function developmentBuildId(cwd, entrypoint) {
|
|
|
1730
885
|
"pnpm-lock.yaml",
|
|
1731
886
|
"yarn.lock"
|
|
1732
887
|
]) {
|
|
1733
|
-
if ((0,
|
|
888
|
+
if (_fs.existsSync.call(void 0, _path2.default.join(root, file))) files.push(file);
|
|
1734
889
|
}
|
|
1735
|
-
const hash = (0,
|
|
890
|
+
const hash = _crypto.createHash.call(void 0, "sha256").update(JSON.stringify([
|
|
1736
891
|
"miaoda-mcp-dev-build-v1",
|
|
1737
892
|
relative
|
|
1738
893
|
]));
|
|
1739
894
|
for (const file of [
|
|
1740
895
|
...new Set(files)
|
|
1741
896
|
].sort()) {
|
|
1742
|
-
const digest = (0,
|
|
897
|
+
const digest = _crypto.createHash.call(void 0, "sha256").update(_fs.readFileSync.call(void 0, _path2.default.join(root, file))).digest("hex");
|
|
1743
898
|
hash.update(JSON.stringify([
|
|
1744
899
|
file,
|
|
1745
900
|
digest
|
|
@@ -1747,34 +902,34 @@ function developmentBuildId(cwd, entrypoint) {
|
|
|
1747
902
|
}
|
|
1748
903
|
return hash.digest("hex");
|
|
1749
904
|
}
|
|
1750
|
-
__name(developmentBuildId, "developmentBuildId");
|
|
905
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, developmentBuildId, "developmentBuildId");
|
|
1751
906
|
|
|
1752
907
|
// src/services/mcp-revision.service.ts
|
|
1753
908
|
function _ts_decorate4(decorators, target, key, desc) {
|
|
1754
|
-
var c = arguments.length,
|
|
1755
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1756
|
-
else for (var
|
|
1757
|
-
return c > 3 &&
|
|
909
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
910
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
911
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
912
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1758
913
|
}
|
|
1759
|
-
__name(_ts_decorate4, "_ts_decorate");
|
|
1760
|
-
function _ts_metadata4(
|
|
1761
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(
|
|
914
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, _ts_decorate4, "_ts_decorate");
|
|
915
|
+
function _ts_metadata4(k, v) {
|
|
916
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1762
917
|
}
|
|
1763
|
-
__name(_ts_metadata4, "_ts_metadata");
|
|
918
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, _ts_metadata4, "_ts_metadata");
|
|
1764
919
|
function _ts_param4(paramIndex, decorator) {
|
|
1765
920
|
return function(target, key) {
|
|
1766
921
|
decorator(target, key, paramIndex);
|
|
1767
922
|
};
|
|
1768
923
|
}
|
|
1769
|
-
__name(_ts_param4, "_ts_param");
|
|
1770
|
-
var McpRevisionState = class _McpRevisionState {
|
|
924
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, _ts_param4, "_ts_param");
|
|
925
|
+
var McpRevisionState = (_class4 = class _McpRevisionState {
|
|
1771
926
|
static {
|
|
1772
|
-
__name(this, "McpRevisionState");
|
|
927
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, this, "McpRevisionState");
|
|
1773
928
|
}
|
|
1774
|
-
|
|
1775
|
-
ui = new UiSnapshotReader()
|
|
1776
|
-
|
|
1777
|
-
constructor(cwd, production, buildId, entrypoint = process.argv[1], captureDevelopmentBuild = true) {
|
|
929
|
+
|
|
930
|
+
__init10() {this.ui = new (0, _chunkCFHAFLNNcjs.UiSnapshotReader)()}
|
|
931
|
+
|
|
932
|
+
constructor(cwd, production, buildId, entrypoint = process.argv[1], captureDevelopmentBuild = true) {;_class4.prototype.__init10.call(this);
|
|
1778
933
|
this.cwd = cwd;
|
|
1779
934
|
let base = buildId;
|
|
1780
935
|
if (base === void 0 && production) {
|
|
@@ -1792,7 +947,7 @@ var McpRevisionState = class _McpRevisionState {
|
|
|
1792
947
|
try {
|
|
1793
948
|
base = developmentBuildId(cwd, entrypoint);
|
|
1794
949
|
} catch (error) {
|
|
1795
|
-
new
|
|
950
|
+
new (0, _common.Logger)(_McpRevisionState.name).warn(`MCP \u7248\u672C\u6307\u7EB9\u4E0D\u53EF\u7528\uFF1A${error instanceof Error ? error.message : String(error)}\u3002\u8BF7\u68C0\u67E5\u7F16\u8BD1\u4EA7\u7269\u6216\u914D\u7F6E appBuildId\u3002`, MCP_LOG_ATTRIBUTES);
|
|
1796
951
|
}
|
|
1797
952
|
}
|
|
1798
953
|
this.base = Promise.resolve(base);
|
|
@@ -1809,9 +964,9 @@ var McpRevisionState = class _McpRevisionState {
|
|
|
1809
964
|
const [base, ui, skills] = await Promise.all([
|
|
1810
965
|
this.getBase(),
|
|
1811
966
|
this.ui.read(this.cwd),
|
|
1812
|
-
skillsSnapshot
|
|
967
|
+
_nullishCoalesce(skillsSnapshot, () => ( readMcpSkills(this.cwd)))
|
|
1813
968
|
]);
|
|
1814
|
-
const revision = base === void 0 ? void 0 : revisionHash([
|
|
969
|
+
const revision = base === void 0 ? void 0 : _chunkCFHAFLNNcjs.revisionHash.call(void 0, [
|
|
1815
970
|
base,
|
|
1816
971
|
ui.fingerprint,
|
|
1817
972
|
skills.map(({ name, description, content }) => [
|
|
@@ -1826,14 +981,14 @@ var McpRevisionState = class _McpRevisionState {
|
|
|
1826
981
|
skills
|
|
1827
982
|
};
|
|
1828
983
|
}
|
|
1829
|
-
};
|
|
984
|
+
}, _class4);
|
|
1830
985
|
var McpRevisionService = class _McpRevisionService {
|
|
1831
986
|
static {
|
|
1832
|
-
__name(this, "McpRevisionService");
|
|
987
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, this, "McpRevisionService");
|
|
1833
988
|
}
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
989
|
+
|
|
990
|
+
|
|
991
|
+
|
|
1837
992
|
constructor(options, registry) {
|
|
1838
993
|
this.options = options;
|
|
1839
994
|
this.registry = registry;
|
|
@@ -1847,7 +1002,7 @@ var McpRevisionService = class _McpRevisionService {
|
|
|
1847
1002
|
try {
|
|
1848
1003
|
if ((await readMcpSkills()).length) this.initialize(true);
|
|
1849
1004
|
} catch (error) {
|
|
1850
|
-
new
|
|
1005
|
+
new (0, _common.Logger)(_McpRevisionService.name).warn(`MCP Skill \u521D\u59CB\u5316\u8BFB\u53D6\u5931\u8D25\uFF1A${error instanceof Error ? error.message : String(error)}`, MCP_LOG_ATTRIBUTES);
|
|
1851
1006
|
}
|
|
1852
1007
|
}
|
|
1853
1008
|
initialize(atStartup) {
|
|
@@ -1862,9 +1017,9 @@ var McpRevisionService = class _McpRevisionService {
|
|
|
1862
1017
|
}
|
|
1863
1018
|
};
|
|
1864
1019
|
McpRevisionService = _ts_decorate4([
|
|
1865
|
-
(0,
|
|
1866
|
-
_ts_param4(0, (0,
|
|
1867
|
-
_ts_param4(1, (0,
|
|
1020
|
+
_common.Injectable.call(void 0, ),
|
|
1021
|
+
_ts_param4(0, _common.Inject.call(void 0, _chunkCFHAFLNNcjs.MCP_MODULE_OPTIONS)),
|
|
1022
|
+
_ts_param4(1, _common.Inject.call(void 0, McpRegistryService)),
|
|
1868
1023
|
_ts_metadata4("design:type", Function),
|
|
1869
1024
|
_ts_metadata4("design:paramtypes", [
|
|
1870
1025
|
typeof McpModuleOptions === "undefined" ? Object : McpModuleOptions,
|
|
@@ -1874,31 +1029,31 @@ McpRevisionService = _ts_decorate4([
|
|
|
1874
1029
|
|
|
1875
1030
|
// src/services/mcp-server.service.ts
|
|
1876
1031
|
function _ts_decorate5(decorators, target, key, desc) {
|
|
1877
|
-
var c = arguments.length,
|
|
1878
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1879
|
-
else for (var
|
|
1880
|
-
return c > 3 &&
|
|
1032
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1033
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1034
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1035
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1881
1036
|
}
|
|
1882
|
-
__name(_ts_decorate5, "_ts_decorate");
|
|
1883
|
-
function _ts_metadata5(
|
|
1884
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(
|
|
1037
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, _ts_decorate5, "_ts_decorate");
|
|
1038
|
+
function _ts_metadata5(k, v) {
|
|
1039
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1885
1040
|
}
|
|
1886
|
-
__name(_ts_metadata5, "_ts_metadata");
|
|
1041
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, _ts_metadata5, "_ts_metadata");
|
|
1887
1042
|
function _ts_param5(paramIndex, decorator) {
|
|
1888
1043
|
return function(target, key) {
|
|
1889
1044
|
decorator(target, key, paramIndex);
|
|
1890
1045
|
};
|
|
1891
1046
|
}
|
|
1892
|
-
__name(_ts_param5, "_ts_param");
|
|
1893
|
-
var McpServerService = class _McpServerService {
|
|
1047
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, _ts_param5, "_ts_param");
|
|
1048
|
+
var McpServerService = (_class5 = class _McpServerService {
|
|
1894
1049
|
static {
|
|
1895
|
-
__name(this, "McpServerService");
|
|
1050
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, this, "McpServerService");
|
|
1896
1051
|
}
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
logger = new
|
|
1901
|
-
constructor(registry, options, revisions) {
|
|
1052
|
+
|
|
1053
|
+
|
|
1054
|
+
|
|
1055
|
+
__init11() {this.logger = new (0, _common.Logger)(_McpServerService.name)}
|
|
1056
|
+
constructor(registry, options, revisions) {;_class5.prototype.__init11.call(this);
|
|
1902
1057
|
this.registry = registry;
|
|
1903
1058
|
this.options = options;
|
|
1904
1059
|
this.revisions = revisions;
|
|
@@ -1908,10 +1063,10 @@ var McpServerService = class _McpServerService {
|
|
|
1908
1063
|
*/
|
|
1909
1064
|
createContext(req, extra) {
|
|
1910
1065
|
return {
|
|
1911
|
-
user: req.userContext
|
|
1066
|
+
user: _nullishCoalesce(req.userContext, () => ( {})),
|
|
1912
1067
|
request: req,
|
|
1913
|
-
signal: extra
|
|
1914
|
-
requestId: extra
|
|
1068
|
+
signal: _nullishCoalesce(_optionalChain([extra, 'optionalAccess', _14 => _14.signal]), () => ( new AbortController().signal)),
|
|
1069
|
+
requestId: _nullishCoalesce(_optionalChain([extra, 'optionalAccess', _15 => _15.requestId]), () => ( "")),
|
|
1915
1070
|
extra
|
|
1916
1071
|
};
|
|
1917
1072
|
}
|
|
@@ -1941,27 +1096,29 @@ var McpServerService = class _McpServerService {
|
|
|
1941
1096
|
return;
|
|
1942
1097
|
}
|
|
1943
1098
|
const { skills, revision } = snapshot;
|
|
1099
|
+
const protocol = await loadMcpProtocol();
|
|
1100
|
+
const { createMcpServer, StreamableHTTPServerTransport, isJSONRPCResultResponse, McpError, assertAppRevision } = protocol;
|
|
1944
1101
|
const server = createMcpServer({
|
|
1945
1102
|
skills,
|
|
1946
1103
|
tools: this.registry.getTools(),
|
|
1947
1104
|
resources: this.registry.getResources(),
|
|
1948
1105
|
options: this.options,
|
|
1949
|
-
createContext: /* @__PURE__ */ __name((extra) => this.createContext(req, extra), "createContext"),
|
|
1950
|
-
onError: /* @__PURE__ */ __name((error, location) => log.exception(error, location), "onError")
|
|
1106
|
+
createContext: /* @__PURE__ */ _chunkCFHAFLNNcjs.__name.call(void 0, (extra) => this.createContext(req, extra), "createContext"),
|
|
1107
|
+
onError: /* @__PURE__ */ _chunkCFHAFLNNcjs.__name.call(void 0, (error, location) => log.exception(error, location), "onError")
|
|
1951
1108
|
});
|
|
1952
|
-
const transport = new
|
|
1109
|
+
const transport = new StreamableHTTPServerTransport({
|
|
1953
1110
|
sessionIdGenerator: void 0,
|
|
1954
1111
|
enableJsonResponse: true
|
|
1955
1112
|
});
|
|
1956
1113
|
const send = transport.send.bind(transport);
|
|
1957
1114
|
transport.send = (message, options) => {
|
|
1958
|
-
log.response(message);
|
|
1959
|
-
if (!
|
|
1115
|
+
log.response(message, protocol);
|
|
1116
|
+
if (!isJSONRPCResultResponse(message)) return send(message, options);
|
|
1960
1117
|
const meta = {
|
|
1961
1118
|
...message.result._meta
|
|
1962
1119
|
};
|
|
1963
|
-
delete meta[MCP_APP_REVISION_META_KEY];
|
|
1964
|
-
if (revision !== void 0) meta[MCP_APP_REVISION_META_KEY] = revision;
|
|
1120
|
+
delete meta[_chunkCFHAFLNNcjs.MCP_APP_REVISION_META_KEY];
|
|
1121
|
+
if (revision !== void 0) meta[_chunkCFHAFLNNcjs.MCP_APP_REVISION_META_KEY] = revision;
|
|
1965
1122
|
return send({
|
|
1966
1123
|
...message,
|
|
1967
1124
|
result: {
|
|
@@ -1984,9 +1141,9 @@ var McpServerService = class _McpServerService {
|
|
|
1984
1141
|
"prompts/get"
|
|
1985
1142
|
].includes(message.method)) {
|
|
1986
1143
|
try {
|
|
1987
|
-
assertAppRevision(message.params
|
|
1144
|
+
assertAppRevision(_optionalChain([message, 'access', _16 => _16.params, 'optionalAccess', _17 => _17._meta]), revision);
|
|
1988
1145
|
} catch (error) {
|
|
1989
|
-
if (!(error instanceof
|
|
1146
|
+
if (!(error instanceof McpError)) throw error;
|
|
1990
1147
|
void transport.send({
|
|
1991
1148
|
jsonrpc: "2.0",
|
|
1992
1149
|
id: message.id,
|
|
@@ -1997,20 +1154,20 @@ var McpServerService = class _McpServerService {
|
|
|
1997
1154
|
}
|
|
1998
1155
|
}, {
|
|
1999
1156
|
relatedRequestId: message.id
|
|
2000
|
-
}).catch((error2) => transport.onerror
|
|
1157
|
+
}).catch((error2) => _optionalChain([transport, 'access', _18 => _18.onerror, 'optionalCall', _19 => _19(error2)]));
|
|
2001
1158
|
return;
|
|
2002
1159
|
}
|
|
2003
1160
|
}
|
|
2004
1161
|
onmessage(message, extra);
|
|
2005
1162
|
};
|
|
2006
|
-
await withUiSnapshot(snapshot.ui, () => transport.handleRequest(req, res, req.body));
|
|
1163
|
+
await _chunkCFHAFLNNcjs.withUiSnapshot.call(void 0, snapshot.ui, () => transport.handleRequest(req, res, req.body));
|
|
2007
1164
|
}
|
|
2008
|
-
};
|
|
1165
|
+
}, _class5);
|
|
2009
1166
|
McpServerService = _ts_decorate5([
|
|
2010
|
-
(0,
|
|
2011
|
-
_ts_param5(0, (0,
|
|
2012
|
-
_ts_param5(1, (0,
|
|
2013
|
-
_ts_param5(2, (0,
|
|
1167
|
+
_common.Injectable.call(void 0, ),
|
|
1168
|
+
_ts_param5(0, _common.Inject.call(void 0, McpRegistryService)),
|
|
1169
|
+
_ts_param5(1, _common.Inject.call(void 0, _chunkCFHAFLNNcjs.MCP_MODULE_OPTIONS)),
|
|
1170
|
+
_ts_param5(2, _common.Inject.call(void 0, McpRevisionService)),
|
|
2014
1171
|
_ts_metadata5("design:type", Function),
|
|
2015
1172
|
_ts_metadata5("design:paramtypes", [
|
|
2016
1173
|
typeof McpRegistryService === "undefined" ? Object : McpRegistryService,
|
|
@@ -2021,34 +1178,34 @@ McpServerService = _ts_decorate5([
|
|
|
2021
1178
|
|
|
2022
1179
|
// src/controllers/mcp.controller.ts
|
|
2023
1180
|
function _ts_decorate6(decorators, target, key, desc) {
|
|
2024
|
-
var c = arguments.length,
|
|
2025
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2026
|
-
else for (var
|
|
2027
|
-
return c > 3 &&
|
|
1181
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1182
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1183
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1184
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2028
1185
|
}
|
|
2029
|
-
__name(_ts_decorate6, "_ts_decorate");
|
|
2030
|
-
function _ts_metadata6(
|
|
2031
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(
|
|
1186
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, _ts_decorate6, "_ts_decorate");
|
|
1187
|
+
function _ts_metadata6(k, v) {
|
|
1188
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2032
1189
|
}
|
|
2033
|
-
__name(_ts_metadata6, "_ts_metadata");
|
|
1190
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, _ts_metadata6, "_ts_metadata");
|
|
2034
1191
|
function _ts_param6(paramIndex, decorator) {
|
|
2035
1192
|
return function(target, key) {
|
|
2036
1193
|
decorator(target, key, paramIndex);
|
|
2037
1194
|
};
|
|
2038
1195
|
}
|
|
2039
|
-
__name(_ts_param6, "_ts_param");
|
|
1196
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, _ts_param6, "_ts_param");
|
|
2040
1197
|
var McpController = class {
|
|
2041
1198
|
static {
|
|
2042
|
-
__name(this, "McpController");
|
|
1199
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, this, "McpController");
|
|
2043
1200
|
}
|
|
2044
|
-
|
|
1201
|
+
|
|
2045
1202
|
constructor(serverService) {
|
|
2046
1203
|
this.serverService = serverService;
|
|
2047
1204
|
}
|
|
2048
1205
|
async handlePost(req, res) {
|
|
2049
1206
|
try {
|
|
2050
1207
|
await this.serverService.handle(req, res);
|
|
2051
|
-
} catch {
|
|
1208
|
+
} catch (e5) {
|
|
2052
1209
|
if (!res.headersSent) {
|
|
2053
1210
|
res.status(500).json({
|
|
2054
1211
|
jsonrpc: "2.0",
|
|
@@ -2079,9 +1236,9 @@ var McpController = class {
|
|
|
2079
1236
|
}
|
|
2080
1237
|
};
|
|
2081
1238
|
_ts_decorate6([
|
|
2082
|
-
(0,
|
|
2083
|
-
_ts_param6(0, (0,
|
|
2084
|
-
_ts_param6(1, (0,
|
|
1239
|
+
_common.Post.call(void 0, ),
|
|
1240
|
+
_ts_param6(0, _common.Req.call(void 0, )),
|
|
1241
|
+
_ts_param6(1, _common.Res.call(void 0, )),
|
|
2085
1242
|
_ts_metadata6("design:type", Function),
|
|
2086
1243
|
_ts_metadata6("design:paramtypes", [
|
|
2087
1244
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -2090,9 +1247,9 @@ _ts_decorate6([
|
|
|
2090
1247
|
_ts_metadata6("design:returntype", Promise)
|
|
2091
1248
|
], McpController.prototype, "handlePost", null);
|
|
2092
1249
|
_ts_decorate6([
|
|
2093
|
-
(0,
|
|
2094
|
-
_ts_param6(0, (0,
|
|
2095
|
-
_ts_param6(1, (0,
|
|
1250
|
+
_common.All.call(void 0, ),
|
|
1251
|
+
_ts_param6(0, _common.Req.call(void 0, )),
|
|
1252
|
+
_ts_param6(1, _common.Res.call(void 0, )),
|
|
2096
1253
|
_ts_metadata6("design:type", Function),
|
|
2097
1254
|
_ts_metadata6("design:paramtypes", [
|
|
2098
1255
|
typeof Request === "undefined" ? Object : Request,
|
|
@@ -2101,9 +1258,9 @@ _ts_decorate6([
|
|
|
2101
1258
|
_ts_metadata6("design:returntype", void 0)
|
|
2102
1259
|
], McpController.prototype, "handleOthers", null);
|
|
2103
1260
|
McpController = _ts_decorate6([
|
|
2104
|
-
(0,
|
|
2105
|
-
(0,
|
|
2106
|
-
_ts_param6(0, (0,
|
|
1261
|
+
_swagger.ApiExcludeController.call(void 0, ),
|
|
1262
|
+
_common.Controller.call(void 0, _chunkCFHAFLNNcjs.MCP_CONTROLLER_PATH),
|
|
1263
|
+
_ts_param6(0, _common.Inject.call(void 0, McpServerService)),
|
|
2107
1264
|
_ts_metadata6("design:type", Function),
|
|
2108
1265
|
_ts_metadata6("design:paramtypes", [
|
|
2109
1266
|
typeof McpServerService === "undefined" ? Object : McpServerService
|
|
@@ -2112,21 +1269,21 @@ McpController = _ts_decorate6([
|
|
|
2112
1269
|
|
|
2113
1270
|
// src/mcp.module.ts
|
|
2114
1271
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
2115
|
-
var c = arguments.length,
|
|
2116
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2117
|
-
else for (var
|
|
2118
|
-
return c > 3 &&
|
|
1272
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1273
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1274
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1275
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2119
1276
|
}
|
|
2120
|
-
__name(_ts_decorate7, "_ts_decorate");
|
|
1277
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, _ts_decorate7, "_ts_decorate");
|
|
2121
1278
|
var McpModule = class _McpModule {
|
|
2122
1279
|
static {
|
|
2123
|
-
__name(this, "McpModule");
|
|
1280
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, this, "McpModule");
|
|
2124
1281
|
}
|
|
2125
1282
|
static forRoot(options = {}) {
|
|
2126
1283
|
const enabled = options.enabled !== false;
|
|
2127
1284
|
const providers = [
|
|
2128
1285
|
{
|
|
2129
|
-
provide: MCP_MODULE_OPTIONS,
|
|
1286
|
+
provide: _chunkCFHAFLNNcjs.MCP_MODULE_OPTIONS,
|
|
2130
1287
|
useValue: options
|
|
2131
1288
|
},
|
|
2132
1289
|
McpRegistryService,
|
|
@@ -2138,7 +1295,7 @@ var McpModule = class _McpModule {
|
|
|
2138
1295
|
module: _McpModule,
|
|
2139
1296
|
global: true,
|
|
2140
1297
|
imports: [
|
|
2141
|
-
|
|
1298
|
+
_core.DiscoveryModule
|
|
2142
1299
|
],
|
|
2143
1300
|
controllers: enabled ? [
|
|
2144
1301
|
McpManifestController,
|
|
@@ -2153,28 +1310,28 @@ var McpModule = class _McpModule {
|
|
|
2153
1310
|
};
|
|
2154
1311
|
}
|
|
2155
1312
|
};
|
|
2156
|
-
McpModule = _ts_decorate7([
|
|
2157
|
-
(0,
|
|
1313
|
+
McpModule = exports.McpModule = _ts_decorate7([
|
|
1314
|
+
_common.Module.call(void 0, {})
|
|
2158
1315
|
], McpModule);
|
|
2159
1316
|
|
|
2160
1317
|
// src/ui-template.ts
|
|
2161
|
-
|
|
2162
|
-
|
|
1318
|
+
|
|
1319
|
+
|
|
2163
1320
|
var cache = /* @__PURE__ */ new Map();
|
|
2164
1321
|
async function readMcpUiTemplate(entry, cwd = process.cwd()) {
|
|
2165
1322
|
if (!/^[A-Za-z0-9_-]+$/.test(entry)) {
|
|
2166
1323
|
throw new Error(`MCP Apps \u754C\u9762\u5165\u53E3\u540D\u300C${entry}\u300D\u4E0D\u5408\u6CD5\uFF0C\u4EC5\u5141\u8BB8\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u4E0B\u5212\u7EBF\u4E0E\u8FDE\u5B57\u7B26`);
|
|
2167
1324
|
}
|
|
2168
|
-
const snapshot = await snapshotUiTemplate(entry, cwd);
|
|
1325
|
+
const snapshot = await _chunkCFHAFLNNcjs.snapshotUiTemplate.call(void 0, entry, cwd);
|
|
2169
1326
|
if (snapshot) return snapshot.html;
|
|
2170
|
-
const file =
|
|
1327
|
+
const file = _path2.default.join(cwd, _chunkCFHAFLNNcjs.MCP_UI_DIST_DIR, `${entry}.html`);
|
|
2171
1328
|
const useCache = process.env.NODE_ENV === "production";
|
|
2172
1329
|
if (useCache && cache.has(file)) {
|
|
2173
1330
|
return cache.get(file);
|
|
2174
1331
|
}
|
|
2175
1332
|
let html;
|
|
2176
1333
|
try {
|
|
2177
|
-
html = await
|
|
1334
|
+
html = await _fs.promises.readFile(file, "utf8");
|
|
2178
1335
|
} catch (error) {
|
|
2179
1336
|
const reason = error instanceof Error ? error.message : String(error);
|
|
2180
1337
|
throw new Error(`\u8BFB\u53D6 MCP Apps \u754C\u9762\u4EA7\u7269\u5931\u8D25\uFF1A${file}\u3002\u8BF7\u786E\u8BA4 server/mcp/ui/${entry}/index.html \u5B58\u5728\u4E14\u5DF2\u6267\u884C\u6784\u5EFA\u3002\u539F\u56E0\uFF1A${reason}`);
|
|
@@ -2182,29 +1339,28 @@ async function readMcpUiTemplate(entry, cwd = process.cwd()) {
|
|
|
2182
1339
|
if (useCache) cache.set(file, html);
|
|
2183
1340
|
return html;
|
|
2184
1341
|
}
|
|
2185
|
-
__name(readMcpUiTemplate, "readMcpUiTemplate");
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
});
|
|
1342
|
+
_chunkCFHAFLNNcjs.__name.call(void 0, readMcpUiTemplate, "readMcpUiTemplate");
|
|
1343
|
+
|
|
1344
|
+
|
|
1345
|
+
|
|
1346
|
+
|
|
1347
|
+
|
|
1348
|
+
|
|
1349
|
+
|
|
1350
|
+
|
|
1351
|
+
|
|
1352
|
+
|
|
1353
|
+
|
|
1354
|
+
|
|
1355
|
+
|
|
1356
|
+
|
|
1357
|
+
|
|
1358
|
+
|
|
1359
|
+
|
|
1360
|
+
|
|
1361
|
+
|
|
1362
|
+
|
|
1363
|
+
|
|
1364
|
+
|
|
1365
|
+
exports.MCP_APP_REVISION_META_KEY = _chunkCFHAFLNNcjs.MCP_APP_REVISION_META_KEY; exports.MCP_APP_REVISION_MISMATCH = _chunkCFHAFLNNcjs.MCP_APP_REVISION_MISMATCH; exports.MCP_CONTROLLER_PATH = _chunkCFHAFLNNcjs.MCP_CONTROLLER_PATH; exports.MCP_DEFAULT_SERVER_NAME = _chunkCFHAFLNNcjs.MCP_DEFAULT_SERVER_NAME; exports.MCP_DEFAULT_SERVER_VERSION = _chunkCFHAFLNNcjs.MCP_DEFAULT_SERVER_VERSION; exports.MCP_ENDPOINT_PATH = _chunkCFHAFLNNcjs.MCP_ENDPOINT_PATH; exports.MCP_MANIFEST_VERSION = _chunkCFHAFLNNcjs.MCP_MANIFEST_VERSION; exports.MCP_MODULE_OPTIONS = _chunkCFHAFLNNcjs.MCP_MODULE_OPTIONS; exports.MCP_SKILLS_PATH = _chunkCFHAFLNNcjs.MCP_SKILLS_PATH; exports.MCP_TOOLS_METADATA_KEY = _chunkCFHAFLNNcjs.MCP_TOOLS_METADATA_KEY; exports.MCP_TOOL_METADATA_KEY = _chunkCFHAFLNNcjs.MCP_TOOL_METADATA_KEY; exports.MCP_TOOL_NAME_PATTERN = _chunkCFHAFLNNcjs.MCP_TOOL_NAME_PATTERN; exports.MCP_UI_DIST_DIR = _chunkCFHAFLNNcjs.MCP_UI_DIST_DIR; exports.MCP_UI_RESOURCE_METADATA_KEY = _chunkCFHAFLNNcjs.MCP_UI_RESOURCE_METADATA_KEY; exports.MCP_UI_RESOURCE_SCHEME = _chunkCFHAFLNNcjs.MCP_UI_RESOURCE_SCHEME; exports.McpModule = McpModule; exports.McpTool = McpTool; exports.McpToolError = _chunkCFHAFLNNcjs.McpToolError; exports.McpTools = McpTools; exports.McpUiResource = McpUiResource; exports.readMcpUiTemplate = readMcpUiTemplate;
|
|
2210
1366
|
//# sourceMappingURL=index.cjs.map
|