easy-mcp-nest 0.1.3 → 0.2.1
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/README.md +57 -27
- package/dist/EasyMCP.js +53 -1
- package/dist/EasyMCP.js.map +1 -1
- package/dist/app.module.js +3 -1
- package/dist/app.module.js.map +1 -1
- package/dist/config/config-validator.js +92 -20
- package/dist/config/config-validator.js.map +1 -1
- package/dist/config/constants.d.ts +3 -0
- package/dist/config/constants.js +4 -1
- package/dist/config/constants.js.map +1 -1
- package/dist/config/mcp-config.interface.d.ts +51 -5
- package/dist/core/core.module.js +3 -1
- package/dist/core/core.module.js.map +1 -1
- package/dist/core/mcp-server/mcp-server.service.d.ts +15 -1
- package/dist/core/mcp-server/mcp-server.service.js +324 -35
- package/dist/core/mcp-server/mcp-server.service.js.map +1 -1
- package/dist/core/utils/sanitize.util.d.ts +3 -0
- package/dist/core/utils/sanitize.util.js +51 -0
- package/dist/core/utils/sanitize.util.js.map +1 -1
- package/dist/core/utils/schema-validator.d.ts +6 -1
- package/dist/core/utils/schema-validator.js +15 -6
- package/dist/core/utils/schema-validator.js.map +1 -1
- package/dist/core/utils/tool-naming-validator.d.ts +4 -0
- package/dist/core/utils/tool-naming-validator.js +68 -0
- package/dist/core/utils/tool-naming-validator.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/interface/mcp-protocol.interface.d.ts +136 -2
- package/dist/interface/mcp-protocol.interface.js +6 -0
- package/dist/interface/mcp-protocol.interface.js.map +1 -1
- package/dist/prompts/prompt-registry.service.d.ts +28 -0
- package/dist/prompts/prompt-registry.service.js +55 -0
- package/dist/prompts/prompt-registry.service.js.map +1 -0
- package/dist/prompts/prompt.interface.d.ts +30 -0
- package/dist/prompts/prompt.interface.js +3 -0
- package/dist/prompts/prompt.interface.js.map +1 -0
- package/dist/prompts/prompt.module.d.ts +2 -0
- package/dist/prompts/prompt.module.js +21 -0
- package/dist/prompts/prompt.module.js.map +1 -0
- package/dist/resources/resource-registry.service.d.ts +18 -0
- package/dist/resources/resource-registry.service.js +56 -0
- package/dist/resources/resource-registry.service.js.map +1 -0
- package/dist/resources/resource.interface.d.ts +19 -0
- package/dist/resources/resource.interface.js +3 -0
- package/dist/resources/resource.interface.js.map +1 -0
- package/dist/resources/resource.module.d.ts +2 -0
- package/dist/resources/resource.module.js +21 -0
- package/dist/resources/resource.module.js.map +1 -0
- package/dist/tooling/tool-registry/tool-registry.service.d.ts +5 -3
- package/dist/tooling/tool-registry/tool-registry.service.js +82 -49
- package/dist/tooling/tool-registry/tool-registry.service.js.map +1 -1
- package/dist/tooling/tool.interface.d.ts +27 -7
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.interface.js","sourceRoot":"","sources":["../../src/resources/resource.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
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.ResourceModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const resource_registry_service_1 = require("./resource-registry.service");
|
|
12
|
+
let ResourceModule = class ResourceModule {
|
|
13
|
+
};
|
|
14
|
+
exports.ResourceModule = ResourceModule;
|
|
15
|
+
exports.ResourceModule = ResourceModule = __decorate([
|
|
16
|
+
(0, common_1.Module)({
|
|
17
|
+
providers: [resource_registry_service_1.ResourceRegistryService],
|
|
18
|
+
exports: [resource_registry_service_1.ResourceRegistryService],
|
|
19
|
+
})
|
|
20
|
+
], ResourceModule);
|
|
21
|
+
//# sourceMappingURL=resource.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.module.js","sourceRoot":"","sources":["../../src/resources/resource.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,2EAAsE;AAM/D,IAAM,cAAc,GAApB,MAAM,cAAc;CAAG,CAAA;AAAjB,wCAAc;yBAAd,cAAc;IAJ1B,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,mDAAuB,CAAC;QACpC,OAAO,EAAE,CAAC,mDAAuB,CAAC;KACnC,CAAC;GACW,cAAc,CAAG"}
|
|
@@ -7,8 +7,9 @@ export interface LlmToolSchema {
|
|
|
7
7
|
description: string;
|
|
8
8
|
parameters: {
|
|
9
9
|
type: "object";
|
|
10
|
-
properties
|
|
11
|
-
required
|
|
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
|
|
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
|
-
|
|
44
|
-
|
|
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
|
-
|
|
69
|
-
|
|
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
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
|
|
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":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAG5C,qEAAyF;AACzF,8DAAsD;
|
|
1
|
+
{"version":3,"file":"tool-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AAM,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
|
|
3
|
-
description
|
|
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
|
|
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
|
-
|
|
12
|
-
|
|
26
|
+
inputSchema: {
|
|
27
|
+
type: "object";
|
|
28
|
+
properties?: Record<string, ToolParameter>;
|
|
29
|
+
required?: string[];
|
|
30
|
+
[key: string]: any;
|
|
31
|
+
};
|
|
32
|
+
icon?: string;
|
|
13
33
|
}
|