easy-mcp-nest 0.2.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/README.md +342 -8
  2. package/dist/EasyMCP.js +0 -3
  3. package/dist/EasyMCP.js.map +1 -1
  4. package/dist/adapters/express/express-adapter.d.ts +3 -0
  5. package/dist/adapters/express/express-adapter.js +135 -0
  6. package/dist/adapters/express/express-adapter.js.map +1 -0
  7. package/dist/adapters/express/http-gateway.service.d.ts +13 -0
  8. package/dist/adapters/express/http-gateway.service.js +102 -0
  9. package/dist/adapters/express/http-gateway.service.js.map +1 -0
  10. package/dist/adapters/express/index.d.ts +3 -0
  11. package/dist/adapters/express/index.js +8 -0
  12. package/dist/adapters/express/index.js.map +1 -0
  13. package/dist/adapters/express/types.d.ts +15 -0
  14. package/dist/adapters/express/types.js +3 -0
  15. package/dist/adapters/express/types.js.map +1 -0
  16. package/dist/app.module.js +2 -0
  17. package/dist/app.module.js.map +1 -1
  18. package/dist/auth/oauth/index.d.ts +3 -0
  19. package/dist/auth/oauth/index.js +8 -0
  20. package/dist/auth/oauth/index.js.map +1 -0
  21. package/dist/auth/oauth/oauth-config.interface.d.ts +12 -0
  22. package/dist/auth/oauth/oauth-config.interface.js +3 -0
  23. package/dist/auth/oauth/oauth-config.interface.js.map +1 -0
  24. package/dist/auth/oauth/oauth-middleware.d.ts +3 -0
  25. package/dist/auth/oauth/oauth-middleware.js +54 -0
  26. package/dist/auth/oauth/oauth-middleware.js.map +1 -0
  27. package/dist/auth/oauth/oauth-provider.service.d.ts +8 -0
  28. package/dist/auth/oauth/oauth-provider.service.js +63 -0
  29. package/dist/auth/oauth/oauth-provider.service.js.map +1 -0
  30. package/dist/config/mcp-config.interface.d.ts +1 -1
  31. package/dist/core/batch/batch-executor.service.d.ts +21 -0
  32. package/dist/core/batch/batch-executor.service.js +101 -0
  33. package/dist/core/batch/batch-executor.service.js.map +1 -0
  34. package/dist/core/context/context-provider.service.d.ts +8 -0
  35. package/dist/core/context/context-provider.service.js +55 -0
  36. package/dist/core/context/context-provider.service.js.map +1 -0
  37. package/dist/core/context/mcp-context.interface.d.ts +12 -0
  38. package/dist/core/context/mcp-context.interface.js +3 -0
  39. package/dist/core/context/mcp-context.interface.js.map +1 -0
  40. package/dist/core/documentation/openapi-generator.service.d.ts +13 -0
  41. package/dist/core/documentation/openapi-generator.service.js +116 -0
  42. package/dist/core/documentation/openapi-generator.service.js.map +1 -0
  43. package/dist/core/errors/error-handler.interface.d.ts +11 -0
  44. package/dist/core/errors/error-handler.interface.js +3 -0
  45. package/dist/core/errors/error-handler.interface.js.map +1 -0
  46. package/dist/core/health/health-check.service.d.ts +33 -0
  47. package/dist/core/health/health-check.service.js +71 -0
  48. package/dist/core/health/health-check.service.js.map +1 -0
  49. package/dist/core/mcp-server/mcp-server.service.d.ts +16 -1
  50. package/dist/core/mcp-server/mcp-server.service.js +201 -3
  51. package/dist/core/mcp-server/mcp-server.service.js.map +1 -1
  52. package/dist/core/middleware/middleware-executor.service.d.ts +8 -0
  53. package/dist/core/middleware/middleware-executor.service.js +46 -0
  54. package/dist/core/middleware/middleware-executor.service.js.map +1 -0
  55. package/dist/core/middleware/middleware.interface.d.ts +6 -0
  56. package/dist/core/middleware/middleware.interface.js +3 -0
  57. package/dist/core/middleware/middleware.interface.js.map +1 -0
  58. package/dist/core/observability/metrics.service.d.ts +29 -0
  59. package/dist/core/observability/metrics.service.js +124 -0
  60. package/dist/core/observability/metrics.service.js.map +1 -0
  61. package/dist/core/observability/tracing.service.d.ts +12 -0
  62. package/dist/core/observability/tracing.service.js +88 -0
  63. package/dist/core/observability/tracing.service.js.map +1 -0
  64. package/dist/core/progress/progress-notifier.service.d.ts +16 -0
  65. package/dist/core/progress/progress-notifier.service.js +96 -0
  66. package/dist/core/progress/progress-notifier.service.js.map +1 -0
  67. package/dist/core/rate-limiting/rate-limit.interface.d.ts +11 -0
  68. package/dist/core/rate-limiting/rate-limit.interface.js +3 -0
  69. package/dist/core/rate-limiting/rate-limit.interface.js.map +1 -0
  70. package/dist/core/rate-limiting/rate-limiter.service.d.ts +13 -0
  71. package/dist/core/rate-limiting/rate-limiter.service.js +147 -0
  72. package/dist/core/rate-limiting/rate-limiter.service.js.map +1 -0
  73. package/dist/core/resilience/circuit-breaker.interface.d.ts +15 -0
  74. package/dist/core/resilience/circuit-breaker.interface.js +3 -0
  75. package/dist/core/resilience/circuit-breaker.interface.js.map +1 -0
  76. package/dist/core/resilience/circuit-breaker.service.d.ts +11 -0
  77. package/dist/core/resilience/circuit-breaker.service.js +117 -0
  78. package/dist/core/resilience/circuit-breaker.service.js.map +1 -0
  79. package/dist/core/resilience/retry.service.d.ts +6 -0
  80. package/dist/core/resilience/retry.service.js +66 -0
  81. package/dist/core/resilience/retry.service.js.map +1 -0
  82. package/dist/core/utils/decorator-scanner.d.ts +4 -0
  83. package/dist/core/utils/decorator-scanner.js +112 -0
  84. package/dist/core/utils/decorator-scanner.js.map +1 -0
  85. package/dist/core/utils/sanitize.util.d.ts +2 -0
  86. package/dist/core/utils/sanitize.util.js +48 -0
  87. package/dist/core/utils/sanitize.util.js.map +1 -1
  88. package/dist/decorators/factory-provider.d.ts +2 -0
  89. package/dist/decorators/factory-provider.js +20 -0
  90. package/dist/decorators/factory-provider.js.map +1 -0
  91. package/dist/decorators/index.d.ts +7 -0
  92. package/dist/decorators/index.js +28 -0
  93. package/dist/decorators/index.js.map +1 -0
  94. package/dist/decorators/mcp-context.decorator.d.ts +3 -0
  95. package/dist/decorators/mcp-context.decorator.js +20 -0
  96. package/dist/decorators/mcp-context.decorator.js.map +1 -0
  97. package/dist/decorators/mcp-error-handler.decorator.d.ts +4 -0
  98. package/dist/decorators/mcp-error-handler.decorator.js +15 -0
  99. package/dist/decorators/mcp-error-handler.decorator.js.map +1 -0
  100. package/dist/decorators/mcp-middleware.decorator.d.ts +4 -0
  101. package/dist/decorators/mcp-middleware.decorator.js +17 -0
  102. package/dist/decorators/mcp-middleware.decorator.js.map +1 -0
  103. package/dist/decorators/mcp-param.decorator.d.ts +10 -0
  104. package/dist/decorators/mcp-param.decorator.js +41 -0
  105. package/dist/decorators/mcp-param.decorator.js.map +1 -0
  106. package/dist/decorators/mcp-service.decorator.d.ts +6 -0
  107. package/dist/decorators/mcp-service.decorator.js +27 -0
  108. package/dist/decorators/mcp-service.decorator.js.map +1 -0
  109. package/dist/decorators/mcp-tool.decorator.d.ts +28 -0
  110. package/dist/decorators/mcp-tool.decorator.js +36 -0
  111. package/dist/decorators/mcp-tool.decorator.js.map +1 -0
  112. package/dist/index.d.ts +12 -1
  113. package/dist/index.js +30 -1
  114. package/dist/index.js.map +1 -1
  115. package/dist/interface/interface.interface.d.ts +2 -0
  116. package/dist/interface/jsonrpc.interface.d.ts +8 -0
  117. package/dist/interface/jsonrpc.interface.js.map +1 -1
  118. package/dist/interface/mcp-protocol.interface.d.ts +14 -0
  119. package/dist/interface/mcp-protocol.interface.js.map +1 -1
  120. package/dist/standalone/core-services.d.ts +29 -0
  121. package/dist/standalone/core-services.js +94 -0
  122. package/dist/standalone/core-services.js.map +1 -0
  123. package/dist/standalone/index.d.ts +3 -0
  124. package/dist/standalone/index.js +11 -0
  125. package/dist/standalone/index.js.map +1 -0
  126. package/dist/standalone/standalone-server.d.ts +23 -0
  127. package/dist/standalone/standalone-server.js +366 -0
  128. package/dist/standalone/standalone-server.js.map +1 -0
  129. package/dist/standalone/types.d.ts +14 -0
  130. package/dist/standalone/types.js +3 -0
  131. package/dist/standalone/types.js.map +1 -0
  132. package/dist/testing/index.d.ts +3 -0
  133. package/dist/testing/index.js +14 -0
  134. package/dist/testing/index.js.map +1 -0
  135. package/dist/testing/mock-context.d.ts +2 -0
  136. package/dist/testing/mock-context.js +17 -0
  137. package/dist/testing/mock-context.js.map +1 -0
  138. package/dist/testing/test-app.factory.d.ts +15 -0
  139. package/dist/testing/test-app.factory.js +37 -0
  140. package/dist/testing/test-app.factory.js.map +1 -0
  141. package/dist/testing/test-helpers.d.ts +10 -0
  142. package/dist/testing/test-helpers.js +46 -0
  143. package/dist/testing/test-helpers.js.map +1 -0
  144. package/dist/tooling/tool-registry/tool-registry.service.d.ts +7 -1
  145. package/dist/tooling/tool-registry/tool-registry.service.js +40 -3
  146. package/dist/tooling/tool-registry/tool-registry.service.js.map +1 -1
  147. package/dist/tooling/tool.interface.d.ts +9 -2
  148. package/dist/tsconfig.build.tsbuildinfo +1 -1
  149. package/dist/validation/index.d.ts +1 -0
  150. package/dist/validation/index.js +8 -0
  151. package/dist/validation/index.js.map +1 -0
  152. package/dist/validation/zod-integration.d.ts +11 -0
  153. package/dist/validation/zod-integration.js +148 -0
  154. package/dist/validation/zod-integration.js.map +1 -0
  155. package/package.json +4 -2
@@ -0,0 +1,23 @@
1
+ import { CreateMcpServerOptions } from "./types";
2
+ import { JsonRpcRequest, JsonRpcResponse } from "../interface/jsonrpc.interface";
3
+ export declare class StandaloneMcpServer {
4
+ private toolRegistry;
5
+ private resourceRegistry;
6
+ private promptRegistry;
7
+ private serverInfo;
8
+ private transport;
9
+ private auth?;
10
+ private httpServer?;
11
+ private port?;
12
+ private host?;
13
+ constructor(options: CreateMcpServerOptions);
14
+ start(): Promise<void>;
15
+ private startStdio;
16
+ private startHttp;
17
+ handleRequest(request: JsonRpcRequest): Promise<JsonRpcResponse>;
18
+ private handleInitialize;
19
+ private handleListTools;
20
+ private handleCallTool;
21
+ stop(): Promise<void>;
22
+ }
23
+ export declare function createMcpServer(options: CreateMcpServerOptions): StandaloneMcpServer;
@@ -0,0 +1,366 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.StandaloneMcpServer = void 0;
37
+ exports.createMcpServer = createMcpServer;
38
+ const core_services_1 = require("./core-services");
39
+ const jsonrpc_interface_1 = require("../interface/jsonrpc.interface");
40
+ const mcp_protocol_interface_1 = require("../interface/mcp-protocol.interface");
41
+ const logger_util_1 = require("../core/utils/logger.util");
42
+ const sanitize_util_1 = require("../core/utils/sanitize.util");
43
+ const easy_mcp_error_1 = require("../core/errors/easy-mcp-error");
44
+ const readline = __importStar(require("readline"));
45
+ const http = __importStar(require("http"));
46
+ class StandaloneMcpServer {
47
+ toolRegistry;
48
+ resourceRegistry;
49
+ promptRegistry;
50
+ serverInfo;
51
+ transport;
52
+ auth;
53
+ httpServer;
54
+ port;
55
+ host;
56
+ constructor(options) {
57
+ this.toolRegistry = new core_services_1.StandaloneToolRegistry();
58
+ this.resourceRegistry = new core_services_1.StandaloneResourceRegistry();
59
+ this.promptRegistry = new core_services_1.StandalonePromptRegistry();
60
+ this.transport = options.transport || "stdio";
61
+ this.auth = options.auth;
62
+ this.port = options.port;
63
+ this.host = options.host;
64
+ this.serverInfo = options.serverInfo || {
65
+ name: "easy-mcp-standalone",
66
+ version: "0.2.1",
67
+ };
68
+ for (const tool of options.tools) {
69
+ this.toolRegistry.registerTool(tool);
70
+ }
71
+ if (options.resources) {
72
+ for (const resource of options.resources) {
73
+ this.resourceRegistry.registerResource(resource);
74
+ }
75
+ }
76
+ if (options.prompts) {
77
+ for (const prompt of options.prompts) {
78
+ this.promptRegistry.registerPrompt(prompt);
79
+ }
80
+ }
81
+ }
82
+ async start() {
83
+ if (this.transport === "stdio") {
84
+ await this.startStdio();
85
+ }
86
+ else if (this.transport === "http") {
87
+ await this.startHttp();
88
+ }
89
+ else {
90
+ throw new Error(`Unsupported transport: ${this.transport}`);
91
+ }
92
+ }
93
+ async startStdio() {
94
+ logger_util_1.logger.info("StandaloneMcpServer", "Starting stdio transport", {
95
+ component: "Standalone",
96
+ });
97
+ const rl = readline.createInterface({
98
+ input: process.stdin,
99
+ output: process.stdout,
100
+ terminal: false,
101
+ });
102
+ rl.on("line", async (line) => {
103
+ let requestId = null;
104
+ try {
105
+ const request = JSON.parse(line);
106
+ requestId = request?.id ?? null;
107
+ if ((0, jsonrpc_interface_1.isValidJsonRpcRequest)(request)) {
108
+ const response = await this.handleRequest(request);
109
+ process.stdout.write(JSON.stringify(response) + "\n");
110
+ }
111
+ else {
112
+ const errorResponse = (0, jsonrpc_interface_1.createJsonRpcError)(requestId, jsonrpc_interface_1.JsonRpcErrorCode.InvalidRequest, "Invalid JSON-RPC request structure");
113
+ process.stdout.write(JSON.stringify(errorResponse) + "\n");
114
+ }
115
+ }
116
+ catch (error) {
117
+ const errorResponse = (0, jsonrpc_interface_1.createJsonRpcError)(requestId, jsonrpc_interface_1.JsonRpcErrorCode.ParseError, "Invalid JSON");
118
+ process.stdout.write(JSON.stringify(errorResponse) + "\n");
119
+ logger_util_1.logger.error("StandaloneMcpServer", "Error processing stdio request", {
120
+ component: "Standalone",
121
+ error: (0, sanitize_util_1.sanitizeErrorMessage)(error),
122
+ });
123
+ }
124
+ });
125
+ }
126
+ async startHttp() {
127
+ const isExposed = !this.host || this.host === "0.0.0.0" || this.host !== "localhost" && this.host !== "127.0.0.1";
128
+ if (isExposed && !this.auth) {
129
+ logger_util_1.logger.warn("StandaloneMcpServer", "HTTP server is exposed without authentication", {
130
+ component: "Standalone",
131
+ host: this.host || "0.0.0.0",
132
+ port: this.port,
133
+ warning: "Unauthenticated tool execution is enabled. This is a security risk in production.",
134
+ recommendation: "Configure 'auth' option or bind to localhost only.",
135
+ });
136
+ }
137
+ logger_util_1.logger.info("StandaloneMcpServer", "Starting HTTP transport", {
138
+ component: "Standalone",
139
+ host: this.host || "0.0.0.0",
140
+ port: this.port,
141
+ hasAuth: !!this.auth,
142
+ });
143
+ this.httpServer = http.createServer(async (req, res) => {
144
+ if (req.method !== "POST") {
145
+ res.writeHead(405, { "Content-Type": "application/json" });
146
+ res.end(JSON.stringify({ error: "Method not allowed" }));
147
+ return;
148
+ }
149
+ const MAX_BODY_SIZE = 10 * 1024 * 1024;
150
+ let body = "";
151
+ let bodySize = 0;
152
+ req.on("data", (chunk) => {
153
+ bodySize += chunk.length;
154
+ if (bodySize > MAX_BODY_SIZE) {
155
+ req.destroy();
156
+ res.writeHead(413, { "Content-Type": "application/json" });
157
+ res.end(JSON.stringify({
158
+ jsonrpc: "2.0",
159
+ id: null,
160
+ error: {
161
+ code: jsonrpc_interface_1.JsonRpcErrorCode.InvalidRequest,
162
+ message: "Request body too large",
163
+ },
164
+ }));
165
+ return;
166
+ }
167
+ body += chunk.toString();
168
+ });
169
+ req.on("error", (error) => {
170
+ logger_util_1.logger.error("StandaloneMcpServer", "Error reading HTTP request", {
171
+ component: "Standalone",
172
+ error: error instanceof Error ? error.message : String(error),
173
+ });
174
+ if (!res.headersSent) {
175
+ res.writeHead(500, { "Content-Type": "application/json" });
176
+ res.end(JSON.stringify({
177
+ jsonrpc: "2.0",
178
+ id: null,
179
+ error: {
180
+ code: jsonrpc_interface_1.JsonRpcErrorCode.InternalError,
181
+ message: "Internal error",
182
+ },
183
+ }));
184
+ }
185
+ });
186
+ req.on("end", async () => {
187
+ if (res.headersSent) {
188
+ return;
189
+ }
190
+ try {
191
+ const request = JSON.parse(body);
192
+ if ((0, jsonrpc_interface_1.isValidJsonRpcRequest)(request)) {
193
+ delete request.metadata;
194
+ let context;
195
+ if (this.auth) {
196
+ const authContext = await this.auth(req);
197
+ context = authContext || undefined;
198
+ }
199
+ if (context) {
200
+ request.metadata = {
201
+ userId: context.userId,
202
+ scopes: context.scopes,
203
+ buildingIds: context.buildingIds,
204
+ sessionId: context.sessionId,
205
+ };
206
+ }
207
+ const response = await this.handleRequest(request);
208
+ res.writeHead(200, { "Content-Type": "application/json" });
209
+ res.end(JSON.stringify(response));
210
+ }
211
+ else {
212
+ res.writeHead(400, { "Content-Type": "application/json" });
213
+ res.end(JSON.stringify({
214
+ jsonrpc: "2.0",
215
+ id: null,
216
+ error: {
217
+ code: jsonrpc_interface_1.JsonRpcErrorCode.InvalidRequest,
218
+ message: "Invalid JSON-RPC request",
219
+ },
220
+ }));
221
+ }
222
+ }
223
+ catch (error) {
224
+ logger_util_1.logger.error("StandaloneMcpServer", "Error processing HTTP request", {
225
+ component: "Standalone",
226
+ error: error instanceof Error ? error.message : String(error),
227
+ });
228
+ res.writeHead(500, { "Content-Type": "application/json" });
229
+ res.end(JSON.stringify({
230
+ jsonrpc: "2.0",
231
+ id: null,
232
+ error: {
233
+ code: jsonrpc_interface_1.JsonRpcErrorCode.InternalError,
234
+ message: "Internal error",
235
+ },
236
+ }));
237
+ }
238
+ });
239
+ });
240
+ const port = this.port || 3000;
241
+ const host = this.host || "localhost";
242
+ this.httpServer.listen(port, host, () => {
243
+ logger_util_1.logger.info("StandaloneMcpServer", `HTTP server listening on ${host}:${port}`, {
244
+ component: "Standalone",
245
+ });
246
+ });
247
+ }
248
+ async handleRequest(request) {
249
+ switch (request.method) {
250
+ case "initialize":
251
+ return this.handleInitialize(request);
252
+ case "tools/list":
253
+ return this.handleListTools(request);
254
+ case "tools/call":
255
+ return this.handleCallTool(request);
256
+ default:
257
+ return (0, jsonrpc_interface_1.createJsonRpcError)(request.id, jsonrpc_interface_1.JsonRpcErrorCode.MethodNotFound, `Method not found: ${request.method}`);
258
+ }
259
+ }
260
+ handleInitialize(request) {
261
+ const params = request.params;
262
+ if (params && params.protocolVersion !== "2025-11-25") {
263
+ return (0, jsonrpc_interface_1.createJsonRpcError)(request.id, jsonrpc_interface_1.JsonRpcErrorCode.InvalidParams, `Unsupported protocol version: ${params.protocolVersion}. Supported version: 2025-11-25`);
264
+ }
265
+ const result = {
266
+ protocolVersion: "2025-11-25",
267
+ capabilities: {
268
+ tools: {},
269
+ },
270
+ serverInfo: this.serverInfo,
271
+ };
272
+ return (0, jsonrpc_interface_1.createJsonRpcSuccess)(request.id, result);
273
+ }
274
+ handleListTools(request) {
275
+ const tools = this.toolRegistry.getToolSchemasForLLM();
276
+ const mcpTools = tools.map((tool) => {
277
+ const toolDef = this.toolRegistry.getTool(tool.function.name);
278
+ return {
279
+ name: tool.function.name,
280
+ description: tool.function.description,
281
+ inputSchema: tool.function.parameters,
282
+ ...(toolDef?.icon && { icon: toolDef.icon }),
283
+ };
284
+ });
285
+ const result = {
286
+ tools: mcpTools,
287
+ };
288
+ return (0, jsonrpc_interface_1.createJsonRpcSuccess)(request.id, result);
289
+ }
290
+ async handleCallTool(request) {
291
+ const params = request.params;
292
+ if (!params || !params.name || typeof params.name !== "string") {
293
+ return (0, jsonrpc_interface_1.createJsonRpcError)(request.id, jsonrpc_interface_1.JsonRpcErrorCode.InvalidParams, "Missing or invalid tool name");
294
+ }
295
+ const args = params.arguments || {};
296
+ const toolName = params.name;
297
+ let context;
298
+ if (request.metadata) {
299
+ context = {
300
+ userId: request.metadata.userId,
301
+ scopes: request.metadata.scopes,
302
+ buildingIds: request.metadata.buildingIds,
303
+ sessionId: request.metadata.sessionId,
304
+ };
305
+ }
306
+ const actorId = (0, sanitize_util_1.sanitizeActorId)(context?.sessionId || context?.userId || undefined);
307
+ try {
308
+ const toolResult = await this.toolRegistry.executeTool(toolName, args, undefined, context);
309
+ const sanitizedResult = (0, sanitize_util_1.sanitizeToolResult)(toolResult);
310
+ const result = {
311
+ content: [
312
+ {
313
+ type: "text",
314
+ text: sanitizedResult,
315
+ },
316
+ ],
317
+ isError: false,
318
+ };
319
+ logger_util_1.logger.audit("StandaloneMcpServer", "tools/call", "success", {
320
+ toolName: (0, sanitize_util_1.sanitizeName)(toolName),
321
+ resultSize: sanitizedResult.length,
322
+ method: request.method,
323
+ }, request.id, actorId);
324
+ return (0, jsonrpc_interface_1.createJsonRpcSuccess)(request.id, result);
325
+ }
326
+ catch (error) {
327
+ if (error instanceof easy_mcp_error_1.ToolNotFoundError) {
328
+ logger_util_1.logger.audit("StandaloneMcpServer", "tools/call", "failure", {
329
+ reason: "ToolNotFoundError",
330
+ toolName: (0, sanitize_util_1.sanitizeName)(toolName),
331
+ method: request.method,
332
+ }, request.id, actorId);
333
+ return (0, jsonrpc_interface_1.createJsonRpcError)(request.id, mcp_protocol_interface_1.McpErrorCode.ToolNotFound, `Tool not found: ${toolName}`);
334
+ }
335
+ const sanitizedError = (0, sanitize_util_1.sanitizeErrorMessage)(error);
336
+ logger_util_1.logger.error("StandaloneMcpServer", "Tool execution failed", {
337
+ component: "Standalone",
338
+ toolName: (0, sanitize_util_1.sanitizeName)(toolName),
339
+ error: sanitizedError,
340
+ });
341
+ logger_util_1.logger.audit("StandaloneMcpServer", "tools/call", "failure", {
342
+ reason: "ToolExecutionError",
343
+ toolName: (0, sanitize_util_1.sanitizeName)(toolName),
344
+ method: request.method,
345
+ }, request.id, actorId);
346
+ return (0, jsonrpc_interface_1.createJsonRpcError)(request.id, mcp_protocol_interface_1.McpErrorCode.ToolExecutionError, "Tool execution failed");
347
+ }
348
+ }
349
+ async stop() {
350
+ if (this.httpServer) {
351
+ return new Promise((resolve) => {
352
+ this.httpServer.close(() => {
353
+ logger_util_1.logger.info("StandaloneMcpServer", "HTTP server stopped", {
354
+ component: "Standalone",
355
+ });
356
+ resolve();
357
+ });
358
+ });
359
+ }
360
+ }
361
+ }
362
+ exports.StandaloneMcpServer = StandaloneMcpServer;
363
+ function createMcpServer(options) {
364
+ return new StandaloneMcpServer(options);
365
+ }
366
+ //# sourceMappingURL=standalone-server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standalone-server.js","sourceRoot":"","sources":["../../src/standalone/standalone-server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgeA,0CAEC;AAjeD,mDAA+G;AAC/G,sEAAoK;AACpK,gFAAiK;AAEjK,2DAAmD;AACnD,+DAAsH;AACtH,kEAAkE;AAClE,mDAAqC;AACrC,2CAA6B;AAK7B,MAAa,mBAAmB;IACtB,YAAY,CAAyB;IACrC,gBAAgB,CAA6B;IAC7C,cAAc,CAA2B;IACzC,UAAU,CAAoC;IAC9C,SAAS,CAAsB;IAC/B,IAAI,CAA6D;IACjE,UAAU,CAAe;IACzB,IAAI,CAAU;IACd,IAAI,CAAU;IAEtB,YAAY,OAA+B;QACzC,IAAI,CAAC,YAAY,GAAG,IAAI,sCAAsB,EAAE,CAAC;QACjD,IAAI,CAAC,gBAAgB,GAAG,IAAI,0CAA0B,EAAE,CAAC;QACzD,IAAI,CAAC,cAAc,GAAG,IAAI,wCAAwB,EAAE,CAAC;QACrD,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC;QAC9C,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QAEzB,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI;YACtC,IAAI,EAAE,qBAAqB;YAC3B,OAAO,EAAE,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AQ,CAAC;gBAChC,KAAK,EAAE,cAAc;aACtB,CAAC,CAAC;YAGH,oBAAM,CAAC,KAAK,CACV,qBAAqB,EACrB,YAAY,EACZ,SAAS,EACT;gBACE,MAAM,EAAE,oBAAoB;gBAC5B,QAAQ,EAAE,IAAA,4BAAY,EAAC,QAAQ,CAAC;gBAChC,MAAM,EAAE,OAAO,CAAC,MAAM;aACvB,EACD,OAAO,CAAC,EAAE,EACV,OAAO,CACR,CAAC;YAEF,OAAO,IAAA,sCAAkB,EACvB,OAAO,CAAC,EAAE,EACV,qCAAY,CAAC,kBAAkB,EAC/B,uBAAuB,CACxB,CAAC;QACJ,CAAC;IACH,CAAC;IAKD,KAAK,CAAC,IAAI;QACR,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;gBAC7B,IAAI,CAAC,UAAW,CAAC,KAAK,CAAC,GAAG,EAAE;oBAC1B,oBAAM,CAAC,IAAI,CAAC,qBAAqB,EAAE,qBAAqB,EAAE;wBACxD,SAAS,EAAE,YAAY;qBACxB,CAAC,CAAC;oBACH,OAAO,EAAE,CAAC;gBACZ,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF;AA/bD,kDA+bC;AAmBD,SAAgB,eAAe,CAAC,OAA+B;IAC7D,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { ToolRegistrationInput, ResourceRegistrationInput, PromptRegistrationInput, ServerInfo } from "../config/mcp-config.interface";
2
+ import { McpContext } from "../core/context/mcp-context.interface";
3
+ export type StandaloneTransport = "stdio" | "http";
4
+ export type StandaloneAuthFunction = (request: any) => Promise<McpContext> | McpContext | null;
5
+ export interface CreateMcpServerOptions {
6
+ tools: ToolRegistrationInput[];
7
+ resources?: ResourceRegistrationInput[];
8
+ prompts?: PromptRegistrationInput[];
9
+ serverInfo?: ServerInfo;
10
+ transport?: StandaloneTransport;
11
+ auth?: StandaloneAuthFunction;
12
+ port?: number;
13
+ host?: string;
14
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/standalone/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export { createMcpTestApp, McpTestApp } from "./test-app.factory";
2
+ export { mockMcpContext } from "./mock-context";
3
+ export { createMockJsonRpcRequest, createMockTool, wait, createMockCancellationToken, } from "./test-helpers";
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createMockCancellationToken = exports.wait = exports.createMockTool = exports.createMockJsonRpcRequest = exports.mockMcpContext = exports.McpTestApp = exports.createMcpTestApp = void 0;
4
+ var test_app_factory_1 = require("./test-app.factory");
5
+ Object.defineProperty(exports, "createMcpTestApp", { enumerable: true, get: function () { return test_app_factory_1.createMcpTestApp; } });
6
+ Object.defineProperty(exports, "McpTestApp", { enumerable: true, get: function () { return test_app_factory_1.McpTestApp; } });
7
+ var mock_context_1 = require("./mock-context");
8
+ Object.defineProperty(exports, "mockMcpContext", { enumerable: true, get: function () { return mock_context_1.mockMcpContext; } });
9
+ var test_helpers_1 = require("./test-helpers");
10
+ Object.defineProperty(exports, "createMockJsonRpcRequest", { enumerable: true, get: function () { return test_helpers_1.createMockJsonRpcRequest; } });
11
+ Object.defineProperty(exports, "createMockTool", { enumerable: true, get: function () { return test_helpers_1.createMockTool; } });
12
+ Object.defineProperty(exports, "wait", { enumerable: true, get: function () { return test_helpers_1.wait; } });
13
+ Object.defineProperty(exports, "createMockCancellationToken", { enumerable: true, get: function () { return test_helpers_1.createMockCancellationToken; } });
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":";;;AAAA,uDAAkE;AAAzD,oHAAA,gBAAgB,OAAA;AAAE,8GAAA,UAAU,OAAA;AACrC,+CAAgD;AAAvC,8GAAA,cAAc,OAAA;AACvB,+CAKwB;AAJtB,wHAAA,wBAAwB,OAAA;AACxB,8GAAA,cAAc,OAAA;AACd,oGAAA,IAAI,OAAA;AACJ,2HAAA,2BAA2B,OAAA"}
@@ -0,0 +1,2 @@
1
+ import { McpContext } from "../core/context/mcp-context.interface";
2
+ export declare function mockMcpContext(overrides?: Partial<McpContext>): McpContext;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mockMcpContext = mockMcpContext;
4
+ function mockMcpContext(overrides) {
5
+ return {
6
+ userId: "test-user-id",
7
+ scopes: ["test-scope"],
8
+ buildingIds: ["test-building-id"],
9
+ sessionId: "test-session-id",
10
+ metadata: {
11
+ ip: "127.0.0.1",
12
+ userAgent: "test-agent",
13
+ },
14
+ ...overrides,
15
+ };
16
+ }
17
+ //# sourceMappingURL=mock-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock-context.js","sourceRoot":"","sources":["../../src/testing/mock-context.ts"],"names":[],"mappings":";;AAcA,wCAYC;AAZD,SAAgB,cAAc,CAAC,SAA+B;IAC5D,OAAO;QACL,MAAM,EAAE,cAAc;QACtB,MAAM,EAAE,CAAC,YAAY,CAAC;QACtB,WAAW,EAAE,CAAC,kBAAkB,CAAC;QACjC,SAAS,EAAE,iBAAiB;QAC5B,QAAQ,EAAE;YACR,EAAE,EAAE,WAAW;YACf,SAAS,EAAE,YAAY;SACxB;QACD,GAAG,SAAS;KACb,CAAC;AACJ,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { INestApplicationContext } from "@nestjs/common";
2
+ import { McpConfig, ToolRegistrationInput } from "../config/mcp-config.interface";
3
+ import { ToolRegistryService } from "../tooling/tool-registry/tool-registry.service";
4
+ import { McpContext } from "../core/context/mcp-context.interface";
5
+ import { CancellationToken } from "../tooling/tool.interface";
6
+ export declare class McpTestApp {
7
+ private app;
8
+ private toolRegistry;
9
+ constructor(app: INestApplicationContext);
10
+ callTool(name: string, params: Record<string, any>, context?: McpContext, cancellationToken?: CancellationToken): Promise<any>;
11
+ getToolRegistry(): ToolRegistryService;
12
+ getService<T>(token: string | symbol): T;
13
+ close(): Promise<void>;
14
+ }
15
+ export declare function createMcpTestApp(tools: ToolRegistrationInput[], config?: Partial<McpConfig>): Promise<McpTestApp>;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.McpTestApp = void 0;
4
+ exports.createMcpTestApp = createMcpTestApp;
5
+ const EasyMCP_1 = require("../EasyMCP");
6
+ const tool_registry_service_1 = require("../tooling/tool-registry/tool-registry.service");
7
+ class McpTestApp {
8
+ app;
9
+ toolRegistry;
10
+ constructor(app) {
11
+ this.app = app;
12
+ this.toolRegistry = app.get(tool_registry_service_1.ToolRegistryService);
13
+ }
14
+ async callTool(name, params, context, cancellationToken) {
15
+ return this.toolRegistry.executeTool(name, params, cancellationToken, context);
16
+ }
17
+ getToolRegistry() {
18
+ return this.toolRegistry;
19
+ }
20
+ getService(token) {
21
+ return this.app.get(token);
22
+ }
23
+ async close() {
24
+ await this.app.close();
25
+ }
26
+ }
27
+ exports.McpTestApp = McpTestApp;
28
+ async function createMcpTestApp(tools, config) {
29
+ const fullConfig = {
30
+ tools,
31
+ ...config,
32
+ };
33
+ await EasyMCP_1.EasyMCP.initialize(fullConfig);
34
+ const app = EasyMCP_1.EasyMCP.app;
35
+ return new McpTestApp(app);
36
+ }
37
+ //# sourceMappingURL=test-app.factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-app.factory.js","sourceRoot":"","sources":["../../src/testing/test-app.factory.ts"],"names":[],"mappings":";;;AA2EA,4CAaC;AArFD,wCAAqC;AAErC,0FAAqF;AAQrF,MAAa,UAAU;IACb,GAAG,CAA0B;IAC7B,YAAY,CAAsB;IAE1C,YAAY,GAA4B;QACtC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,YAAY,GAAG,GAAG,CAAC,GAAG,CAAC,2CAAmB,CAAC,CAAC;IACnD,CAAC;IAWD,KAAK,CAAC,QAAQ,CACZ,IAAY,EACZ,MAA2B,EAC3B,OAAoB,EACpB,iBAAqC;QAErC,OAAO,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,iBAAiB,EAAE,OAAO,CAAC,CAAC;IACjF,CAAC;IAKD,eAAe;QACb,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAKD,UAAU,CAAI,KAAsB;QAClC,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAI,KAAK,CAAC,CAAC;IAChC,CAAC;IAKD,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;CACF;AA/CD,gCA+CC;AAeM,KAAK,UAAU,gBAAgB,CACpC,KAA8B,EAC9B,MAA2B;IAE3B,MAAM,UAAU,GAAc;QAC5B,KAAK;QACL,GAAG,MAAM;KACV,CAAC;IAEF,MAAM,iBAAO,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IACrC,MAAM,GAAG,GAAI,iBAAe,CAAC,GAA8B,CAAC;IAE5D,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { ToolRegistrationInput } from "../config/mcp-config.interface";
2
+ import { JsonRpcRequest } from "../interface/jsonrpc.interface";
3
+ export declare function createMockJsonRpcRequest(method: string, params?: any, id?: string | number): JsonRpcRequest;
4
+ export declare function createMockTool(name: string, description: string, handler: (args: Record<string, any>) => Promise<any>): ToolRegistrationInput;
5
+ export declare function wait(ms: number): Promise<void>;
6
+ export declare function createMockCancellationToken(): {
7
+ isCancelled: boolean;
8
+ onCancel: (callback: () => void) => void;
9
+ cancel: () => void;
10
+ };
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createMockJsonRpcRequest = createMockJsonRpcRequest;
4
+ exports.createMockTool = createMockTool;
5
+ exports.wait = wait;
6
+ exports.createMockCancellationToken = createMockCancellationToken;
7
+ function createMockJsonRpcRequest(method, params, id = 1) {
8
+ return {
9
+ jsonrpc: "2.0",
10
+ id,
11
+ method,
12
+ params,
13
+ };
14
+ }
15
+ function createMockTool(name, description, handler) {
16
+ return {
17
+ name,
18
+ description,
19
+ function: handler,
20
+ inputSchema: {
21
+ type: "object",
22
+ properties: {},
23
+ required: [],
24
+ },
25
+ };
26
+ }
27
+ function wait(ms) {
28
+ return new Promise((resolve) => setTimeout(resolve, ms));
29
+ }
30
+ function createMockCancellationToken() {
31
+ let cancelled = false;
32
+ const callbacks = [];
33
+ return {
34
+ get isCancelled() {
35
+ return cancelled;
36
+ },
37
+ onCancel(callback) {
38
+ callbacks.push(callback);
39
+ },
40
+ cancel() {
41
+ cancelled = true;
42
+ callbacks.forEach((cb) => cb());
43
+ },
44
+ };
45
+ }
46
+ //# sourceMappingURL=test-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-helpers.js","sourceRoot":"","sources":["../../src/testing/test-helpers.ts"],"names":[],"mappings":";;AAOA,4DAWC;AAKD,wCAeC;AAKD,oBAEC;AAKD,kEAoBC;AA/DD,SAAgB,wBAAwB,CACtC,MAAc,EACd,MAAY,EACZ,KAAsB,CAAC;IAEvB,OAAO;QACL,OAAO,EAAE,KAAK;QACd,EAAE;QACF,MAAM;QACN,MAAM;KACP,CAAC;AACJ,CAAC;AAKD,SAAgB,cAAc,CAC5B,IAAY,EACZ,WAAmB,EACnB,OAAoD;IAEpD,OAAO;QACL,IAAI;QACJ,WAAW;QACX,QAAQ,EAAE,OAAO;QACjB,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,EAAE;YACd,QAAQ,EAAE,EAAE;SACb;KACF,CAAC;AACJ,CAAC;AAKD,SAAgB,IAAI,CAAC,EAAU;IAC7B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC;AAKD,SAAgB,2BAA2B;IAKzC,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,MAAM,SAAS,GAAsB,EAAE,CAAC;IAExC,OAAO;QACL,IAAI,WAAW;YACb,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,QAAQ,CAAC,QAAoB;YAC3B,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC3B,CAAC;QACD,MAAM;YACJ,SAAS,GAAG,IAAI,CAAC;YACjB,SAAS,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAClC,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -1,5 +1,8 @@
1
1
  import { ToolDefinition, ToolParameter } from "../tool.interface";
2
2
  import { ToolRegistrationInput } from "../../config/mcp-config.interface";
3
+ import { McpContext } from "../../core/context/mcp-context.interface";
4
+ import { ProgressCallback } from "../../core/progress/progress-notifier.service";
5
+ import { MetricsService } from "../../core/observability/metrics.service";
3
6
  export interface LlmToolSchema {
4
7
  type: "function";
5
8
  function: {
@@ -14,10 +17,13 @@ export interface LlmToolSchema {
14
17
  };
15
18
  }
16
19
  export declare class ToolRegistryService {
20
+ private metricsService?;
17
21
  private readonly registry;
22
+ constructor(metricsService?: MetricsService | undefined);
18
23
  registerTool(definition: ToolDefinition): void;
19
24
  getTool(name: string): ToolDefinition | undefined;
20
- executeTool(name: string, args: Record<string, any>, cancellationToken?: import("../tool.interface").CancellationToken): Promise<any>;
25
+ executeTool(name: string, args: Record<string, any>, cancellationToken?: import("../tool.interface").CancellationToken, context?: McpContext, progress?: ProgressCallback): Promise<any>;
26
+ registerToolsFromDecorators(classes: Array<new (...args: any[]) => any>, instances?: Map<new (...args: any[]) => any, any>): void;
21
27
  registerToolFromConfig(toolInput: ToolRegistrationInput): void;
22
28
  getToolSchemasForLLM(): LlmToolSchema[];
23
29
  private convertToolParameterToJsonSchema;