Skip to content

feat: Add Logs Panel with MCP Tool Calls Monitoring and System Logs Viewer #131

@olivermontes

Description

@olivermontes

Summary

Create a new Logs page to provide visibility into MCP tool executions and system logs. This feature enhances transparency, helps users identify potential security issues (like prompt injection), and assists with debugging.

Requirements

1. MCP Tool Calls Monitor (All Users)

Real-time monitoring of MCP tool executions:

interface MCPToolCall {
  id: string;
  serverId: string;
  serverName: string;
  toolName: string;
  arguments: Record<string, unknown>;
  result?: unknown;
  error?: string;
  status: 'pending' | 'success' | 'error';
  duration_ms: number;
  timestamp: Date;
  sessionId?: string;
  messageId?: string;
}

UI Components:

  • Server selector (filter by MCP server)
  • Tool calls timeline/list with expandable details
  • Status indicators (success/error/pending)
  • Search and filter by tool name
  • Clear history button

Security Features:

  • Highlight potentially dangerous tool calls (file writes, shell commands)
  • Flag unusual patterns (rapid repeated calls, large payloads)
  • Visual indicators for tools with sensitive permissions

2. System Logs Viewer (Developer Mode Only)

File: ~/levante/levante.log

Features:

  • Real-time log streaming (tail -f style)
  • Log level filters (debug, info, warn, error)
  • Category filters (ai-sdk, mcp, database, ipc, preferences, core)
  • Search/grep functionality
  • Line highlighting for errors/warnings
  • Clear log file button (with confirmation)
  • Download/export logs
  • Auto-scroll toggle

Access Control:

  • Only visible when "Developer Mode" is enabled in Settings
  • Add developerMode flag to user preferences

3. Page Structure

/logs
├── Tab: MCP Tool Calls (all users)
│   ├── Server Filter Dropdown
│   ├── Tool Calls List/Timeline
│   │   ├── Timestamp
│   │   ├── Server Name
│   │   ├── Tool Name
│   │   ├── Status Badge
│   │   ├── Duration
│   │   └── Expandable: Arguments & Result
│   └── Actions: Clear, Export
│
└── Tab: System Logs (developer mode only)
    ├── Level Filter (debug/info/warn/error)
    ├── Category Filter
    ├── Search Input
    ├── Log Viewer (virtualized for performance)
    └── Actions: Clear File, Download, Refresh

4. Database Schema (Optional - for persistence)

-- MCP tool call history (optional, for analytics)
CREATE TABLE mcp_tool_calls (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  server_id TEXT NOT NULL,
  server_name TEXT NOT NULL,
  tool_name TEXT NOT NULL,
  arguments TEXT,              -- JSON string
  result TEXT,                 -- JSON string (truncated)
  error TEXT,
  status TEXT NOT NULL,
  duration_ms INTEGER,
  session_id TEXT,
  message_id TEXT,
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);

CREATE INDEX idx_mcp_tool_calls_server ON mcp_tool_calls(server_id);
CREATE INDEX idx_mcp_tool_calls_created ON mcp_tool_calls(created_at);

Security Monitoring Features

Prompt Injection Detection

  • Flag tool calls with suspicious patterns in arguments
  • Highlight calls that bypass expected workflows
  • Alert on unusual argument lengths or encoded content

Audit Trail

  • Track which model/session triggered each tool call
  • Correlate tool calls with chat messages
  • Export audit logs for security review

Suggestions

Phase 1 (MVP)

  • Add "Developer Mode" toggle to Settings
  • MCP Tool Calls tab with basic list view
  • Real-time tool call capture from MCPService
  • Filter by MCP server
  • Expandable tool call details

Phase 2 (Enhanced)

  • System Logs viewer (developer mode)
  • Log file streaming with virtual scroll
  • Clear/download log file actions
  • Log level and category filters
  • Search functionality

Phase 3 (Security & Analytics)

  • Persist tool calls to SQLite
  • Security warning indicators
  • Tool call statistics per server
  • Export tool calls to JSON/CSV
  • Prompt injection pattern detection

Phase 4 (Advanced)

  • Real-time notifications for errors
  • Custom alert rules
  • Log rotation settings
  • Integration with external logging services

Technical Considerations

MCP Tool Call Capture

  • Hook into MCPUseService and MCPLegacyService tool execution
  • Emit events via IPC for renderer consumption
  • Use Zustand store for real-time state

Log File Handling

  • Use fs.watch or chokidar for file changes
  • Implement chunked reading for large files
  • Virtual scrolling for performance (react-window)
  • Consider log rotation (max file size)

Performance

  • Limit in-memory tool call history (last 1000)
  • Paginate database queries
  • Debounce log file reads
  • Lazy load expanded details

UI/UX Suggestions

  • Add logs indicator in status bar (error count badge)
  • Quick access from MCP server cards in Settings
  • Toast notifications for tool errors
  • Keyboard shortcuts for navigation (j/k for up/down)
  • Syntax highlighting for JSON arguments/results
  • Copy button for tool call details

Related Files

  • src/main/services/mcp/mcpUseService.ts - Tool execution
  • src/main/services/logging/ - Logging system
  • src/renderer/stores/ - Add logsStore
  • ~/levante/levante.log - Log file location

Labels: enhancement, feature, security, developer-experience

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestv1.8.0Planned for v1.8.0 release

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions