@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
|
+
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../../../examples/tools/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/tools/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,23 @@
|
|
|
1
|
+
import { CallToolResult } from '@modelcontextprotocol/sdk/types';
|
|
2
|
+
export declare class ToolsResolver {
|
|
3
|
+
healthCheck(): CallToolResult;
|
|
4
|
+
calculateDiscount({ price, discountPercentage, }: {
|
|
5
|
+
price: number;
|
|
6
|
+
discountPercentage: number;
|
|
7
|
+
}): CallToolResult;
|
|
8
|
+
generateUniqueId(): CallToolResult;
|
|
9
|
+
getWeatherForecast({ location, days, tempUnit, }: {
|
|
10
|
+
location: string;
|
|
11
|
+
days: number;
|
|
12
|
+
tempUnit: 'celsius' | 'fahrenheit';
|
|
13
|
+
}): CallToolResult;
|
|
14
|
+
registerUser({ username, email, age, preferences, }: {
|
|
15
|
+
username: string;
|
|
16
|
+
email: string;
|
|
17
|
+
age?: number;
|
|
18
|
+
preferences?: {
|
|
19
|
+
theme: 'light' | 'dark' | 'system';
|
|
20
|
+
notifications: boolean;
|
|
21
|
+
};
|
|
22
|
+
}): CallToolResult;
|
|
23
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
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.ToolsResolver = void 0;
|
|
13
|
+
const crypto_1 = require("crypto");
|
|
14
|
+
const zod_1 = require("zod");
|
|
15
|
+
const src_1 = require("../../src");
|
|
16
|
+
let ToolsResolver = class ToolsResolver {
|
|
17
|
+
healthCheck() {
|
|
18
|
+
return {
|
|
19
|
+
content: [
|
|
20
|
+
{
|
|
21
|
+
type: 'text',
|
|
22
|
+
text: 'Server is operational. All systems running normally.',
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
calculateDiscount({ price, discountPercentage, }) {
|
|
28
|
+
const discountAmount = price * (discountPercentage / 100);
|
|
29
|
+
const finalPrice = price - discountAmount;
|
|
30
|
+
return {
|
|
31
|
+
content: [
|
|
32
|
+
{
|
|
33
|
+
type: 'text',
|
|
34
|
+
text: `Original price: $${price.toFixed(2)}\nDiscount: $${discountAmount.toFixed(2)} (${discountPercentage}%)\nFinal price: $${finalPrice.toFixed(2)}`,
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
generateUniqueId() {
|
|
40
|
+
const uuid = (0, crypto_1.randomUUID)();
|
|
41
|
+
return {
|
|
42
|
+
content: [
|
|
43
|
+
{
|
|
44
|
+
type: 'text',
|
|
45
|
+
text: `Generated ID: ${uuid}`,
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
getWeatherForecast({ location, days, tempUnit, }) {
|
|
51
|
+
const weatherTypes = [
|
|
52
|
+
'Sunny',
|
|
53
|
+
'Partly Cloudy',
|
|
54
|
+
'Cloudy',
|
|
55
|
+
'Rainy',
|
|
56
|
+
'Thunderstorms',
|
|
57
|
+
];
|
|
58
|
+
const forecast = Array.from({ length: days }, (_, i) => {
|
|
59
|
+
const date = new Date();
|
|
60
|
+
date.setDate(date.getDate() + i);
|
|
61
|
+
let temp = Math.floor(Math.random() * 15) + 15;
|
|
62
|
+
if (tempUnit === 'fahrenheit') {
|
|
63
|
+
temp = Math.round((temp * 9) / 5 + 32);
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
date: date.toDateString(),
|
|
67
|
+
condition: weatherTypes[Math.floor(Math.random() * weatherTypes.length)],
|
|
68
|
+
temperature: temp,
|
|
69
|
+
unit: tempUnit === 'celsius' ? '°C' : '°F',
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
const formattedForecast = forecast
|
|
73
|
+
.map((day) => `${day.date}: ${day.condition}, ${day.temperature}${day.unit}`)
|
|
74
|
+
.join('\n');
|
|
75
|
+
return {
|
|
76
|
+
content: [
|
|
77
|
+
{
|
|
78
|
+
type: 'text',
|
|
79
|
+
text: `Weather forecast for ${location} (next ${days} days):\n\n${formattedForecast}`,
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
registerUser({ username, email, age, preferences, }) {
|
|
85
|
+
const userId = (0, crypto_1.randomInt)(10000, 100000);
|
|
86
|
+
return {
|
|
87
|
+
content: [
|
|
88
|
+
{
|
|
89
|
+
type: 'text',
|
|
90
|
+
text: `User registered successfully!\n
|
|
91
|
+
User ID: ${userId}
|
|
92
|
+
Username: ${username}
|
|
93
|
+
Email: ${email}
|
|
94
|
+
${age ? `Age: ${age}` : ''}
|
|
95
|
+
${preferences
|
|
96
|
+
? `Theme: ${preferences.theme}
|
|
97
|
+
Notifications: ${preferences.notifications ? 'Enabled' : 'Disabled'}`
|
|
98
|
+
: ''}`,
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
exports.ToolsResolver = ToolsResolver;
|
|
105
|
+
__decorate([
|
|
106
|
+
(0, src_1.Tool)({
|
|
107
|
+
name: 'server_health_check',
|
|
108
|
+
}),
|
|
109
|
+
__metadata("design:type", Function),
|
|
110
|
+
__metadata("design:paramtypes", []),
|
|
111
|
+
__metadata("design:returntype", Object)
|
|
112
|
+
], ToolsResolver.prototype, "healthCheck", null);
|
|
113
|
+
__decorate([
|
|
114
|
+
(0, src_1.Tool)({
|
|
115
|
+
name: 'calculate_discount',
|
|
116
|
+
paramSchema: {
|
|
117
|
+
price: zod_1.z.number().positive().min(0.01),
|
|
118
|
+
discountPercentage: zod_1.z.number().min(0).max(100),
|
|
119
|
+
},
|
|
120
|
+
}),
|
|
121
|
+
__metadata("design:type", Function),
|
|
122
|
+
__metadata("design:paramtypes", [Object]),
|
|
123
|
+
__metadata("design:returntype", Object)
|
|
124
|
+
], ToolsResolver.prototype, "calculateDiscount", null);
|
|
125
|
+
__decorate([
|
|
126
|
+
(0, src_1.Tool)({
|
|
127
|
+
name: 'generate_unique_id',
|
|
128
|
+
description: 'Generates a cryptographically strong unique identifier suitable for database keys or session tokens',
|
|
129
|
+
}),
|
|
130
|
+
__metadata("design:type", Function),
|
|
131
|
+
__metadata("design:paramtypes", []),
|
|
132
|
+
__metadata("design:returntype", Object)
|
|
133
|
+
], ToolsResolver.prototype, "generateUniqueId", null);
|
|
134
|
+
__decorate([
|
|
135
|
+
(0, src_1.Tool)({
|
|
136
|
+
name: 'weather_forecast',
|
|
137
|
+
description: 'Retrieves weather forecast for a specified location and timeframe',
|
|
138
|
+
paramSchema: {
|
|
139
|
+
location: zod_1.z.string().min(2).max(100),
|
|
140
|
+
days: zod_1.z.number().int().min(1).max(7).default(3),
|
|
141
|
+
tempUnit: zod_1.z.enum(['celsius', 'fahrenheit']).default('celsius'),
|
|
142
|
+
},
|
|
143
|
+
}),
|
|
144
|
+
__metadata("design:type", Function),
|
|
145
|
+
__metadata("design:paramtypes", [Object]),
|
|
146
|
+
__metadata("design:returntype", Object)
|
|
147
|
+
], ToolsResolver.prototype, "getWeatherForecast", null);
|
|
148
|
+
__decorate([
|
|
149
|
+
(0, src_1.Tool)({
|
|
150
|
+
name: 'register_user',
|
|
151
|
+
description: 'Registers a new user in the system with validation',
|
|
152
|
+
paramSchema: {
|
|
153
|
+
username: zod_1.z
|
|
154
|
+
.string()
|
|
155
|
+
.min(3)
|
|
156
|
+
.max(20)
|
|
157
|
+
.regex(/^[a-zA-Z0-9_]+$/),
|
|
158
|
+
email: zod_1.z.string().email(),
|
|
159
|
+
age: zod_1.z.number().int().min(18).optional(),
|
|
160
|
+
preferences: zod_1.z
|
|
161
|
+
.object({
|
|
162
|
+
theme: zod_1.z.enum(['light', 'dark', 'system']).default('system'),
|
|
163
|
+
notifications: zod_1.z.boolean().default(true),
|
|
164
|
+
})
|
|
165
|
+
.optional(),
|
|
166
|
+
},
|
|
167
|
+
}),
|
|
168
|
+
__metadata("design:type", Function),
|
|
169
|
+
__metadata("design:paramtypes", [Object]),
|
|
170
|
+
__metadata("design:returntype", Object)
|
|
171
|
+
], ToolsResolver.prototype, "registerUser", null);
|
|
172
|
+
exports.ToolsResolver = ToolsResolver = __decorate([
|
|
173
|
+
(0, src_1.Resolver)('tools')
|
|
174
|
+
], ToolsResolver);
|
|
175
|
+
//# sourceMappingURL=tools.resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.resolver.js","sourceRoot":"","sources":["../../../examples/tools/tools.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,mCAA+C;AAC/C,6BAAwB;AAExB,mCAA2C;AAGpC,IAA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C/D;KACF,CAAC;;;;uDAmDD;AAyBD;IAnBC,IAAA,UAAI,EAAC;QACJ,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE,oDAAoD;QACjE,WAAW,EAAE;YACX,QAAQ,EAAE,OAAC;iBACR,MAAM,EAAE;iBACR,GAAG,CAAC,CAAC,CAAC;iBACN,GAAG,CAAC,EAAE,CAAC;iBACP,KAAK,CAAC,iBAAiB,CAAC;YAC3B,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE;YACzB,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;YACxC,WAAW,EAAE,OAAC;iBACX,MAAM,CAAC;gBACN,KAAK,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;gBAC5D,aAAa,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;aACzC,CAAC;iBACD,QAAQ,EAAE;SACd;KACF,CAAC;;;;iDAmCD;wBApMU,aAAa;IADzB,IAAA,cAAQ,EAAC,OAAO,CAAC;GACL,aAAa,CAqMzB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
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("./sse.controller"), exports);
|
|
18
|
+
__exportStar(require("./sse.service"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/controllers/sse/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,gDAA8B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Request, Response } from 'express';
|
|
2
|
+
import { SseService } from './sse.service';
|
|
3
|
+
export declare class SseController {
|
|
4
|
+
private readonly service;
|
|
5
|
+
constructor(service: SseService);
|
|
6
|
+
handleSse(req: Request, res: Response): Promise<void>;
|
|
7
|
+
handleMessages(req: Request, res: Response): Promise<void>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.SseController = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const sse_service_1 = require("./sse.service");
|
|
18
|
+
let SseController = class SseController {
|
|
19
|
+
service;
|
|
20
|
+
constructor(service) {
|
|
21
|
+
this.service = service;
|
|
22
|
+
}
|
|
23
|
+
async handleSse(req, res) {
|
|
24
|
+
await this.service.handleSse(req, res);
|
|
25
|
+
}
|
|
26
|
+
async handleMessages(req, res) {
|
|
27
|
+
await this.service.handleMessage(req, res);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
exports.SseController = SseController;
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, common_1.Get)('sse'),
|
|
33
|
+
__param(0, (0, common_1.Req)()),
|
|
34
|
+
__param(1, (0, common_1.Res)()),
|
|
35
|
+
__metadata("design:type", Function),
|
|
36
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
37
|
+
__metadata("design:returntype", Promise)
|
|
38
|
+
], SseController.prototype, "handleSse", null);
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, common_1.Post)('messages'),
|
|
41
|
+
__param(0, (0, common_1.Req)()),
|
|
42
|
+
__param(1, (0, common_1.Res)()),
|
|
43
|
+
__metadata("design:type", Function),
|
|
44
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
45
|
+
__metadata("design:returntype", Promise)
|
|
46
|
+
], SseController.prototype, "handleMessages", null);
|
|
47
|
+
exports.SseController = SseController = __decorate([
|
|
48
|
+
(0, common_1.Controller)(),
|
|
49
|
+
__metadata("design:paramtypes", [sse_service_1.SseService])
|
|
50
|
+
], SseController);
|
|
51
|
+
//# sourceMappingURL=sse.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sse.controller.js","sourceRoot":"","sources":["../../../../src/controllers/sse/sse.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAiE;AAGjE,+CAA2C;AAGpC,IAAM,aAAa,GAAnB,MAAM,aAAa;IACK;IAA7B,YAA6B,OAAmB;QAAnB,YAAO,GAAP,OAAO,CAAY;IAAG,CAAC;IAG9C,AAAN,KAAK,CAAC,SAAS,CAAQ,GAAY,EAAS,GAAa;QACvD,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACzC,CAAC;IAGK,AAAN,KAAK,CAAC,cAAc,CAAQ,GAAY,EAAS,GAAa;QAC5D,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC7C,CAAC;CACF,CAAA;AAZY,sCAAa;AAIlB;IADL,IAAA,YAAG,EAAC,KAAK,CAAC;IACM,WAAA,IAAA,YAAG,GAAE,CAAA;IAAgB,WAAA,IAAA,YAAG,GAAE,CAAA;;;;8CAE1C;AAGK;IADL,IAAA,aAAI,EAAC,UAAU,CAAC;IACK,WAAA,IAAA,YAAG,GAAE,CAAA;IAAgB,WAAA,IAAA,YAAG,GAAE,CAAA;;;;mDAE/C;wBAXU,aAAa;IADzB,IAAA,mBAAU,GAAE;qCAE2B,wBAAU;GADrC,aAAa,CAYzB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { OnModuleInit } from '@nestjs/common';
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
import { McpServerOptions } from '../../interfaces/mcp-server-options.interface';
|
|
4
|
+
import { McpLoggerService } from '../../registry/logger.service';
|
|
5
|
+
import { RegistryService } from '../../registry/registry.service';
|
|
6
|
+
export declare class SseService implements OnModuleInit {
|
|
7
|
+
private readonly options;
|
|
8
|
+
private readonly registry;
|
|
9
|
+
private readonly logger;
|
|
10
|
+
private server;
|
|
11
|
+
private transports;
|
|
12
|
+
constructor(options: McpServerOptions, registry: RegistryService, logger: McpLoggerService);
|
|
13
|
+
onModuleInit(): Promise<void>;
|
|
14
|
+
handleSse(req: Request, res: Response): Promise<void>;
|
|
15
|
+
handleMessage(req: Request, res: Response): Promise<void>;
|
|
16
|
+
}
|
|
@@ -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
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.SseService = void 0;
|
|
16
|
+
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
17
|
+
const sse_js_1 = require("@modelcontextprotocol/sdk/server/sse.js");
|
|
18
|
+
const common_1 = require("@nestjs/common");
|
|
19
|
+
const logger_service_1 = require("../../registry/logger.service");
|
|
20
|
+
const registry_service_1 = require("../../registry/registry.service");
|
|
21
|
+
let SseService = class SseService {
|
|
22
|
+
options;
|
|
23
|
+
registry;
|
|
24
|
+
logger;
|
|
25
|
+
server;
|
|
26
|
+
transports = {};
|
|
27
|
+
constructor(options, registry, logger) {
|
|
28
|
+
this.options = options;
|
|
29
|
+
this.registry = registry;
|
|
30
|
+
this.logger = logger;
|
|
31
|
+
this.server = new mcp_js_1.McpServer(this.options.serverInfo, this.options.options);
|
|
32
|
+
}
|
|
33
|
+
async onModuleInit() {
|
|
34
|
+
this.logger.log('Starting MCP controller registration', 'MCP_SERVER');
|
|
35
|
+
await this.registry.registerAll(this.server);
|
|
36
|
+
this.logger.log('MCP initialization completed', 'MCP_SERVER');
|
|
37
|
+
}
|
|
38
|
+
async handleSse(req, res) {
|
|
39
|
+
const transport = new sse_js_1.SSEServerTransport('/messages', res);
|
|
40
|
+
this.transports[transport.sessionId] = transport;
|
|
41
|
+
this.logger.debug(`Starting SSE for sessionId: ${transport.sessionId}`, 'api');
|
|
42
|
+
res.on('close', () => {
|
|
43
|
+
delete this.transports[transport.sessionId];
|
|
44
|
+
});
|
|
45
|
+
await this.server.connect(transport);
|
|
46
|
+
}
|
|
47
|
+
async handleMessage(req, res) {
|
|
48
|
+
const sessionId = req.query.sessionId;
|
|
49
|
+
const transport = this.transports[sessionId];
|
|
50
|
+
this.logger.debug(`Receiving SSE message for sessionId: ${sessionId}`, 'api');
|
|
51
|
+
this.logger.debug(`SSE message: ${JSON.stringify(req.body)}`, 'MCP_SERVER');
|
|
52
|
+
try {
|
|
53
|
+
if (transport) {
|
|
54
|
+
await transport.handlePostMessage(req, res, req.body);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
res.status(400).send('No transport found for sessionId');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
62
|
+
this.logger.error('Error al manejar mensaje SSE', errorMessage, 'MCP_SERVER');
|
|
63
|
+
res.status(500).send({
|
|
64
|
+
statusCode: 500,
|
|
65
|
+
error: 'Internal Server Error',
|
|
66
|
+
message: errorMessage,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
exports.SseService = SseService;
|
|
72
|
+
exports.SseService = SseService = __decorate([
|
|
73
|
+
(0, common_1.Injectable)(),
|
|
74
|
+
__param(0, (0, common_1.Inject)('MCP_SERVER_OPTIONS')),
|
|
75
|
+
__metadata("design:paramtypes", [Object, registry_service_1.RegistryService,
|
|
76
|
+
logger_service_1.McpLoggerService])
|
|
77
|
+
], SseService);
|
|
78
|
+
//# sourceMappingURL=sse.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sse.service.js","sourceRoot":"","sources":["../../../../src/controllers/sse/sse.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oEAAoE;AACpE,oEAA6E;AAC7E,2CAAkE;AAIlE,kEAAiE;AACjE,sEAAkE;AAG3D,IAAM,UAAU,GAAhB,MAAM,UAAU;IAOF;IACA;IACA;IARX,MAAM,CAAY;IAElB,UAAU,GAAG,EAAwC,CAAC;IAE9D,YAEmB,OAAyB,EACzB,QAAyB,EACzB,MAAwB;QAFxB,YAAO,GAAP,OAAO,CAAkB;QACzB,aAAQ,GAAR,QAAQ,CAAiB;QACzB,WAAM,GAAN,MAAM,CAAkB;QAEzC,IAAI,CAAC,MAAM,GAAG,IAAI,kBAAS,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7E,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,sCAAsC,EAAE,YAAY,CAAC,CAAC;QACtE,MAAM,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,8BAA8B,EAAE,YAAY,CAAC,CAAC;IAChE,CAAC;IAOD,KAAK,CAAC,SAAS,CAAC,GAAY,EAAE,GAAa;QAEzC,MAAM,SAAS,GAAG,IAAI,2BAAkB,CAAC,WAAW,EAAE,GAAG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CAAC,KAAK,CACf,8BAA8B,EAC9B,YAAY,EACZ,YAAY,CACb,CAAC;YAEF,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBACnB,UAAU,EAAE,GAAG;gBACf,KAAK,EAAE,uBAAuB;gBAC9B,OAAO,EAAE,YAAY;aACtB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF,CAAA;AA/EY,gCAAU;qBAAV,UAAU;IADtB,IAAA,mBAAU,GAAE;IAOR,WAAA,IAAA,eAAM,EAAC,oBAAoB,CAAC,CAAA;6CAEF,kCAAe;QACjB,iCAAgB;GAThC,UAAU,CA+EtB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
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("./streamable.controller"), exports);
|
|
18
|
+
__exportStar(require("./streamable.service"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/controllers/streamable/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,uDAAqC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Request, Response } from 'express';
|
|
2
|
+
import { StreamableService } from './streamable.service';
|
|
3
|
+
export declare class StreamableController {
|
|
4
|
+
private readonly service;
|
|
5
|
+
constructor(service: StreamableService);
|
|
6
|
+
handleMcpPost(req: Request, res: Response): Promise<void>;
|
|
7
|
+
handleMcpGet(req: Request, res: Response): Promise<void>;
|
|
8
|
+
handleMcpDelete(req: Request, res: Response): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.StreamableController = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const streamable_service_1 = require("./streamable.service");
|
|
18
|
+
let StreamableController = class StreamableController {
|
|
19
|
+
service;
|
|
20
|
+
constructor(service) {
|
|
21
|
+
this.service = service;
|
|
22
|
+
}
|
|
23
|
+
async handleMcpPost(req, res) {
|
|
24
|
+
await this.service.handlePostRequest(req, res);
|
|
25
|
+
}
|
|
26
|
+
async handleMcpGet(req, res) {
|
|
27
|
+
await this.service.handleGetRequest(req, res);
|
|
28
|
+
}
|
|
29
|
+
async handleMcpDelete(req, res) {
|
|
30
|
+
await this.service.handleDeleteRequest(req, res);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
exports.StreamableController = StreamableController;
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, common_1.Post)('mcp'),
|
|
36
|
+
__param(0, (0, common_1.Req)()),
|
|
37
|
+
__param(1, (0, common_1.Res)()),
|
|
38
|
+
__metadata("design:type", Function),
|
|
39
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
40
|
+
__metadata("design:returntype", Promise)
|
|
41
|
+
], StreamableController.prototype, "handleMcpPost", null);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, common_1.Get)('mcp'),
|
|
44
|
+
__param(0, (0, common_1.Req)()),
|
|
45
|
+
__param(1, (0, common_1.Res)()),
|
|
46
|
+
__metadata("design:type", Function),
|
|
47
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
48
|
+
__metadata("design:returntype", Promise)
|
|
49
|
+
], StreamableController.prototype, "handleMcpGet", null);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, common_1.Delete)('mcp'),
|
|
52
|
+
__param(0, (0, common_1.Req)()),
|
|
53
|
+
__param(1, (0, common_1.Res)()),
|
|
54
|
+
__metadata("design:type", Function),
|
|
55
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
56
|
+
__metadata("design:returntype", Promise)
|
|
57
|
+
], StreamableController.prototype, "handleMcpDelete", null);
|
|
58
|
+
exports.StreamableController = StreamableController = __decorate([
|
|
59
|
+
(0, common_1.Controller)(),
|
|
60
|
+
__metadata("design:paramtypes", [streamable_service_1.StreamableService])
|
|
61
|
+
], StreamableController);
|
|
62
|
+
//# sourceMappingURL=streamable.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streamable.controller.js","sourceRoot":"","sources":["../../../../src/controllers/streamable/streamable.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAyE;AAGzE,6DAAyD;AAGlD,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IACF;IAA7B,YAA6B,OAA0B;QAA1B,YAAO,GAAP,OAAO,CAAmB;IAAG,CAAC;IAGrD,AAAN,KAAK,CAAC,aAAa,CAAQ,GAAY,EAAS,GAAa;QAC3D,MAAM,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACjD,CAAC;IAGK,AAAN,KAAK,CAAC,YAAY,CAAQ,GAAY,EAAS,GAAa;QAC1D,MAAM,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAChD,CAAC;IAGK,AAAN,KAAK,CAAC,eAAe,CAAQ,GAAY,EAAS,GAAa;QAC7D,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACnD,CAAC;CACF,CAAA;AAjBY,oDAAoB;AAIzB;IADL,IAAA,aAAI,EAAC,KAAK,CAAC;IACS,WAAA,IAAA,YAAG,GAAE,CAAA;IAAgB,WAAA,IAAA,YAAG,GAAE,CAAA;;;;yDAE9C;AAGK;IADL,IAAA,YAAG,EAAC,KAAK,CAAC;IACS,WAAA,IAAA,YAAG,GAAE,CAAA;IAAgB,WAAA,IAAA,YAAG,GAAE,CAAA;;;;wDAE7C;AAGK;IADL,IAAA,eAAM,EAAC,KAAK,CAAC;IACS,WAAA,IAAA,YAAG,GAAE,CAAA;IAAgB,WAAA,IAAA,YAAG,GAAE,CAAA;;;;2DAEhD;+BAhBU,oBAAoB;IADhC,IAAA,mBAAU,GAAE;qCAE2B,sCAAiB;GAD5C,oBAAoB,CAiBhC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { OnModuleInit } from '@nestjs/common';
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
import { McpModuleTransportOptions, McpServerOptions } from '../../interfaces/mcp-server-options.interface';
|
|
4
|
+
import { McpLoggerService } from '../../registry/logger.service';
|
|
5
|
+
import { RegistryService } from '../../registry/registry.service';
|
|
6
|
+
export declare class StreamableService implements OnModuleInit {
|
|
7
|
+
private readonly options;
|
|
8
|
+
private readonly transportOptions;
|
|
9
|
+
private readonly registry;
|
|
10
|
+
private readonly logger;
|
|
11
|
+
private server;
|
|
12
|
+
private transports;
|
|
13
|
+
constructor(options: McpServerOptions, transportOptions: McpModuleTransportOptions, registry: RegistryService, logger: McpLoggerService);
|
|
14
|
+
onModuleInit(): Promise<void>;
|
|
15
|
+
handlePostRequest(req: Request<any, any, any, {
|
|
16
|
+
sessionId?: string;
|
|
17
|
+
}>, res: Response): Promise<void>;
|
|
18
|
+
handleGetRequest(req: Request<any, any, any, {
|
|
19
|
+
sessionId?: string;
|
|
20
|
+
}>, res: Response): Promise<void>;
|
|
21
|
+
handleDeleteRequest(req: Request<any, any, any, {
|
|
22
|
+
sessionId?: string;
|
|
23
|
+
}>, res: Response): Promise<void>;
|
|
24
|
+
}
|