easy-mcp-nest 0.1.2 → 0.2.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 (52) hide show
  1. package/README.md +66 -28
  2. package/dist/EasyMCP.js +53 -1
  3. package/dist/EasyMCP.js.map +1 -1
  4. package/dist/app.module.js +3 -1
  5. package/dist/app.module.js.map +1 -1
  6. package/dist/config/config-validator.js +92 -20
  7. package/dist/config/config-validator.js.map +1 -1
  8. package/dist/config/constants.d.ts +3 -0
  9. package/dist/config/constants.js +4 -1
  10. package/dist/config/constants.js.map +1 -1
  11. package/dist/config/mcp-config.interface.d.ts +51 -5
  12. package/dist/core/core.module.js +3 -1
  13. package/dist/core/core.module.js.map +1 -1
  14. package/dist/core/mcp-server/mcp-server.service.d.ts +15 -1
  15. package/dist/core/mcp-server/mcp-server.service.js +300 -23
  16. package/dist/core/mcp-server/mcp-server.service.js.map +1 -1
  17. package/dist/core/utils/sanitize.util.d.ts +3 -0
  18. package/dist/core/utils/sanitize.util.js +51 -0
  19. package/dist/core/utils/sanitize.util.js.map +1 -1
  20. package/dist/core/utils/schema-validator.d.ts +6 -1
  21. package/dist/core/utils/schema-validator.js +15 -6
  22. package/dist/core/utils/schema-validator.js.map +1 -1
  23. package/dist/core/utils/tool-naming-validator.d.ts +4 -0
  24. package/dist/core/utils/tool-naming-validator.js +52 -0
  25. package/dist/core/utils/tool-naming-validator.js.map +1 -0
  26. package/dist/interface/mcp-protocol.interface.d.ts +136 -2
  27. package/dist/interface/mcp-protocol.interface.js +6 -0
  28. package/dist/interface/mcp-protocol.interface.js.map +1 -1
  29. package/dist/prompts/prompt-registry.service.d.ts +28 -0
  30. package/dist/prompts/prompt-registry.service.js +55 -0
  31. package/dist/prompts/prompt-registry.service.js.map +1 -0
  32. package/dist/prompts/prompt.interface.d.ts +30 -0
  33. package/dist/prompts/prompt.interface.js +3 -0
  34. package/dist/prompts/prompt.interface.js.map +1 -0
  35. package/dist/prompts/prompt.module.d.ts +2 -0
  36. package/dist/prompts/prompt.module.js +21 -0
  37. package/dist/prompts/prompt.module.js.map +1 -0
  38. package/dist/resources/resource-registry.service.d.ts +18 -0
  39. package/dist/resources/resource-registry.service.js +56 -0
  40. package/dist/resources/resource-registry.service.js.map +1 -0
  41. package/dist/resources/resource.interface.d.ts +19 -0
  42. package/dist/resources/resource.interface.js +3 -0
  43. package/dist/resources/resource.interface.js.map +1 -0
  44. package/dist/resources/resource.module.d.ts +2 -0
  45. package/dist/resources/resource.module.js +21 -0
  46. package/dist/resources/resource.module.js.map +1 -0
  47. package/dist/tooling/tool-registry/tool-registry.service.d.ts +5 -3
  48. package/dist/tooling/tool-registry/tool-registry.service.js +82 -49
  49. package/dist/tooling/tool-registry/tool-registry.service.js.map +1 -1
  50. package/dist/tooling/tool.interface.d.ts +27 -7
  51. package/dist/tsconfig.build.tsbuildinfo +1 -1
  52. package/package.json +1 -1
@@ -7,8 +7,9 @@ export interface LlmToolSchema {
7
7
  description: string;
8
8
  parameters: {
9
9
  type: "object";
10
- properties: Record<string, ToolParameter>;
11
- required: string[];
10
+ properties?: Record<string, ToolParameter>;
11
+ required?: string[];
12
+ [key: string]: any;
12
13
  };
13
14
  };
14
15
  }
@@ -16,8 +17,9 @@ export declare class ToolRegistryService {
16
17
  private readonly registry;
17
18
  registerTool(definition: ToolDefinition): void;
18
19
  getTool(name: string): ToolDefinition | undefined;
19
- executeTool(name: string, args: Record<string, any>): Promise<any>;
20
+ executeTool(name: string, args: Record<string, any>, cancellationToken?: import("../tool.interface").CancellationToken): Promise<any>;
20
21
  registerToolFromConfig(toolInput: ToolRegistrationInput): void;
21
22
  getToolSchemasForLLM(): LlmToolSchema[];
23
+ private convertToolParameterToJsonSchema;
22
24
  getToolsAsRegistrationInput(): ToolRegistrationInput[];
23
25
  }
@@ -10,6 +10,7 @@ exports.ToolRegistryService = void 0;
10
10
  const common_1 = require("@nestjs/common");
11
11
  const easy_mcp_error_1 = require("../../core/errors/easy-mcp-error");
12
12
  const logger_util_1 = require("../../core/utils/logger.util");
13
+ const sanitize_util_1 = require("../../core/utils/sanitize.util");
13
14
  let ToolRegistryService = class ToolRegistryService {
14
15
  registry = new Map();
15
16
  registerTool(definition) {
@@ -25,13 +26,13 @@ let ToolRegistryService = class ToolRegistryService {
25
26
  getTool(name) {
26
27
  return this.registry.get(name);
27
28
  }
28
- async executeTool(name, args) {
29
+ async executeTool(name, args, cancellationToken) {
29
30
  const tool = this.getTool(name);
30
31
  if (!tool) {
31
32
  throw new easy_mcp_error_1.ToolNotFoundError(name);
32
33
  }
33
34
  try {
34
- const result = await tool.execute(args);
35
+ const result = await tool.execute(args, cancellationToken);
35
36
  return result;
36
37
  }
37
38
  catch (error) {
@@ -40,33 +41,20 @@ let ToolRegistryService = class ToolRegistryService {
40
41
  }
41
42
  }
42
43
  registerToolFromConfig(toolInput) {
43
- const parameters = {};
44
- for (const [key, prop] of Object.entries(toolInput.inputSchema.properties)) {
45
- const typeMap = {
46
- 'STRING': 'string',
47
- 'NUMBER': 'number',
48
- 'INTEGER': 'integer',
49
- 'BOOLEAN': 'boolean',
50
- 'ARRAY': 'array',
51
- 'OBJECT': 'object',
52
- };
53
- const lowerType = typeMap[prop.type];
54
- if (!lowerType) {
55
- throw new Error(`Tool '${toolInput.name}': Unsupported property type '${prop.type}' for property '${key}'. Must be one of: STRING, NUMBER, INTEGER, BOOLEAN, ARRAY, OBJECT`);
56
- }
57
- parameters[key] = {
58
- type: lowerType,
59
- description: prop.description || '',
60
- ...(prop.enum && { enum: prop.enum }),
61
- };
44
+ if (toolInput.inputSchema.type !== "object") {
45
+ throw new Error(`Tool '${toolInput.name}': inputSchema.type must be "object" for tool definitions`);
62
46
  }
63
- const required = toolInput.inputSchema.required || [];
64
47
  const toolDefinition = {
65
48
  name: toolInput.name,
66
49
  description: toolInput.description,
67
50
  execute: toolInput.function,
68
- parameters,
69
- required,
51
+ inputSchema: {
52
+ type: "object",
53
+ properties: toolInput.inputSchema.properties || {},
54
+ required: toolInput.inputSchema.required || [],
55
+ ...Object.fromEntries(Object.entries(toolInput.inputSchema).filter(([key]) => !["type", "properties", "required"].includes(key) && (0, sanitize_util_1.isSafeObjectKey)(key))),
56
+ },
57
+ icon: toolInput.icon,
70
58
  };
71
59
  this.registerTool(toolDefinition);
72
60
  }
@@ -76,41 +64,86 @@ let ToolRegistryService = class ToolRegistryService {
76
64
  function: {
77
65
  name: tool.name,
78
66
  description: tool.description,
79
- parameters: {
80
- type: "object",
81
- properties: tool.parameters,
82
- required: tool.required,
83
- },
67
+ parameters: tool.inputSchema,
84
68
  },
85
69
  }));
86
70
  }
71
+ convertToolParameterToJsonSchema(param) {
72
+ const schema = {
73
+ ...(param.type !== undefined && { type: param.type }),
74
+ ...(param.description && { description: param.description }),
75
+ ...(param.enum && { enum: param.enum }),
76
+ ...(param.default !== undefined && { default: param.default }),
77
+ ...(param.const !== undefined && { const: param.const }),
78
+ ...(param.$ref && { $ref: param.$ref }),
79
+ ...(param.oneOf && { oneOf: param.oneOf.map((p) => this.convertToolParameterToJsonSchema(p)) }),
80
+ ...(param.anyOf && { anyOf: param.anyOf.map((p) => this.convertToolParameterToJsonSchema(p)) }),
81
+ ...(param.allOf && { allOf: param.allOf.map((p) => this.convertToolParameterToJsonSchema(p)) }),
82
+ };
83
+ if (param.properties) {
84
+ schema.type = schema.type ?? "object";
85
+ schema.properties = {};
86
+ for (const [key, value] of Object.entries(param.properties)) {
87
+ if ((0, sanitize_util_1.isSafeObjectKey)(key)) {
88
+ schema.properties[key] = this.convertToolParameterToJsonSchema(value);
89
+ }
90
+ }
91
+ if (Array.isArray(param.required)) {
92
+ schema.required = param.required;
93
+ }
94
+ }
95
+ if (param.items) {
96
+ schema.type = schema.type ?? "array";
97
+ schema.items = Array.isArray(param.items)
98
+ ? param.items.map((item) => this.convertToolParameterToJsonSchema(item))
99
+ : this.convertToolParameterToJsonSchema(param.items);
100
+ }
101
+ for (const [key, value] of Object.entries(param)) {
102
+ if (![
103
+ "type",
104
+ "description",
105
+ "enum",
106
+ "default",
107
+ "const",
108
+ "required",
109
+ "$ref",
110
+ "oneOf",
111
+ "anyOf",
112
+ "allOf",
113
+ "properties",
114
+ "items",
115
+ ].includes(key) &&
116
+ (0, sanitize_util_1.isSafeObjectKey)(key)) {
117
+ schema[key] = value;
118
+ }
119
+ }
120
+ return schema;
121
+ }
87
122
  getToolsAsRegistrationInput() {
88
123
  return Array.from(this.registry.values()).map((tool) => {
89
- const properties = {};
90
- for (const [key, param] of Object.entries(tool.parameters)) {
91
- const typeMap = {
92
- 'string': 'STRING',
93
- 'number': 'NUMBER',
94
- 'integer': 'INTEGER',
95
- 'boolean': 'BOOLEAN',
96
- 'array': 'ARRAY',
97
- 'object': 'OBJECT',
98
- };
99
- properties[key] = {
100
- type: typeMap[param.type] || 'STRING',
101
- description: param.description,
102
- ...(param.enum && { enum: param.enum }),
103
- };
124
+ const convertedSchema = {
125
+ type: "object",
126
+ ...(tool.inputSchema.required && { required: tool.inputSchema.required }),
127
+ };
128
+ if (tool.inputSchema.properties) {
129
+ convertedSchema.properties = {};
130
+ for (const [key, value] of Object.entries(tool.inputSchema.properties)) {
131
+ if ((0, sanitize_util_1.isSafeObjectKey)(key)) {
132
+ convertedSchema.properties[key] = this.convertToolParameterToJsonSchema(value);
133
+ }
134
+ }
135
+ }
136
+ for (const [key, value] of Object.entries(tool.inputSchema)) {
137
+ if (!["type", "properties", "required"].includes(key) && (0, sanitize_util_1.isSafeObjectKey)(key)) {
138
+ convertedSchema[key] = value;
139
+ }
104
140
  }
105
141
  return {
106
142
  name: tool.name,
107
143
  description: tool.description,
108
144
  function: tool.execute,
109
- inputSchema: {
110
- type: 'OBJECT',
111
- properties,
112
- required: tool.required,
113
- },
145
+ inputSchema: convertedSchema,
146
+ icon: tool.icon,
114
147
  };
115
148
  });
116
149
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tool-registry.service.js","sourceRoot":"","sources":["../../../src/tooling/tool-registry/tool-registry.service.ts"],"names":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AAE,CAAC;iBACxC,CAAC;YACJ,CAAC;YAED,OAAO;gBACL,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,QAAQ,EAAE,IAAI,CAAC,OAAO;gBACtB,WAAW,EAAE;oBACX,IAAI,EAAE,QAAQ;oBACd,UAAU;oBACV,QAAQ,EAAE,IAAI,CAAC,QAAQ;iBACxB;aACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AA/JY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;GACA,mBAAmB,CA+J/B"}
1
+ {"version":3,"file":"tool-registry.service.js","sourceRoot":"","sources":["../../../src/tooling/tool-registry/tool-registry.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAG5C,qEAAyF;AACzF,8DAAsD;AACtD,kEAAiE;AAsB1D,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IACb,QAAQ,GAAG,IAAI,GAAG,EAA0B,CAAC;IAMvD,YAAY,CAAC,UAA0B;QAC5C,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,cAAc,UAAU,CAAC,IAAI,uBAAuB,CAAC,CAAC;QACxE,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAC/C,oBAAM,CAAC,IAAI,CAAC,qBAAqB,EAAE,oBAAoB,UAAU,CAAC,IAAI,EAAE,EAAE;YACxE,SAAS,EAAE,cAAc;YACzB,QAAQ,EAAE,UAAU,CAAC,IAAI;SAC1B,CAAC,CAAC;IACL,CAAC;IAKM,OAAO,CAAC,IAAY;QACzB,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAWM,KAAK,CAAC,WA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,CAAC;gBAChC,eAAe,CAAC,UAAU,GAAG,EAAE,CAAC;gBAChC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,CAAC;oBAEvE,IAAI,IAAA,+BAAe,EAAC,GAAG,CAAC,EAAE,CAAC;wBACzB,eAAe,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,gCAAgC,CAAC,KAAK,CAAC,CAAC;oBACjF,CAAC;gBACH,CAAC;YACH,CAAC;YAGD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;gBAC5D,IAAI,CAAC,CAAC,MAAM,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,IAAA,+BAAe,EAAC,GAAG,CAAC,EAAE,CAAC;oBAC7E,eAAuB,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;gBACxC,CAAC;YACH,CAAC;YAED,OAAO;gBACL,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,QAAQ,EAAE,IAAI,CAAC,OAAO;gBACtB,WAAW,EAAE,eAAe;gBAC5B,IAAI,EAAE,IAAI,CAAC,IAAI;aAChB,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AArNY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;GACA,mBAAmB,CAqN/B"}
@@ -1,13 +1,33 @@
1
- export interface ToolParameter {
2
- type: "string" | "number" | "integer" | "boolean" | "array" | "object";
3
- description: string;
4
- enum?: string[];
1
+ export interface ToolParameter extends Record<string, any> {
2
+ type?: "string" | "number" | "integer" | "boolean" | "array" | "object";
3
+ description?: string;
4
+ enum?: (string | number | boolean)[];
5
+ default?: any;
6
+ const?: any;
7
+ items?: ToolParameter | ToolParameter[];
8
+ properties?: Record<string, ToolParameter>;
9
+ required?: string[];
10
+ oneOf?: ToolParameter[];
11
+ anyOf?: ToolParameter[];
12
+ allOf?: ToolParameter[];
13
+ $ref?: string;
14
+ [key: string]: any;
15
+ }
16
+ export interface CancellationToken {
17
+ isCancelled: boolean;
18
+ onCancel: (callback: () => void) => void;
19
+ cancel: () => void;
5
20
  }
6
- export type ToolFunction = (args: Record<string, any>) => Promise<any>;
21
+ export type ToolFunction = (args: Record<string, any>, cancellationToken?: CancellationToken) => Promise<any>;
7
22
  export interface ToolDefinition {
8
23
  name: string;
9
24
  description: string;
10
25
  execute: ToolFunction;
11
- parameters: Record<string, ToolParameter>;
12
- required: string[];
26
+ inputSchema: {
27
+ type: "object";
28
+ properties?: Record<string, ToolParameter>;
29
+ required?: string[];
30
+ [key: string]: any;
31
+ };
32
+ icon?: string;
13
33
  }