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.
- package/README.md +66 -28
- 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 +300 -23
- 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 +52 -0
- package/dist/core/utils/tool-naming-validator.js.map +1 -0
- 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
package/README.md
CHANGED
|
@@ -86,6 +86,8 @@ The main configuration object passed to `EasyMCP.initialize()`:
|
|
|
86
86
|
```typescript
|
|
87
87
|
interface McpConfig {
|
|
88
88
|
tools: ToolRegistrationInput[];
|
|
89
|
+
resources?: ResourceRegistrationInput[]; // Optional resources
|
|
90
|
+
prompts?: PromptRegistrationInput[]; // Optional prompts
|
|
89
91
|
serverInfo?: ServerInfo;
|
|
90
92
|
}
|
|
91
93
|
```
|
|
@@ -100,14 +102,19 @@ interface ToolRegistrationInput {
|
|
|
100
102
|
description: string;
|
|
101
103
|
function: (args: Record<string, any>) => Promise<any>;
|
|
102
104
|
inputSchema: {
|
|
103
|
-
type: '
|
|
104
|
-
properties
|
|
105
|
-
type: '
|
|
106
|
-
description
|
|
107
|
-
enum?: string[];
|
|
105
|
+
type: 'object'; // JSON Schema 2020-12 format
|
|
106
|
+
properties?: Record<string, {
|
|
107
|
+
type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object';
|
|
108
|
+
description?: string;
|
|
109
|
+
enum?: (string | number | boolean)[];
|
|
110
|
+
default?: any;
|
|
111
|
+
// Additional JSON Schema 2020-12 properties supported
|
|
112
|
+
[key: string]: any;
|
|
108
113
|
}>;
|
|
109
114
|
required?: string[];
|
|
115
|
+
[key: string]: any; // Additional JSON Schema 2020-12 properties
|
|
110
116
|
};
|
|
117
|
+
icon?: string; // Optional icon URI
|
|
111
118
|
}
|
|
112
119
|
```
|
|
113
120
|
|
|
@@ -134,20 +141,20 @@ const searchTool: ToolRegistrationInput = {
|
|
|
134
141
|
name: 'searchDatabase',
|
|
135
142
|
description: 'Searches the database for matching records',
|
|
136
143
|
function: searchDatabase,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
inputSchema: {
|
|
145
|
+
type: 'object', // JSON Schema 2020-12 format
|
|
146
|
+
properties: {
|
|
147
|
+
query: {
|
|
148
|
+
type: 'string',
|
|
149
|
+
description: 'The search query',
|
|
150
|
+
},
|
|
151
|
+
limit: {
|
|
152
|
+
type: 'integer',
|
|
153
|
+
description: 'Maximum number of results to return',
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
required: ['query'],
|
|
147
157
|
},
|
|
148
|
-
},
|
|
149
|
-
required: ['query'],
|
|
150
|
-
},
|
|
151
158
|
};
|
|
152
159
|
```
|
|
153
160
|
|
|
@@ -189,12 +196,16 @@ process.on('SIGINT', async () => {
|
|
|
189
196
|
- `McpConfig` - Main configuration interface
|
|
190
197
|
- `ToolRegistrationInput` - Tool definition interface
|
|
191
198
|
- `ServerInfo` - Optional server information
|
|
192
|
-
- `JsonRpcRequest`, `JsonRpcResponse` - JSON-RPC 2.0 types
|
|
199
|
+
- `JsonRpcRequest`, `JsonRpcResponse`, `JsonRpcError` - JSON-RPC 2.0 types
|
|
200
|
+
- `JsonRpcErrorCode` - JSON-RPC 2.0 error code enum
|
|
193
201
|
- `InitializeParams`, `InitializeResult` - MCP initialize types
|
|
194
202
|
- `ListToolsResult`, `McpTool` - MCP tools types
|
|
195
203
|
- `CallToolParams`, `CallToolResult` - MCP tool call types
|
|
196
204
|
- `ToolDefinition`, `ToolParameter`, `ToolFunction` - Tool interfaces
|
|
197
205
|
- `IInterfaceLayer` - Interface layer interface
|
|
206
|
+
- `McpErrorCode` - MCP error code enum
|
|
207
|
+
- `VERSION`, `PACKAGE_NAME`, `getVersion()`, `getPackageName()` - Version information utilities
|
|
208
|
+
- `INTERFACE_LAYER_TOKEN` - Token for accessing the interface layer (advanced use cases)
|
|
198
209
|
|
|
199
210
|
## Architecture
|
|
200
211
|
|
|
@@ -218,11 +229,11 @@ graph TB
|
|
|
218
229
|
|
|
219
230
|
## MCP Protocol Compliance
|
|
220
231
|
|
|
221
|
-
EasyMCP implements the standard Model Context Protocol (MCP) specification version **
|
|
232
|
+
EasyMCP implements the standard Model Context Protocol (MCP) specification version **2025-11-25**.
|
|
222
233
|
|
|
223
234
|
### Protocol Version
|
|
224
235
|
|
|
225
|
-
- **Supported Version**: `
|
|
236
|
+
- **Supported Version**: `2025-11-25`
|
|
226
237
|
- **Validation**: The framework validates that clients use the supported protocol version during initialization
|
|
227
238
|
- **Error Handling**: Unsupported protocol versions are rejected with a clear error message
|
|
228
239
|
|
|
@@ -235,15 +246,28 @@ EasyMCP implements the following MCP protocol methods:
|
|
|
235
246
|
- Returns server capabilities (currently supports tools)
|
|
236
247
|
- Returns server information (name and version)
|
|
237
248
|
|
|
238
|
-
- **`tools/list`** - Returns all registered tools with their JSON Schema definitions
|
|
249
|
+
- **`tools/list`** - Returns all registered tools with their JSON Schema 2020-12 definitions
|
|
239
250
|
- Returns array of tool definitions in MCP format
|
|
240
|
-
- Each tool includes name, description, and
|
|
251
|
+
- Each tool includes name, description, inputSchema, and optional icon
|
|
241
252
|
|
|
242
253
|
- **`tools/call`** - Executes a tool with provided arguments and returns the result
|
|
243
|
-
- Validates tool arguments against
|
|
254
|
+
- Validates tool arguments against JSON Schema 2020-12
|
|
244
255
|
- Executes tool function
|
|
245
256
|
- Returns result in MCP content format
|
|
246
257
|
- Handles errors according to MCP error code specification
|
|
258
|
+
- Supports cancellation tokens for long-running operations
|
|
259
|
+
|
|
260
|
+
- **`resources/list`** - Returns all registered resources
|
|
261
|
+
- Returns array of resource definitions with URI, name, description, mimeType, and optional icon
|
|
262
|
+
|
|
263
|
+
- **`resources/read`** - Reads the content of a resource by URI
|
|
264
|
+
- Returns resource content in MCP format
|
|
265
|
+
|
|
266
|
+
- **`prompts/list`** - Returns all registered prompts
|
|
267
|
+
- Returns array of prompt definitions with name, description, arguments, and optional icon
|
|
268
|
+
|
|
269
|
+
- **`prompts/get`** - Generates prompt content from arguments
|
|
270
|
+
- Returns prompt messages in MCP format
|
|
247
271
|
|
|
248
272
|
### Error Codes
|
|
249
273
|
|
|
@@ -274,11 +298,21 @@ MCP_USE_CONTENT_LENGTH=1
|
|
|
274
298
|
|
|
275
299
|
This enables the MCP-specified Content-Length header format, which some clients may not parse correctly.
|
|
276
300
|
|
|
301
|
+
### Features
|
|
302
|
+
|
|
303
|
+
- **Tools**: Full support for tool registration and execution with JSON Schema 2020-12
|
|
304
|
+
- **Resources**: Support for resource registration and reading
|
|
305
|
+
- **Prompts**: Support for prompt templates and generation
|
|
306
|
+
- **Client Features**: Basic support for Sampling, Roots, and Elicitation (client-initiated)
|
|
307
|
+
- **Metadata/Icons**: Optional icon support for tools, resources, and prompts
|
|
308
|
+
- **Progress & Cancellation**: Basic support for cancellation tokens in tool execution
|
|
309
|
+
- **Tool Naming**: Validation according to MCP 2025-11-25 naming guidelines
|
|
310
|
+
|
|
277
311
|
### Limitations
|
|
278
312
|
|
|
279
313
|
- **Transport**: Currently only stdio transport is supported. WebSocket and HTTP transports are not available.
|
|
280
|
-
- **
|
|
281
|
-
- **
|
|
314
|
+
- **Protocol Version**: Only protocol version 2025-11-25 is supported. Older or newer versions will be rejected.
|
|
315
|
+
- **Resources Subscribe/Unsubscribe**: Basic resource subscription is not yet implemented (resources/list and resources/read are supported)
|
|
282
316
|
|
|
283
317
|
For more information on testing EasyMCP with real MCP clients, see [Integration Testing Guide](docs/INTEGRATION_TESTING.md).
|
|
284
318
|
|
|
@@ -344,7 +378,7 @@ All error messages are designed to be helpful for debugging:
|
|
|
344
378
|
|
|
345
379
|
Example error messages:
|
|
346
380
|
- `"Tool 'getUser': property 'userId' must have a description"`
|
|
347
|
-
- `"Unsupported protocol version: 2024-10-01. Supported version:
|
|
381
|
+
- `"Unsupported protocol version: 2024-10-01. Supported version: 2025-11-25"`
|
|
348
382
|
- `"Missing required parameter: userId"`
|
|
349
383
|
|
|
350
384
|
## Troubleshooting
|
|
@@ -372,7 +406,7 @@ If you encounter TypeScript or import errors:
|
|
|
372
406
|
|
|
373
407
|
If you see "Unsupported protocol version" errors:
|
|
374
408
|
|
|
375
|
-
1. **Check Client Version**: Ensure your MCP client uses protocol version `
|
|
409
|
+
1. **Check Client Version**: Ensure your MCP client uses protocol version `2025-11-25`
|
|
376
410
|
2. **Update Client**: Update your MCP client to the latest version
|
|
377
411
|
3. **Debug Mode**: Set `DEBUG=1` to see detailed protocol version information
|
|
378
412
|
|
|
@@ -392,6 +426,8 @@ Enable debug logging to troubleshoot issues:
|
|
|
392
426
|
|
|
393
427
|
```bash
|
|
394
428
|
DEBUG=1 node your-server.js
|
|
429
|
+
# or
|
|
430
|
+
DEBUG=true node your-server.js
|
|
395
431
|
```
|
|
396
432
|
|
|
397
433
|
Debug mode provides detailed information about:
|
|
@@ -400,6 +436,8 @@ Debug mode provides detailed information about:
|
|
|
400
436
|
- Protocol version validation
|
|
401
437
|
- Argument validation
|
|
402
438
|
|
|
439
|
+
**Note**: The `DEBUG` environment variable accepts either `'1'` or `'true'` (case-sensitive) to enable debug logging.
|
|
440
|
+
|
|
403
441
|
## Examples
|
|
404
442
|
|
|
405
443
|
See the `examples/` directory for complete working examples.
|
package/dist/EasyMCP.js
CHANGED
|
@@ -7,6 +7,8 @@ const constants_1 = require("./config/constants");
|
|
|
7
7
|
const mcp_server_service_1 = require("./core/mcp-server/mcp-server.service");
|
|
8
8
|
const config_validator_1 = require("./config/config-validator");
|
|
9
9
|
const tool_registry_service_1 = require("./tooling/tool-registry/tool-registry.service");
|
|
10
|
+
const resource_registry_service_1 = require("./resources/resource-registry.service");
|
|
11
|
+
const prompt_registry_service_1 = require("./prompts/prompt-registry.service");
|
|
10
12
|
const logger_util_1 = require("./core/utils/logger.util");
|
|
11
13
|
const sanitize_util_1 = require("./core/utils/sanitize.util");
|
|
12
14
|
const nestjs_stderr_logger_1 = require("./core/utils/nestjs-stderr-logger");
|
|
@@ -34,7 +36,13 @@ class EasyMCP {
|
|
|
34
36
|
}
|
|
35
37
|
catch (error) {
|
|
36
38
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
37
|
-
|
|
39
|
+
const sanitizedToolName = (0, sanitize_util_1.sanitizeName)(tool.name);
|
|
40
|
+
logger_util_1.logger.error("EasyMCP", "Failed to register tool", {
|
|
41
|
+
component: "EasyMCP",
|
|
42
|
+
toolName: sanitizedToolName,
|
|
43
|
+
error: (0, sanitize_util_1.sanitizeErrorMessage)(error),
|
|
44
|
+
});
|
|
45
|
+
throw new Error(`Failed to register tool '${sanitizedToolName}'`);
|
|
38
46
|
}
|
|
39
47
|
}
|
|
40
48
|
logger_util_1.logger.info("EasyMCP", `Registered ${config.tools.length} tool(s) from configuration`, {
|
|
@@ -42,6 +50,50 @@ class EasyMCP {
|
|
|
42
50
|
toolCount: config.tools.length,
|
|
43
51
|
});
|
|
44
52
|
}
|
|
53
|
+
if (config.resources && config.resources.length > 0) {
|
|
54
|
+
const resourceRegistry = moduleRef.get(resource_registry_service_1.ResourceRegistryService);
|
|
55
|
+
for (const resource of config.resources) {
|
|
56
|
+
try {
|
|
57
|
+
resourceRegistry.registerResourceFromConfig(resource);
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
61
|
+
const sanitizedUri = (0, sanitize_util_1.sanitizeUri)(resource.uri);
|
|
62
|
+
logger_util_1.logger.error("EasyMCP", "Failed to register resource", {
|
|
63
|
+
component: "EasyMCP",
|
|
64
|
+
uri: sanitizedUri,
|
|
65
|
+
error: (0, sanitize_util_1.sanitizeErrorMessage)(error),
|
|
66
|
+
});
|
|
67
|
+
throw new Error(`Failed to register resource '${sanitizedUri}'`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
logger_util_1.logger.info("EasyMCP", `Registered ${config.resources.length} resource(s) from configuration`, {
|
|
71
|
+
component: "EasyMCP",
|
|
72
|
+
resourceCount: config.resources.length,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
if (config.prompts && config.prompts.length > 0) {
|
|
76
|
+
const promptRegistry = moduleRef.get(prompt_registry_service_1.PromptRegistryService);
|
|
77
|
+
for (const prompt of config.prompts) {
|
|
78
|
+
try {
|
|
79
|
+
promptRegistry.registerPromptFromConfig(prompt);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
83
|
+
const sanitizedPromptName = (0, sanitize_util_1.sanitizeName)(prompt.name);
|
|
84
|
+
logger_util_1.logger.error("EasyMCP", "Failed to register prompt", {
|
|
85
|
+
component: "EasyMCP",
|
|
86
|
+
promptName: sanitizedPromptName,
|
|
87
|
+
error: (0, sanitize_util_1.sanitizeErrorMessage)(error),
|
|
88
|
+
});
|
|
89
|
+
throw new Error(`Failed to register prompt '${sanitizedPromptName}'`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
logger_util_1.logger.info("EasyMCP", `Registered ${config.prompts.length} prompt(s) from configuration`, {
|
|
93
|
+
component: "EasyMCP",
|
|
94
|
+
promptCount: config.prompts.length,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
45
97
|
logger_util_1.logger.info("EasyMCP", "EasyMCP Framework initialized successfully", {
|
|
46
98
|
component: "EasyMCP",
|
|
47
99
|
});
|
package/dist/EasyMCP.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EasyMCP.js","sourceRoot":"","sources":["../src/EasyMCP.ts"],"names":[],"mappings":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KAAsB;QAChD,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACjD,CAAC;QAED,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAI,KAAK,CAAC,CAAC;IAChC,CAAC;IAOM,MAAM,CAAC,KAAK,CAAC,QAAQ;QAC1B,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;YACd,oBAAM,CAAC,IAAI,CAAC,SAAS,EAAE,iDAAiD,EAAE;gBACxE,SAAS,EAAE,SAAS;aACrB,CAAC,CAAC;YACH,OAAO;QACT,CAAC;QAED,oBAAM,CAAC,IAAI,CAAC,SAAS,EAAE,iCAAiC,EAAE;YACxD,SAAS,EAAE,SAAS;SACrB,CAAC,CAAC;QAEH,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;YACvB,IAAI,CAAC,GAAG,GAAG,IAAW,CAAC;YACvB,oBAAM,CAAC,IAAI,CAAC,SAAS,EAAE,0CAA0C,EAAE;gBACjE,SAAS,EAAE,SAAS;aACrB,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,oBAAM,CAAC,KAAK,CAAC,SAAS,EAAE,+BAA+B,EAAE;gBACvD,SAAS,EAAE,SAAS;gBACpB,KAAK,EAAE,IAAA,oCAAoB,EAAC,KAAK,CAAC;aACnC,CAAC,CAAC;YACH,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AA/LD,0BA+LC"}
|
package/dist/app.module.js
CHANGED
|
@@ -13,12 +13,14 @@ const tool_registry_service_1 = require("./tooling/tool-registry/tool-registry.s
|
|
|
13
13
|
const config_holder_service_1 = require("./config/config-holder.service");
|
|
14
14
|
const constants_1 = require("./config/constants");
|
|
15
15
|
const interface_module_1 = require("./interface/interface.module");
|
|
16
|
+
const resource_module_1 = require("./resources/resource.module");
|
|
17
|
+
const prompt_module_1 = require("./prompts/prompt.module");
|
|
16
18
|
let AppModule = class AppModule {
|
|
17
19
|
};
|
|
18
20
|
exports.AppModule = AppModule;
|
|
19
21
|
exports.AppModule = AppModule = __decorate([
|
|
20
22
|
(0, common_1.Module)({
|
|
21
|
-
imports: [interface_module_1.InterfaceModule],
|
|
23
|
+
imports: [interface_module_1.InterfaceModule, resource_module_1.ResourceModule, prompt_module_1.PromptModule],
|
|
22
24
|
providers: [
|
|
23
25
|
mcp_server_service_1.McpServerService,
|
|
24
26
|
tool_registry_service_1.ToolRegistryService,
|
package/dist/app.module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAEA,2CAAwC;AACxC,6EAAwE;AACxE,yFAAoF;AACpF,0EAAqE;AACrE,kDAAkD;AAClD,mEAA+D;
|
|
1
|
+
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAEA,2CAAwC;AACxC,6EAAwE;AACxE,yFAAoF;AACpF,0EAAqE;AACrE,kDAAkD;AAClD,mEAA+D;AAC/D,iEAA6D;AAC7D,2DAAuD;AAsBhD,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,8BAAS;oBAAT,SAAS;IAhBrB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,kCAAe,EAAE,gCAAc,EAAE,4BAAY,CAAC;QACxD,SAAS,EAAE;YAET,qCAAgB;YAEhB,2CAAmB;YACnB,2CAAmB;YAEnB;gBACE,OAAO,EAAE,wBAAY;gBACrB,WAAW,EAAE,2CAAmB;aACjC;SACF;QACD,OAAO,EAAE,CAAC,qCAAgB,CAAC;KAC5B,CAAC;GACW,SAAS,CAAG"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConfigValidator = void 0;
|
|
4
4
|
const easy_mcp_error_1 = require("../core/errors/easy-mcp-error");
|
|
5
|
+
const tool_naming_validator_1 = require("../core/utils/tool-naming-validator");
|
|
5
6
|
class ConfigValidator {
|
|
6
7
|
static validate(config) {
|
|
7
8
|
if (!config) {
|
|
@@ -16,6 +17,66 @@ class ConfigValidator {
|
|
|
16
17
|
config.tools.forEach((tool, index) => {
|
|
17
18
|
this.validateTool(tool, index);
|
|
18
19
|
});
|
|
20
|
+
if (config.resources !== undefined) {
|
|
21
|
+
if (!Array.isArray(config.resources)) {
|
|
22
|
+
throw new easy_mcp_error_1.ConfigurationError('resources must be an array if provided');
|
|
23
|
+
}
|
|
24
|
+
config.resources.forEach((res, idx) => {
|
|
25
|
+
if (!res.uri || typeof res.uri !== 'string' || res.uri.trim().length === 0) {
|
|
26
|
+
throw new easy_mcp_error_1.ConfigurationError(`Resource at index ${idx}: 'uri' must be a non-empty string`);
|
|
27
|
+
}
|
|
28
|
+
if (!res.name || typeof res.name !== 'string' || res.name.trim().length === 0) {
|
|
29
|
+
throw new easy_mcp_error_1.ConfigurationError(`Resource '${res.uri}': 'name' must be a non-empty string`);
|
|
30
|
+
}
|
|
31
|
+
if (typeof res.getContent !== 'function') {
|
|
32
|
+
throw new easy_mcp_error_1.ConfigurationError(`Resource '${res.uri}': 'getContent' must be a function`);
|
|
33
|
+
}
|
|
34
|
+
if (res.description !== undefined && typeof res.description !== 'string') {
|
|
35
|
+
throw new easy_mcp_error_1.ConfigurationError(`Resource '${res.uri}': 'description' must be a string if provided`);
|
|
36
|
+
}
|
|
37
|
+
if (res.mimeType !== undefined && typeof res.mimeType !== 'string') {
|
|
38
|
+
throw new easy_mcp_error_1.ConfigurationError(`Resource '${res.uri}': 'mimeType' must be a string if provided`);
|
|
39
|
+
}
|
|
40
|
+
if (res.icon !== undefined && typeof res.icon !== 'string') {
|
|
41
|
+
throw new easy_mcp_error_1.ConfigurationError(`Resource '${res.uri}': 'icon' must be a string if provided`);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (config.prompts !== undefined) {
|
|
46
|
+
if (!Array.isArray(config.prompts)) {
|
|
47
|
+
throw new easy_mcp_error_1.ConfigurationError('prompts must be an array if provided');
|
|
48
|
+
}
|
|
49
|
+
config.prompts.forEach((p, idx) => {
|
|
50
|
+
if (!p.name || typeof p.name !== 'string' || p.name.trim().length === 0) {
|
|
51
|
+
throw new easy_mcp_error_1.ConfigurationError(`Prompt at index ${idx}: 'name' must be a non-empty string`);
|
|
52
|
+
}
|
|
53
|
+
if (typeof p.getPrompt !== 'function') {
|
|
54
|
+
throw new easy_mcp_error_1.ConfigurationError(`Prompt '${p.name}': 'getPrompt' must be a function`);
|
|
55
|
+
}
|
|
56
|
+
if (p.description !== undefined && typeof p.description !== 'string') {
|
|
57
|
+
throw new easy_mcp_error_1.ConfigurationError(`Prompt '${p.name}': 'description' must be a string if provided`);
|
|
58
|
+
}
|
|
59
|
+
if (p.arguments !== undefined) {
|
|
60
|
+
if (!Array.isArray(p.arguments)) {
|
|
61
|
+
throw new easy_mcp_error_1.ConfigurationError(`Prompt '${p.name}': 'arguments' must be an array if provided`);
|
|
62
|
+
}
|
|
63
|
+
p.arguments.forEach((arg, argIdx) => {
|
|
64
|
+
if (!arg.name || typeof arg.name !== 'string' || arg.name.trim().length === 0) {
|
|
65
|
+
throw new easy_mcp_error_1.ConfigurationError(`Prompt '${p.name}': argument at index ${argIdx} must have a non-empty 'name'`);
|
|
66
|
+
}
|
|
67
|
+
if (arg.description !== undefined && typeof arg.description !== 'string') {
|
|
68
|
+
throw new easy_mcp_error_1.ConfigurationError(`Prompt '${p.name}': argument '${arg.name}' description must be a string if provided`);
|
|
69
|
+
}
|
|
70
|
+
if (arg.required !== undefined && typeof arg.required !== 'boolean') {
|
|
71
|
+
throw new easy_mcp_error_1.ConfigurationError(`Prompt '${p.name}': argument '${arg.name}' required must be a boolean if provided`);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
if (p.icon !== undefined && typeof p.icon !== 'string') {
|
|
76
|
+
throw new easy_mcp_error_1.ConfigurationError(`Prompt '${p.name}': 'icon' must be a string if provided`);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
19
80
|
if (config.serverInfo) {
|
|
20
81
|
if (!config.serverInfo.name || typeof config.serverInfo.name !== 'string' || config.serverInfo.name.trim().length === 0) {
|
|
21
82
|
throw new easy_mcp_error_1.ConfigurationError('serverInfo.name must be a non-empty string');
|
|
@@ -32,6 +93,11 @@ class ConfigValidator {
|
|
|
32
93
|
if (!tool.name || typeof tool.name !== 'string' || tool.name.trim().length === 0) {
|
|
33
94
|
throw new easy_mcp_error_1.ConfigurationError(`Tool at index ${index}: name must be a non-empty string`);
|
|
34
95
|
}
|
|
96
|
+
const namingError = tool_naming_validator_1.ToolNamingValidator.validate(tool.name);
|
|
97
|
+
if (namingError) {
|
|
98
|
+
const suggestion = tool_naming_validator_1.ToolNamingValidator.suggest(tool.name);
|
|
99
|
+
throw new easy_mcp_error_1.ConfigurationError(`Tool '${tool.name}': ${namingError}. Suggested name: '${suggestion}'`);
|
|
100
|
+
}
|
|
35
101
|
if (!tool.description || typeof tool.description !== 'string' || tool.description.trim().length === 0) {
|
|
36
102
|
throw new easy_mcp_error_1.ConfigurationError(`Tool '${tool.name}': description must be a non-empty string`);
|
|
37
103
|
}
|
|
@@ -41,37 +107,43 @@ class ConfigValidator {
|
|
|
41
107
|
if (!tool.inputSchema) {
|
|
42
108
|
throw new easy_mcp_error_1.ConfigurationError(`Tool '${tool.name}': inputSchema is required`);
|
|
43
109
|
}
|
|
44
|
-
if (tool.inputSchema.type !== '
|
|
45
|
-
throw new easy_mcp_error_1.ConfigurationError(`Tool '${tool.name}': inputSchema.type must be '
|
|
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`);
|
|
110
|
+
if (tool.inputSchema.type !== 'object') {
|
|
111
|
+
throw new easy_mcp_error_1.ConfigurationError(`Tool '${tool.name}': inputSchema.type must be 'object' (JSON Schema 2020-12 format)`);
|
|
49
112
|
}
|
|
50
|
-
|
|
51
|
-
if (
|
|
52
|
-
throw new easy_mcp_error_1.ConfigurationError(`Tool '${tool.name}':
|
|
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`);
|
|
113
|
+
if (tool.inputSchema.properties !== undefined) {
|
|
114
|
+
if (typeof tool.inputSchema.properties !== 'object' || Array.isArray(tool.inputSchema.properties)) {
|
|
115
|
+
throw new easy_mcp_error_1.ConfigurationError(`Tool '${tool.name}': inputSchema.properties must be an object`);
|
|
56
116
|
}
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
117
|
+
for (const [propName, propDef] of Object.entries(tool.inputSchema.properties)) {
|
|
118
|
+
if (!propDef || typeof propDef !== 'object' || Array.isArray(propDef)) {
|
|
119
|
+
throw new easy_mcp_error_1.ConfigurationError(`Tool '${tool.name}': property '${propName}' must be an object`);
|
|
120
|
+
}
|
|
121
|
+
if (propDef.type !== undefined) {
|
|
122
|
+
const validTypes = ['string', 'number', 'integer', 'boolean', 'array', 'object'];
|
|
123
|
+
if (typeof propDef.type !== 'string' || !validTypes.includes(propDef.type)) {
|
|
124
|
+
throw new easy_mcp_error_1.ConfigurationError(`Tool '${tool.name}': property '${propName}' has invalid type '${propDef.type}'. Must be one of: ${validTypes.join(', ')} (JSON Schema 2020-12 format)`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (propDef.description !== undefined && typeof propDef.description !== 'string') {
|
|
128
|
+
throw new easy_mcp_error_1.ConfigurationError(`Tool '${tool.name}': property '${propName}' description must be a string if provided`);
|
|
129
|
+
}
|
|
63
130
|
}
|
|
64
131
|
}
|
|
65
132
|
if (tool.inputSchema.required !== undefined) {
|
|
66
133
|
if (!Array.isArray(tool.inputSchema.required)) {
|
|
67
134
|
throw new easy_mcp_error_1.ConfigurationError(`Tool '${tool.name}': inputSchema.required must be an array`);
|
|
68
135
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
136
|
+
if (tool.inputSchema.properties) {
|
|
137
|
+
for (const requiredProp of tool.inputSchema.required) {
|
|
138
|
+
if (!(requiredProp in tool.inputSchema.properties)) {
|
|
139
|
+
throw new easy_mcp_error_1.ConfigurationError(`Tool '${tool.name}': required property '${requiredProp}' does not exist in properties`);
|
|
140
|
+
}
|
|
72
141
|
}
|
|
73
142
|
}
|
|
74
143
|
}
|
|
144
|
+
if (tool.icon !== undefined && typeof tool.icon !== 'string') {
|
|
145
|
+
throw new easy_mcp_error_1.ConfigurationError(`Tool '${tool.name}': icon must be a string (URI) if provided`);
|
|
146
|
+
}
|
|
75
147
|
}
|
|
76
148
|
}
|
|
77
149
|
exports.ConfigValidator = ConfigValidator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-validator.js","sourceRoot":"","sources":["../../src/config/config-validator.ts"],"names":[],"mappings":";;;AACA,kEAAmE;
|
|
1
|
+
{"version":3,"file":"config-validator.js","sourceRoot":"","sources":["../../src/config/config-validator.ts"],"names":[],"mappings":";;;AACA,kEAAmE;AACnE,+EAA0E;AAM1E,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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AI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC9C,MAAM,IAAI,mCAAkB,CAAC,SAAS,IAAI,CAAC,IAAI,0CAA0C,CAAC,CAAC;YAC7F,CAAC;YAGD,IAAI,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,CAAC;gBAChC,KAAK,MAAM,YAAY,IAAI,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;oBACrD,IAAI,CAAC,CAAC,YAAY,IAAI,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,CAAC;wBACnD,MAAM,IAAI,mCAAkB,CAAC,SAAS,IAAI,CAAC,IAAI,yBAAyB,YAAY,gCAAgC,CAAC,CAAC;oBACxH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAGD,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7D,MAAM,IAAI,mCAAkB,CAAC,SAAS,IAAI,CAAC,IAAI,4CAA4C,CAAC,CAAC;QAC/F,CAAC;IACH,CAAC;CACF;AAzLD,0CAyLC"}
|
|
@@ -2,3 +2,6 @@ export declare const CONFIG_TOKEN = "MCP_CONFIG_HOLDER";
|
|
|
2
2
|
export declare const INTERFACE_LAYER_TOKEN = "IInterfaceLayer";
|
|
3
3
|
export declare const MAX_MESSAGE_SIZE_BYTES: number;
|
|
4
4
|
export declare const MAX_CONTENT_LENGTH: number;
|
|
5
|
+
export declare const MAX_RESOURCE_CONTENT_SIZE_BYTES: number;
|
|
6
|
+
export declare const MAX_CANCELLATION_TOKENS = 1000;
|
|
7
|
+
export declare const MAX_LOG_STRING_LENGTH = 200;
|
package/dist/config/constants.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
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;
|
|
3
|
+
exports.MAX_LOG_STRING_LENGTH = exports.MAX_CANCELLATION_TOKENS = exports.MAX_RESOURCE_CONTENT_SIZE_BYTES = exports.MAX_CONTENT_LENGTH = exports.MAX_MESSAGE_SIZE_BYTES = exports.INTERFACE_LAYER_TOKEN = exports.CONFIG_TOKEN = void 0;
|
|
4
4
|
exports.CONFIG_TOKEN = "MCP_CONFIG_HOLDER";
|
|
5
5
|
exports.INTERFACE_LAYER_TOKEN = "IInterfaceLayer";
|
|
6
6
|
exports.MAX_MESSAGE_SIZE_BYTES = 10 * 1024 * 1024;
|
|
7
7
|
exports.MAX_CONTENT_LENGTH = exports.MAX_MESSAGE_SIZE_BYTES;
|
|
8
|
+
exports.MAX_RESOURCE_CONTENT_SIZE_BYTES = 10 * 1024 * 1024;
|
|
9
|
+
exports.MAX_CANCELLATION_TOKENS = 1000;
|
|
10
|
+
exports.MAX_LOG_STRING_LENGTH = 200;
|
|
8
11
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +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"}
|
|
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;AAM5C,QAAA,+BAA+B,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAMnD,QAAA,uBAAuB,GAAG,IAAI,CAAC;AAM/B,QAAA,qBAAqB,GAAG,GAAG,CAAC"}
|
|
@@ -1,18 +1,64 @@
|
|
|
1
|
+
export interface JsonSchema2020_12 {
|
|
2
|
+
type: "object" | "string" | "number" | "integer" | "boolean" | "array";
|
|
3
|
+
properties?: Record<string, JsonSchema2020_12>;
|
|
4
|
+
items?: JsonSchema2020_12 | JsonSchema2020_12[];
|
|
5
|
+
required?: string[];
|
|
6
|
+
description?: string;
|
|
7
|
+
enum?: (string | number | boolean)[];
|
|
8
|
+
default?: any;
|
|
9
|
+
const?: any;
|
|
10
|
+
oneOf?: JsonSchema2020_12[];
|
|
11
|
+
anyOf?: JsonSchema2020_12[];
|
|
12
|
+
allOf?: JsonSchema2020_12[];
|
|
13
|
+
$ref?: string;
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}
|
|
1
16
|
export interface ToolRegistrationInput {
|
|
2
17
|
name: string;
|
|
3
18
|
description: string;
|
|
4
19
|
function: (args: Record<string, any>) => Promise<any>;
|
|
5
|
-
inputSchema:
|
|
6
|
-
|
|
7
|
-
properties: Record<string, any>;
|
|
8
|
-
required?: string[];
|
|
9
|
-
};
|
|
20
|
+
inputSchema: JsonSchema2020_12;
|
|
21
|
+
icon?: string;
|
|
10
22
|
}
|
|
11
23
|
export interface ServerInfo {
|
|
12
24
|
name: string;
|
|
13
25
|
version: string;
|
|
14
26
|
}
|
|
27
|
+
export interface ResourceRegistrationInput {
|
|
28
|
+
uri: string;
|
|
29
|
+
name: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
mimeType?: string;
|
|
32
|
+
icon?: string;
|
|
33
|
+
getContent: () => Promise<string | {
|
|
34
|
+
type: string;
|
|
35
|
+
data: string;
|
|
36
|
+
mimeType?: string;
|
|
37
|
+
}>;
|
|
38
|
+
}
|
|
39
|
+
export interface PromptRegistrationInput {
|
|
40
|
+
name: string;
|
|
41
|
+
description?: string;
|
|
42
|
+
arguments?: Array<{
|
|
43
|
+
name: string;
|
|
44
|
+
description?: string;
|
|
45
|
+
required?: boolean;
|
|
46
|
+
}>;
|
|
47
|
+
icon?: string;
|
|
48
|
+
getPrompt: (args: Record<string, any>) => Promise<Array<{
|
|
49
|
+
role: "user" | "assistant";
|
|
50
|
+
content: Array<{
|
|
51
|
+
type: "text" | "image" | "resource";
|
|
52
|
+
text?: string;
|
|
53
|
+
data?: string;
|
|
54
|
+
mimeType?: string;
|
|
55
|
+
uri?: string;
|
|
56
|
+
}>;
|
|
57
|
+
}>>;
|
|
58
|
+
}
|
|
15
59
|
export interface McpConfig {
|
|
16
60
|
tools: ToolRegistrationInput[];
|
|
61
|
+
resources?: ResourceRegistrationInput[];
|
|
62
|
+
prompts?: PromptRegistrationInput[];
|
|
17
63
|
serverInfo?: ServerInfo;
|
|
18
64
|
}
|
package/dist/core/core.module.js
CHANGED
|
@@ -10,13 +10,15 @@ exports.CoreModule = void 0;
|
|
|
10
10
|
const common_1 = require("@nestjs/common");
|
|
11
11
|
const mcp_server_service_1 = require("./mcp-server/mcp-server.service");
|
|
12
12
|
const interface_module_1 = require("../interface/interface.module");
|
|
13
|
+
const resource_module_1 = require("../resources/resource.module");
|
|
14
|
+
const prompt_module_1 = require("../prompts/prompt.module");
|
|
13
15
|
let CoreModule = class CoreModule {
|
|
14
16
|
};
|
|
15
17
|
exports.CoreModule = CoreModule;
|
|
16
18
|
exports.CoreModule = CoreModule = __decorate([
|
|
17
19
|
(0, common_1.Global)(),
|
|
18
20
|
(0, common_1.Module)({
|
|
19
|
-
imports: [interface_module_1.InterfaceModule],
|
|
21
|
+
imports: [interface_module_1.InterfaceModule, resource_module_1.ResourceModule, prompt_module_1.PromptModule],
|
|
20
22
|
providers: [mcp_server_service_1.McpServerService],
|
|
21
23
|
exports: [mcp_server_service_1.McpServerService],
|
|
22
24
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.module.js","sourceRoot":"","sources":["../../src/core/core.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAgD;AAChD,wEAAmE;AACnE,oEAAgE;
|
|
1
|
+
{"version":3,"file":"core.module.js","sourceRoot":"","sources":["../../src/core/core.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAgD;AAChD,wEAAmE;AACnE,oEAAgE;AAChE,kEAA8D;AAC9D,4DAAwD;AAQjD,IAAM,UAAU,GAAhB,MAAM,UAAU;CAAG,CAAA;AAAb,gCAAU;qBAAV,UAAU;IANtB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,kCAAe,EAAE,gCAAc,EAAE,4BAAY,CAAC;QACxD,SAAS,EAAE,CAAC,qCAAgB,CAAC;QAC7B,OAAO,EAAE,CAAC,qCAAgB,CAAC;KAC5B,CAAC;GACW,UAAU,CAAG"}
|