mcp-feedback-enhanced

repository·main·Indexed 26 days ago

https://github.com/minidoracat/mcp-feedback-enhanced

An MCP server providing a dual-interface (Web UI and Desktop Application) for interactive user feedback and command execution in AI-assisted development. It features smart environment detection for Local, SSH Remote, and WSL setups, real-time bidirectional communication via WebSockets, and a dedicated `interactive_feedback` tool for AI agents to request text input and image uploads. Version 2.6.0 includes a sound notification system, prompt management, and multi-language support.

Tokens
31.2K
Snippets
53
Records
178
Agent score
83%

What's inside mcp-feedback-enhanced

  1. Overview of MCP Feedback Enhanced Architecture

    main

    MCP Feedback Enhanced uses an innovative architecture based on a Single Active Session + Persistent Web UI to enable seamless interaction between AI assistants and users. It features real-time bidirectional communication via WebSockets and intelligent environment detection (Local, SSH Remote, or WSL).

    Core Features

    • Smart Environment Detection: Automatically identifies Local/SSH Remote/WSL environments.
    • Single Active Session: Replaces traditional multi-session management for better performance.
    • Persistent Web UI: Supports multiple cyclic calls without needing to reopen the browser.
    • Real-time Bidirectional Communication: Uses WebSockets for frontend/backend state synchronization.
    • Prompt Management System: CRUD operations and quick selection for common prompts.
    • Automatic Submission: Includes a countdown timer and automatic feedback submission mechanism.
    • Session Management: Tracks session history and provides statistical analysis.
    • Sound Notification System: Intelligent audio alerts with customizable sound support.
    • Smart Memory: Remembers input box height and provides one-click copying for project paths and session IDs.
    • Multi-language Support: Dynamic switching between Traditional Chinese, Simplified Chinese, and English.
  2. System Architecture Overview

    main

    MCP Feedback Enhanced uses a Single Active Session + Persistent Web UI architecture. It is a Web-Only system, meaning it has removed all Electron desktop dependencies to reduce resource usage and security risks. It is designed to work seamlessly across Local, SSH Remote, and WSL environments through intelligent environment detection.

    The system is organized into four layers:

    1. MCP Service Layer: Implements the MCP protocol and provides the interactive_feedback core tool.
    2. Web UI Management Layer: Manages session lifecycles and browser control via a singleton WebUIManager.
    3. Web Service Layer: A FastAPI-based layer providing RESTful APIs and WebSocket communication.
    4. Frontend Interaction Layer: A modular JavaScript architecture providing real-time UI updates, prompt management, and session tracking.
  3. Understand the AI Assistant Interaction Workflow

    main

    The interaction between the AI Assistant and the MCP service follows a specific sequence to enable interactive feedback:

    1. Trigger: The AI Assistant calls interactive_feedback() on the MCP service.
    2. Session Setup: The MCP service instructs the WebUIManager to create/update a session and start the Web service.
    3. User Notification: The WebUIManager opens the browser, and the AudioManager plays a notification sound upon session updates.
    4. Feedback Loop: The user submits feedback via the Web UI, which is sent via WebSocket to the MCP service, which then returns the result to the AI Assistant.
    5. Continuous Iteration: The system supports multiple loops where the AI processes feedback and calls the function again for seamless updates.
  4. Understand the MCP Feedback Enhanced interaction flow

    main

    The interaction between an AI Assistant (like Cursor or Claude) and the MCP Feedback Enhanced service follows a specific lifecycle designed for persistent sessions and smart environment adaptation.

    Core Design Principles

    • Persistent Sessions: Supports multiple cyclic calls from the AI assistant without needing to recreate connections.
    • Smart Environment Adaptation: Automatically detects and adapts to Local, SSH Remote, and WSL environments.
    • Seamless State Switching: Uses partial frontend refreshes when sessions update to maintain user operation state.
    • Graceful Error Handling: Includes error recovery mechanisms and timeout protection.
    • Resource Optimization: Operates in a single active session mode to minimize resource usage.
  5. Configure and use Auto-Submit functionality

    main

    The Auto-Submit feature allows users to pre-set prompts and a countdown timer that automatically submits feedback when a new AI call is detected via WebSocket.

    Setup Workflow:

    1. Open the Settings tab in the UI.
    2. Select a prompt from the list (prioritizing auto-submit prompts).
    3. Set a countdown timeout.
    4. The system calls updateSettings(enabled, timeout, promptId) to save settings to the server.

    Execution Workflow: When a session_updated event is received via WebSocket, the AutoSubmitManager (ASM) checks if conditions are met. If enabled, it starts a countdown, displays it in the UI, retrieves the prompt via getPromptById(promptId), fills the input box, and executes submit_feedback automatically when the timer hits zero.

    sequenceDiagram
        participant User as 用戶
        participant UI as 前端界面
        participant ASM as AutoSubmitManager
        participant PM as PromptManager
        participant WS as WebSocket
    
        Note over User,WS: 🔧 設定自動提交
        User->>UI: 開啟設定頁籤
        UI->>PM: 獲取提示詞列表
        PM-->>UI: 返回提示詞(自動提交優先)
        User->>UI: 選擇提示詞並設定倒數時間
        UI->>ASM: updateSettings(enabled, timeout, promptId)
        ASM->>WS: 保存設定到服務器
    
        Note over User,WS: ⏰ 自動提交執行
        WS->>UI: session_updated(AI 新調用)
        UI->>ASM: checkAutoSubmitConditions()
        ASM->>ASM: 檢查設定和狀態
        alt 條件滿足
            ASM->>ASM: start(timeout, promptId)
            ASM->>UI: 顯示倒數計時器
            loop 每秒更新
                ASM->>UI: updateCountdownDisplay(remaining)
            end
            ASM->>PM: getPromptById(promptId)
            PM-->>ASM: 返回提示詞內容
            ASM->>UI: 填入提示詞到輸入框
            ASM->>WS: submit_feedback(自動提交)
        else 條件不滿足
            ASM->>UI: 隱藏倒數計時器
        end
  6. Build the desktop application using Python scripts

    main

    Alternatively, you can build the application directly using the scripts/build_desktop.py script.

    Script Commands:

    • Debug version: python scripts/build_desktop.py
    • Release version: python scripts/build_desktop.py --release
    • Clean build artifacts: python scripts/build_desktop.py --clean
    • View help: python scripts/build_desktop.py --help
    python scripts/build_desktop.py --release
  7. Single Active Session Mode

    main

    Instead of managing multiple concurrent sessions, the system maintains a Single Active Session to improve performance and user experience.

    Session Lifecycle:

    1. NoSession: System startup.
    2. ActiveSession: Triggered by the first AI tool call.
    3. SessionUpdated: Triggered by subsequent AI calls (session switching).
    4. Cleanup: Triggered by timeout or manual cleanup, releasing resources back to NoSession.
  8. Configure Audio Notifications

    main

    The audio notification system (v2.4.3) triggers sounds when session_updated events are received via WebSocket.

    Configuration Options:

    • Volume: Adjust via updateVolume(volume).
    • Sound Selection: Choose specific audio IDs via selectAudio(audioId).
    • Testing: Use testPlayAudio(audioId) to preview a sound.
    • Custom Sounds: Users can upload custom files. The system validates the format, converts the file to Base64 using convertToBase64(), and saves it to localStorage via addCustomAudio(file).
    sequenceDiagram
        participant WS as WebSocket
        participant AM as AudioManager
        participant ASU as AudioSettingsUI
        participant AUDIO as Web Audio API
        participant User as 用戶
    
        Note over WS,User: 🔊 音效通知觸發流程
        WS->>AM: session_updated 事件
        AM->>AM: checkNotificationEnabled()
        alt 音效通知已啟用
            AM->>AM: getSelectedAudio()
            AM->>AUDIO: 創建 Audio 物件
            AM->>AUDIO: 設定音量和來源
            AUDIO->>User: 播放通知音效
            AM->>AM: logPlaybackSuccess()
        else 音效通知已停用
            AM->>AM: logSkippedNotification()
        end
    
        Note over WS,User: 🎵 音效設定管理
        User->>ASU: 開啟音效設定
        ASU->>AM: getAudioSettings()
        AM-->>ASU: 返回當前設定
        ASU->>User: 顯示設定界面
    
        User->>ASU: 調整音量
        ASU->>AM: updateVolume(volume)
        AM->>AM: saveSettings()
    
        User->>ASU: 選擇音效
        ASU->>AM: selectAudio(audioId)
        AM->>AM: saveSettings()
    
        User->>ASU: 測試播放
        ASU->>AM: testPlayAudio(audioId)
        AM->>AUDIO: 播放測試音效
        AUDIO->>User: 播放音效
    
        Note over WS,User: 📁 自訂音效管理
        User->>ASU: 上傳自訂音效
        ASU->>ASU: validateAudioFile()
        ASU->>AM: addCustomAudio(file)
        AM->>AM: convertToBase64()
        AM->>AM: saveToLocalStorage()
        ASU->>User: 顯示上傳成功
  9. Use Smart Memory and One-Click Copy Features

    main

    The UI includes intelligent features to improve interaction efficiency:

    • Textarea Height Management: The combinedFeedbackText input field automatically manages its height using a TextareaHeightManager and ResizeObserver with a 500ms debounce to ensure a smooth typing experience.
    • One-Click Copying:
      • Project Path: Click on the path text to copy it.
      • Session ID: Click on the Session ID to copy it.
      • Feedback Copy: Visual confirmation is provided upon successful copying of feedback content.
  10. Resolve browser launch issues in SSH Remote environments

    main

    When using MCP Feedback Enhanced in SSH Remote environments (like Cursor SSH Remote or VS Code Remote SSH), the browser cannot launch automatically because the remote server is headless. To access the Web UI, you must use port forwarding to connect from your local machine.

    Configuration

    Set the MCP_WEB_HOST environment variable to 0.0.0.0 to allow port forwarding. By default, the system uses port 8765, but this can be customized.

    Correct Workflow

    1. Do NOT manually start the Web UI (e.g., do not run uvx mcp-feedback-enhanced test --web). This prevents integration with the MCP system.
    2. Wait for the AI model to call the interactive_feedback tool. This automatically starts the Web UI.
    3. Check the port: If the browser doesn't open, find the port being used via your IDE's port forwarding settings or by checking the "MCP Log" in the "Output" tab (Debug mode).
    4. Open in local browser: Copy the URL (typically http://localhost:8765) and paste it into your local browser.
  11. Install and run MCP Feedback Enhanced

    main

    You can install and run the project using uvx (recommended), pip, or by cloning the source code.

    Run the latest version directly or specify a version:

    # Run latest
    uvx mcp-feedback-enhanced@latest web
    
    # Run specific version
    uvx mcp-feedback-enhanced@2.4.3 web

    Using pip

    Install via pip and run the web interface:

    pip install mcp-feedback-enhanced
    mcp-feedback-enhanced web

    From Source

    Clone the repository and use uv to sync and run:

    git clone https://github.com/Minidoracat/mcp-feedback-enhanced.git
    cd mcp-feedback-enhanced
    uv sync
    uv run python -m mcp_feedback_enhanced web