@ananay-nag/mcp-decorators 1.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -8
- package/dist/cjs/index.js +2 -35
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/src/client/decorators/client.decorator.js +29 -37
- package/dist/cjs/src/client/decorators/client.decorator.js.map +1 -1
- package/dist/cjs/src/client/decorators/index.js +3 -22
- package/dist/cjs/src/client/decorators/index.js.map +1 -1
- package/dist/cjs/src/client/decorators/notification.decorator.js +5 -9
- package/dist/cjs/src/client/decorators/notification.decorator.js.map +1 -1
- package/dist/cjs/src/client/decorators/requestHandler.decorator.js +1 -5
- package/dist/cjs/src/client/decorators/requestHandler.decorator.js.map +1 -1
- package/dist/cjs/src/client/index.js +3 -19
- package/dist/cjs/src/client/index.js.map +1 -1
- package/dist/cjs/src/client/types/client/client.js +1 -2
- package/dist/cjs/src/client/types/index.js +2 -18
- package/dist/cjs/src/client/types/index.js.map +1 -1
- package/dist/cjs/src/client/utils/clientRegistry.js +2 -7
- package/dist/cjs/src/client/utils/clientRegistry.js.map +1 -1
- package/dist/cjs/src/client/utils/index.js +1 -17
- package/dist/cjs/src/client/utils/index.js.map +1 -1
- package/dist/cjs/src/server/decorators/action.decorator.js +1 -5
- package/dist/cjs/src/server/decorators/action.decorator.js.map +1 -1
- package/dist/cjs/src/server/decorators/completion.decorator.js +5 -9
- package/dist/cjs/src/server/decorators/completion.decorator.js.map +1 -1
- package/dist/cjs/src/server/decorators/index.js +9 -24
- package/dist/cjs/src/server/decorators/index.js.map +1 -1
- package/dist/cjs/src/server/decorators/notification.decorator.js +5 -9
- package/dist/cjs/src/server/decorators/notification.decorator.js.map +1 -1
- package/dist/cjs/src/server/decorators/prompt.decorator.js +5 -9
- package/dist/cjs/src/server/decorators/prompt.decorator.js.map +1 -1
- package/dist/cjs/src/server/decorators/requestHandler.decorator.js +1 -5
- package/dist/cjs/src/server/decorators/requestHandler.decorator.js.map +1 -1
- package/dist/cjs/src/server/decorators/resource.decorator.js +10 -15
- package/dist/cjs/src/server/decorators/resource.decorator.js.map +1 -1
- package/dist/cjs/src/server/decorators/server.decorator.d.ts.map +1 -1
- package/dist/cjs/src/server/decorators/server.decorator.js +48 -57
- package/dist/cjs/src/server/decorators/server.decorator.js.map +1 -1
- package/dist/cjs/src/server/decorators/subscribe.decorator.js +6 -11
- package/dist/cjs/src/server/decorators/subscribe.decorator.js.map +1 -1
- package/dist/cjs/src/server/decorators/tool.decorator.js +5 -9
- package/dist/cjs/src/server/decorators/tool.decorator.js.map +1 -1
- package/dist/cjs/src/server/index.js +3 -32
- package/dist/cjs/src/server/index.js.map +1 -1
- package/dist/cjs/src/server/types/index.js +2 -18
- package/dist/cjs/src/server/types/index.js.map +1 -1
- package/dist/cjs/src/server/types/server/index.js +1 -17
- package/dist/cjs/src/server/types/server/index.js.map +1 -1
- package/dist/cjs/src/server/types/server/server.js +1 -2
- package/dist/cjs/src/server/utils/index.js +1 -17
- package/dist/cjs/src/server/utils/index.js.map +1 -1
- package/dist/cjs/src/server/utils/serverRegistry.js +10 -21
- package/dist/cjs/src/server/utils/serverRegistry.js.map +1 -1
- package/dist/esm/src/client/decorators/client.decorator.js.map +1 -1
- package/dist/esm/src/client/decorators/notification.decorator.js.map +1 -1
- package/dist/esm/src/client/decorators/requestHandler.decorator.js.map +1 -1
- package/dist/esm/src/client/utils/clientRegistry.js.map +1 -1
- package/dist/esm/src/server/decorators/action.decorator.js.map +1 -1
- package/dist/esm/src/server/decorators/completion.decorator.js.map +1 -1
- package/dist/esm/src/server/decorators/notification.decorator.js.map +1 -1
- package/dist/esm/src/server/decorators/prompt.decorator.js.map +1 -1
- package/dist/esm/src/server/decorators/requestHandler.decorator.js.map +1 -1
- package/dist/esm/src/server/decorators/resource.decorator.js.map +1 -1
- package/dist/esm/src/server/decorators/server.decorator.d.ts.map +1 -1
- package/dist/esm/src/server/decorators/server.decorator.js +0 -2
- package/dist/esm/src/server/decorators/server.decorator.js.map +1 -1
- package/dist/esm/src/server/decorators/tool.decorator.js.map +1 -1
- package/dist/esm/src/server/utils/serverRegistry.js.map +1 -1
- package/package.json +32 -8
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./clientRegistry.js"), exports);
|
|
1
|
+
export * from "./clientRegistry.js";
|
|
18
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/client/utils/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/client/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ActionHandler = void 0;
|
|
4
1
|
/**
|
|
5
2
|
*
|
|
6
3
|
* @description
|
|
@@ -11,7 +8,7 @@ exports.ActionHandler = void 0;
|
|
|
11
8
|
* @returns {MethodDecorator} A method decorator that adds metadata to the class prototype.
|
|
12
9
|
*/
|
|
13
10
|
// decorators/action.decorator.ts
|
|
14
|
-
function ActionHandler(actionName) {
|
|
11
|
+
export function ActionHandler(actionName) {
|
|
15
12
|
return function (target, propertyKey) {
|
|
16
13
|
if (!target._actionsMap) {
|
|
17
14
|
target._actionsMap = {};
|
|
@@ -19,5 +16,4 @@ function ActionHandler(actionName) {
|
|
|
19
16
|
target._actionsMap[propertyKey] = actionName;
|
|
20
17
|
};
|
|
21
18
|
}
|
|
22
|
-
exports.ActionHandler = ActionHandler;
|
|
23
19
|
//# sourceMappingURL=action.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.decorator.js","sourceRoot":"","sources":["../../../../../src/server/decorators/action.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"action.decorator.js","sourceRoot":"","sources":["../../../../../src/server/decorators/action.decorator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,iCAAiC;AACjC,MAAM,UAAU,aAAa,CAAC,UAAkB;IAC9C,OAAO,UAAU,MAAW,EAAE,WAA4B;QACxD,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;YACxB,MAAM,CAAC,WAAW,GAAG,EAAE,CAAC;QAC1B,CAAC;QAED,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,GAAG,UAAU,CAAC;IAC/C,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Completion = exports.COMPLETION_META = void 0;
|
|
4
|
-
exports.COMPLETION_META = Symbol("mcpCompletions");
|
|
1
|
+
export const COMPLETION_META = Symbol("mcpCompletions");
|
|
5
2
|
/**
|
|
6
3
|
* @description
|
|
7
4
|
* Decorator to register a method as an MCP completion handler for prompts or resource templates.
|
|
8
5
|
* @param ref - The reference specifying the type ('prompt' | 'resource') and template/prompt name.
|
|
9
6
|
*/
|
|
10
|
-
function Completion(ref) {
|
|
7
|
+
export function Completion(ref) {
|
|
11
8
|
return function (target, propertyKey) {
|
|
12
|
-
if (!target[
|
|
13
|
-
target[
|
|
9
|
+
if (!target[COMPLETION_META]) {
|
|
10
|
+
target[COMPLETION_META] = [];
|
|
14
11
|
}
|
|
15
|
-
target[
|
|
12
|
+
target[COMPLETION_META].push({
|
|
16
13
|
ref,
|
|
17
14
|
methodName: propertyKey,
|
|
18
15
|
});
|
|
19
16
|
};
|
|
20
17
|
}
|
|
21
|
-
exports.Completion = Completion;
|
|
22
18
|
//# sourceMappingURL=completion.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"completion.decorator.js","sourceRoot":"","sources":["../../../../../src/server/decorators/completion.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"completion.decorator.js","sourceRoot":"","sources":["../../../../../src/server/decorators/completion.decorator.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAExD;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,GAAkB;IAC3C,OAAO,UAAU,MAAW,EAAE,WAA4B;QACxD,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC;YAC7B,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE,CAAC;QAC/B,CAAC;QACD,MAAM,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC;YAC3B,GAAG;YACH,UAAU,EAAE,WAAW;SACxB,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,25 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Object.defineProperty(exports, "ActionHandler", { enumerable: true, get: function () { return action_decorator_js_1.ActionHandler; } });
|
|
11
|
-
var notification_decorator_js_1 = require("./notification.decorator.js");
|
|
12
|
-
Object.defineProperty(exports, "NotificationHandler", { enumerable: true, get: function () { return notification_decorator_js_1.NotificationHandler; } });
|
|
13
|
-
var tool_decorator_js_1 = require("./tool.decorator.js");
|
|
14
|
-
Object.defineProperty(exports, "Tool", { enumerable: true, get: function () { return tool_decorator_js_1.Tool; } });
|
|
15
|
-
var prompt_decorator_js_1 = require("./prompt.decorator.js");
|
|
16
|
-
Object.defineProperty(exports, "Prompt", { enumerable: true, get: function () { return prompt_decorator_js_1.Prompt; } });
|
|
17
|
-
var resource_decorator_js_1 = require("./resource.decorator.js");
|
|
18
|
-
Object.defineProperty(exports, "Resource", { enumerable: true, get: function () { return resource_decorator_js_1.Resource; } });
|
|
19
|
-
Object.defineProperty(exports, "ResourceTemplate", { enumerable: true, get: function () { return resource_decorator_js_1.ResourceTemplate; } });
|
|
20
|
-
var subscribe_decorator_js_1 = require("./subscribe.decorator.js");
|
|
21
|
-
Object.defineProperty(exports, "Subscribe", { enumerable: true, get: function () { return subscribe_decorator_js_1.Subscribe; } });
|
|
22
|
-
Object.defineProperty(exports, "Unsubscribe", { enumerable: true, get: function () { return subscribe_decorator_js_1.Unsubscribe; } });
|
|
23
|
-
var completion_decorator_js_1 = require("./completion.decorator.js");
|
|
24
|
-
Object.defineProperty(exports, "Completion", { enumerable: true, get: function () { return completion_decorator_js_1.Completion; } });
|
|
1
|
+
export { RequestHandler } from "./requestHandler.decorator.js";
|
|
2
|
+
export { RegisterServer, UseServer } from "./server.decorator.js";
|
|
3
|
+
export { ActionHandler } from "./action.decorator.js";
|
|
4
|
+
export { NotificationHandler } from "./notification.decorator.js";
|
|
5
|
+
export { Tool } from "./tool.decorator.js";
|
|
6
|
+
export { Prompt } from "./prompt.decorator.js";
|
|
7
|
+
export { Resource, ResourceTemplate } from "./resource.decorator.js";
|
|
8
|
+
export { Subscribe, Unsubscribe } from "./subscribe.decorator.js";
|
|
9
|
+
export { Completion } from "./completion.decorator.js";
|
|
25
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/server/decorators/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/server/decorators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NotificationHandler = exports.NOTIFICATION_META = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* @description
|
|
6
3
|
* This decorator is used to mark a method as a notification handler.
|
|
@@ -10,14 +7,13 @@ exports.NotificationHandler = exports.NOTIFICATION_META = void 0;
|
|
|
10
7
|
* @returns {MethodDecorator} - A method decorator that adds metadata to the class prototype.
|
|
11
8
|
*/
|
|
12
9
|
// decorators/notification.decorator.ts
|
|
13
|
-
|
|
14
|
-
function NotificationHandler(method) {
|
|
10
|
+
export const NOTIFICATION_META = Symbol("pendingNotifications");
|
|
11
|
+
export function NotificationHandler(method) {
|
|
15
12
|
return function (target, propertyKey) {
|
|
16
|
-
if (!target[
|
|
17
|
-
target[
|
|
13
|
+
if (!target[NOTIFICATION_META]) {
|
|
14
|
+
target[NOTIFICATION_META] = [];
|
|
18
15
|
}
|
|
19
|
-
target[
|
|
16
|
+
target[NOTIFICATION_META].push({ method, methodName: propertyKey });
|
|
20
17
|
};
|
|
21
18
|
}
|
|
22
|
-
exports.NotificationHandler = NotificationHandler;
|
|
23
19
|
//# sourceMappingURL=notification.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.decorator.js","sourceRoot":"","sources":["../../../../../src/server/decorators/notification.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"notification.decorator.js","sourceRoot":"","sources":["../../../../../src/server/decorators/notification.decorator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,uCAAuC;AACvC,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,sBAAsB,CAAC,CAAC;AAEhE,MAAM,UAAU,mBAAmB,CAAC,MAAc;IAChD,OAAO,UAAU,MAAW,EAAE,WAA4B;QACxD,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,EAAE,CAAC;YAC/B,MAAM,CAAC,iBAAiB,CAAC,GAAG,EAAE,CAAC;QACjC,CAAC;QAED,MAAM,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC;IACtE,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,23 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Prompt = exports.PROMPT_META = void 0;
|
|
4
|
-
exports.PROMPT_META = Symbol("mcpPrompts");
|
|
1
|
+
export const PROMPT_META = Symbol("mcpPrompts");
|
|
5
2
|
/**
|
|
6
3
|
* @description
|
|
7
4
|
* Decorator to register a method as an MCP Prompt.
|
|
8
5
|
* Handlers are dynamically collected and registered on the server.
|
|
9
6
|
* @param options - Options for the prompt including name, description, and arguments.
|
|
10
7
|
*/
|
|
11
|
-
function Prompt(options) {
|
|
8
|
+
export function Prompt(options) {
|
|
12
9
|
return function (target, propertyKey) {
|
|
13
|
-
if (!target[
|
|
14
|
-
target[
|
|
10
|
+
if (!target[PROMPT_META]) {
|
|
11
|
+
target[PROMPT_META] = [];
|
|
15
12
|
}
|
|
16
|
-
target[
|
|
13
|
+
target[PROMPT_META].push({
|
|
17
14
|
options,
|
|
18
15
|
methodName: propertyKey,
|
|
19
16
|
});
|
|
20
17
|
};
|
|
21
18
|
}
|
|
22
|
-
exports.Prompt = Prompt;
|
|
23
19
|
//# sourceMappingURL=prompt.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.decorator.js","sourceRoot":"","sources":["../../../../../src/server/decorators/prompt.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prompt.decorator.js","sourceRoot":"","sources":["../../../../../src/server/decorators/prompt.decorator.ts"],"names":[],"mappings":"AAYA,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,OAAsB;IAC3C,OAAO,UAAU,MAAW,EAAE,WAA4B;QACxD,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;YACzB,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC;QAC3B,CAAC;QACD,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC;YACvB,OAAO;YACP,UAAU,EAAE,WAAW;SACxB,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
*
|
|
4
3
|
* @param schema - The schema to be used for validation.
|
|
@@ -13,15 +12,13 @@
|
|
|
13
12
|
// if (!target._pendingHandlers) {
|
|
14
13
|
// target._pendingHandlers = [];
|
|
15
14
|
// }
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.RequestHandler = void 0;
|
|
18
15
|
// target._pendingHandlers.push({
|
|
19
16
|
// schema,
|
|
20
17
|
// methodName: propertyKey,
|
|
21
18
|
// });
|
|
22
19
|
// };
|
|
23
20
|
// }
|
|
24
|
-
function RequestHandler(schema) {
|
|
21
|
+
export function RequestHandler(schema) {
|
|
25
22
|
return function (target, propertyKey) {
|
|
26
23
|
if (!target._pendingHandlers) {
|
|
27
24
|
target._pendingHandlers = [];
|
|
@@ -29,5 +26,4 @@ function RequestHandler(schema) {
|
|
|
29
26
|
target._pendingHandlers.push({ schema, methodName: propertyKey });
|
|
30
27
|
};
|
|
31
28
|
}
|
|
32
|
-
exports.RequestHandler = RequestHandler;
|
|
33
29
|
//# sourceMappingURL=requestHandler.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestHandler.decorator.js","sourceRoot":"","sources":["../../../../../src/server/decorators/requestHandler.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"requestHandler.decorator.js","sourceRoot":"","sources":["../../../../../src/server/decorators/requestHandler.decorator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,iEAAiE;AACjE,kGAAkG;AAClG,iEAAiE;AACjE,sCAAsC;AACtC,sCAAsC;AACtC,QAAQ;AAER,qCAAqC;AACrC,gBAAgB;AAChB,iCAAiC;AACjC,UAAU;AACV,OAAO;AACP,IAAI;AAEJ,MAAM,UAAU,cAAc,CAAC,MAAW;IACxC,OAAO,UAAU,MAAW,EAAE,WAA4B;QACxD,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC;YAC7B,MAAM,CAAC,gBAAgB,GAAG,EAAE,CAAC;QAC/B,CAAC;QAED,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC;IACpE,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,40 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ResourceTemplate = exports.Resource = exports.RESOURCE_TEMPLATE_META = exports.RESOURCE_META = void 0;
|
|
4
|
-
exports.RESOURCE_META = Symbol("mcpResources");
|
|
5
|
-
exports.RESOURCE_TEMPLATE_META = Symbol("mcpResourceTemplates");
|
|
1
|
+
export const RESOURCE_META = Symbol("mcpResources");
|
|
2
|
+
export const RESOURCE_TEMPLATE_META = Symbol("mcpResourceTemplates");
|
|
6
3
|
/**
|
|
7
4
|
* @description
|
|
8
5
|
* Decorator to register a method as an MCP Resource handler.
|
|
9
6
|
* @param options - Options for the resource including uri, name, and mimeType.
|
|
10
7
|
*/
|
|
11
|
-
function Resource(options) {
|
|
8
|
+
export function Resource(options) {
|
|
12
9
|
return function (target, propertyKey) {
|
|
13
|
-
if (!target[
|
|
14
|
-
target[
|
|
10
|
+
if (!target[RESOURCE_META]) {
|
|
11
|
+
target[RESOURCE_META] = [];
|
|
15
12
|
}
|
|
16
|
-
target[
|
|
13
|
+
target[RESOURCE_META].push({
|
|
17
14
|
options,
|
|
18
15
|
methodName: propertyKey,
|
|
19
16
|
});
|
|
20
17
|
};
|
|
21
18
|
}
|
|
22
|
-
exports.Resource = Resource;
|
|
23
19
|
/**
|
|
24
20
|
* @description
|
|
25
21
|
* Decorator to register a method as an MCP Resource Template handler.
|
|
26
22
|
* @param options - Options for the resource template including uriTemplate, name, and mimeType.
|
|
27
23
|
*/
|
|
28
|
-
function ResourceTemplate(options) {
|
|
24
|
+
export function ResourceTemplate(options) {
|
|
29
25
|
return function (target, propertyKey) {
|
|
30
|
-
if (!target[
|
|
31
|
-
target[
|
|
26
|
+
if (!target[RESOURCE_TEMPLATE_META]) {
|
|
27
|
+
target[RESOURCE_TEMPLATE_META] = [];
|
|
32
28
|
}
|
|
33
|
-
target[
|
|
29
|
+
target[RESOURCE_TEMPLATE_META].push({
|
|
34
30
|
options,
|
|
35
31
|
methodName: propertyKey,
|
|
36
32
|
});
|
|
37
33
|
};
|
|
38
34
|
}
|
|
39
|
-
exports.ResourceTemplate = ResourceTemplate;
|
|
40
35
|
//# sourceMappingURL=resource.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.decorator.js","sourceRoot":"","sources":["../../../../../src/server/decorators/resource.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resource.decorator.js","sourceRoot":"","sources":["../../../../../src/server/decorators/resource.decorator.ts"],"names":[],"mappings":"AAcA,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;AACpD,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,sBAAsB,CAAC,CAAC;AAErE;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAwB;IAC/C,OAAO,UAAU,MAAW,EAAE,WAA4B;QACxD,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;YAC3B,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC;QAC7B,CAAC;QACD,MAAM,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC;YACzB,OAAO;YACP,UAAU,EAAE,WAAW;SACxB,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAgC;IAC/D,OAAO,UAAU,MAAW,EAAE,WAA4B;QACxD,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,EAAE,CAAC;YACpC,MAAM,CAAC,sBAAsB,CAAC,GAAG,EAAE,CAAC;QACtC,CAAC;QACD,MAAM,CAAC,sBAAsB,CAAC,CAAC,IAAI,CAAC;YAClC,OAAO;YACP,UAAU,EAAE,WAAW;SACxB,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.decorator.d.ts","sourceRoot":"","sources":["../../../../../src/server/decorators/server.decorator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAuBrD;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,cAAc,CAoB/C;AAGD,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"server.decorator.d.ts","sourceRoot":"","sources":["../../../../../src/server/decorators/server.decorator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAuBrD;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,cAAc,CAoB/C;AAGD,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,QAiE9E;AAGD,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,QAkBnF;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,cAAc,CA2InE"}
|
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const resource_decorator_js_1 = require("./resource.decorator.js");
|
|
12
|
-
const subscribe_decorator_js_1 = require("./subscribe.decorator.js");
|
|
13
|
-
const completion_decorator_js_1 = require("./completion.decorator.js");
|
|
1
|
+
import { getServer, registerServer, getOrCreateServerRegistration, matchUriTemplate } from "../utils/serverRegistry.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
4
|
+
import { ListToolsRequestSchema, CallToolRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, ListResourceTemplatesRequestSchema, SubscribeRequestSchema, UnsubscribeRequestSchema, CompleteRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
5
|
+
import { NOTIFICATION_META } from "./notification.decorator.js";
|
|
6
|
+
import { TOOL_META } from "./tool.decorator.js";
|
|
7
|
+
import { PROMPT_META } from "./prompt.decorator.js";
|
|
8
|
+
import { RESOURCE_META, RESOURCE_TEMPLATE_META } from "./resource.decorator.js";
|
|
9
|
+
import { SUBSCRIBE_META, UNSUBSCRIBE_META } from "./subscribe.decorator.js";
|
|
10
|
+
import { COMPLETION_META } from "./completion.decorator.js";
|
|
14
11
|
/**
|
|
15
12
|
* @description
|
|
16
13
|
* This decorator is used to register a server instance.
|
|
17
14
|
* @returns {ClassDecorator} A class decorator that registers the server instance.
|
|
18
15
|
*/
|
|
19
|
-
function RegisterServer() {
|
|
16
|
+
export function RegisterServer() {
|
|
20
17
|
return function (target) {
|
|
21
18
|
const originalConstructor = target;
|
|
22
19
|
const newConstructor = function (...args) {
|
|
@@ -25,7 +22,7 @@ function RegisterServer() {
|
|
|
25
22
|
console.log(`[Server] Registering server "${JSON.stringify(serverInfo)}"`);
|
|
26
23
|
// Relaxed check to support both SDK v1 Server and SDK v2 McpServer
|
|
27
24
|
if (instance && (typeof instance.connect === "function")) {
|
|
28
|
-
|
|
25
|
+
registerServer(serverInfo, instance);
|
|
29
26
|
}
|
|
30
27
|
return instance;
|
|
31
28
|
};
|
|
@@ -33,13 +30,10 @@ function RegisterServer() {
|
|
|
33
30
|
return newConstructor;
|
|
34
31
|
};
|
|
35
32
|
}
|
|
36
|
-
exports.RegisterServer = RegisterServer;
|
|
37
33
|
// Modular: Register request handlers grouped by method string + actionName
|
|
38
|
-
function registerRequestHandlers(target, instance, server) {
|
|
34
|
+
export function registerRequestHandlers(target, instance, server) {
|
|
39
35
|
const pendingHandlers = target.prototype._pendingHandlers || [];
|
|
40
36
|
const actionsMap = target.prototype._actionsMap || {};
|
|
41
|
-
console.error("[Server Debug] pendingHandlers:", pendingHandlers);
|
|
42
|
-
console.error("[Server Debug] actionsMap:", actionsMap);
|
|
43
37
|
const methodGroups = new Map();
|
|
44
38
|
for (const { schema, methodName } of pendingHandlers) {
|
|
45
39
|
const handlerFn = instance[methodName].bind(instance);
|
|
@@ -74,9 +68,9 @@ function registerRequestHandlers(target, instance, server) {
|
|
|
74
68
|
for (const [methodKey, group] of methodGroups.entries()) {
|
|
75
69
|
let finalSchema = group.schema;
|
|
76
70
|
if (!finalSchema) {
|
|
77
|
-
finalSchema =
|
|
78
|
-
method:
|
|
79
|
-
params:
|
|
71
|
+
finalSchema = z.object({
|
|
72
|
+
method: z.literal(methodKey),
|
|
73
|
+
params: z.any().optional(),
|
|
80
74
|
});
|
|
81
75
|
}
|
|
82
76
|
const dispatcher = async (request, extra) => {
|
|
@@ -92,25 +86,23 @@ function registerRequestHandlers(target, instance, server) {
|
|
|
92
86
|
console.log(`[Server] ✅ Bound dispatcher for method "${methodKey}"`);
|
|
93
87
|
}
|
|
94
88
|
}
|
|
95
|
-
exports.registerRequestHandlers = registerRequestHandlers;
|
|
96
89
|
// Modular: Register notification handlers
|
|
97
|
-
function registerNotificationHandlers(target, instance, server) {
|
|
98
|
-
const pendingNotifications = target.prototype[
|
|
90
|
+
export function registerNotificationHandlers(target, instance, server) {
|
|
91
|
+
const pendingNotifications = target.prototype[NOTIFICATION_META] || [];
|
|
99
92
|
for (const { method, methodName } of pendingNotifications) {
|
|
100
93
|
const handlerFn = instance[methodName].bind(instance);
|
|
101
94
|
// Normalize notification method if string is passed
|
|
102
95
|
let normalizedSchema = method;
|
|
103
96
|
if (typeof method === "string") {
|
|
104
|
-
normalizedSchema =
|
|
105
|
-
method:
|
|
106
|
-
params:
|
|
97
|
+
normalizedSchema = z.object({
|
|
98
|
+
method: z.literal(method),
|
|
99
|
+
params: z.any().optional(),
|
|
107
100
|
});
|
|
108
101
|
}
|
|
109
102
|
server.setNotificationHandler(normalizedSchema, handlerFn);
|
|
110
103
|
console.log(`[Server] ✅ Registered notification "${typeof method === "string" ? method : method.shape.method.value}" -> ${String(methodName)}`);
|
|
111
104
|
}
|
|
112
105
|
}
|
|
113
|
-
exports.registerNotificationHandlers = registerNotificationHandlers;
|
|
114
106
|
/**
|
|
115
107
|
* @description
|
|
116
108
|
* This decorator is used to inject a server instance into a class.
|
|
@@ -118,7 +110,7 @@ exports.registerNotificationHandlers = registerNotificationHandlers;
|
|
|
118
110
|
* @param {UseServerOptions} options - Options for the decorator.
|
|
119
111
|
* @returns {ClassDecorator} A class decorator that injects the server instance.
|
|
120
112
|
*/
|
|
121
|
-
function UseServer(options) {
|
|
113
|
+
export function UseServer(options) {
|
|
122
114
|
return function (target) {
|
|
123
115
|
const originalConstructor = target;
|
|
124
116
|
function newConstructor(...args) {
|
|
@@ -126,7 +118,7 @@ function UseServer(options) {
|
|
|
126
118
|
if (!options.name) {
|
|
127
119
|
throw new Error("Server name is required in @UseServer options.");
|
|
128
120
|
}
|
|
129
|
-
const server =
|
|
121
|
+
const server = getServer(options);
|
|
130
122
|
if (!server) {
|
|
131
123
|
throw new Error(`Server with name "${options.name}" not found.`);
|
|
132
124
|
}
|
|
@@ -137,9 +129,9 @@ function UseServer(options) {
|
|
|
137
129
|
registerRequestHandlers(target, instance, underlyingServer);
|
|
138
130
|
registerNotificationHandlers(target, instance, underlyingServer);
|
|
139
131
|
// 2. Fetch/create server registration for decorators
|
|
140
|
-
const reg =
|
|
132
|
+
const reg = getOrCreateServerRegistration(underlyingServer);
|
|
141
133
|
// 3. Register Tools
|
|
142
|
-
const pendingTools = target.prototype[
|
|
134
|
+
const pendingTools = target.prototype[TOOL_META] || [];
|
|
143
135
|
for (const { options: toolOpts, methodName } of pendingTools) {
|
|
144
136
|
const handlerFn = instance[methodName].bind(instance);
|
|
145
137
|
if (isMcpServer) {
|
|
@@ -156,7 +148,7 @@ function UseServer(options) {
|
|
|
156
148
|
}
|
|
157
149
|
}
|
|
158
150
|
// 4. Register Prompts
|
|
159
|
-
const pendingPrompts = target.prototype[
|
|
151
|
+
const pendingPrompts = target.prototype[PROMPT_META] || [];
|
|
160
152
|
for (const { options: promptOpts, methodName } of pendingPrompts) {
|
|
161
153
|
const handlerFn = instance[methodName].bind(instance);
|
|
162
154
|
if (isMcpServer) {
|
|
@@ -173,7 +165,7 @@ function UseServer(options) {
|
|
|
173
165
|
}
|
|
174
166
|
}
|
|
175
167
|
// 5. Register Resources
|
|
176
|
-
const pendingResources = target.prototype[
|
|
168
|
+
const pendingResources = target.prototype[RESOURCE_META] || [];
|
|
177
169
|
for (const { options: resOpts, methodName } of pendingResources) {
|
|
178
170
|
const handlerFn = instance[methodName].bind(instance);
|
|
179
171
|
if (isMcpServer) {
|
|
@@ -190,7 +182,7 @@ function UseServer(options) {
|
|
|
190
182
|
}
|
|
191
183
|
}
|
|
192
184
|
// 6. Register Resource Templates
|
|
193
|
-
const pendingTemplates = target.prototype[
|
|
185
|
+
const pendingTemplates = target.prototype[RESOURCE_TEMPLATE_META] || [];
|
|
194
186
|
for (const { options: tempOpts, methodName } of pendingTemplates) {
|
|
195
187
|
const handlerFn = instance[methodName].bind(instance);
|
|
196
188
|
if (isMcpServer) {
|
|
@@ -200,7 +192,7 @@ function UseServer(options) {
|
|
|
200
192
|
mimeType: tempOpts.mimeType
|
|
201
193
|
}, (uri, extra) => {
|
|
202
194
|
const uriStr = uri.href || String(uri);
|
|
203
|
-
const params =
|
|
195
|
+
const params = matchUriTemplate(tempOpts.uriTemplate, uriStr) || {};
|
|
204
196
|
return handlerFn(params, uriStr, extra === null || extra === void 0 ? void 0 : extra.mcpReq, extra);
|
|
205
197
|
});
|
|
206
198
|
console.log(`[Server] Registered Resource Template Decorator "${tempOpts.uriTemplate}" natively on McpServer`);
|
|
@@ -211,16 +203,16 @@ function UseServer(options) {
|
|
|
211
203
|
}
|
|
212
204
|
}
|
|
213
205
|
// 7. Register Subscribe/Unsubscribe
|
|
214
|
-
if (target.prototype[
|
|
215
|
-
reg.subscribeHandler = instance[target.prototype[
|
|
216
|
-
console.log(`[Server] Registered Subscribe Decorator -> ${String(target.prototype[
|
|
206
|
+
if (target.prototype[SUBSCRIBE_META]) {
|
|
207
|
+
reg.subscribeHandler = instance[target.prototype[SUBSCRIBE_META]].bind(instance);
|
|
208
|
+
console.log(`[Server] Registered Subscribe Decorator -> ${String(target.prototype[SUBSCRIBE_META])}`);
|
|
217
209
|
}
|
|
218
|
-
if (target.prototype[
|
|
219
|
-
reg.unsubscribeHandler = instance[target.prototype[
|
|
220
|
-
console.log(`[Server] Registered Unsubscribe Decorator -> ${String(target.prototype[
|
|
210
|
+
if (target.prototype[UNSUBSCRIBE_META]) {
|
|
211
|
+
reg.unsubscribeHandler = instance[target.prototype[UNSUBSCRIBE_META]].bind(instance);
|
|
212
|
+
console.log(`[Server] Registered Unsubscribe Decorator -> ${String(target.prototype[UNSUBSCRIBE_META])}`);
|
|
221
213
|
}
|
|
222
214
|
// 8. Register Completions
|
|
223
|
-
const pendingCompletions = target.prototype[
|
|
215
|
+
const pendingCompletions = target.prototype[COMPLETION_META] || [];
|
|
224
216
|
for (const { ref, methodName } of pendingCompletions) {
|
|
225
217
|
const handlerFn = instance[methodName].bind(instance);
|
|
226
218
|
reg.completionHandlers.push({ ref, handler: handlerFn });
|
|
@@ -249,19 +241,18 @@ function UseServer(options) {
|
|
|
249
241
|
return newConstructor;
|
|
250
242
|
};
|
|
251
243
|
}
|
|
252
|
-
exports.UseServer = UseServer;
|
|
253
244
|
/**
|
|
254
245
|
* Binds aggregated handlers to the server for core schemas.
|
|
255
246
|
*/
|
|
256
247
|
function bindAggregatedDispatchers(server, reg) {
|
|
257
248
|
// --- Tools Dispatchers ---
|
|
258
249
|
if (reg.tools.size > 0) {
|
|
259
|
-
server.setRequestHandler(
|
|
250
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
260
251
|
const tools = Array.from(reg.tools.values()).map((t) => {
|
|
261
252
|
let inputSchema = { type: "object", properties: {} };
|
|
262
253
|
if (t.options.inputSchema) {
|
|
263
254
|
if (t.options.inputSchema._def || t.options.inputSchema._zod) {
|
|
264
|
-
inputSchema =
|
|
255
|
+
inputSchema = zodToJsonSchema(t.options.inputSchema);
|
|
265
256
|
}
|
|
266
257
|
else {
|
|
267
258
|
inputSchema = t.options.inputSchema;
|
|
@@ -275,7 +266,7 @@ function bindAggregatedDispatchers(server, reg) {
|
|
|
275
266
|
});
|
|
276
267
|
return { tools };
|
|
277
268
|
});
|
|
278
|
-
server.setRequestHandler(
|
|
269
|
+
server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
|
|
279
270
|
const toolName = request.params.name;
|
|
280
271
|
const tool = reg.tools.get(toolName);
|
|
281
272
|
if (!tool) {
|
|
@@ -286,7 +277,7 @@ function bindAggregatedDispatchers(server, reg) {
|
|
|
286
277
|
}
|
|
287
278
|
// --- Prompts Dispatchers ---
|
|
288
279
|
if (reg.prompts.size > 0) {
|
|
289
|
-
server.setRequestHandler(
|
|
280
|
+
server.setRequestHandler(ListPromptsRequestSchema, async () => {
|
|
290
281
|
const prompts = Array.from(reg.prompts.values()).map((p) => ({
|
|
291
282
|
name: p.options.name,
|
|
292
283
|
description: p.options.description,
|
|
@@ -294,7 +285,7 @@ function bindAggregatedDispatchers(server, reg) {
|
|
|
294
285
|
}));
|
|
295
286
|
return { prompts };
|
|
296
287
|
});
|
|
297
|
-
server.setRequestHandler(
|
|
288
|
+
server.setRequestHandler(GetPromptRequestSchema, async (request, extra) => {
|
|
298
289
|
const promptName = request.params.name;
|
|
299
290
|
const prompt = reg.prompts.get(promptName);
|
|
300
291
|
if (!prompt) {
|
|
@@ -305,7 +296,7 @@ function bindAggregatedDispatchers(server, reg) {
|
|
|
305
296
|
}
|
|
306
297
|
// --- Resources & Templates Dispatchers ---
|
|
307
298
|
if (reg.resources.size > 0 || reg.resourceTemplates.size > 0) {
|
|
308
|
-
server.setRequestHandler(
|
|
299
|
+
server.setRequestHandler(ListResourcesRequestSchema, async () => {
|
|
309
300
|
const resources = Array.from(reg.resources.values()).map((r) => ({
|
|
310
301
|
uri: r.options.uri,
|
|
311
302
|
name: r.options.name,
|
|
@@ -314,7 +305,7 @@ function bindAggregatedDispatchers(server, reg) {
|
|
|
314
305
|
}));
|
|
315
306
|
return { resources };
|
|
316
307
|
});
|
|
317
|
-
server.setRequestHandler(
|
|
308
|
+
server.setRequestHandler(ListResourceTemplatesRequestSchema, async () => {
|
|
318
309
|
const resourceTemplates = Array.from(reg.resourceTemplates.values()).map((rt) => ({
|
|
319
310
|
uriTemplate: rt.options.uriTemplate,
|
|
320
311
|
name: rt.options.name,
|
|
@@ -323,14 +314,14 @@ function bindAggregatedDispatchers(server, reg) {
|
|
|
323
314
|
}));
|
|
324
315
|
return { resourceTemplates };
|
|
325
316
|
});
|
|
326
|
-
server.setRequestHandler(
|
|
317
|
+
server.setRequestHandler(ReadResourceRequestSchema, async (request, extra) => {
|
|
327
318
|
const uri = request.params.uri;
|
|
328
319
|
const resource = reg.resources.get(uri);
|
|
329
320
|
if (resource) {
|
|
330
321
|
return resource.handler(uri, request, extra);
|
|
331
322
|
}
|
|
332
323
|
for (const [uriTemplate, template] of reg.resourceTemplates.entries()) {
|
|
333
|
-
const params =
|
|
324
|
+
const params = matchUriTemplate(uriTemplate, uri);
|
|
334
325
|
if (params) {
|
|
335
326
|
return template.handler(params, uri, request, extra);
|
|
336
327
|
}
|
|
@@ -339,7 +330,7 @@ function bindAggregatedDispatchers(server, reg) {
|
|
|
339
330
|
});
|
|
340
331
|
}
|
|
341
332
|
// --- Subscriptions Dispatchers ---
|
|
342
|
-
server.setRequestHandler(
|
|
333
|
+
server.setRequestHandler(SubscribeRequestSchema, async (request, extra) => {
|
|
343
334
|
const { uri } = request.params;
|
|
344
335
|
const sessionId = extra.sessionId || "default";
|
|
345
336
|
if (!reg.subscribers.has(uri)) {
|
|
@@ -352,7 +343,7 @@ function bindAggregatedDispatchers(server, reg) {
|
|
|
352
343
|
}
|
|
353
344
|
return {};
|
|
354
345
|
});
|
|
355
|
-
server.setRequestHandler(
|
|
346
|
+
server.setRequestHandler(UnsubscribeRequestSchema, async (request, extra) => {
|
|
356
347
|
const { uri } = request.params;
|
|
357
348
|
const sessionId = extra.sessionId || "default";
|
|
358
349
|
if (reg.subscribers.has(uri)) {
|
|
@@ -366,7 +357,7 @@ function bindAggregatedDispatchers(server, reg) {
|
|
|
366
357
|
});
|
|
367
358
|
// --- Completion Dispatchers ---
|
|
368
359
|
if (reg.completionHandlers.length > 0) {
|
|
369
|
-
server.setRequestHandler(
|
|
360
|
+
server.setRequestHandler(CompleteRequestSchema, async (request, extra) => {
|
|
370
361
|
const { ref, argument } = request.params;
|
|
371
362
|
const normalizedType = ref.type === "ref/prompt" ? "prompt" : ref.type === "ref/resource" ? "resource" : ref.type;
|
|
372
363
|
const refName = ref.type === "ref/prompt" ? ref.name : ref.type === "ref/resource" ? ref.uri : "";
|