@nestjs-mcp/server 0.1.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.copilotignore +38 -0
- package/.devcontainer/Dockerfile.dev +28 -0
- package/.devcontainer/devcontainer.json +56 -0
- package/.devcontainer/docker-compose.yml +15 -0
- package/.dockerignore +37 -0
- package/.github/codeql-config.yml +4 -0
- package/.github/copilot-instructions.md +138 -0
- package/.github/prompts/memory.prompt.md +120 -0
- package/.github/workflows/auto-tag-release.yml +84 -0
- package/.github/workflows/codeql-analysis.yml +56 -0
- package/.github/workflows/npm-publish.yml +58 -0
- package/.github/workflows/pr-branch-validation.yml +78 -0
- package/.github/workflows/run-tests.yml +41 -0
- package/.github/workflows/sync-main-to-develop.yml +53 -0
- package/.handbook/GIT_GUIDELINES.md +250 -0
- package/.handbook/PACKAGE_VERSIONING.md +140 -0
- package/.handbook/STACK.md +75 -0
- package/.prettierrc +4 -0
- package/.vscode/extensions.json +44 -0
- package/.vscode/settings.json +40 -0
- package/CONTRIBUTING.md +261 -0
- package/LICENSE +21 -0
- package/README.md +490 -0
- package/dist/examples/async-import/app.module.d.ts +2 -0
- package/dist/examples/async-import/app.module.js +33 -0
- package/dist/examples/async-import/app.module.js.map +1 -0
- package/dist/examples/async-import/main.d.ts +1 -0
- package/dist/examples/async-import/main.js +17 -0
- package/dist/examples/async-import/main.js.map +1 -0
- package/dist/examples/guards/app.module.d.ts +6 -0
- package/dist/examples/guards/app.module.js +48 -0
- package/dist/examples/guards/app.module.js.map +1 -0
- package/dist/examples/guards/guards.resolver.d.ts +13 -0
- package/dist/examples/guards/guards.resolver.js +61 -0
- package/dist/examples/guards/guards.resolver.js.map +1 -0
- package/dist/examples/guards/main.d.ts +1 -0
- package/dist/examples/guards/main.js +11 -0
- package/dist/examples/guards/main.js.map +1 -0
- package/dist/examples/mixed/app.module.d.ts +2 -0
- package/dist/examples/mixed/app.module.js +31 -0
- package/dist/examples/mixed/app.module.js.map +1 -0
- package/dist/examples/mixed/main.d.ts +1 -0
- package/dist/examples/mixed/main.js +11 -0
- package/dist/examples/mixed/main.js.map +1 -0
- package/dist/examples/mixed/mixed.resolver.d.ts +6 -0
- package/dist/examples/mixed/mixed.resolver.js +78 -0
- package/dist/examples/mixed/mixed.resolver.js.map +1 -0
- package/dist/examples/prompts/app.module.d.ts +2 -0
- package/dist/examples/prompts/app.module.js +31 -0
- package/dist/examples/prompts/app.module.js.map +1 -0
- package/dist/examples/prompts/main.d.ts +1 -0
- package/dist/examples/prompts/main.js +11 -0
- package/dist/examples/prompts/main.js.map +1 -0
- package/dist/examples/prompts/prompts.resolver.d.ts +14 -0
- package/dist/examples/prompts/prompts.resolver.js +165 -0
- package/dist/examples/prompts/prompts.resolver.js.map +1 -0
- package/dist/examples/resources/app.module.d.ts +2 -0
- package/dist/examples/resources/app.module.js +31 -0
- package/dist/examples/resources/app.module.js.map +1 -0
- package/dist/examples/resources/main.d.ts +1 -0
- package/dist/examples/resources/main.js +11 -0
- package/dist/examples/resources/main.js.map +1 -0
- package/dist/examples/resources/resources.resolver.d.ts +12 -0
- package/dist/examples/resources/resources.resolver.js +114 -0
- package/dist/examples/resources/resources.resolver.js.map +1 -0
- package/dist/examples/tools/app.module.d.ts +2 -0
- package/dist/examples/tools/app.module.js +31 -0
- package/dist/examples/tools/app.module.js.map +1 -0
- package/dist/examples/tools/main.d.ts +1 -0
- package/dist/examples/tools/main.js +11 -0
- package/dist/examples/tools/main.js.map +1 -0
- package/dist/examples/tools/tools.resolver.d.ts +23 -0
- package/dist/examples/tools/tools.resolver.js +175 -0
- package/dist/examples/tools/tools.resolver.js.map +1 -0
- package/dist/src/controllers/sse/index.d.ts +2 -0
- package/dist/src/controllers/sse/index.js +19 -0
- package/dist/src/controllers/sse/index.js.map +1 -0
- package/dist/src/controllers/sse/sse.controller.d.ts +8 -0
- package/dist/src/controllers/sse/sse.controller.js +51 -0
- package/dist/src/controllers/sse/sse.controller.js.map +1 -0
- package/dist/src/controllers/sse/sse.service.d.ts +16 -0
- package/dist/src/controllers/sse/sse.service.js +78 -0
- package/dist/src/controllers/sse/sse.service.js.map +1 -0
- package/dist/src/controllers/streamable/index.d.ts +2 -0
- package/dist/src/controllers/streamable/index.js +19 -0
- package/dist/src/controllers/streamable/index.js.map +1 -0
- package/dist/src/controllers/streamable/streamable.controller.d.ts +9 -0
- package/dist/src/controllers/streamable/streamable.controller.js +62 -0
- package/dist/src/controllers/streamable/streamable.controller.js.map +1 -0
- package/dist/src/controllers/streamable/streamable.service.d.ts +24 -0
- package/dist/src/controllers/streamable/streamable.service.js +117 -0
- package/dist/src/controllers/streamable/streamable.service.js.map +1 -0
- package/dist/src/decorators/capabilities.constants.d.ts +4 -0
- package/dist/src/decorators/capabilities.constants.js +8 -0
- package/dist/src/decorators/capabilities.constants.js.map +1 -0
- package/dist/src/decorators/capabilities.decorators.d.ts +8 -0
- package/dist/src/decorators/capabilities.decorators.js +49 -0
- package/dist/src/decorators/capabilities.decorators.js.map +1 -0
- package/dist/src/decorators/index.d.ts +2 -0
- package/dist/src/decorators/index.js +19 -0
- package/dist/src/decorators/index.js.map +1 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +21 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/interfaces/capabilities.interface.d.ts +52 -0
- package/dist/src/interfaces/capabilities.interface.js +3 -0
- package/dist/src/interfaces/capabilities.interface.js.map +1 -0
- package/dist/src/interfaces/guards.interface.d.ts +4 -0
- package/dist/src/interfaces/guards.interface.js +3 -0
- package/dist/src/interfaces/guards.interface.js.map +1 -0
- package/dist/src/interfaces/index.d.ts +2 -0
- package/dist/src/interfaces/index.js +19 -0
- package/dist/src/interfaces/index.js.map +1 -0
- package/dist/src/interfaces/mcp-server-options.interface.d.ts +42 -0
- package/dist/src/interfaces/mcp-server-options.interface.js +3 -0
- package/dist/src/interfaces/mcp-server-options.interface.js.map +1 -0
- package/dist/src/mcp.module.d.ts +13 -0
- package/dist/src/mcp.module.js +176 -0
- package/dist/src/mcp.module.js.map +1 -0
- package/dist/src/registry/discovery.service.d.ts +16 -0
- package/dist/src/registry/discovery.service.js +85 -0
- package/dist/src/registry/discovery.service.js.map +1 -0
- package/dist/src/registry/index.d.ts +2 -0
- package/dist/src/registry/index.js +19 -0
- package/dist/src/registry/index.js.map +1 -0
- package/dist/src/registry/logger.service.d.ts +16 -0
- package/dist/src/registry/logger.service.js +97 -0
- package/dist/src/registry/logger.service.js.map +1 -0
- package/dist/src/registry/registry.service.d.ts +14 -0
- package/dist/src/registry/registry.service.js +165 -0
- package/dist/src/registry/registry.service.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/eslint.config.mjs +40 -0
- package/examples/README.md +56 -0
- package/examples/async-import/app.module.ts +22 -0
- package/examples/async-import/main.ts +15 -0
- package/examples/guards/app.module.ts +44 -0
- package/examples/guards/guards.resolver.ts +52 -0
- package/examples/guards/main.ts +11 -0
- package/examples/mixed/app.module.ts +20 -0
- package/examples/mixed/main.ts +11 -0
- package/examples/mixed/mixed.resolver.ts +56 -0
- package/examples/prompts/app.module.ts +20 -0
- package/examples/prompts/main.ts +11 -0
- package/examples/prompts/prompts.resolver.ts +184 -0
- package/examples/resources/app.module.ts +19 -0
- package/examples/resources/main.ts +11 -0
- package/examples/resources/resources.resolver.ts +123 -0
- package/examples/tools/app.module.ts +20 -0
- package/examples/tools/main.ts +11 -0
- package/examples/tools/tools.resolver.ts +205 -0
- package/nest-cli.json +8 -0
- package/package.json +106 -0
- package/scripts/npm-publish.js +301 -0
- package/src/controllers/sse/index.ts +2 -0
- package/src/controllers/sse/sse.controller.ts +19 -0
- package/src/controllers/sse/sse.service.ts +90 -0
- package/src/controllers/streamable/index.ts +2 -0
- package/src/controllers/streamable/streamable.controller.ts +24 -0
- package/src/controllers/streamable/streamable.service.ts +168 -0
- package/src/decorators/capabilities.constants.ts +7 -0
- package/src/decorators/capabilities.decorators.ts +150 -0
- package/src/decorators/index.ts +2 -0
- package/src/index.ts +11 -0
- package/src/interfaces/capabilities.interface.ts +95 -0
- package/src/interfaces/guards.interface.ts +13 -0
- package/src/interfaces/index.ts +2 -0
- package/src/interfaces/mcp-server-options.interface.ts +105 -0
- package/src/mcp.module.ts +233 -0
- package/src/mcp.service.spec.ts +28 -0
- package/src/registry/discovery.service.ts +116 -0
- package/src/registry/index.ts +2 -0
- package/src/registry/logger.service.ts +143 -0
- package/src/registry/registry.service.ts +281 -0
- package/test/base.e2e-spec.ts +74 -0
- package/test/jest-e2e.json +9 -0
- package/tsconfig.build.json +4 -0
- package/tsconfig.json +23 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@nestjs/core");
|
|
4
|
+
const app_module_1 = require("./app.module");
|
|
5
|
+
async function bootstrap() {
|
|
6
|
+
const app = await core_1.NestFactory.create(app_module_1.AppModule);
|
|
7
|
+
await app.listen(3000);
|
|
8
|
+
console.log('Resources example server running on http://localhost:3000');
|
|
9
|
+
}
|
|
10
|
+
void bootstrap();
|
|
11
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../../examples/guards/main.ts"],"names":[],"mappings":";;AAAA,uCAA2C;AAE3C,6CAAyC;AAEzC,KAAK,UAAU,SAAS;IACtB,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,sBAAS,CAAC,CAAC;IAChD,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACvB,OAAO,CAAC,GAAG,CAAC,2DAA2D,CAAC,CAAC;AAC3E,CAAC;AAED,KAAK,SAAS,EAAE,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.AppModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const mcp_module_1 = require("../../src/mcp.module");
|
|
12
|
+
const mixed_resolver_1 = require("./mixed.resolver");
|
|
13
|
+
let AppModule = class AppModule {
|
|
14
|
+
};
|
|
15
|
+
exports.AppModule = AppModule;
|
|
16
|
+
exports.AppModule = AppModule = __decorate([
|
|
17
|
+
(0, common_1.Module)({
|
|
18
|
+
imports: [
|
|
19
|
+
mcp_module_1.McpModule.forRoot({
|
|
20
|
+
name: 'tools',
|
|
21
|
+
version: '1.0.0',
|
|
22
|
+
logging: {
|
|
23
|
+
enabled: true,
|
|
24
|
+
level: 'verbose',
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
27
|
+
],
|
|
28
|
+
providers: [mixed_resolver_1.MixedResolver],
|
|
29
|
+
})
|
|
30
|
+
], AppModule);
|
|
31
|
+
//# sourceMappingURL=app.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../../../examples/mixed/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AAExC,qDAAiD;AAEjD,qDAAiD;AAe1C,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,8BAAS;oBAAT,SAAS;IAbrB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,sBAAS,CAAC,OAAO,CAAC;gBAChB,IAAI,EAAE,OAAO;gBACb,OAAO,EAAE,OAAO;gBAChB,OAAO,EAAE;oBACP,OAAO,EAAE,IAAI;oBACb,KAAK,EAAE,SAAS;iBACjB;aACF,CAAC;SACH;QACD,SAAS,EAAE,CAAC,8BAAa,CAAC;KAC3B,CAAC;GACW,SAAS,CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@nestjs/core");
|
|
4
|
+
const app_module_1 = require("./app.module");
|
|
5
|
+
async function bootstrap() {
|
|
6
|
+
const app = await core_1.NestFactory.create(app_module_1.AppModule);
|
|
7
|
+
await app.listen(3000);
|
|
8
|
+
console.log('Resources example server running on http://localhost:3000');
|
|
9
|
+
}
|
|
10
|
+
void bootstrap();
|
|
11
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../../examples/mixed/main.ts"],"names":[],"mappings":";;AAAA,uCAA2C;AAE3C,6CAAyC;AAEzC,KAAK,UAAU,SAAS;IACtB,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,sBAAS,CAAC,CAAC;IAChD,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACvB,OAAO,CAAC,GAAG,CAAC,2DAA2D,CAAC,CAAC;AAC3E,CAAC;AAED,KAAK,SAAS,EAAE,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CallToolResult, GetPromptResult, ReadResourceResult } from '@modelcontextprotocol/sdk/types';
|
|
2
|
+
export declare class MixedResolver {
|
|
3
|
+
getCountryList(uri: URL): ReadResourceResult;
|
|
4
|
+
getCountryInfo(): CallToolResult;
|
|
5
|
+
getCountryInfoPrompt(): GetPromptResult;
|
|
6
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.MixedResolver = void 0;
|
|
13
|
+
const src_1 = require("../../src");
|
|
14
|
+
let MixedResolver = class MixedResolver {
|
|
15
|
+
getCountryList(uri) {
|
|
16
|
+
return {
|
|
17
|
+
contents: [
|
|
18
|
+
{
|
|
19
|
+
uri: uri.href,
|
|
20
|
+
text: 'Mexico, USA, Canada',
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
getCountryInfo() {
|
|
26
|
+
return {
|
|
27
|
+
content: [
|
|
28
|
+
{
|
|
29
|
+
type: 'text',
|
|
30
|
+
text: 'The capital of France is Paris.',
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
getCountryInfoPrompt() {
|
|
36
|
+
return {
|
|
37
|
+
messages: [
|
|
38
|
+
{
|
|
39
|
+
role: 'assistant',
|
|
40
|
+
content: {
|
|
41
|
+
type: 'text',
|
|
42
|
+
text: 'What is the capital of France?',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
exports.MixedResolver = MixedResolver;
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, src_1.Resource)({
|
|
52
|
+
name: 'country_list',
|
|
53
|
+
uri: 'contry://list',
|
|
54
|
+
}),
|
|
55
|
+
__metadata("design:type", Function),
|
|
56
|
+
__metadata("design:paramtypes", [URL]),
|
|
57
|
+
__metadata("design:returntype", Object)
|
|
58
|
+
], MixedResolver.prototype, "getCountryList", null);
|
|
59
|
+
__decorate([
|
|
60
|
+
(0, src_1.Tool)({
|
|
61
|
+
name: 'get_country_info',
|
|
62
|
+
}),
|
|
63
|
+
__metadata("design:type", Function),
|
|
64
|
+
__metadata("design:paramtypes", []),
|
|
65
|
+
__metadata("design:returntype", Object)
|
|
66
|
+
], MixedResolver.prototype, "getCountryInfo", null);
|
|
67
|
+
__decorate([
|
|
68
|
+
(0, src_1.Prompt)({
|
|
69
|
+
name: 'get_country_info',
|
|
70
|
+
}),
|
|
71
|
+
__metadata("design:type", Function),
|
|
72
|
+
__metadata("design:paramtypes", []),
|
|
73
|
+
__metadata("design:returntype", Object)
|
|
74
|
+
], MixedResolver.prototype, "getCountryInfoPrompt", null);
|
|
75
|
+
exports.MixedResolver = MixedResolver = __decorate([
|
|
76
|
+
(0, src_1.Resolver)('mixed')
|
|
77
|
+
], MixedResolver);
|
|
78
|
+
//# sourceMappingURL=mixed.resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mixed.resolver.js","sourceRoot":"","sources":["../../../examples/mixed/mixed.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;AAMA,mCAA6D;AAGtD,IAAM,aAAa,GAAnB,MAAM,aAAa;IAKxB,cAAc,CAAC,GAAQ;QACrB,OAAO;YACL,QAAQ,EAAE;gBACR;oBACE,GAAG,EAAE,GAAG,CAAC,IAAI;oBACb,IAAI,EAAE,qBAAqB;iBAC5B;aACF;SACF,CAAC;IACJ,CAAC;IAKD,cAAc;QACZ,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,iCAAiC;iBACxC;aACF;SACF,CAAC;IACJ,CAAC;IAKD,oBAAoB;QAClB,OAAO;YACL,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,WAAW;oBACjB,OAAO,EAAE;wBACP,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,gCAAgC;qBACvC;iBACF;aACF;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AA9CY,sCAAa;AAKxB;IAJC,IAAA,cAAQ,EAAC;QACR,IAAI,EAAE,cAAc;QACpB,GAAG,EAAE,eAAe;KACrB,CAAC;;qCACkB,GAAG;;mDAStB;AAKD;IAHC,IAAA,UAAI,EAAC;QACJ,IAAI,EAAE,kBAAkB;KACzB,CAAC;;;;mDAUD;AAKD;IAHC,IAAA,YAAM,EAAC;QACN,IAAI,EAAE,kBAAkB;KACzB,CAAC;;;;yDAaD;wBA7CU,aAAa;IADzB,IAAA,cAAQ,EAAC,OAAO,CAAC;GACL,aAAa,CA8CzB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.AppModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const mcp_module_1 = require("../../src/mcp.module");
|
|
12
|
+
const prompts_resolver_1 = require("./prompts.resolver");
|
|
13
|
+
let AppModule = class AppModule {
|
|
14
|
+
};
|
|
15
|
+
exports.AppModule = AppModule;
|
|
16
|
+
exports.AppModule = AppModule = __decorate([
|
|
17
|
+
(0, common_1.Module)({
|
|
18
|
+
imports: [
|
|
19
|
+
mcp_module_1.McpModule.forRoot({
|
|
20
|
+
name: 'tools',
|
|
21
|
+
version: '1.0.0',
|
|
22
|
+
logging: {
|
|
23
|
+
enabled: true,
|
|
24
|
+
level: 'verbose',
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
27
|
+
],
|
|
28
|
+
providers: [prompts_resolver_1.PromptsResolver],
|
|
29
|
+
})
|
|
30
|
+
], AppModule);
|
|
31
|
+
//# sourceMappingURL=app.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../../../examples/prompts/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AAExC,qDAAiD;AAEjD,yDAAqD;AAe9C,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,8BAAS;oBAAT,SAAS;IAbrB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,sBAAS,CAAC,OAAO,CAAC;gBAChB,IAAI,EAAE,OAAO;gBACb,OAAO,EAAE,OAAO;gBAChB,OAAO,EAAE;oBACP,OAAO,EAAE,IAAI;oBACb,KAAK,EAAE,SAAS;iBACjB;aACF,CAAC;SACH;QACD,SAAS,EAAE,CAAC,kCAAe,CAAC;KAC7B,CAAC;GACW,SAAS,CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@nestjs/core");
|
|
4
|
+
const app_module_1 = require("./app.module");
|
|
5
|
+
async function bootstrap() {
|
|
6
|
+
const app = await core_1.NestFactory.create(app_module_1.AppModule);
|
|
7
|
+
await app.listen(3000);
|
|
8
|
+
console.log('Resources example server running on http://localhost:3000');
|
|
9
|
+
}
|
|
10
|
+
void bootstrap();
|
|
11
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../../examples/prompts/main.ts"],"names":[],"mappings":";;AAAA,uCAA2C;AAE3C,6CAAyC;AAEzC,KAAK,UAAU,SAAS;IACtB,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,sBAAS,CAAC,CAAC;IAChD,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACvB,OAAO,CAAC,GAAG,CAAC,2DAA2D,CAAC,CAAC;AAC3E,CAAC;AAED,KAAK,SAAS,EAAE,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { GetPromptResult } from '@modelcontextprotocol/sdk/types';
|
|
2
|
+
export declare class PromptsResolver {
|
|
3
|
+
basicGreeting(): GetPromptResult;
|
|
4
|
+
personalizedGreeting({ name, timeOfDay, }: {
|
|
5
|
+
name: string;
|
|
6
|
+
timeOfDay: 'morning' | 'afternoon' | 'evening' | 'night';
|
|
7
|
+
}): GetPromptResult;
|
|
8
|
+
helpGuide(): GetPromptResult;
|
|
9
|
+
productRecommendation({ category, budget, preferences, }: {
|
|
10
|
+
category: string;
|
|
11
|
+
budget: string;
|
|
12
|
+
preferences?: string;
|
|
13
|
+
}): GetPromptResult;
|
|
14
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PromptsResolver = void 0;
|
|
13
|
+
const zod_1 = require("zod");
|
|
14
|
+
const src_1 = require("../../src");
|
|
15
|
+
let PromptsResolver = class PromptsResolver {
|
|
16
|
+
basicGreeting() {
|
|
17
|
+
return {
|
|
18
|
+
messages: [
|
|
19
|
+
{
|
|
20
|
+
role: 'assistant',
|
|
21
|
+
content: {
|
|
22
|
+
type: 'text',
|
|
23
|
+
text: 'Hello! How can I assist you today?',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
personalizedGreeting({ name, timeOfDay, }) {
|
|
30
|
+
const greetings = {
|
|
31
|
+
morning: 'Good morning',
|
|
32
|
+
afternoon: 'Good afternoon',
|
|
33
|
+
evening: 'Good evening',
|
|
34
|
+
night: 'Good night',
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
messages: [
|
|
38
|
+
{
|
|
39
|
+
role: 'assistant',
|
|
40
|
+
content: {
|
|
41
|
+
type: 'text',
|
|
42
|
+
text: `${greetings[timeOfDay]}, ${name}! How can I assist you today?`,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
helpGuide() {
|
|
49
|
+
return {
|
|
50
|
+
messages: [
|
|
51
|
+
{
|
|
52
|
+
role: 'assistant',
|
|
53
|
+
content: {
|
|
54
|
+
type: 'text',
|
|
55
|
+
text: `
|
|
56
|
+
# System Help Guide
|
|
57
|
+
|
|
58
|
+
Here are the main features available:
|
|
59
|
+
- **Account Management**: Update your profile, change settings
|
|
60
|
+
- **Content Creation**: Create and edit documents, media, and more
|
|
61
|
+
- **Collaboration**: Share and work with others
|
|
62
|
+
- **Analytics**: View performance metrics and reports
|
|
63
|
+
|
|
64
|
+
For more detailed help, please specify which feature you need assistance with.
|
|
65
|
+
`,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
productRecommendation({ category, budget, preferences, }) {
|
|
72
|
+
const parsedCategory = category;
|
|
73
|
+
const parsedBudget = parseFloat(budget);
|
|
74
|
+
const parsedPreferences = preferences
|
|
75
|
+
? preferences.split(',').map((p) => p.trim())
|
|
76
|
+
: undefined;
|
|
77
|
+
const recommendations = {
|
|
78
|
+
electronics: [
|
|
79
|
+
{ name: 'Wireless Earbuds', price: 79.99 },
|
|
80
|
+
{ name: 'Smart Watch', price: 149.99 },
|
|
81
|
+
{ name: 'Bluetooth Speaker', price: 59.99 },
|
|
82
|
+
],
|
|
83
|
+
clothing: [
|
|
84
|
+
{ name: 'Casual T-Shirt', price: 24.99 },
|
|
85
|
+
{ name: 'Jeans', price: 49.99 },
|
|
86
|
+
{ name: 'Sneakers', price: 89.99 },
|
|
87
|
+
],
|
|
88
|
+
home: [
|
|
89
|
+
{ name: 'Coffee Maker', price: 69.99 },
|
|
90
|
+
{ name: 'Throw Blanket', price: 34.99 },
|
|
91
|
+
{ name: 'Table Lamp', price: 42.99 },
|
|
92
|
+
],
|
|
93
|
+
beauty: [
|
|
94
|
+
{ name: 'Face Serum', price: 29.99 },
|
|
95
|
+
{ name: 'Makeup Palette', price: 54.99 },
|
|
96
|
+
{ name: 'Hair Dryer', price: 99.99 },
|
|
97
|
+
],
|
|
98
|
+
};
|
|
99
|
+
const affordableProducts = recommendations[parsedCategory].filter((product) => product.price <= parsedBudget);
|
|
100
|
+
const productList = affordableProducts
|
|
101
|
+
.map((product) => `- ${product.name}: $${product.price.toFixed(2)}`)
|
|
102
|
+
.join('\n');
|
|
103
|
+
return {
|
|
104
|
+
messages: [
|
|
105
|
+
{
|
|
106
|
+
role: 'assistant',
|
|
107
|
+
content: {
|
|
108
|
+
type: 'text',
|
|
109
|
+
text: `Based on your ${parsedCategory} category and budget of $${parsedBudget.toFixed(2)}${parsedPreferences
|
|
110
|
+
? ` with preferences for ${parsedPreferences.join(', ')}`
|
|
111
|
+
: ''}, here are my recommendations:\n\n${productList}`,
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
exports.PromptsResolver = PromptsResolver;
|
|
119
|
+
__decorate([
|
|
120
|
+
(0, src_1.Prompt)({
|
|
121
|
+
name: 'greeting',
|
|
122
|
+
}),
|
|
123
|
+
__metadata("design:type", Function),
|
|
124
|
+
__metadata("design:paramtypes", []),
|
|
125
|
+
__metadata("design:returntype", Object)
|
|
126
|
+
], PromptsResolver.prototype, "basicGreeting", null);
|
|
127
|
+
__decorate([
|
|
128
|
+
(0, src_1.Prompt)({
|
|
129
|
+
name: 'personalized_greeting',
|
|
130
|
+
argsSchema: {
|
|
131
|
+
name: zod_1.z.string().min(1),
|
|
132
|
+
timeOfDay: zod_1.z.enum(['morning', 'afternoon', 'evening', 'night']),
|
|
133
|
+
},
|
|
134
|
+
}),
|
|
135
|
+
__metadata("design:type", Function),
|
|
136
|
+
__metadata("design:paramtypes", [Object]),
|
|
137
|
+
__metadata("design:returntype", Object)
|
|
138
|
+
], PromptsResolver.prototype, "personalizedGreeting", null);
|
|
139
|
+
__decorate([
|
|
140
|
+
(0, src_1.Prompt)({
|
|
141
|
+
name: 'help_guide',
|
|
142
|
+
description: 'Provides a general help guide about available system features',
|
|
143
|
+
}),
|
|
144
|
+
__metadata("design:type", Function),
|
|
145
|
+
__metadata("design:paramtypes", []),
|
|
146
|
+
__metadata("design:returntype", Object)
|
|
147
|
+
], PromptsResolver.prototype, "helpGuide", null);
|
|
148
|
+
__decorate([
|
|
149
|
+
(0, src_1.Prompt)({
|
|
150
|
+
name: 'product_recommendation',
|
|
151
|
+
description: 'Recommends products based on user preferences and requirements',
|
|
152
|
+
argsSchema: {
|
|
153
|
+
category: zod_1.z.string(),
|
|
154
|
+
budget: zod_1.z.string(),
|
|
155
|
+
preferences: zod_1.z.string().optional(),
|
|
156
|
+
},
|
|
157
|
+
}),
|
|
158
|
+
__metadata("design:type", Function),
|
|
159
|
+
__metadata("design:paramtypes", [Object]),
|
|
160
|
+
__metadata("design:returntype", Object)
|
|
161
|
+
], PromptsResolver.prototype, "productRecommendation", null);
|
|
162
|
+
exports.PromptsResolver = PromptsResolver = __decorate([
|
|
163
|
+
(0, src_1.Resolver)('prompts')
|
|
164
|
+
], PromptsResolver);
|
|
165
|
+
//# sourceMappingURL=prompts.resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.resolver.js","sourceRoot":"","sources":["../../../examples/prompts/prompts.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,6BAAwB;AAExB,mCAA6C;AAGtC,IAAM,eAAe,GAArB,MAAM,eAAe;IAQ1B,aAAa;QACX,OAAO;YACL,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,WAAW;oBACjB,OAAO,EAAE;wBACP,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,oCAAoC;qBAC3C;iBACF;aACF;SACF,CAAC;IACJ,CAAC;IAaD,oBAAoB,CAAC,EACnB,IAAI,EACJ,SAAS,GAIV;QACC,MAAM,SAAS,GAAG;YAChB,OAAO,EAAE,cAAc;YACvB,SAAS,EAAE,gBAAgB;YAC3B,OAAO,EAAE,cAAc;YACvB,KAAK,EAAE,YAAY;SACpB,CAAC;QAEF,OAAO;YACL,Q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BAAuB;QAC7B,UAAU,EAAE;YACV,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;YACvB,SAAS,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;SAChE;KACF,CAAC;;;;2DA0BD;AAWD;IALC,IAAA,YAAM,EAAC;QACN,IAAI,EAAE,YAAY;QAClB,WAAW,EACT,+DAA+D;KAClE,CAAC;;;;gDAuBD;AAgBD;IAVC,IAAA,YAAM,EAAC;QACN,IAAI,EAAE,wBAAwB;QAC9B,WAAW,EACT,gEAAgE;QAClE,UAAU,EAAE;YACV,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE;YACpB,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;YAClB,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;SACnC;KACF,CAAC;;;;4DAsED;0BAhLU,eAAe;IAD3B,IAAA,cAAQ,EAAC,SAAS,CAAC;GACP,eAAe,CAiL3B"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.AppModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const mcp_module_1 = require("../../src/mcp.module");
|
|
12
|
+
const resources_resolver_1 = require("./resources.resolver");
|
|
13
|
+
let AppModule = class AppModule {
|
|
14
|
+
};
|
|
15
|
+
exports.AppModule = AppModule;
|
|
16
|
+
exports.AppModule = AppModule = __decorate([
|
|
17
|
+
(0, common_1.Module)({
|
|
18
|
+
imports: [
|
|
19
|
+
mcp_module_1.McpModule.forRoot({
|
|
20
|
+
name: 'tools',
|
|
21
|
+
version: '1.0.0',
|
|
22
|
+
logging: {
|
|
23
|
+
enabled: true,
|
|
24
|
+
level: 'verbose',
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
27
|
+
],
|
|
28
|
+
providers: [resources_resolver_1.ResourcesResolver],
|
|
29
|
+
})
|
|
30
|
+
], AppModule);
|
|
31
|
+
//# sourceMappingURL=app.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../../../examples/resources/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AAExC,qDAAiD;AACjD,6DAAyD;AAelD,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,8BAAS;oBAAT,SAAS;IAbrB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,sBAAS,CAAC,OAAO,CAAC;gBAChB,IAAI,EAAE,OAAO;gBACb,OAAO,EAAE,OAAO;gBAChB,OAAO,EAAE;oBACP,OAAO,EAAE,IAAI;oBACb,KAAK,EAAE,SAAS;iBACjB;aACF,CAAC;SACH;QACD,SAAS,EAAE,CAAC,sCAAiB,CAAC;KAC/B,CAAC;GACW,SAAS,CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@nestjs/core");
|
|
4
|
+
const app_module_1 = require("./app.module");
|
|
5
|
+
async function bootstrap() {
|
|
6
|
+
const app = await core_1.NestFactory.create(app_module_1.AppModule);
|
|
7
|
+
await app.listen(3000);
|
|
8
|
+
console.log('Resources example server running on http://localhost:3000');
|
|
9
|
+
}
|
|
10
|
+
void bootstrap();
|
|
11
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../../examples/resources/main.ts"],"names":[],"mappings":";;AAAA,uCAA2C;AAE3C,6CAAyC;AAEzC,KAAK,UAAU,SAAS;IACtB,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,sBAAS,CAAC,CAAC;IAChD,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACvB,OAAO,CAAC,GAAG,CAAC,2DAA2D,CAAC,CAAC;AAC3E,CAAC;AAED,KAAK,SAAS,EAAE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol';
|
|
2
|
+
import { ReadResourceResult, ServerNotification, ServerRequest } from '@modelcontextprotocol/sdk/types';
|
|
3
|
+
export declare class ResourcesResolver {
|
|
4
|
+
getSimpleDocument(uri: URL, _extra: RequestHandlerExtra<ServerRequest, ServerNotification>): ReadResourceResult;
|
|
5
|
+
getUserProfile(uri: URL): ReadResourceResult;
|
|
6
|
+
getUserById(uri: URL, variables: {
|
|
7
|
+
name: string;
|
|
8
|
+
}, _extra: RequestHandlerExtra<ServerRequest, ServerNotification>): ReadResourceResult;
|
|
9
|
+
getUserByIdWithMetada(uri: URL, variables: {
|
|
10
|
+
userId: string;
|
|
11
|
+
}, _extra: RequestHandlerExtra<ServerRequest, ServerNotification>): ReadResourceResult;
|
|
12
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ResourcesResolver = void 0;
|
|
13
|
+
const src_1 = require("../../src");
|
|
14
|
+
const USER_LIST = [
|
|
15
|
+
{
|
|
16
|
+
id: '1',
|
|
17
|
+
name: 'John Doe',
|
|
18
|
+
email: 'john.doe@example.com',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: '2',
|
|
22
|
+
name: 'Jane Smith',
|
|
23
|
+
email: 'jane.smith@example.com',
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
let ResourcesResolver = class ResourcesResolver {
|
|
27
|
+
getSimpleDocument(uri, _extra) {
|
|
28
|
+
return {
|
|
29
|
+
contents: [
|
|
30
|
+
{
|
|
31
|
+
uri: uri.href,
|
|
32
|
+
text: JSON.stringify(USER_LIST),
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
getUserProfile(uri) {
|
|
38
|
+
const users = USER_LIST.map((user) => ({ id: user.id, name: user.name }));
|
|
39
|
+
return {
|
|
40
|
+
contents: [
|
|
41
|
+
{
|
|
42
|
+
uri: uri.href,
|
|
43
|
+
text: JSON.stringify(users),
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
getUserById(uri, variables, _extra) {
|
|
49
|
+
return {
|
|
50
|
+
contents: [
|
|
51
|
+
{
|
|
52
|
+
uri: uri.href,
|
|
53
|
+
text: `Hello, ${variables.name}!`,
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
getUserByIdWithMetada(uri, variables, _extra) {
|
|
59
|
+
const user = USER_LIST.find((user) => user.id === variables.userId);
|
|
60
|
+
return {
|
|
61
|
+
contents: [
|
|
62
|
+
{
|
|
63
|
+
uri: uri.href,
|
|
64
|
+
text: user ? JSON.stringify(user) : 'User not found',
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
exports.ResourcesResolver = ResourcesResolver;
|
|
71
|
+
__decorate([
|
|
72
|
+
(0, src_1.Resource)({
|
|
73
|
+
name: 'get_users',
|
|
74
|
+
uri: 'users://list',
|
|
75
|
+
}),
|
|
76
|
+
__metadata("design:type", Function),
|
|
77
|
+
__metadata("design:paramtypes", [URL, Object]),
|
|
78
|
+
__metadata("design:returntype", Object)
|
|
79
|
+
], ResourcesResolver.prototype, "getSimpleDocument", null);
|
|
80
|
+
__decorate([
|
|
81
|
+
(0, src_1.Resource)({
|
|
82
|
+
name: 'get_users_with_filters',
|
|
83
|
+
uri: 'users://list/metadata',
|
|
84
|
+
metadata: {},
|
|
85
|
+
}),
|
|
86
|
+
__metadata("design:type", Function),
|
|
87
|
+
__metadata("design:paramtypes", [URL]),
|
|
88
|
+
__metadata("design:returntype", Object)
|
|
89
|
+
], ResourcesResolver.prototype, "getUserProfile", null);
|
|
90
|
+
__decorate([
|
|
91
|
+
(0, src_1.Resource)({
|
|
92
|
+
name: 'greet',
|
|
93
|
+
template: 'geet://{name}',
|
|
94
|
+
}),
|
|
95
|
+
__metadata("design:type", Function),
|
|
96
|
+
__metadata("design:paramtypes", [URL, Object, Object]),
|
|
97
|
+
__metadata("design:returntype", Object)
|
|
98
|
+
], ResourcesResolver.prototype, "getUserById", null);
|
|
99
|
+
__decorate([
|
|
100
|
+
(0, src_1.Resource)({
|
|
101
|
+
name: 'get_user_by_id',
|
|
102
|
+
template: 'users://{userId}',
|
|
103
|
+
metadata: {
|
|
104
|
+
version: 1,
|
|
105
|
+
},
|
|
106
|
+
}),
|
|
107
|
+
__metadata("design:type", Function),
|
|
108
|
+
__metadata("design:paramtypes", [URL, Object, Object]),
|
|
109
|
+
__metadata("design:returntype", Object)
|
|
110
|
+
], ResourcesResolver.prototype, "getUserByIdWithMetada", null);
|
|
111
|
+
exports.ResourcesResolver = ResourcesResolver = __decorate([
|
|
112
|
+
(0, src_1.Resolver)('resources')
|
|
113
|
+
], ResourcesResolver);
|
|
114
|
+
//# sourceMappingURL=resources.resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resources.resolver.js","sourceRoot":"","sources":["../../../examples/resources/resources.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;AAOA,mCAA+C;AAE/C,MAAM,SAAS,GAAG;IAChB;QACE,EAAE,EAAE,GAAG;QACP,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,sBAAsB;KAC9B;IACD;QACE,EAAE,EAAE,GAAG;QACP,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,wBAAwB;KAChC;CACF,CAAC;AAGK,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAS5B,iBAAiB,CACf,GAAQ,EACR,MAA8D;QAE9D,OAAO;YACL,QAAQ,EAAE;gBACR;oBACE,GAAG,EAAE,GAAG,CAAC,IAAI;oBACb,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;iBAChC;aACF;SACF,CAAC;IACJ,CAAC;IAWD,cAAc,CAAC,GAAQ;QACrB,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,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ACR,IAAI,EAAE,gBAAgB;QACtB,QAAQ,EAAE,kBAAkB;QAC5B,QAAQ,EAAE;YACR,OAAO,EAAE,CAAC;SACX;KACF,CAAC;;qCAEK,GAAG;;8DAgBT;4BAlGU,iBAAiB;IAD7B,IAAA,cAAQ,EAAC,WAAW,CAAC;GACT,iBAAiB,CAmG7B"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.AppModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const mcp_module_1 = require("../../src/mcp.module");
|
|
12
|
+
const tools_resolver_1 = require("./tools.resolver");
|
|
13
|
+
let AppModule = class AppModule {
|
|
14
|
+
};
|
|
15
|
+
exports.AppModule = AppModule;
|
|
16
|
+
exports.AppModule = AppModule = __decorate([
|
|
17
|
+
(0, common_1.Module)({
|
|
18
|
+
imports: [
|
|
19
|
+
mcp_module_1.McpModule.forRoot({
|
|
20
|
+
name: 'tools',
|
|
21
|
+
version: '1.0.0',
|
|
22
|
+
logging: {
|
|
23
|
+
enabled: true,
|
|
24
|
+
level: 'verbose',
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
27
|
+
],
|
|
28
|
+
providers: [tools_resolver_1.ToolsResolver],
|
|
29
|
+
})
|
|
30
|
+
], AppModule);
|
|
31
|
+
//# sourceMappingURL=app.module.js.map
|