Compare commits
2 Commits
69cf7e8a05
...
ff85a11c0e
349
INSTALL.md
Normal file
349
INSTALL.md
Normal file
@@ -0,0 +1,349 @@
|
|||||||
|
# 🐾 QwenClaw Installation & Setup Guide
|
||||||
|
|
||||||
|
**Complete guide to installing and using QwenClaw with Qwen Code CLI**
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ⚡ Quick Start (5 Minutes)
|
||||||
|
|
||||||
|
### Step 1: Install QwenClaw
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Option A: Install globally (recommended)
|
||||||
|
npm install -g qwenclaw
|
||||||
|
|
||||||
|
# Option B: Use from source
|
||||||
|
git clone https://github.rommark.dev/admin/QwenClaw-with-Auth.git
|
||||||
|
cd QwenClaw-with-Auth
|
||||||
|
npm install
|
||||||
|
npm link
|
||||||
|
```
|
||||||
|
|
||||||
|
### Step 2: Run Setup
|
||||||
|
|
||||||
|
```bash
|
||||||
|
qwenclaw setup
|
||||||
|
```
|
||||||
|
|
||||||
|
### Step 3: Start Using
|
||||||
|
|
||||||
|
**In Terminal:**
|
||||||
|
```bash
|
||||||
|
qwenclaw start
|
||||||
|
qwenclaw status
|
||||||
|
```
|
||||||
|
|
||||||
|
**In Qwen Code CLI:**
|
||||||
|
```
|
||||||
|
/qwenclaw:status
|
||||||
|
/qwenclaw:start
|
||||||
|
/qwenclaw:send "Check my tasks"
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📋 Prerequisites
|
||||||
|
|
||||||
|
- **Node.js** version 22 or higher
|
||||||
|
- **Qwen Code CLI** installed and configured
|
||||||
|
- **npm** or **bun** package manager
|
||||||
|
|
||||||
|
### Check Node Version
|
||||||
|
|
||||||
|
```bash
|
||||||
|
node --version # Should be v22.x or higher
|
||||||
|
```
|
||||||
|
|
||||||
|
### Install Node.js (if needed)
|
||||||
|
|
||||||
|
- **Windows/macOS:** Download from https://nodejs.org/
|
||||||
|
- **Linux:** `curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - && sudo apt-get install -y nodejs`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🚀 Installation Methods
|
||||||
|
|
||||||
|
### Method 1: npm (Recommended)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Install globally
|
||||||
|
npm install -g qwenclaw
|
||||||
|
|
||||||
|
# Verify installation
|
||||||
|
qwenclaw --version
|
||||||
|
```
|
||||||
|
|
||||||
|
### Method 2: From Source
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Clone repository
|
||||||
|
git clone https://github.rommark.dev/admin/QwenClaw-with-Auth.git
|
||||||
|
cd QwenClaw-with-Auth
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
npm install
|
||||||
|
|
||||||
|
# Link globally
|
||||||
|
npm link
|
||||||
|
|
||||||
|
# Verify
|
||||||
|
qwenclaw --version
|
||||||
|
```
|
||||||
|
|
||||||
|
### Method 3: Development Mode
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Clone and install
|
||||||
|
git clone https://github.rommark.dev/admin/QwenClaw-with-Auth.git
|
||||||
|
cd QwenClaw-with-Auth
|
||||||
|
npm install
|
||||||
|
|
||||||
|
# Run without installing
|
||||||
|
npm run start
|
||||||
|
npm run status
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ⚙️ Configuration
|
||||||
|
|
||||||
|
### Run Setup Wizard
|
||||||
|
|
||||||
|
```bash
|
||||||
|
qwenclaw setup
|
||||||
|
```
|
||||||
|
|
||||||
|
This will:
|
||||||
|
1. Create `~/.qwen/qwenclaw/` directory
|
||||||
|
2. Generate default settings
|
||||||
|
3. Configure Qwen Code integration
|
||||||
|
|
||||||
|
### Manual Configuration
|
||||||
|
|
||||||
|
Create `~/.qwen/qwenclaw/settings.json`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"model": "qwen-plus",
|
||||||
|
"api": "",
|
||||||
|
"timezone": "UTC",
|
||||||
|
"heartbeat": {
|
||||||
|
"enabled": false,
|
||||||
|
"interval": 15
|
||||||
|
},
|
||||||
|
"telegram": {
|
||||||
|
"token": "",
|
||||||
|
"allowedUserIds": []
|
||||||
|
},
|
||||||
|
"security": {
|
||||||
|
"level": "moderate"
|
||||||
|
},
|
||||||
|
"web": {
|
||||||
|
"enabled": true,
|
||||||
|
"host": "127.0.0.1",
|
||||||
|
"port": 4632
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🎯 Usage
|
||||||
|
|
||||||
|
### Terminal Commands
|
||||||
|
|
||||||
|
| Command | Description |
|
||||||
|
|---------|-------------|
|
||||||
|
| `qwenclaw start` | Start daemon |
|
||||||
|
| `qwenclaw status` | Check status |
|
||||||
|
| `qwenclaw send "message"` | Send task |
|
||||||
|
| `qwenclaw skills` | List skills |
|
||||||
|
| `qwenclaw help` | Show help |
|
||||||
|
|
||||||
|
### Qwen Code Slash Commands
|
||||||
|
|
||||||
|
After installation, use these inside Qwen Code chat:
|
||||||
|
|
||||||
|
| Command | Description |
|
||||||
|
|---------|-------------|
|
||||||
|
| `/qwenclaw:start` | Start daemon |
|
||||||
|
| `/qwenclaw:status` | Check status |
|
||||||
|
| `/qwenclaw:send "task"` | Send task |
|
||||||
|
| `/qwenclaw:skills` | List skills |
|
||||||
|
| `/qwenclaw:help` | Show help |
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
**Start Daemon:**
|
||||||
|
```bash
|
||||||
|
qwenclaw start
|
||||||
|
```
|
||||||
|
|
||||||
|
**Check Status:**
|
||||||
|
```
|
||||||
|
/qwenclaw:status
|
||||||
|
```
|
||||||
|
|
||||||
|
**Send Task:**
|
||||||
|
```bash
|
||||||
|
qwenclaw send "Summarize my GitHub notifications"
|
||||||
|
```
|
||||||
|
|
||||||
|
**List Skills:**
|
||||||
|
```
|
||||||
|
/qwenclaw:skills
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🌐 Web Dashboard
|
||||||
|
|
||||||
|
Access the web dashboard at:
|
||||||
|
|
||||||
|
```
|
||||||
|
http://127.0.0.1:4632
|
||||||
|
```
|
||||||
|
|
||||||
|
Features:
|
||||||
|
- Real-time daemon status
|
||||||
|
- Skill management
|
||||||
|
- Job scheduling
|
||||||
|
- Logs viewer
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📚 Available Skills (81 Total)
|
||||||
|
|
||||||
|
### By Category
|
||||||
|
|
||||||
|
| Category | Count | Examples |
|
||||||
|
|----------|-------|----------|
|
||||||
|
| Content | 8 | Research writer, changelog |
|
||||||
|
| Development | 25 | Code mentor, plugin dev |
|
||||||
|
| Design | 3 | UI/UX Pro Max, shadcn/ui |
|
||||||
|
| Automation | 5 | GUI automation |
|
||||||
|
| Multi-Agent | 2 | Agents Council |
|
||||||
|
| Economic | 1 | ClawWork (220 tasks) |
|
||||||
|
| Tools | 10 | QwenBot, file ops |
|
||||||
|
| Business | 8 | Internal comms |
|
||||||
|
| Creative | 5 | Theme factory |
|
||||||
|
| Productivity | 7 | Meeting insights |
|
||||||
|
| Media | 3 | Image, video |
|
||||||
|
| Writing | 3 | Resume, brand |
|
||||||
|
| Social | 2 | Twitter, Slack |
|
||||||
|
| Community | 1 | AChurch |
|
||||||
|
| Document | 1 | Document skills |
|
||||||
|
|
||||||
|
### List All Skills
|
||||||
|
|
||||||
|
```bash
|
||||||
|
qwenclaw skills
|
||||||
|
```
|
||||||
|
|
||||||
|
Or in Qwen Code:
|
||||||
|
```
|
||||||
|
/qwenclaw:skills
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🔧 Troubleshooting
|
||||||
|
|
||||||
|
### Issue: "command not found: qwenclaw"
|
||||||
|
|
||||||
|
**Solution:**
|
||||||
|
```bash
|
||||||
|
# Reinstall globally
|
||||||
|
npm install -g qwenclaw
|
||||||
|
|
||||||
|
# Or add npm global bin to PATH
|
||||||
|
# Windows: %APPDATA%\npm
|
||||||
|
# macOS/Linux: ~/.npm-global/bin
|
||||||
|
```
|
||||||
|
|
||||||
|
### Issue: "/qwenclaw:status unknown command"
|
||||||
|
|
||||||
|
**Solution:**
|
||||||
|
```bash
|
||||||
|
# Verify commands directory exists
|
||||||
|
ls -la ~/.qwen/commands/qwenclaw/
|
||||||
|
|
||||||
|
# Should contain: start.md, status.md, send.md, skills.md, help.md
|
||||||
|
|
||||||
|
# Restart Qwen Code
|
||||||
|
exit
|
||||||
|
qwen
|
||||||
|
```
|
||||||
|
|
||||||
|
### Issue: "Daemon not running"
|
||||||
|
|
||||||
|
**Solution:**
|
||||||
|
```bash
|
||||||
|
# Start daemon
|
||||||
|
qwenclaw start
|
||||||
|
|
||||||
|
# Or use slash command
|
||||||
|
/qwenclaw:start
|
||||||
|
```
|
||||||
|
|
||||||
|
### Issue: "Skills not available"
|
||||||
|
|
||||||
|
**Solution:**
|
||||||
|
```bash
|
||||||
|
# Check skills directory
|
||||||
|
ls -la ~/.qwen/qwenclaw/skills/
|
||||||
|
|
||||||
|
# Re-run setup
|
||||||
|
qwenclaw setup
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📖 Additional Resources
|
||||||
|
|
||||||
|
- **GitHub:** https://github.rommark.dev/admin/QwenClaw-with-Auth
|
||||||
|
- **Issues:** https://github.rommark.dev/admin/QwenClaw-with-Auth/issues
|
||||||
|
- **OpenClaw:** https://github.com/openclaw/openclaw
|
||||||
|
- **Qwen Code:** https://github.com/QwenLM/Qwen-Code
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 🆘 Getting Help
|
||||||
|
|
||||||
|
### View Help
|
||||||
|
|
||||||
|
```bash
|
||||||
|
qwenclaw help
|
||||||
|
```
|
||||||
|
|
||||||
|
Or in Qwen Code:
|
||||||
|
```
|
||||||
|
/qwenclaw:help
|
||||||
|
```
|
||||||
|
|
||||||
|
### Report Issues
|
||||||
|
|
||||||
|
1. Check existing issues: https://github.rommark.dev/admin/QwenClaw-with-Auth/issues
|
||||||
|
2. Create new issue with:
|
||||||
|
- QwenClaw version: `qwenclaw --version`
|
||||||
|
- Node version: `node --version`
|
||||||
|
- OS and version
|
||||||
|
- Error message
|
||||||
|
- Steps to reproduce
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## ✅ Verification Checklist
|
||||||
|
|
||||||
|
After installation, verify:
|
||||||
|
|
||||||
|
- [ ] `qwenclaw --version` shows version 2.0.1 or higher
|
||||||
|
- [ ] `qwenclaw status` shows daemon status
|
||||||
|
- [ ] `/qwenclaw:status` works in Qwen Code
|
||||||
|
- [ ] Web dashboard accessible at http://127.0.0.1:4632
|
||||||
|
- [ ] Skills directory exists: `~/.qwen/qwenclaw/skills/`
|
||||||
|
- [ ] Commands directory exists: `~/.qwen/commands/qwenclaw/`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**You're all set! Start using QwenClaw with `/qwenclaw:status` in Qwen Code!** 🐾🎉
|
||||||
78
README.md
78
README.md
@@ -6,24 +6,45 @@ Built from [OpenClaw](https://github.com/openclaw/openclaw) • Powered by Qwen
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Quick Start
|
## ⚡ Quick Start (5 Minutes)
|
||||||
|
|
||||||
|
### 1. Install
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Install globally
|
|
||||||
npm install -g qwenclaw
|
npm install -g qwenclaw
|
||||||
|
|
||||||
# Or use from source
|
|
||||||
cd qwenclaw
|
|
||||||
npm link
|
|
||||||
|
|
||||||
# Setup (one-time)
|
|
||||||
qwenclaw setup
|
|
||||||
|
|
||||||
# Start using
|
|
||||||
qwenclaw start
|
|
||||||
qwenclaw send "Check my tasks"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### 2. Setup
|
||||||
|
|
||||||
|
```bash
|
||||||
|
qwenclaw setup
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Use
|
||||||
|
|
||||||
|
**In Terminal:**
|
||||||
|
```bash
|
||||||
|
qwenclaw start
|
||||||
|
qwenclaw status
|
||||||
|
```
|
||||||
|
|
||||||
|
**In Qwen Code CLI:**
|
||||||
|
```
|
||||||
|
/qwenclaw:status
|
||||||
|
/qwenclaw:start
|
||||||
|
/qwenclaw:send "Check my tasks"
|
||||||
|
```
|
||||||
|
|
||||||
|
**Web Dashboard:** http://127.0.0.1:4632
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📖 Full Documentation
|
||||||
|
|
||||||
|
- **[INSTALL.md](INSTALL.md)** - Complete installation guide
|
||||||
|
- **[docs/QWEN-CODE-SETUP.md](docs/QWEN-CODE-SETUP.md)** - Qwen Code integration setup
|
||||||
|
- **[skills/](skills/)** - All 81+ skills documentation
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
@@ -64,6 +85,8 @@ qwenclaw send "Check my tasks"
|
|||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
|
### Terminal Commands
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
qwenclaw start # Start daemon
|
qwenclaw start # Start daemon
|
||||||
qwenclaw status # Check status
|
qwenclaw status # Check status
|
||||||
@@ -73,6 +96,35 @@ qwenclaw setup # Setup wizard
|
|||||||
qwenclaw help # Show help
|
qwenclaw help # Show help
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Inside Qwen Code CLI (Slash Commands)
|
||||||
|
|
||||||
|
After setup, use `/qwenclaw:` commands directly in Qwen Code chat:
|
||||||
|
|
||||||
|
```
|
||||||
|
/qwenclaw:start - Start daemon
|
||||||
|
/qwenclaw:status - Check daemon status
|
||||||
|
/qwenclaw:send "task" - Send task to daemon
|
||||||
|
/qwenclaw:skills - List available skills
|
||||||
|
/qwenclaw:help - Show help
|
||||||
|
```
|
||||||
|
|
||||||
|
**Example:**
|
||||||
|
```
|
||||||
|
/qwenclaw:status
|
||||||
|
```
|
||||||
|
|
||||||
|
**Response:**
|
||||||
|
```
|
||||||
|
🐾 QwenClaw Status
|
||||||
|
════════════════════════════════════════
|
||||||
|
Daemon: Ready
|
||||||
|
Provider: Qwen Code CLI
|
||||||
|
Skills: 81 available
|
||||||
|
Web Dashboard: http://127.0.0.1:4632
|
||||||
|
```
|
||||||
|
|
||||||
|
**Note:** Commands execute in your terminal and show output in Qwen Code chat.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Usage Examples
|
## Usage Examples
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const command = args[0];
|
|||||||
const commands = {
|
const commands = {
|
||||||
async start() {
|
async start() {
|
||||||
console.log('🐾 QwenClaw - Starting daemon...');
|
console.log('🐾 QwenClaw - Starting daemon...');
|
||||||
const proc = spawn('qwen', ['-p', 'QwenClaw daemon started. Ready for tasks.'], {
|
const proc = spawn('qwen', ['QwenClaw daemon started. Ready for tasks.'], {
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
shell: true,
|
shell: true,
|
||||||
});
|
});
|
||||||
@@ -39,7 +39,7 @@ const commands = {
|
|||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
console.log('📤 Sending to Qwen Code CLI...');
|
console.log('📤 Sending to Qwen Code CLI...');
|
||||||
const proc = spawn('qwen', ['-p', message], {
|
const proc = spawn('qwen', [message], {
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
shell: true,
|
shell: true,
|
||||||
});
|
});
|
||||||
|
|||||||
1146
package-lock.json
generated
Normal file
1146
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
12
package.json
12
package.json
@@ -4,7 +4,8 @@
|
|||||||
"description": "Qwen Code CLI's ALWAYS-ON AI Assistant - Built from OpenClaw",
|
"description": "Qwen Code CLI's ALWAYS-ON AI Assistant - Built from OpenClaw",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"bin": {
|
"bin": {
|
||||||
"qwenclaw": "./bin/qwenclaw.js"
|
"qwenclaw": "./bin/qwenclaw.js",
|
||||||
|
"qwenclaw-mcp": "./src/mcp-server.js"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node bin/qwenclaw.js start",
|
"start": "node bin/qwenclaw.js start",
|
||||||
@@ -12,7 +13,8 @@
|
|||||||
"send": "node bin/qwenclaw.js send",
|
"send": "node bin/qwenclaw.js send",
|
||||||
"skills": "node bin/qwenclaw.js skills",
|
"skills": "node bin/qwenclaw.js skills",
|
||||||
"setup": "node bin/qwenclaw.js setup",
|
"setup": "node bin/qwenclaw.js setup",
|
||||||
"help": "node bin/qwenclaw.js help"
|
"help": "node bin/qwenclaw.js help",
|
||||||
|
"mcp": "node src/mcp-server.js"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"qwen",
|
"qwen",
|
||||||
@@ -21,7 +23,8 @@
|
|||||||
"ai-assistant",
|
"ai-assistant",
|
||||||
"openclaw",
|
"openclaw",
|
||||||
"multi-agent",
|
"multi-agent",
|
||||||
"automation"
|
"automation",
|
||||||
|
"mcp"
|
||||||
],
|
],
|
||||||
"author": "QwenClaw Team",
|
"author": "QwenClaw Team",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@@ -35,5 +38,8 @@
|
|||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=22.0.0"
|
"node": ">=22.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@modelcontextprotocol/sdk": "^1.27.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
200
src/mcp-server.js
Normal file
200
src/mcp-server.js
Normal file
@@ -0,0 +1,200 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
/**
|
||||||
|
* QwenClaw MCP Server
|
||||||
|
*
|
||||||
|
* Provides QwenClaw functionality as MCP tools for Qwen Code CLI
|
||||||
|
*
|
||||||
|
* Usage:
|
||||||
|
* In Qwen Code, type: /qwenclaw <command>
|
||||||
|
* Commands: start, status, send, skills, help
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
||||||
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
||||||
|
import {
|
||||||
|
CallToolRequestSchema,
|
||||||
|
ListToolsRequestSchema,
|
||||||
|
} from '@modelcontextprotocol/sdk/types.js';
|
||||||
|
import { spawn } from 'child_process';
|
||||||
|
import { join } from 'path';
|
||||||
|
|
||||||
|
const QWENCLAW_DIR = join(process.cwd());
|
||||||
|
|
||||||
|
// Tool definitions
|
||||||
|
const TOOLS = [
|
||||||
|
{
|
||||||
|
name: 'qwenclaw_start',
|
||||||
|
description: 'Start QwenClaw daemon',
|
||||||
|
inputSchema: {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
web: {
|
||||||
|
type: 'boolean',
|
||||||
|
description: 'Enable web dashboard',
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'qwenclaw_status',
|
||||||
|
description: 'Check QwenClaw daemon status',
|
||||||
|
inputSchema: {
|
||||||
|
type: 'object',
|
||||||
|
properties: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'qwenclaw_send',
|
||||||
|
description: 'Send message to QwenClaw daemon',
|
||||||
|
inputSchema: {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
message: {
|
||||||
|
type: 'string',
|
||||||
|
description: 'Message to send',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
required: ['message'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'qwenclaw_skills',
|
||||||
|
description: 'List all available QwenClaw skills',
|
||||||
|
inputSchema: {
|
||||||
|
type: 'object',
|
||||||
|
properties: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'qwenclaw_help',
|
||||||
|
description: 'Show QwenClaw help information',
|
||||||
|
inputSchema: {
|
||||||
|
type: 'object',
|
||||||
|
properties: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
// Create MCP server
|
||||||
|
const server = new Server(
|
||||||
|
{
|
||||||
|
name: 'qwenclaw',
|
||||||
|
version: '2.0.0',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
capabilities: {
|
||||||
|
tools: {},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// Handle tool listing
|
||||||
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
||||||
|
return {
|
||||||
|
tools: TOOLS,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
// Handle tool execution
|
||||||
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
||||||
|
const { name, arguments: args = {} } = request.params;
|
||||||
|
|
||||||
|
try {
|
||||||
|
switch (name) {
|
||||||
|
case 'qwenclaw_start': {
|
||||||
|
const web = args.web || false;
|
||||||
|
const result = await runCommand('start', web ? ['--web'] : []);
|
||||||
|
return {
|
||||||
|
content: [{ type: 'text', text: result }],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'qwenclaw_status': {
|
||||||
|
const result = await runCommand('status', []);
|
||||||
|
return {
|
||||||
|
content: [{ type: 'text', text: result }],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'qwenclaw_send': {
|
||||||
|
const message = args.message;
|
||||||
|
if (!message) {
|
||||||
|
return {
|
||||||
|
content: [{ type: 'text', text: 'Error: message is required' }],
|
||||||
|
isError: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const result = await runCommand('send', [message]);
|
||||||
|
return {
|
||||||
|
content: [{ type: 'text', text: result }],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'qwenclaw_skills': {
|
||||||
|
const result = await runCommand('skills', []);
|
||||||
|
return {
|
||||||
|
content: [{ type: 'text', text: result }],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'qwenclaw_help': {
|
||||||
|
const result = await runCommand('help', []);
|
||||||
|
return {
|
||||||
|
content: [{ type: 'text', text: result }],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
return {
|
||||||
|
content: [{ type: 'text', text: `Unknown tool: ${name}` }],
|
||||||
|
isError: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
return {
|
||||||
|
content: [{ type: 'text', text: `Error: ${error.message}` }],
|
||||||
|
isError: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Run QwenClaw command
|
||||||
|
async function runCommand(command, args = []) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const proc = spawn('node', [join(QWENCLAW_DIR, 'bin', 'qwenclaw.js'), command, ...args], {
|
||||||
|
stdio: ['pipe', 'pipe', 'pipe'],
|
||||||
|
});
|
||||||
|
|
||||||
|
let output = '';
|
||||||
|
let error = '';
|
||||||
|
|
||||||
|
proc.stdout.on('data', (data) => {
|
||||||
|
output += data.toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
proc.stderr.on('data', (data) => {
|
||||||
|
error += data.toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
proc.on('close', (code) => {
|
||||||
|
if (code === 0) {
|
||||||
|
resolve(output.trim());
|
||||||
|
} else {
|
||||||
|
reject(new Error(error || `Command failed with code ${code}`));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start server
|
||||||
|
async function main() {
|
||||||
|
const transport = new StdioServerTransport();
|
||||||
|
await server.connect(transport);
|
||||||
|
console.error('QwenClaw MCP server running on stdio');
|
||||||
|
}
|
||||||
|
|
||||||
|
main().catch((error) => {
|
||||||
|
console.error('Fatal error:', error);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user