easy-mcp-nest 0.1.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 (82) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +417 -0
  3. package/dist/EasyMCP.d.ts +8 -0
  4. package/dist/EasyMCP.js +105 -0
  5. package/dist/EasyMCP.js.map +1 -0
  6. package/dist/app.controller.d.ts +6 -0
  7. package/dist/app.controller.js +35 -0
  8. package/dist/app.controller.js.map +1 -0
  9. package/dist/app.module.d.ts +2 -0
  10. package/dist/app.module.js +34 -0
  11. package/dist/app.module.js.map +1 -0
  12. package/dist/app.service.d.ts +3 -0
  13. package/dist/app.service.js +20 -0
  14. package/dist/app.service.js.map +1 -0
  15. package/dist/config/config-holder.service.d.ts +6 -0
  16. package/dist/config/config-holder.service.js +32 -0
  17. package/dist/config/config-holder.service.js.map +1 -0
  18. package/dist/config/config-validator.d.ts +5 -0
  19. package/dist/config/config-validator.js +78 -0
  20. package/dist/config/config-validator.js.map +1 -0
  21. package/dist/config/constants.d.ts +4 -0
  22. package/dist/config/constants.js +8 -0
  23. package/dist/config/constants.js.map +1 -0
  24. package/dist/config/mcp-config.interface.d.ts +18 -0
  25. package/dist/config/mcp-config.interface.js +3 -0
  26. package/dist/config/mcp-config.interface.js.map +1 -0
  27. package/dist/config/version.d.ts +4 -0
  28. package/dist/config/version.js +41 -0
  29. package/dist/config/version.js.map +1 -0
  30. package/dist/core/core.module.d.ts +2 -0
  31. package/dist/core/core.module.js +24 -0
  32. package/dist/core/core.module.js.map +1 -0
  33. package/dist/core/errors/easy-mcp-error.d.ts +14 -0
  34. package/dist/core/errors/easy-mcp-error.js +39 -0
  35. package/dist/core/errors/easy-mcp-error.js.map +1 -0
  36. package/dist/core/mcp-server/mcp-server.service.d.ts +22 -0
  37. package/dist/core/mcp-server/mcp-server.service.js +285 -0
  38. package/dist/core/mcp-server/mcp-server.service.js.map +1 -0
  39. package/dist/core/utils/logger.util.d.ts +26 -0
  40. package/dist/core/utils/logger.util.js +44 -0
  41. package/dist/core/utils/logger.util.js.map +1 -0
  42. package/dist/core/utils/nestjs-stderr-logger.d.ts +9 -0
  43. package/dist/core/utils/nestjs-stderr-logger.js +123 -0
  44. package/dist/core/utils/nestjs-stderr-logger.js.map +1 -0
  45. package/dist/core/utils/sanitize.util.d.ts +6 -0
  46. package/dist/core/utils/sanitize.util.js +111 -0
  47. package/dist/core/utils/sanitize.util.js.map +1 -0
  48. package/dist/core/utils/schema-validator.d.ts +2 -0
  49. package/dist/core/utils/schema-validator.js +62 -0
  50. package/dist/core/utils/schema-validator.js.map +1 -0
  51. package/dist/index.d.ts +11 -0
  52. package/dist/index.js +22 -0
  53. package/dist/index.js.map +1 -0
  54. package/dist/interface/interface.interface.d.ts +4 -0
  55. package/dist/interface/interface.interface.js +3 -0
  56. package/dist/interface/interface.interface.js.map +1 -0
  57. package/dist/interface/interface.module.d.ts +2 -0
  58. package/dist/interface/interface.module.js +29 -0
  59. package/dist/interface/interface.module.js.map +1 -0
  60. package/dist/interface/jsonrpc.interface.d.ts +27 -0
  61. package/dist/interface/jsonrpc.interface.js +42 -0
  62. package/dist/interface/jsonrpc.interface.js.map +1 -0
  63. package/dist/interface/mcp-protocol.interface.d.ts +58 -0
  64. package/dist/interface/mcp-protocol.interface.js +13 -0
  65. package/dist/interface/mcp-protocol.interface.js.map +1 -0
  66. package/dist/interface/mcp.interface.d.ts +44 -0
  67. package/dist/interface/mcp.interface.js +3 -0
  68. package/dist/interface/mcp.interface.js.map +1 -0
  69. package/dist/interface/stdio-gateway.service.d.ts +20 -0
  70. package/dist/interface/stdio-gateway.service.js +373 -0
  71. package/dist/interface/stdio-gateway.service.js.map +1 -0
  72. package/dist/main.d.ts +1 -0
  73. package/dist/main.js +17 -0
  74. package/dist/main.js.map +1 -0
  75. package/dist/tooling/tool-registry/tool-registry.service.d.ts +23 -0
  76. package/dist/tooling/tool-registry/tool-registry.service.js +122 -0
  77. package/dist/tooling/tool-registry/tool-registry.service.js.map +1 -0
  78. package/dist/tooling/tool.interface.d.ts +13 -0
  79. package/dist/tooling/tool.interface.js +3 -0
  80. package/dist/tooling/tool.interface.js.map +1 -0
  81. package/dist/tsconfig.build.tsbuildinfo +1 -0
  82. package/package.json +104 -0
@@ -0,0 +1,6 @@
1
+ import { McpConfig } from "./mcp-config.interface";
2
+ export declare class ConfigHolderService {
3
+ private config;
4
+ setConfig(config: McpConfig): void;
5
+ getConfig(): McpConfig;
6
+ }
@@ -0,0 +1,32 @@
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.ConfigHolderService = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ const logger_util_1 = require("../core/utils/logger.util");
12
+ let ConfigHolderService = class ConfigHolderService {
13
+ config;
14
+ setConfig(config) {
15
+ this.config = config;
16
+ logger_util_1.logger.info("ConfigHolderService", "Configuration successfully loaded into ConfigHolderService", {
17
+ component: "Config",
18
+ toolCount: config.tools?.length || 0,
19
+ });
20
+ }
21
+ getConfig() {
22
+ if (!this.config) {
23
+ throw new Error("EasyMCP Configuration not set. Call EasyMCP.initialize() first.");
24
+ }
25
+ return this.config;
26
+ }
27
+ };
28
+ exports.ConfigHolderService = ConfigHolderService;
29
+ exports.ConfigHolderService = ConfigHolderService = __decorate([
30
+ (0, common_1.Injectable)()
31
+ ], ConfigHolderService);
32
+ //# sourceMappingURL=config-holder.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-holder.service.js","sourceRoot":"","sources":["../../src/config/config-holder.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAE5C,2DAAmD;AAG5C,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IACtB,MAAM,CAAY;IAEnB,SAAS,CAAC,MAAiB;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,oBAAM,CAAC,IAAI,CAAC,qBAAqB,EAAE,4DAA4D,EAAE;YAC/F,SAAS,EAAE,QAAQ;YACnB,SAAS,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC;SACrC,CAAC,CAAC;IACL,CAAC;IAEM,SAAS;QACd,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF,CAAA;AAnBY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;GACA,mBAAmB,CAmB/B"}
@@ -0,0 +1,5 @@
1
+ import { McpConfig } from './mcp-config.interface';
2
+ export declare class ConfigValidator {
3
+ static validate(config: McpConfig): void;
4
+ private static validateTool;
5
+ }
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConfigValidator = void 0;
4
+ const easy_mcp_error_1 = require("../core/errors/easy-mcp-error");
5
+ class ConfigValidator {
6
+ static validate(config) {
7
+ if (!config) {
8
+ throw new easy_mcp_error_1.ConfigurationError('Configuration object is required');
9
+ }
10
+ if (!config.tools || !Array.isArray(config.tools)) {
11
+ throw new easy_mcp_error_1.ConfigurationError('tools must be a non-empty array');
12
+ }
13
+ if (config.tools.length === 0) {
14
+ throw new easy_mcp_error_1.ConfigurationError('At least one tool must be provided');
15
+ }
16
+ config.tools.forEach((tool, index) => {
17
+ this.validateTool(tool, index);
18
+ });
19
+ if (config.serverInfo) {
20
+ if (!config.serverInfo.name || typeof config.serverInfo.name !== 'string' || config.serverInfo.name.trim().length === 0) {
21
+ throw new easy_mcp_error_1.ConfigurationError('serverInfo.name must be a non-empty string');
22
+ }
23
+ if (!config.serverInfo.version || typeof config.serverInfo.version !== 'string' || config.serverInfo.version.trim().length === 0) {
24
+ throw new easy_mcp_error_1.ConfigurationError('serverInfo.version must be a non-empty string');
25
+ }
26
+ }
27
+ }
28
+ static validateTool(tool, index) {
29
+ if (!tool) {
30
+ throw new easy_mcp_error_1.ConfigurationError(`Tool at index ${index} is null or undefined`);
31
+ }
32
+ if (!tool.name || typeof tool.name !== 'string' || tool.name.trim().length === 0) {
33
+ throw new easy_mcp_error_1.ConfigurationError(`Tool at index ${index}: name must be a non-empty string`);
34
+ }
35
+ if (!tool.description || typeof tool.description !== 'string' || tool.description.trim().length === 0) {
36
+ throw new easy_mcp_error_1.ConfigurationError(`Tool '${tool.name}': description must be a non-empty string`);
37
+ }
38
+ if (typeof tool.function !== 'function') {
39
+ throw new easy_mcp_error_1.ConfigurationError(`Tool '${tool.name}': function must be a function`);
40
+ }
41
+ if (!tool.inputSchema) {
42
+ throw new easy_mcp_error_1.ConfigurationError(`Tool '${tool.name}': inputSchema is required`);
43
+ }
44
+ if (tool.inputSchema.type !== 'OBJECT') {
45
+ throw new easy_mcp_error_1.ConfigurationError(`Tool '${tool.name}': inputSchema.type must be 'OBJECT'`);
46
+ }
47
+ if (!tool.inputSchema.properties || typeof tool.inputSchema.properties !== 'object' || Array.isArray(tool.inputSchema.properties)) {
48
+ throw new easy_mcp_error_1.ConfigurationError(`Tool '${tool.name}': inputSchema.properties must be an object`);
49
+ }
50
+ for (const [propName, propDef] of Object.entries(tool.inputSchema.properties)) {
51
+ if (!propDef || typeof propDef !== 'object' || Array.isArray(propDef)) {
52
+ throw new easy_mcp_error_1.ConfigurationError(`Tool '${tool.name}': property '${propName}' must be an object`);
53
+ }
54
+ if (!propDef.type || typeof propDef.type !== 'string') {
55
+ throw new easy_mcp_error_1.ConfigurationError(`Tool '${tool.name}': property '${propName}' must have a type`);
56
+ }
57
+ const validTypes = ['STRING', 'NUMBER', 'INTEGER', 'BOOLEAN', 'ARRAY', 'OBJECT'];
58
+ if (!validTypes.includes(propDef.type)) {
59
+ throw new easy_mcp_error_1.ConfigurationError(`Tool '${tool.name}': property '${propName}' has invalid type '${propDef.type}'. Must be one of: ${validTypes.join(', ')}`);
60
+ }
61
+ if (!propDef.description || typeof propDef.description !== 'string') {
62
+ throw new easy_mcp_error_1.ConfigurationError(`Tool '${tool.name}': property '${propName}' must have a description`);
63
+ }
64
+ }
65
+ if (tool.inputSchema.required !== undefined) {
66
+ if (!Array.isArray(tool.inputSchema.required)) {
67
+ throw new easy_mcp_error_1.ConfigurationError(`Tool '${tool.name}': inputSchema.required must be an array`);
68
+ }
69
+ for (const requiredProp of tool.inputSchema.required) {
70
+ if (!(requiredProp in tool.inputSchema.properties)) {
71
+ throw new easy_mcp_error_1.ConfigurationError(`Tool '${tool.name}': required property '${requiredProp}' does not exist in properties`);
72
+ }
73
+ }
74
+ }
75
+ }
76
+ }
77
+ exports.ConfigValidator = ConfigValidator;
78
+ //# sourceMappingURL=config-validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-validator.js","sourceRoot":"","sources":["../../src/config/config-validator.ts"],"names":[],"mappings":";;;AACA,kEAAmE;AAMnE,MAAa,eAAe;IAM1B,MAAM,CAAC,QAAQ,CAAC,MAAiB;QAC/B,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,mCAAkB,CAAC,kCAAkC,CAAC,CAAC;QACnE,CAAC;QAGD,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YAClD,MAAM,IAAI,mCAAkB,CAAC,iCAAiC,CAAC,CAAC;QAClE,CAAC;QAED,IAAI,MAAM,CAAC,KAAK,CAAC,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,CAAC,UAAU,CAAC,EAAE,CAAC;oBACnD,MAAM,IAAI,mCAAkB,CAAC,SAAS,IAAI,CAAC,IAAI,yBAAyB,YAAY,gCAAgC,CAAC,CAAC;gBACxH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAtGD,0CAsGC"}
@@ -0,0 +1,4 @@
1
+ export declare const CONFIG_TOKEN = "MCP_CONFIG_HOLDER";
2
+ export declare const INTERFACE_LAYER_TOKEN = "IInterfaceLayer";
3
+ export declare const MAX_MESSAGE_SIZE_BYTES: number;
4
+ export declare const MAX_CONTENT_LENGTH: number;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MAX_CONTENT_LENGTH = exports.MAX_MESSAGE_SIZE_BYTES = exports.INTERFACE_LAYER_TOKEN = exports.CONFIG_TOKEN = void 0;
4
+ exports.CONFIG_TOKEN = "MCP_CONFIG_HOLDER";
5
+ exports.INTERFACE_LAYER_TOKEN = "IInterfaceLayer";
6
+ exports.MAX_MESSAGE_SIZE_BYTES = 10 * 1024 * 1024;
7
+ exports.MAX_CONTENT_LENGTH = exports.MAX_MESSAGE_SIZE_BYTES;
8
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/config/constants.ts"],"names":[],"mappings":";;;AACa,QAAA,YAAY,GAAG,mBAAmB,CAAC;AAGnC,QAAA,qBAAqB,GAAG,iBAAiB,CAAC;AAO1C,QAAA,sBAAsB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAM1C,QAAA,kBAAkB,GAAG,8BAAsB,CAAC"}
@@ -0,0 +1,18 @@
1
+ export interface ToolRegistrationInput {
2
+ name: string;
3
+ description: string;
4
+ function: (args: Record<string, any>) => Promise<any>;
5
+ inputSchema: {
6
+ type: "OBJECT";
7
+ properties: Record<string, any>;
8
+ required?: string[];
9
+ };
10
+ }
11
+ export interface ServerInfo {
12
+ name: string;
13
+ version: string;
14
+ }
15
+ export interface McpConfig {
16
+ tools: ToolRegistrationInput[];
17
+ serverInfo?: ServerInfo;
18
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=mcp-config.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-config.interface.js","sourceRoot":"","sources":["../../src/config/mcp-config.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ export declare const PACKAGE_NAME: string;
2
+ export declare const VERSION: string;
3
+ export declare function getVersion(): string;
4
+ export declare function getPackageName(): string;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VERSION = exports.PACKAGE_NAME = void 0;
4
+ exports.getVersion = getVersion;
5
+ exports.getPackageName = getPackageName;
6
+ const logger_util_1 = require("../core/utils/logger.util");
7
+ function readPackageJson() {
8
+ try {
9
+ const packageJson = require("../../package.json");
10
+ const name = typeof packageJson.name === "string"
11
+ ? packageJson.name
12
+ : "easy-mcp-framework";
13
+ const version = typeof packageJson.version === "string"
14
+ ? packageJson.version
15
+ : "0.0.0";
16
+ return {
17
+ name,
18
+ version,
19
+ };
20
+ }
21
+ catch (error) {
22
+ const errorMessage = error instanceof Error ? error.message : String(error);
23
+ logger_util_1.logger.warn("version", "Could not read package.json. Using fallback version.", {
24
+ error: errorMessage,
25
+ });
26
+ return {
27
+ name: "easy-mcp-framework",
28
+ version: "0.0.0",
29
+ };
30
+ }
31
+ }
32
+ const packageInfo = readPackageJson();
33
+ exports.PACKAGE_NAME = packageInfo.name;
34
+ exports.VERSION = packageInfo.version;
35
+ function getVersion() {
36
+ return exports.VERSION;
37
+ }
38
+ function getPackageName() {
39
+ return exports.PACKAGE_NAME;
40
+ }
41
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/config/version.ts"],"names":[],"mappings":";;;AA6DA,gCAEC;AAMD,wCAEC;AAvED,2DAAmD;AAYnD,SAAS,eAAe;IACtB,IAAI,CAAC;QAIH,MAAM,WAAW,GAAG,OAAO,CAAC,oBAAoB,CAAgB,CAAC;QAGjE,MAAM,IAAI,GAAG,OAAO,WAAW,CAAC,IAAI,KAAK,QAAQ;YAC/C,CAAC,CAAC,WAAW,CAAC,IAAI;YAClB,CAAC,CAAC,oBAAoB,CAAC;QACzB,MAAM,OAAO,GAAG,OAAO,WAAW,CAAC,OAAO,KAAK,QAAQ;YACrD,CAAC,CAAC,WAAW,CAAC,OAAO;YACrB,CAAC,CAAC,OAAO,CAAC;QAEZ,OAAO;YACL,IAAI;YACJ,OAAO;SACR,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAGf,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5E,oBAAM,CAAC,IAAI,CAAC,SAAS,EAAE,sDAAsD,EAAE;YAC7E,KAAK,EAAE,YAAY;SACpB,CAAC,CAAC;QACH,OAAO;YACL,IAAI,EAAE,oBAAoB;YAC1B,OAAO,EAAE,OAAO;SACjB,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,WAAW,GAAG,eAAe,EAAE,CAAC;AAKzB,QAAA,YAAY,GAAG,WAAW,CAAC,IAAI,CAAC;AAKhC,QAAA,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC;AAM3C,SAAgB,UAAU;IACxB,OAAO,eAAO,CAAC;AACjB,CAAC;AAMD,SAAgB,cAAc;IAC5B,OAAO,oBAAY,CAAC;AACtB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare class CoreModule {
2
+ }
@@ -0,0 +1,24 @@
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.CoreModule = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ const mcp_server_service_1 = require("./mcp-server/mcp-server.service");
12
+ const interface_module_1 = require("../interface/interface.module");
13
+ let CoreModule = class CoreModule {
14
+ };
15
+ exports.CoreModule = CoreModule;
16
+ exports.CoreModule = CoreModule = __decorate([
17
+ (0, common_1.Global)(),
18
+ (0, common_1.Module)({
19
+ imports: [interface_module_1.InterfaceModule],
20
+ providers: [mcp_server_service_1.McpServerService],
21
+ exports: [mcp_server_service_1.McpServerService],
22
+ })
23
+ ], CoreModule);
24
+ //# sourceMappingURL=core.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.module.js","sourceRoot":"","sources":["../../src/core/core.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAgD;AAChD,wEAAmE;AACnE,oEAAgE;AAQzD,IAAM,UAAU,GAAhB,MAAM,UAAU;CAAG,CAAA;AAAb,gCAAU;qBAAV,UAAU;IANtB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,kCAAe,CAAC;QAC1B,SAAS,EAAE,CAAC,qCAAgB,CAAC;QAC7B,OAAO,EAAE,CAAC,qCAAgB,CAAC;KAC5B,CAAC;GACW,UAAU,CAAG"}
@@ -0,0 +1,14 @@
1
+ export declare class EasyMcpError extends Error {
2
+ constructor(message: string);
3
+ }
4
+ export declare class ConfigurationError extends EasyMcpError {
5
+ constructor(message: string);
6
+ }
7
+ export declare class ToolExecutionError extends EasyMcpError {
8
+ readonly toolName?: string | undefined;
9
+ readonly originalError?: Error | undefined;
10
+ constructor(message: string, toolName?: string | undefined, originalError?: Error | undefined);
11
+ }
12
+ export declare class ToolNotFoundError extends EasyMcpError {
13
+ constructor(toolName: string);
14
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ToolNotFoundError = exports.ToolExecutionError = exports.ConfigurationError = exports.EasyMcpError = void 0;
4
+ class EasyMcpError extends Error {
5
+ constructor(message) {
6
+ super(message);
7
+ this.name = 'EasyMcpError';
8
+ if (Error.captureStackTrace) {
9
+ Error.captureStackTrace(this, this.constructor);
10
+ }
11
+ }
12
+ }
13
+ exports.EasyMcpError = EasyMcpError;
14
+ class ConfigurationError extends EasyMcpError {
15
+ constructor(message) {
16
+ super(message);
17
+ this.name = 'ConfigurationError';
18
+ }
19
+ }
20
+ exports.ConfigurationError = ConfigurationError;
21
+ class ToolExecutionError extends EasyMcpError {
22
+ toolName;
23
+ originalError;
24
+ constructor(message, toolName, originalError) {
25
+ super(message);
26
+ this.toolName = toolName;
27
+ this.originalError = originalError;
28
+ this.name = 'ToolExecutionError';
29
+ }
30
+ }
31
+ exports.ToolExecutionError = ToolExecutionError;
32
+ class ToolNotFoundError extends EasyMcpError {
33
+ constructor(toolName) {
34
+ super(`Tool '${toolName}' not found in registry`);
35
+ this.name = 'ToolNotFoundError';
36
+ }
37
+ }
38
+ exports.ToolNotFoundError = ToolNotFoundError;
39
+ //# sourceMappingURL=easy-mcp-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"easy-mcp-error.js","sourceRoot":"","sources":["../../../src/core/errors/easy-mcp-error.ts"],"names":[],"mappings":";;;AAGA,MAAa,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAE3B,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;CACF;AATD,oCASC;AAKD,MAAa,kBAAmB,SAAQ,YAAY;IAClD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AALD,gDAKC;AAKD,MAAa,kBAAmB,SAAQ,YAAY;IACL;IAAmC;IAAhF,YAAY,OAAe,EAAkB,QAAiB,EAAkB,aAAqB;QACnG,KAAK,CAAC,OAAO,CAAC,CAAC;QAD4B,aAAQ,GAAR,QAAQ,CAAS;QAAkB,kBAAa,GAAb,aAAa,CAAQ;QAEnG,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AALD,gDAKC;AAKD,MAAa,iBAAkB,SAAQ,YAAY;IACjD,YAAY,QAAgB;QAC1B,KAAK,CAAC,SAAS,QAAQ,yBAAyB,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AALD,8CAKC"}
@@ -0,0 +1,22 @@
1
+ import { OnModuleInit } from "@nestjs/common";
2
+ import { ToolRegistryService } from "../../tooling/tool-registry/tool-registry.service";
3
+ import { type IInterfaceLayer } from "../../interface/interface.interface";
4
+ import { StdioGatewayService } from "../../interface/stdio-gateway.service";
5
+ import { JsonRpcRequest, JsonRpcResponse } from "../../interface/jsonrpc.interface";
6
+ import { ConfigHolderService } from "../../config/config-holder.service";
7
+ export declare class McpServerService implements OnModuleInit {
8
+ private readonly toolRegistry;
9
+ private readonly interfaceLayer;
10
+ private readonly stdioGatewayService;
11
+ private readonly configHolder;
12
+ private clientIdentifier;
13
+ constructor(toolRegistry: ToolRegistryService, interfaceLayer: IInterfaceLayer, stdioGatewayService: StdioGatewayService, configHolder: ConfigHolderService);
14
+ private getServerInfo;
15
+ private getActorIdentifier;
16
+ onModuleInit(): void;
17
+ startListening(): Promise<void>;
18
+ handleRequest(request: JsonRpcRequest): Promise<JsonRpcResponse>;
19
+ private handleInitialize;
20
+ private handleListTools;
21
+ private handleCallTool;
22
+ }
@@ -0,0 +1,285 @@
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.McpServerService = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const tool_registry_service_1 = require("../../tooling/tool-registry/tool-registry.service");
18
+ const constants_1 = require("../../config/constants");
19
+ const stdio_gateway_service_1 = require("../../interface/stdio-gateway.service");
20
+ const jsonrpc_interface_1 = require("../../interface/jsonrpc.interface");
21
+ const mcp_protocol_interface_1 = require("../../interface/mcp-protocol.interface");
22
+ const easy_mcp_error_1 = require("../errors/easy-mcp-error");
23
+ const constants_2 = require("../../config/constants");
24
+ const config_holder_service_1 = require("../../config/config-holder.service");
25
+ const version_1 = require("../../config/version");
26
+ const schema_validator_1 = require("../utils/schema-validator");
27
+ const logger_util_1 = require("../utils/logger.util");
28
+ const sanitize_util_1 = require("../utils/sanitize.util");
29
+ let McpServerService = class McpServerService {
30
+ toolRegistry;
31
+ interfaceLayer;
32
+ stdioGatewayService;
33
+ configHolder;
34
+ clientIdentifier = "stdio-client";
35
+ constructor(toolRegistry, interfaceLayer, stdioGatewayService, configHolder) {
36
+ this.toolRegistry = toolRegistry;
37
+ this.interfaceLayer = interfaceLayer;
38
+ this.stdioGatewayService = stdioGatewayService;
39
+ this.configHolder = configHolder;
40
+ }
41
+ getServerInfo() {
42
+ const config = this.configHolder.getConfig();
43
+ const defaultInfo = {
44
+ name: version_1.PACKAGE_NAME,
45
+ version: version_1.VERSION,
46
+ };
47
+ return config.serverInfo ?? defaultInfo;
48
+ }
49
+ getActorIdentifier(request) {
50
+ if (request.method === "initialize") {
51
+ const params = request.params;
52
+ if (params?.clientInfo?.name) {
53
+ this.clientIdentifier = params.clientInfo.name;
54
+ return this.clientIdentifier;
55
+ }
56
+ }
57
+ return this.clientIdentifier;
58
+ }
59
+ onModuleInit() {
60
+ this.stdioGatewayService.setMcpServerService(this);
61
+ logger_util_1.logger.info("McpServerService", "Circular dependency resolved", {
62
+ component: "Layer 3",
63
+ });
64
+ }
65
+ async startListening() {
66
+ logger_util_1.logger.info("McpServerService", "Initiating Layer 1 Interface startup", {
67
+ component: "Layer 3: Abstraction Core",
68
+ });
69
+ await this.interfaceLayer.start();
70
+ logger_util_1.logger.info("McpServerService", "McpServerService is operational and awaiting Layer 1 input", {
71
+ component: "Layer 3",
72
+ });
73
+ }
74
+ async handleRequest(request) {
75
+ const isDebugMode = process.env.DEBUG === '1' || process.env.DEBUG === 'true';
76
+ if (isDebugMode) {
77
+ logger_util_1.logger.debug("McpServerService", "Received JSON-RPC request", {
78
+ method: request.method,
79
+ requestId: request.id,
80
+ hasParams: !!request.params,
81
+ });
82
+ }
83
+ try {
84
+ let response;
85
+ switch (request.method) {
86
+ case "initialize":
87
+ response = this.handleInitialize(request);
88
+ if (isDebugMode) {
89
+ const initResult = response.result;
90
+ logger_util_1.logger.debug("McpServerService", "Initialize response", {
91
+ protocolVersion: initResult?.protocolVersion,
92
+ hasError: !!response.error,
93
+ errorCode: response.error?.code,
94
+ });
95
+ }
96
+ logger_util_1.logger.audit("McpServerService", "initialize", response.error ? "failure" : "success", { method: request.method }, request.id, this.getActorIdentifier(request));
97
+ return response;
98
+ case "tools/list":
99
+ response = this.handleListTools(request);
100
+ if (isDebugMode) {
101
+ const listResult = response.result;
102
+ logger_util_1.logger.debug("McpServerService", "Tools/list response", {
103
+ toolCount: listResult?.tools?.length || 0,
104
+ hasError: !!response.error,
105
+ });
106
+ }
107
+ logger_util_1.logger.audit("McpServerService", "tools/list", response.error ? "failure" : "success", { method: request.method }, request.id, this.getActorIdentifier(request));
108
+ return response;
109
+ case "tools/call":
110
+ response = await this.handleCallTool(request);
111
+ return response;
112
+ default:
113
+ logger_util_1.logger.warn("McpServerService", "Method not found", {
114
+ component: "Layer 3",
115
+ method: request.method,
116
+ requestId: request.id,
117
+ });
118
+ return (0, jsonrpc_interface_1.createJsonRpcError)(request.id, jsonrpc_interface_1.JsonRpcErrorCode.MethodNotFound, `Method not found: ${request.method}`);
119
+ }
120
+ }
121
+ catch (error) {
122
+ logger_util_1.logger.error("McpServerService", "Unhandled error in handleRequest", {
123
+ component: "Layer 3",
124
+ method: request.method,
125
+ requestId: request.id,
126
+ error: (0, sanitize_util_1.sanitizeErrorMessage)(error),
127
+ });
128
+ return (0, jsonrpc_interface_1.createJsonRpcError)(request.id, jsonrpc_interface_1.JsonRpcErrorCode.InternalError, "Internal error");
129
+ }
130
+ }
131
+ handleInitialize(request) {
132
+ const params = request.params;
133
+ if (!params || typeof params.protocolVersion !== "string") {
134
+ return (0, jsonrpc_interface_1.createJsonRpcError)(request.id, jsonrpc_interface_1.JsonRpcErrorCode.InvalidParams, "Missing or invalid protocolVersion");
135
+ }
136
+ const SUPPORTED_PROTOCOL_VERSION = "2024-11-05";
137
+ if (params.protocolVersion !== SUPPORTED_PROTOCOL_VERSION) {
138
+ logger_util_1.logger.warn("McpServerService", "Unsupported protocol version", {
139
+ component: "Layer 3",
140
+ supportedVersion: SUPPORTED_PROTOCOL_VERSION,
141
+ requestId: request.id,
142
+ });
143
+ const isDebugMode = process.env.DEBUG === '1' || process.env.DEBUG === 'true';
144
+ if (isDebugMode) {
145
+ logger_util_1.logger.debug("McpServerService", "Protocol version mismatch", {
146
+ supported: SUPPORTED_PROTOCOL_VERSION,
147
+ clientName: params.clientInfo?.name || 'unknown',
148
+ });
149
+ }
150
+ return (0, jsonrpc_interface_1.createJsonRpcError)(request.id, jsonrpc_interface_1.JsonRpcErrorCode.InvalidParams, `Unsupported protocol version: ${params.protocolVersion}. Supported version: ${SUPPORTED_PROTOCOL_VERSION}. Please update your client to use protocol version ${SUPPORTED_PROTOCOL_VERSION}.`);
151
+ }
152
+ const result = {
153
+ protocolVersion: SUPPORTED_PROTOCOL_VERSION,
154
+ capabilities: {
155
+ tools: {},
156
+ },
157
+ serverInfo: this.getServerInfo(),
158
+ };
159
+ return (0, jsonrpc_interface_1.createJsonRpcSuccess)(request.id, result);
160
+ }
161
+ handleListTools(request) {
162
+ const tools = this.toolRegistry.getToolSchemasForLLM();
163
+ const mcpTools = tools.map((tool) => ({
164
+ name: tool.function.name,
165
+ description: tool.function.description,
166
+ inputSchema: tool.function.parameters,
167
+ }));
168
+ const result = {
169
+ tools: mcpTools,
170
+ };
171
+ return (0, jsonrpc_interface_1.createJsonRpcSuccess)(request.id, result);
172
+ }
173
+ async handleCallTool(request) {
174
+ const params = request.params;
175
+ const actorId = this.getActorIdentifier(request);
176
+ if (!params) {
177
+ logger_util_1.logger.audit("McpServerService", "tools/call", "failure", { reason: "Missing params", method: request.method }, request.id, actorId);
178
+ return (0, jsonrpc_interface_1.createJsonRpcError)(request.id, jsonrpc_interface_1.JsonRpcErrorCode.InvalidParams, "Missing params");
179
+ }
180
+ if (!params.name || typeof params.name !== "string") {
181
+ logger_util_1.logger.audit("McpServerService", "tools/call", "failure", { reason: "Missing or invalid tool name", method: request.method }, request.id, actorId);
182
+ return (0, jsonrpc_interface_1.createJsonRpcError)(request.id, jsonrpc_interface_1.JsonRpcErrorCode.InvalidParams, "Missing or invalid tool name");
183
+ }
184
+ const toolName = params.name;
185
+ if (params.arguments !== undefined && params.arguments !== null) {
186
+ if (typeof params.arguments !== "object" ||
187
+ Array.isArray(params.arguments)) {
188
+ logger_util_1.logger.audit("McpServerService", "tools/call", "failure", {
189
+ reason: "Invalid arguments type - must be a plain object",
190
+ toolName,
191
+ method: request.method,
192
+ }, request.id, actorId);
193
+ return (0, jsonrpc_interface_1.createJsonRpcError)(request.id, jsonrpc_interface_1.JsonRpcErrorCode.InvalidParams, "Arguments must be a plain object");
194
+ }
195
+ }
196
+ const args = params.arguments || {};
197
+ const tool = this.toolRegistry.getTool(toolName);
198
+ if (!tool) {
199
+ logger_util_1.logger.audit("McpServerService", "tools/call", "failure", {
200
+ reason: "Tool not found",
201
+ toolName,
202
+ method: request.method,
203
+ }, request.id, actorId);
204
+ return (0, jsonrpc_interface_1.createJsonRpcError)(request.id, mcp_protocol_interface_1.McpErrorCode.ToolNotFound, "Tool not found");
205
+ }
206
+ const validationError = (0, schema_validator_1.validateToolArguments)(args, tool.parameters, tool.required);
207
+ if (validationError) {
208
+ logger_util_1.logger.audit("McpServerService", "tools/call", "failure", {
209
+ reason: "Invalid arguments",
210
+ toolName,
211
+ validationError,
212
+ method: request.method,
213
+ }, request.id, actorId);
214
+ const isDebugMode = process.env.DEBUG === '1' || process.env.DEBUG === 'true';
215
+ if (isDebugMode) {
216
+ logger_util_1.logger.debug("McpServerService", "Tool argument validation failed", {
217
+ toolName,
218
+ validationError,
219
+ providedArgs: Object.keys(args),
220
+ expectedParams: Object.keys(tool.parameters),
221
+ requiredParams: tool.required,
222
+ });
223
+ }
224
+ return (0, jsonrpc_interface_1.createJsonRpcError)(request.id, jsonrpc_interface_1.JsonRpcErrorCode.InvalidParams, `Tool '${toolName}' validation failed: ${validationError}. Check the tool schema and ensure all required parameters are provided.`);
225
+ }
226
+ try {
227
+ const toolResult = await this.toolRegistry.executeTool(toolName, args);
228
+ const sanitizedResult = (0, sanitize_util_1.sanitizeToolResult)(toolResult);
229
+ const result = {
230
+ content: [
231
+ {
232
+ type: "text",
233
+ text: sanitizedResult,
234
+ },
235
+ ],
236
+ isError: false,
237
+ };
238
+ logger_util_1.logger.audit("McpServerService", "tools/call", "success", {
239
+ toolName,
240
+ resultSize: sanitizedResult.length,
241
+ method: request.method,
242
+ }, request.id, actorId);
243
+ return (0, jsonrpc_interface_1.createJsonRpcSuccess)(request.id, result);
244
+ }
245
+ catch (error) {
246
+ if (error instanceof easy_mcp_error_1.ToolNotFoundError) {
247
+ logger_util_1.logger.audit("McpServerService", "tools/call", "failure", {
248
+ reason: "ToolNotFoundError",
249
+ toolName,
250
+ method: request.method,
251
+ }, request.id, actorId);
252
+ return (0, jsonrpc_interface_1.createJsonRpcError)(request.id, mcp_protocol_interface_1.McpErrorCode.ToolNotFound, "Tool not found");
253
+ }
254
+ if (error instanceof easy_mcp_error_1.ToolExecutionError) {
255
+ logger_util_1.logger.audit("McpServerService", "tools/call", "failure", {
256
+ reason: "ToolExecutionError",
257
+ toolName,
258
+ method: request.method,
259
+ }, request.id, actorId);
260
+ return (0, jsonrpc_interface_1.createJsonRpcError)(request.id, mcp_protocol_interface_1.McpErrorCode.ToolExecutionError, "Tool execution failed");
261
+ }
262
+ logger_util_1.logger.error("McpServerService", "Unknown error during tool execution", {
263
+ component: "Layer 3",
264
+ toolName,
265
+ requestId: request.id,
266
+ error: (0, sanitize_util_1.sanitizeErrorMessage)(error),
267
+ });
268
+ logger_util_1.logger.audit("McpServerService", "tools/call", "failure", {
269
+ reason: "Unknown error",
270
+ toolName,
271
+ method: request.method,
272
+ }, request.id, actorId);
273
+ return (0, jsonrpc_interface_1.createJsonRpcError)(request.id, mcp_protocol_interface_1.McpErrorCode.ToolExecutionError, "Tool execution failed");
274
+ }
275
+ }
276
+ };
277
+ exports.McpServerService = McpServerService;
278
+ exports.McpServerService = McpServerService = __decorate([
279
+ (0, common_1.Injectable)(),
280
+ __param(1, (0, common_1.Inject)(constants_1.INTERFACE_LAYER_TOKEN)),
281
+ __param(3, (0, common_1.Inject)(constants_2.CONFIG_TOKEN)),
282
+ __metadata("design:paramtypes", [tool_registry_service_1.ToolRegistryService, Object, stdio_gateway_service_1.StdioGatewayService,
283
+ config_holder_service_1.ConfigHolderService])
284
+ ], McpServerService);
285
+ //# sourceMappingURL=mcp-server.service.js.map