it-tools-mcp 5.2.5 → 5.2.6
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/build/index.js +49 -2
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -275,8 +275,35 @@ function mcpLog(level, message, data) {
|
|
|
275
275
|
// Only send if level meets minimum threshold
|
|
276
276
|
if (levelValue >= currentLogLevel && mcpTransportReady) {
|
|
277
277
|
try {
|
|
278
|
-
//
|
|
279
|
-
|
|
278
|
+
// Prepare safe data for notification
|
|
279
|
+
let safeData = undefined;
|
|
280
|
+
try {
|
|
281
|
+
if (data instanceof Error) {
|
|
282
|
+
safeData = { error: data.message, stack: data.stack };
|
|
283
|
+
}
|
|
284
|
+
else if (typeof data === 'object' && data !== null) {
|
|
285
|
+
safeData = data;
|
|
286
|
+
}
|
|
287
|
+
else if (data !== undefined) {
|
|
288
|
+
safeData = { info: data };
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
catch (e) {
|
|
292
|
+
safeData = { info: String(data) };
|
|
293
|
+
}
|
|
294
|
+
// Send MCP logging notification (notifications/message)
|
|
295
|
+
server.server.notification({
|
|
296
|
+
method: "notifications/message",
|
|
297
|
+
params: {
|
|
298
|
+
level,
|
|
299
|
+
logger: packageInfo.name || 'it-tools-mcp',
|
|
300
|
+
data: {
|
|
301
|
+
message,
|
|
302
|
+
...(safeData !== undefined ? { details: safeData } : {}),
|
|
303
|
+
timestamp: new Date().toISOString()
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
});
|
|
280
307
|
}
|
|
281
308
|
catch (error) {
|
|
282
309
|
// Fallback to console if MCP notification fails
|
|
@@ -313,6 +340,26 @@ server.registerTool("logging_setLevel", {
|
|
|
313
340
|
}]
|
|
314
341
|
};
|
|
315
342
|
});
|
|
343
|
+
// Also register the JSON-RPC method name expected by the MCP spec so
|
|
344
|
+
// clients that call "logging/setLevel" receive a proper response instead
|
|
345
|
+
// of a Method Not Found (-32601). This bridges the tool-style registration
|
|
346
|
+
// with the spec-compliant JSON-RPC method name.
|
|
347
|
+
server.server.setRequestHandler(z.object({
|
|
348
|
+
method: z.literal("logging/setLevel"),
|
|
349
|
+
params: z.object({ level: z.enum(['debug', 'info', 'notice', 'warning', 'error', 'critical', 'alert', 'emergency']) })
|
|
350
|
+
}), async (request) => {
|
|
351
|
+
const { level } = request.params;
|
|
352
|
+
const oldLevelName = Object.keys(LOG_LEVELS).find(k => LOG_LEVELS[k] === currentLogLevel);
|
|
353
|
+
currentLogLevel = LOG_LEVELS[level];
|
|
354
|
+
mcpLog('info', `Log level changed from ${oldLevelName} to ${level}`);
|
|
355
|
+
// Per-spec the server may return an empty result; returning a small
|
|
356
|
+
// confirmation object is helpful for clients and tooling.
|
|
357
|
+
return {
|
|
358
|
+
previousLevel: oldLevelName,
|
|
359
|
+
newLevel: level,
|
|
360
|
+
message: `Logging level set to ${level}`
|
|
361
|
+
};
|
|
362
|
+
});
|
|
316
363
|
// Add logging status tool
|
|
317
364
|
server.registerTool("logging_status", {
|
|
318
365
|
description: "Get current MCP logging configuration and status",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "it-tools-mcp",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.6",
|
|
4
4
|
"description": "Full MCP 2025-06-18 compliant server with 121+ IT tools, logging, ping, progress tracking, cancellation, and sampling utilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./build/index.js",
|