mark_notification_read
Mark a notification as read using its unique ID to clear unread status.
Instructions
Mark a specific notification as read
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| notificationId | Yes | ID of notification to mark as read |
Implementation Reference
- src/tools/users/index.js:286-301 (handler)The `markNotificationRead` async method on the `UserTools` class. It extracts `notificationId` from args, sends a PUT request to `/notifications/${notificationId}/read`, and returns a formatted success response. Handles 404 errors by throwing an `McpError` with `InvalidRequest`.
async markNotificationRead(args) { const { notificationId } = args; try { await this.baseUtils.makeApiRequest(`/notifications/${notificationId}/read`, 'PUT'); return this.baseUtils.formatResponse( `✅ **Notification Marked as Read**\n\n` + `Notification ${notificationId} has been marked as read.` ); } catch (error) { if (error.response?.status === 404) { throw new McpError(ErrorCode.InvalidRequest, `Notification ${notificationId} not found`); } throw new McpError(ErrorCode.InternalError, `Failed to mark notification as read: ${error.message}`); } - src/tools/users/index.js:79-89 (schema)The input schema definition for the 'mark_notification_read' tool. Defines a single required parameter `notificationId` (type: string).
{ name: "mark_notification_read", description: "Mark a specific notification as read", inputSchema: { type: "object", properties: { notificationId: { type: "string", description: "ID of notification to mark as read" } }, required: ["notificationId"] } }, - src/tools/users/index.js:8-11 (registration)The `UserTools` class that is loaded dynamically by `ToolLoader`. The tool is registered via the `getToolDefinitions()` method (line 14) and its handler is bound in `getToolHandlers()` (line 110). The module is loaded from `src/tools/users/index.js` by `ToolLoader.loadModule()` in `src/utils/toolLoader.js`.
export class UserTools { constructor() { this.baseUtils = baseUtils; } - src/utils/toolLoader.js:79-133 (registration)The `loadModule` method in `ToolLoader` that dynamically imports the users module, instantiates `UserTools`, calls `getToolDefinitions()` and `getToolHandlers()`, and collects all tools/handlers into the global registries. This is how `mark_notification_read` gets registered with the MCP server.
async loadModule(moduleName) { const modulePath = path.join(__dirname, `../tools/${moduleName}/index.js`); // Check if module file exists if (!fs.existsSync(modulePath)) { throw new Error(`Module file not found: ${modulePath}`); } try { // Dynamic import of the module const moduleExports = await import(`../tools/${moduleName}/index.js`); const ModuleClass = moduleExports.default; if (!ModuleClass) { throw new Error(`Module ${moduleName} does not export a default class`); } // Instantiate the module const moduleInstance = new ModuleClass(); // Get tools and handlers from the module const toolDefinitions = moduleInstance.getToolDefinitions(); const toolHandlers = moduleInstance.getToolHandlers(); // Validate that tools and handlers match const toolNames = toolDefinitions.map(tool => tool.name); const handlerNames = Object.keys(toolHandlers); const missingHandlers = toolNames.filter(name => !handlerNames.includes(name)); const extraHandlers = handlerNames.filter(name => !toolNames.includes(name)); if (missingHandlers.length > 0) { console.error(`⚠️ Warning: ${moduleName} module missing handlers for tools: ${missingHandlers.join(', ')}`); } if (extraHandlers.length > 0) { console.error(`⚠️ Warning: ${moduleName} module has extra handlers: ${extraHandlers.join(', ')}`); } // Store module reference this.loadedModules.set(moduleName, { instance: moduleInstance, tools: toolDefinitions, handlers: toolHandlers }); // Add to global collections this.allTools.push(...toolDefinitions); Object.assign(this.allHandlers, toolHandlers); return moduleInstance; } catch (error) { throw new Error(`Failed to load module ${moduleName}: ${error.message}`); } } - src/utils/baseServer.js:412-421 (helper)The `formatResponse` helper in `BaseServerUtils` that wraps text into the MCP response format (`{ content: [{ type: 'text', text }] }`). Used by the handler to produce the final return value.
formatResponse(text) { return { content: [ { type: "text", text: text } ] }; }