feat: Phase 10 - UI Notifications (request-only)

Implement visual feedback for MCP tool calls with configurable notifications.

Features:
- Real-time notifications when tools are called (request only, no completion)
- Tool-specific emoji icons for visual clarity
- Rate limiting (max 10 notifications/second)
- Notification history tracking (last 100 entries)
- Configurable settings: enable/disable, show parameters, duration, console logging
- History modal with filtering and export to clipboard

Implementation:
- Created NotificationManager with queue-based rate limiting
- Created NotificationHistoryModal for viewing past tool calls
- Integrated into tool call interceptor in ToolRegistry
- Added notification settings UI section
- Added 'View MCP Notification History' command

Benefits:
- Visual feedback for debugging and monitoring
- Transparency into AI agent actions
- Simple on/off toggle, no complex verbosity settings
- Zero performance impact when disabled
- History tracks success/failure/duration for all calls

All 10 phases of the roadmap are now complete\!
This commit is contained in:
2025-10-17 01:11:10 -04:00
parent 6017f879f4
commit b681327970
10 changed files with 1178 additions and 65 deletions

View File

@@ -2,15 +2,21 @@ import { Notice, Plugin } from 'obsidian';
import { MCPServer } from './server/mcp-server';
import { MCPPluginSettings, DEFAULT_SETTINGS } from './types/settings-types';
import { MCPServerSettingTab } from './settings';
import { NotificationManager } from './ui/notifications';
import { NotificationHistoryModal } from './ui/notification-history';
export default class MCPServerPlugin extends Plugin {
settings!: MCPPluginSettings;
mcpServer: MCPServer | null = null;
statusBarItem: HTMLElement | null = null;
notificationManager: NotificationManager | null = null;
async onload() {
await this.loadSettings();
// Initialize notification manager
this.updateNotificationManager();
// Add status bar item
this.statusBarItem = this.addStatusBarItem();
this.updateStatusBar();
@@ -50,6 +56,14 @@ export default class MCPServerPlugin extends Plugin {
}
});
this.addCommand({
id: 'view-notification-history',
name: 'View MCP Notification History',
callback: () => {
this.showNotificationHistory();
}
});
// Add settings tab
this.addSettingTab(new MCPServerSettingTab(this.app, this));
@@ -126,4 +140,43 @@ export default class MCPServerPlugin extends Plugin {
this.mcpServer.updateSettings(this.settings);
}
}
/**
* Update or create notification manager based on settings
*/
updateNotificationManager() {
if (this.settings.notificationsEnabled) {
if (!this.notificationManager) {
this.notificationManager = new NotificationManager(this.app, this.settings);
} else {
this.notificationManager.updateSettings(this.settings);
}
// Update server's tool registry if server is running
if (this.mcpServer) {
this.mcpServer.setNotificationManager(this.notificationManager);
}
} else {
this.notificationManager = null;
// Clear notification manager from server if running
if (this.mcpServer) {
this.mcpServer.setNotificationManager(null);
}
}
}
/**
* Show notification history modal
*/
showNotificationHistory() {
if (!this.notificationManager) {
new Notice('Notifications are not enabled. Enable them in settings to view history.');
return;
}
const history = this.notificationManager.getHistory();
const modal = new NotificationHistoryModal(this.app, history);
modal.open();
}
}