mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-22 17:57:46 +00:00
5.9 KiB
5.9 KiB
Qwen CLI Bridge - Chrome Extension
A Chrome extension that bridges your browser with Qwen CLI, enabling AI-powered analysis and interaction with web content.
This package is part of the Qwen Code mono repository.
Features
- Page Data Extraction: Extract structured data from any webpage including text, links, images, and metadata
- Screenshot Capture: Capture and analyze screenshots with AI
- Console & Network Monitoring: Monitor console logs and network requests
- Selected Text Processing: Send selected text to Qwen CLI for processing
- AI Analysis: Leverage Qwen's AI capabilities to analyze web content
- MCP Server Integration: Support for multiple MCP (Model Context Protocol) servers
Architecture
┌─────────────────────┐
│ Chrome Extension │
│ - Content Script │
│ - Background Worker│
│ - Popup UI │
└──────────┬──────────┘
│
Native Messaging
│
┌──────▼──────────┐
│ Native Host │
│ (Node.js) │
└──────┬──────────┘
│
┌──────▼──────────┐
│ Qwen CLI │
│ + MCP Servers │
└─────────────────┘
Installation
Prerequisites
- Node.js: Install from nodejs.org
- Qwen CLI: Install the Qwen CLI tool (required for full functionality)
- Chrome Browser: Version 88 or higher
Step 1: Install the Chrome Extension
- Open Chrome and navigate to
chrome://extensions/ - Enable "Developer mode" (toggle in top right)
- Click "Load unpacked"
- Select the
chrome-qwen-bridge/extensionfolder - Note the Extension ID that appears (you'll need this for the next step)
Step 2: Install the Native Messaging Host
The Native Messaging Host allows the Chrome extension to communicate with Qwen CLI.
macOS/Linux
cd chrome-qwen-bridge/native-host
./install.sh
When prompted, enter your Chrome Extension ID.
Windows
- Run Command Prompt as Administrator
- Navigate to the
native-hostdirectory:cd chrome-qwen-bridge\native-host - Run the installation script:
install.bat - Enter your Chrome Extension ID when prompted
Step 3: Configure Qwen CLI (Optional)
If you want to use MCP servers with the extension:
# Add chrome-devtools MCP server
qwen mcp add chrome-devtools
# Add other MCP servers as needed
qwen mcp add playwright-mcp
Usage
Basic Usage
- Click the Qwen CLI Bridge extension icon in Chrome
- Click "Connect to Qwen CLI" to establish connection
- Click "Start Qwen CLI" to launch the CLI process
- Use the action buttons to:
- Extract and analyze page data
- Capture screenshots
- Send selected text to Qwen
- Monitor console and network logs
Advanced Settings
In the popup's "Advanced Settings" section, you can configure:
- MCP Servers: Comma-separated list of MCP servers to load
- HTTP Port: Port for Qwen CLI HTTP server (default: 8080)
- Auto-connect: Automatically connect when opening the popup
API Actions
The extension supports the following actions that can be sent to Qwen CLI:
analyze_page: Analyze extracted page dataanalyze_screenshot: Analyze captured screenshotai_analyze: Perform AI analysis on contentprocess_text: Process selected text- Custom actions based on your MCP server configurations
Development
Project Structure
chrome-qwen-bridge/
├── extension/ # Chrome extension source
│ ├── manifest.json # Extension manifest
│ ├── background/ # Service worker
│ ├── content/ # Content scripts
│ ├── popup/ # Popup UI
│ └── icons/ # Extension icons
├── native-host/ # Native messaging host
│ ├── host.js # Node.js host script
│ ├── manifest.json # Native host manifest
│ └── install scripts # Platform-specific installers
└── docs/ # Documentation
Building from Source
- Clone the repository
- No build step required - the extension uses vanilla JavaScript
- Load the extension as unpacked in Chrome for development
Testing
- Enable Chrome Developer Tools
- Check the extension's background page console for logs
- Native host logs are written to:
- macOS/Linux:
/tmp/qwen-bridge-host.log - Windows:
%TEMP%\qwen-bridge-host.log
- macOS/Linux:
Troubleshooting
Extension not connecting to Native Host
- Verify Node.js is installed:
node --version - Check that the Native Host is properly installed
- Ensure the Extension ID in the manifest matches your actual extension
- Check logs for errors
Qwen CLI not starting
- Verify Qwen CLI is installed:
qwen --version - Check that Qwen CLI can run normally from terminal
- Review Native Host logs for error messages
No response from Qwen CLI
- Ensure Qwen CLI server is running
- Check the configured HTTP port is not in use
- Verify MCP servers are properly configured
Security Considerations
- The extension requires broad permissions to function properly
- Native Messaging Host runs with user privileges
- All communication between components uses structured JSON messages
- No sensitive data is stored; all processing is ephemeral
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
License
MIT License - See LICENSE file for details
Support
For issues, questions, or feature requests:
- Open an issue on GitHub
- Check the logs for debugging information
- Ensure all prerequisites are properly installed